
ACTOR RLSoulstormRifle : RLWeapon
{
  Inventory.Pickupsound "weapons/unique"
  Obituary "%o was struck down by %k's soulstorm rifle."
  Decal BulletChip
  Tag "Soulstorm Rifle"
  Scale 0.35
  Weapon.SelectionOrder 11
  Weapon.SlotNumber 4
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLSoulstormRifleClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "SOLRICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, 12)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, 9)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, 6)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, 3)
    SOLZ A 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Loop
    SOLZ B 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Loop
    SOLZ C 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Loop
    SOLZ D 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Loop
    SOLZ E 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Loop
  ReadyNoReload:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, 12)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, 9)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, 6)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, 3)
    SOLZ A 2 A_WeaponReady (WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
    SOLZ B 2 A_WeaponReady (WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
    SOLZ C 2 A_WeaponReady (WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
    SOLZ D 2 A_WeaponReady (WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
    SOLZ E 2 A_WeaponReady (WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto Ready
	
  ScavengerDrop:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"WeaponDropConfirm")
	TNT1 A 0 A_GiveInventory("RLScavengerDrop",1)
	TNT1 A 0 A_Print("Press again to drop current weapon,\nor press \crAlt Fire\c- to scrap it to retrieve a \cgDemon Artifact.")
	Goto AfterModDrop
  WeaponDropConfirm:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts", 1, "WeaponDropModded")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLSoulstormRiflePickup", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLSoulstormRiflePickupModded", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRiflePowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleNanoMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleDemonArtifacts", 3)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLSoulstormRifle",1)
	Stop
	
  AfterModDrop:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, "AfterModDrop4")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, "AfterModDrop3")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, "AfterModDrop2")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, "AfterModDrop1")
    SOLZ A 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ B 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ C 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ D 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
  AfterModDrop1:
    SOLZ B 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ C 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ D 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ E 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto Ready
  AfterModDrop2:
    SOLZ C 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ D 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ E 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    SOLZ A 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
  AfterModDrop3:
    SOLZ D 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ E 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    SOLZ A 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ B 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
  AfterModDrop4:
    SOLZ E 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    SOLZ A 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ B 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    SOLZ C 2 A_WeaponReady (WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto Ready
  MisfirePrevention:
    SOLZ A 1 A_WeaponReady (WRF_NOFIRE | WRF_NOBOB)
    TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, "DeselectLoop4")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, "DeselectLoop3")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, "DeselectLoop2")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, "DeselectLoop1")
    TNT1 A 0 A_Lower
    SOLZ A 1 A_Lower
    TNT1 A 0 A_Lower
    SOLZ A 1 A_Lower
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto DeselectLoop
  DeselectLoop1:
    TNT1 A 0 A_Lower
    SOLZ B 1 A_Lower
    TNT1 A 0 A_Lower
    SOLZ B 1 A_Lower
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto DeselectLoop
  DeselectLoop2:
    TNT1 A 0 A_Lower
    SOLZ C 1 A_Lower
    TNT1 A 0 A_Lower
    SOLZ C 1 A_Lower
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto DeselectLoop
  DeselectLoop3:
    TNT1 A 0 A_Lower
    SOLZ D 1 A_Lower
    TNT1 A 0 A_Lower
    SOLZ D 1 A_Lower
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto DeselectLoop
  DeselectLoop4:
    TNT1 A 0 A_Lower
    SOLZ E 1 A_Lower
    TNT1 A 0 A_Lower
    SOLZ E 1 A_Lower
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto DeselectLoop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLDemonicWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, "SelectLoop4")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, "SelectLoop3")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, "SelectLoop2")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, "SelectLoop1")
    TNT1 A 0 A_Raise
    SOLZ A 1 A_Raise
    TNT1 A 0 A_Raise
    SOLZ A 1 A_Raise
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto SelectLoop
  SelectLoop1:
    TNT1 A 0 A_Raise
    SOLZ B 1 A_Raise
    TNT1 A 0 A_Raise
    SOLZ B 1 A_Raise
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto SelectLoop
  SelectLoop2:
    TNT1 A 0 A_Raise
    SOLZ C 1 A_Raise
    TNT1 A 0 A_Raise
    SOLZ C 1 A_Raise
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto SelectLoop
  SelectLoop3:
    TNT1 A 0 A_Raise
    SOLZ D 1 A_Raise
    TNT1 A 0 A_Raise
    SOLZ D 1 A_Raise
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto SelectLoop
  SelectLoop4:
    TNT1 A 0 A_Raise
    SOLZ E 1 A_Raise
    TNT1 A 0 A_Raise
    SOLZ E 1 A_Raise
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto SelectLoop
	
  Fire:
	
	SOLZ A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	SOLZ A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	SOLZ A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	SOLZ A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	SOLZ A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRiflePowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAgilityMod",1,"FireA")
  FireNormal:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",2,"FireX")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, -1, random(20,24), "RLSoulstormRiflePuff", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, -1, random(20,24), "RLSoulstormRiflePuff", FBF_NORANDOM)
    Goto FireFinish
  FireX:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireXX")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, -1, random(20,24), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, -1, random(20,24), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
	
  FireXX:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
	
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",2,"FireXP")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, -1, random(29,33), "RLSoulstormRiflePuff", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, -1, random(29,33), "RLSoulstormRiflePuff", FBF_NORANDOM)
    Goto FireFinish
  FireXP:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireXXP")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, -1, random(29,33), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, -1, random(29,33), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
  FireXXP:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (6, 4, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 4, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
	
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",2,"FireXA")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (3, 1, -1, random(20,24), "RLSoulstormRiflePuff", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 1, -1, random(20,24), "RLSoulstormRiflePuff", FBF_NORANDOM)
    Goto FireFinish
  FireXA:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireXXA")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (3, 1, -1, random(20,24), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 1, -1, random(20,24), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
  FireXXA:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
	TNT1 A 0 A_FireBullets (3, 1, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 1, 1, (6*6), "RLSoulstormRiflePuffX", FBF_NORANDOM)
    Goto FireFinish
	
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireXXS")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleBlast", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleBlast", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
  FireXXS:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,4)
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleBlastXX", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleBlastXX", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
	
  FireF:
/*	TNT1 A 0 A_JumpIfInventory("RLPowerSoulstormRifleLaserMode",1, "FireLaser")
	TNT1 A 0 A_Jump(8, "LaserMode")
    Goto FireNormal
  LaserMode:
	TNT1 A 0 A_GiveInventory("RLPowerSoulstormRifleLaserMode",1)
    Goto FireLaser*/
  FireLaser:
    TNT1 A 0 A_PlaySound("weapons/soulstormriflelaser", 6, 1, 0, 0.8)
    TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "FireLaser.Fancy")
  FireLaser.Normal:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireLaserXX")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireLaserNoAmmo.Normal")
    TNT1 A 0 A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack (random(30,36), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleLaserCore", -2)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireLaserNoAmmo.Normal:
    TNT1 A 0 A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack (random(30,36), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleLaserCore", -2)
    Goto FireFinish
  FireLaserXX:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireLaserXXNoAmmo.Normal")
    TNT1 AAA 0 A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack ((6*6), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleLaserCore", -2)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireLaserXXNoAmmo.Normal:
    TNT1 AAA 0 A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack ((6*6), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleLaserCore", -2)
    Goto FireFinish

  FireLaser.Fancy:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",3,"FireLaserXX.Fancy")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireLaserNoAmmo.Fancy")
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleSpiral",0,0,0,0,CMF_TRACKOWNER) //A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack (random(30,36), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleFancyLaserCore", -2)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireLaserNoAmmo.Fancy:
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleSpiral",0,0,0,0,CMF_TRACKOWNER) //A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack (random(30,36), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleFancyLaserCore", -2)
    Goto FireFinish
  FireLaserXX.Fancy:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireLaserXXNoAmmo.Fancy")
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleSpiral",0,0,0,0,CMF_TRACKOWNER) //A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "", -2)
    TNT1 A 0 A_RailAttack ((6*6), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleFancyLaserCore", -2)
	TNT1 A 0 A_JumpIfInventory("PowerRLSoulstormRifleReloadTimer",1,"FireFinish")
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleClip", 1, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireLaserXXNoAmmo.Fancy:
    TNT1 A 0 A_FireCustomMissile("RLSoulstormRifleSpiral",0,0,0,0,CMF_TRACKOWNER) //A_RailAttack (0, 0, 0, "White", "None", RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 10, "RLParticleBeamCannonPuff2", 0, 0, 0, 3, 2, 0, "None", -2)
    TNT1 A 0 A_RailAttack ((6*6), 0, 0, "None", White, RGF_SILENT | RGF_NOPIERCING | RGF_FULLBRIGHT, 0, "RLParticleBeamCannonPuffNoSpecial", 0, 0, 0, 1, 10, 1, "RLSoulstormRifleFancyLaserCore", -2)
    Goto FireFinish
	
  FireFinish:
    TNT1 A 0 A_PlaySound("weapons/soulstormrifle", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/soulstormrifle", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
    TNT1 A 0 A_SpawnItemEx ("RLBattleRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SOLZ F 1 Bright A_GunFlash
    SOLZ G 1 Bright
    SOLZ HA 1
	Goto FireFinishContinue
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAmmochain",0,2)
	TNT1 A 0 A_Jump(256,3)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAmmochain",0)
    TNT1 A 0 A_ReFire
    Goto Ready
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAmmochain",1)
    TNT1 A 0 A_ReFire
    Goto Ready

//-------------------------------------------------------------------------------------------------
  FireFinishPowerupCheck: // Marine fires one Firestorm's worth faster while affected by powerups.
	TNT1 A 0 A_JumpIfInventory("PowerInvulnerable",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInvisibility",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerIronFeet",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerLightAmp",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerDrain",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerRLBerserkResistance",1,"FireFinishPowerupCheckConfirmed")
	Goto FireFinishPowerupCheckDone
  FireFinishPowerupCheckConfirmed:
    TNT1 A 0 A_SpawnItemEx ("RLUziRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SOLZ F 1 Bright A_GunFlash
    SOLZ G 1 Bright
    SOLZ H 1
	Goto FireFinishContinue
//-------------------------------------------------------------------------------------------------
  
	
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, 12)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, 9)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, 6)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, 3)
    SOLZ A 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReloadFrameChosen
    SOLZ B 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReloadFrameChosen
    SOLZ C 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReloadFrameChosen
    SOLZ D 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReloadFrameChosen
    SOLZ E 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto ReloadFrameChosen
  ReloadFrameChosen:
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleClip", 50, "Ready")
	Goto ReloadStartCheck
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleClip", 95, "Ready")
	Goto ReloadStartCheck
  ReloadStartCheck:
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleTechnicalMod",1,"Reload1")
    SOLD A 2
    SOLD B 2
    SOLD C 2
    SOLD D 2
    SOLD E 2
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleNanoMod",1,1)
	Goto ReloadNoX
	TNT1 A 0 A_RadiusGive("RLSoulstormRifleHealthDrain", 256, RGF_MONSTERS, 1)
	TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
    TNT1 A 0 A_Quake (1, 6, 0, 256, "")
    TNT1 A 0 A_Quake (3, 2, 0, 128, "")
  ReloadNoX:
	TNT1 A 0 A_PlaySound("weapons/soulstormriflescream", CHAN_WEAPON, 1, 0, 0.7)
    SOLD F 2
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleunload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SOLD G 2
    SOLD H 2
    SOLD I 2
    SOLD J 2
    SOLD K 2
    SOLD L 13
    SOLD M 2
    SOLD N 2
    SOLD O 2
	Goto ReloadWorking
  Reload1:
    SOLD A 2
    SOLD B 2
    SOLD C 2
    SOLD D 2
    SOLD E 2
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleNanoMod",1,1)
	Goto ReloadNoX1
	TNT1 A 0 A_RadiusGive("RLSoulstormRifleHealthDrain", 256, RGF_MONSTERS, 1)
	TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
    TNT1 A 0 A_Quake (1, 6, 0, 256, "")
    TNT1 A 0 A_Quake (3, 2, 0, 128, "")
  ReloadNoX1:
	TNT1 A 0 A_PlaySound("weapons/soulstormriflescream", CHAN_WEAPON, 1, 0, 0.7)
    SOLD F 2
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleunload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SOLD G 2
    SOLD H 2
    SOLD I 2
    SOLD J 2
    SOLD K 2
    SOLD L 10
    SOLD M 2
    SOLD N 2
    SOLD O 2
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleClip",50,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleClip",95,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleTechnicalMod",1,"ReloadFinish1")
    SOLD P 2
    SOLD Q 2
    SOLD R 2
    SOLD S 2
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleactivate", 7)
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleactivatepower", CHAN_WEAPON, 1, 0, 1.3)
    SOLD T 2
    SOLD U 2
    SOLD V 2
    SOLD A 3
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",1,2)
    SOLD A 7 A_ReFire
	Goto Ready
	TNT1 A 0 A_GiveInventory("PowerRLSoulstormRifleReloadTimer", 1)
    SOLD A 7 A_ReFire
	Goto Ready
  ReloadFinish1:
    SOLD P 2
    SOLD Q 2
    SOLD R 2
    SOLD S 2
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleactivate", 7)
	TNT1 A 0 A_PlaySound("weapons/soulstormrifleactivatepower", CHAN_WEAPON, 1, 0, 1.3)
    SOLD T 2
    SOLD U 2
    SOLD V 2
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",1,2)
    SOLD A 7 A_ReFire
	Goto Ready
	TNT1 A 0 A_GiveInventory("PowerRLSoulstormRifleReloadTimer", 1)
    SOLD A 7 A_ReFire
	Goto Ready
	
  Flash:
    TNT1 A 1 A_Light1
    TNT1 A 1 A_Light2
    TNT1 A 0 A_Light0
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLSoulstormRiflePickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION, 0, tid)
    Stop
  Altfire:
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ArmorModConversion")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ScavengerTime")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 4, 12)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 3, 9)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 2, 6)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleAnimationState", 1, 3)
    SOLZ A 2 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReadyNoReload
    SOLZ B 2 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReadyNoReload
    SOLZ C 2 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReadyNoReload
    SOLZ D 2 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	TNT1 A 0 A_GiveInventory("RLSoulstormRifleAnimationState", 1)
    Goto ReadyNoReload
    SOLZ E 2 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleAnimationState", 4)
    Goto ReadyNoReload
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRiflePowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleNanoMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleDemonArtifacts", 3)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	Goto ScavengerTimeEnd
  ArtifactDiscombobulation:
	TNT1 A 0 A_Print("The weapon tries to fight your attempts to remove an artifact.\nYou manage to remove one, but the weapon is ruined.")
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRiflePowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleNanoMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleDemonArtifacts", 3)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_FireCustomMissile("DroppedRLDemonArtifact",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",1,"ArtifactDiscombobulation")
	TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("OH GOD WHAT DID YOU DO")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRiflePowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleNanoMod", 1)
    TNT1 A 0 A_TakeInventory("RLSoulstormRifleDemonArtifacts", 3)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSoulstormRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_FireCustomMissile("DroppedRLDemonArtifact",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLSoulstormRifle",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		PROJECTILES

const float srst_velx = -3.5;
const float srst_x = -0.5;

ACTOR RLSoulstormRifleFancyLaserCore : RLSoulstormRifleLaserCore
{
	//Renderstyle Subtract
}

ACTOR RLSoulstormRifleSpiral
{
	Renderstyle Add
	Speed 20
	Scale 0.5
	+MISSILE
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			NRXP A 1 A_Weave(5,5,1,1)
			"####" "#" 0 A_SpawnItemEx("RLSoulstormRifleSpiralTrail",srst_x,0,0,srst_velx)
			
			"####" A 0 A_JumpIfInTargetInventory("RLPowerSoulstormRifleLaserMode",1,2)
			"####" B 0 A_JumpIfInTargetInventory("RLPowerSoulstormRifleLaserMode",1,1)
			Goto Death
			"####" "#" 0
			Goto Spawn
		Death:
			TNT1 A 1
			Stop
	}
}

ACTOR RLSoulstormRifleSpiralTrail
{
	Renderstyle Add
	Scale 0.5
	Alpha 0.5
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			NRXP B 1 A_SetScale(scalex - 0.1)
			"####" "#" 0 A_FadeOut
			NRXP C 1 A_SetScale(scalex - 0.1)
			"####" "#" 0 A_FadeOut
			NRXP D 1 A_SetScale(scalex - 0.1)
			"####" "#" 0 A_FadeOut
			NRXP E 1 A_SetScale(scalex - 0.1)
			"####" "#" 0 A_FadeOut
			NRXP F 1 A_SetScale(scalex - 0.1)
			"####" "#" 0 A_FadeOut
			Stop
	}
}

actor RLSoulstormRiflePuff : BulletPuff
{
	RenderStyle ADD
	Alpha 0.9
	Scale 0.5
	VSpeed 0
	DamageType "Bullet"
	Species "Player"
	+MTHRUSPECIES
	+FLOORCLIP
	+NOEXTREMEDEATH
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+PUFFGETSOWNER
	-ALLOWPARTICLES
	-SOLID
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump (256, "Animation")
			Goto Animation
		XDeath:
			TNT1 A 0
			TNT1 A 0 A_Jump (256, "Animation")
			Goto Animation
		Crash:
			TNT1 A 0
			TNT1 A 0 A_Jump (256, "Animation")
			Goto Animation
		Animation:
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Animation.Fancy")
		Animation.Normal:
			TNT1 A 0 A_Jump (128, 4)
			UNPF ABE 2 Bright
			stop
			UNPF CDE 2 Bright
			stop
		Animation.Fancy:
			TNT1 A 0 A_SpawnItemEx("RLDemonicWeponEvilTrace",0,0,frandom(-0.4,0.4),0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("RLPuffSmoke",0,0,0,0,0,0,0,0,188)
			TNT1 A 0 A_SpawnItemEx("RLRicochetEffect", 0, 0, 0, frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(0.0,360.0),0,128)
			TNT1 AAAA 0 A_SpawnItemEx("RLBulletPuffShrapnel", 0, 0, 0, frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(0.0,360.0),0,128)
			TNT1 A 0 A_Jump (128, 4)
			UNPF ABE 2 Bright
			Stop
			UNPF CDE 2 Bright
			Stop
	}
}

ACTOR RLSoulstormRiflePuffX : RLSoulstormRiflePuff
{
	+PUFFONACTORS
	DamageType "Unholy"
	States
	{
		Animation:
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Animation.Fancy")
		Animation.Normal:
			TNT1 A 0 A_Explode (10, 36, 0)
			SOLX AAABCDE 1 Bright
			stop
		Animation.Fancy:
			TNT1 A 0 A_SpawnItemEx("RLDemonicWeponEvilTrace",0,0,frandom(-0.4,0.4),0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("RLPuffSmoke",0,0,0,0,0,0,0,0,188)
			TNT1 A 0 A_SpawnItemEx("RLRicochetEffect", 0, 0, 0, frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(0.0,360.0),0,128)
			TNT1 AAAA 0 A_SpawnItemEx("RLBulletPuffShrapnel", 0, 0, 0, frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(0.0,360.0),0,128)
			TNT1 A 0 A_Explode (10, 32, 0)
			SOLX AAABCDE 1 Bright
			stop
	}
}

ACTOR RLSoulstormRifleBlast : PlasmaBall
{
	BounceType "Hexen"
	Species "Player"
	+THRUSPECIES
	+THRUGHOST
	+USEBOUNCESTATE
	+DONTREFLECT
	+SEEKERMISSILE
	+SCREENSEEKER
	+FORCEXYBILLBOARD
	BounceFactor 1
	WallBounceFactor 1
	BounceCount 2
	Radius 6
	Height 4
	RenderStyle Add
	Alpha 0.95
	Scale 0.45
	Speed 50
	Damage (random(25,29))
	Decal "Scorch"
	Damagetype "Plasma"
	SeeSound ""
	BounceSound ""
	DeathSound "weapons/unmakerimpact"
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInTargetInventory ("RLSoulstormRifleDemonArtifacts", 2, 1)
			Goto Spawn+3
			TNT1 A 0 A_SetDamageType ("Unholy")
			UNMP A 1 Bright A_SpawnItemEx ("RLSoulstormRifleBlastTrail", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
			TNT1 A 0 A_Jump (256, 1,2,3,4,5)
			TNT1 AAAA 0 A_SpawnItemEx ("RLUnmakerBoltSpark", frandom(-12,1), frandom(-4,4), frandom(-4,4), 0, 0, 0, 0, SXF_NOCHECKPOSITION)
			TNT1 A 0
			Goto Spawn+3
		Death:
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Death.Fancy")
			TNT1 A 0 A_SetScale (0.6)
			TNT1 A 0 A_JumpIfInTargetInventory ("RLSoulstormRifleDemonArtifacts", 2, "ExplodeX")
			UNMP GHIJKL 4 Bright
			Stop
		Death.Fancy:
			TNT1 A 0 A_SpawnItemEx("RLDemonicWeponEvilTrace",0,0,frandom(-0.4,0.4),0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("RLPuffSmoke",0,0,0,0,0,0,0,0,188)
			TNT1 A 0 A_SpawnItemEx("RLRicochetEffect", 0, 0, 0, frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(0.0,360.0),0,128)
			TNT1 AAAA 0 A_SpawnItemEx("RLBulletPuffShrapnel", 0, 0, 0, frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(0.0,360.0),0,128)
			TNT1 A 0 A_SetScale (0.6)
			TNT1 A 0 A_JumpIfInTargetInventory ("RLSoulstormRifleDemonArtifacts", 2, "ExplodeX.Fancy")
			UNMP GHIJKL 4 Bright
			Stop
		ExplodeX:
			TNT1 A 0 A_SetScale (1.4)
			TNT1 A 0 A_Explode (32, 64, 0)
			SOLX FFFGHIJ 2 Bright
			Stop
		ExplodeX.Fancy:
			TNT1 A 0 A_SpawnItemEx("RLDemonicWeponEvilTrace",0,0,frandom(-0.4,0.4),0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("RLPuffSmoke",0,0,0,0,0,0,0,0,188)
			TNT1 A 0 A_SpawnItemEx("RLRicochetEffect", 0, 0, 0, frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(-10.0,10.0), frandom(0.0,360.0),0,128)
			TNT1 AAAA 0 A_SpawnItemEx("RLBulletPuffShrapnel", 0, 0, 0, frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(-5.0,5.0), frandom(0.0,360.0),0,128)
			TNT1 A 0 A_SetScale (1.4)
			TNT1 A 0 A_Explode (32, 64, 0)
			SOLX FFFGHIJ 2 Bright
			Stop
		Bounce:
			TNT1 A 0 A_Jump (128, "Spawn")
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256) 
			Goto Spawn+3
	}
}

ACTOR RLSoulstormRifleBlastXX : RLSoulstormRifleBlast
{
  Damage (6*6)
}

actor RLSoulstormRifleBlastTrail
{
    Radius 1
    Height 1
    Speed 0
    +NOGRAVITY
    -SOLID
    +NOCLIP
    +RANDOMIZE
    +NOINTERACTION
	+FORCEXYBILLBOARD
    Scale 0.45
    RenderStyle Add
    Alpha 0.95
    States
    {
      Spawn:
        TNT1 A 0
        UNMP A 1 Bright A_FadeTo (0, 0.1, 1)
        Goto Spawn+1
    }
}

ACTOR RLSoulstormRifleHealthDrain : CustomInventory
{
  -COUNTITEM
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage ""
  Inventory.PickupSound ""
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_SpawnItemEx ("RLSoulshatterArmorWave", 2,0,16, 0,0,0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_Jump (256, 1,2,3,4,5,6,7,8,9)
	TNT1 AAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("RLUnmakerBoltSpark", frandom(-25,25), frandom(-25,25), frandom(0,56), 0,0,0, 0, SXF_NOCHECKPOSITION)
	TNT1 A 0 ACS_NamedExecuteAlways("DRLA_SoulShatterSplit", 0)
    Stop
  }
}

//-------------------------------------------------------------------
//		MECHANICS

Actor RLSoulstormRifleSelected : RLPermanentInventory {}
Actor RLSoulstormRifleDemonArtifacts : RLDemonArtifactAmount {}
Actor RLSoulstormRifleAmmochain : RLAmmochainDefault {}
Actor RLSoulstormRifleAnimationState : RLPermanentInventory
{
inventory.maxamount 4
}

Actor RLSoulstormRifleModLimit : RLUniqueModAmount {}
Actor RLSoulstormRiflePowerMod : RLUniqueModAmount {}
Actor RLSoulstormRifleBulkMod : RLUniqueModAmount {}
Actor RLSoulstormRifleAgilityMod : RLUniqueModAmount {}
Actor RLSoulstormRifleTechnicalMod : RLUniqueModAmount {}
Actor RLSoulstormRifleNanoMod : RLUniqueModAmount {}
Actor RLSoulstormRifleFirestormMod : RLUniqueModAmount {}
Actor RLSoulstormRifleSniperMod : RLUniqueModAmount {}

ACTOR PowerRLSoulstormRifleReloadTimer : Powerup
{
	Powerup.Duration -5
}

ACTOR RLPowerSoulstormRifleLaserMode : Powerup
{
	Powerup.Duration -6
}

ACTOR RLSoulstormRifleClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 95
   Inventory.Icon ""
}

//-------------------------------------------------------------------
//		PICKUPS

ACTOR RLSoulstormRiflePickup : RLDemonicWeaponPickup
{
	//$Sprite SOLDX0
	Tag "Soulstorm Rifle [Pickup]"
	States
	{
	SpawnFrame:
		SOLD X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(Abs(VelZ) <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 1
		Loop
	FloorHit:
		"####" "#" 0 A_PlaySound("weapons/gundropmedium")
		"####" "#" 0 A_ScaleVelocity (0.5)
		"####" "#" 0 A_ChangeFlag("SPECIAL", true)
		"####" "#" 0 A_ChangeFlag("THRUACTORS", false)
		"####" "#" 0 A_SetUserVar("user_floorhit", 1)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Stop
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLSoulstormRifle",1,"NotPickup") // If the player already has this weapon, they are not given the weapon
		"####" "#" 0 A_JumpIfInventory("RLWeaponLimit",0,"NotPickupLimit") // The absolute max limit check for weapons
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLSoulstormRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLDemonicItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cgSoulstorm Rifle.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_Jump(256, "NotPickup")
		Goto NotPickup
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cg= Soulstorm Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/SoulstormRiflepickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	SuperweaponStuff:
		"####" "#" 0 A_Jump(256, "NoSpecialStartsStuff")
		Goto NoSpecialStartsStuff
	}
}

ACTOR RLSoulstormRifleWorldSpawnPickup : RLSoulstormRiflePickup 17202
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamDemonicWorld", 0,0,0, 0,0,0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
		"####" "#" 0 A_Jump(256, "SpawnFrame")
		Goto SpawnFrame
		
	SpawnFrame:
		SOLD X 4
		"####" "#" 0 A_GiveInventory("RLDemonicItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/demonicspawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLSoulstormRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLDemonicItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cgSoulstorm Rifle.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelDemonicGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}

ACTOR RLSoulstormRiflePickupModded : RLSoulstormRiflePickup
{
	+INVENTORY.TRANSFER
	States
	{
	Spawn:
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("GetWeaponMods", 0)
		TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 0, "NoSpecialStartsStuff")
		"####" "#" 0 A_Jump(256, "SpecialStartsStuff")
		Goto SpecialStartsStuff
		
	SpawnFrame:
		SOLD X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(VelZ <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 0 ACS_NamedExecuteAlways("RLWeaponModDisplay", 0)
		"####" "#" 1
		Loop
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLSoulstormRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLDemonicItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cgSoulstorm Rifle.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cg= Soulstorm Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLSoulstormRifleModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cg= Soulstorm Rifle =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Clip",52)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cg= Soulstorm Rifle =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
