
ACTOR RLStormNuclearPlasmaPistol : RLPistolWeapon
{
  Obituary "%o was blasted apart by %k."
  Tag "Storm Nuclear Plasma Pistol"
  Weapon.SelectionOrder 3900
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLStormNuclearPlasmaPistolClip"
  Inventory.Icon "NUK4ICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/stormnukeplasmapistolidle", 6, 1, 1)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 1, "ReadyCantAltFire")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyCanAltFire")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyCanAltFire")
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	Goto ReadyCycleCharging
  ReadyCanAltFire:
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	Goto ReadyCycleCharging
  ReadyCantAltFire:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyCanFire")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyCanFire")
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
  ReadyCanFire:
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
//=================================================================================
  ReadyCycleCharging:
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 1, "ReadyCycleCharged")
	Goto ReadyChargingAmmo
  ReadyChargingAmmo:
	NUSP A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLStormNuclearPlasmaPistolClip", 1)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyChargingAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyChargingAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    NUSP A 6 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    NUSP A 3 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
  ReadyChargingAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    NUSP A 6 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    NUSP A 3 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
//=================================================================================
  ReadyCycleCharged:
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 24, "Ready")
	Goto ReadyChargedAmmo
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 31, "Ready")
	Goto ReadyChargedAmmo
  ReadyChargedAmmo:
	NUSP A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLStormNuclearPlasmaPistolClip", 1)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyChargedAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyChargedAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    NUSP A 6 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    NUSP A 3 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
  ReadyChargedAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    NUSP A 6 A_WeaponReady (WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    NUSP A 3 A_WeaponReady (WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
//=================================================================================
  ReadyDepleted:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyDepletedCanAltFire")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyDepletedCanAltFire")
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	Goto Ready
  ReadyDepletedCanAltFire:
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	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 Mod Pack.")
	Goto AfterModDrop
  WeaponDropConfirm:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 ACS_NamedExecuteWithResult("RLNuclearSetBonusCheck", 1) // Checks for all parts of the set bonus, gives or removes it accordingly - argument is tic delay before checking
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLStormNuclearPlasmaPistolPickup", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLStormNuclearPlasmaPistolPickupModded", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSniperMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLStormNuclearPlasmaPistol",1)
	Stop
  AfterModDrop:
	TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD)
	TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP A 5 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD)
    Goto Ready
  MisfirePrevention:
	TNT1 A 0 A_GunFlash ("Flash", GFF_NOEXTCHANGE)
    NUSP 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_StopSound(6)
    TNT1 A 0 A_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 AA 0 A_Lower
    NUSP A 1 A_Lower
    Goto DeselectLoop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLAdvancedAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLShotgunTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearAmmoWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLStormNuclearPlasmaPistolSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianAdvancedDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 AA 0 A_Raise
    NUSP A 1 A_Raise
    Loop
// 7x damage with Scout, half spread
  Fire:
	NUSP A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	NUSP A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	NUSP A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	NUSP A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	NUSP A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("ReadyDepleted")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolAgilityMod",1,"FireA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegade")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,3)
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBall", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBall", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallSharpshooter", frandom(-1.5,1.5), 1, 0, 0, 0, frandom(-1,1))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallSharpshooter", frandom(-1.5,1.5), 0, 0, 0, 0, frandom(-1,1))
    Goto FireFinish
  FireRenegade:
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBall", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 AA 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBall", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
  FireP:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeP")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,3)
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallP", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallP", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallPSharpshooter", frandom(-1.5,1.5), 1, 0, 0, 0, frandom(-1,1))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallPSharpshooter", frandom(-1.5,1.5), 0, 0, 0, 0, frandom(-1,1))
    Goto FireFinish
  FireRenegadeP:
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallP", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 AA 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallP", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
  FireA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,3)
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallA", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallA", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallASharpshooter", frandom(-1.5,1.5), 1, 0, 0, 0, frandom(-1,1))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallASharpshooter", frandom(-1.5,1.5), 0, 0, 0, 0, frandom(-1,1))
    Goto FireFinish
  FireRenegadeA:
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallA", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 AA 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallA", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
  FireS:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeS")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,3)
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallS", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallS", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallSSharpshooter", frandom(-1.5,1.5), 1, 0, 0, 0, frandom(-1,1))
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallSSharpshooter", frandom(-1.5,1.5), 0, 0, 0, 0, frandom(-1,1))
    Goto FireFinish
  FireRenegadeS:
	TNT1 A 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallS", frandom(-3,3), 1, 0, 0, 0, frandom(-2,2))
	TNT1 AA 0 A_FireCustomMissile ("RLStormNuclearPlasmaPistolBallS", frandom(-3,3), 0, 0, 0, 0, frandom(-2,2))
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLPistolRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolFirestormMod",1,"FireFinishF")
    NUSP B 3 Bright A_GunFlash ("FlashB")
    NUSP C 3 Bright A_GunFlash ("FlashC")
    NUSP D 3 A_GunFlash ("FlashB")
    TNT1 A 0 A_GunFlash
    NUSP A 5 A_Refire
    Goto Ready
  FireFinishF:
    NUSP B 2 Bright A_GunFlash ("FlashB")
    NUSP C 2 Bright A_GunFlash ("FlashC")
    NUSP D 2 A_GunFlash ("FlashB")
    TNT1 A 0 A_GunFlash
    NUSP A 5 A_Refire
    Goto Ready
  Flash:
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 24, 6)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 12, 4)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 1, 2)
    NU2Y A 6 Bright
    Goto LightDone
    NU2Y B 6 Bright
    Goto LightDone
    NU2Y C 6 Bright
    Goto LightDone
    NU2Y D 6 Bright
    Goto LightDone
  FlashB:
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 24, 6)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 12, 4)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 1, 2)
    NU2Y E 3 Bright
    Goto LightDone
    NU2Y F 3 Bright
    Goto LightDone
    NU2Y G 3 Bright
    Goto LightDone
    NU2Y H 3 Bright
    Goto LightDone
  FlashC:
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 24, 6)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 12, 4)
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolClip", 1, 2)
    NU2Y I 3 Bright
    Goto LightDone
    NU2Y J 3 Bright
    Goto LightDone
    NU2Y K 3 Bright
    Goto LightDone
    NU2Y L 3 Bright
    Goto LightDone
  FlashDrop:
    TNT1 A 0
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLStormNuclearPlasmaPistolPickup",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")
	Goto Ready
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolFirestormMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
	TNT1 A 0 ACS_NamedExecuteWithResult("RLNuclearSetBonusCheck", 1) // Checks for all parts of the set bonus, gives or removes it accordingly - argument is tic delay before checking
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLStormPistolAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolFirestormMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLStormNuclearPlasmaPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
	TNT1 A 0 ACS_NamedExecuteWithResult("RLNuclearSetBonusCheck", 1) // Checks for all parts of the set bonus, gives or removes it accordingly - argument is tic delay before checking
  ScavengerContinue:
	TNT1 A 0 A_Jump(256,1,2,3)
	TNT1 A 0 A_FireCustomMissile("DroppedRLTechnicalMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLStormNuclearPlasmaPistol",1)
	Stop
  }
}

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

ACTOR RLStormNuclearPlasmaPistolBall : RLNuclearPlasmaPistolBall
{
  Species "Player"
  +THRUSPECIES
  +THRUGHOST
  +FORCEXYBILLBOARD
  Decal "PlasmaScorch"
  Alpha 0.85
  Scale 0.7
  Damagetype "Plasma"
  Damage 6
  SeeSound "weapons/stormnukeplasma"
  DeathSound "weapons/stormnukeplasmaimpact"
}

ACTOR RLStormNuclearPlasmaPistolBallP : RLStormNuclearPlasmaPistolBall
{
  Damage 7
}

ACTOR RLStormNuclearPlasmaPistolBallA : RLStormNuclearPlasmaPistolBall
{
  Speed 35
}

ACTOR RLStormNuclearPlasmaPistolBallS : RLStormNuclearPlasmaPistolBall
{
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_JumpIf(CallACS("DRLA_FancyProjectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PLSS AB 4 Bright A_ScaleVelocity(1.10)
			Loop
		Spawn.Fancy:
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			
			Loop
	}
}

//-------------------------------------------------------------------
//		SHARPSHOOTER PROJECTILES

ACTOR RLStormNuclearPlasmaPistolBallSharpshooter : RLStormNuclearPlasmaPistolBall
{
  Damage (42)
}

ACTOR RLStormNuclearPlasmaPistolBallPSharpshooter : RLStormNuclearPlasmaPistolBallSharpshooter
{
  Damage (49)
}

ACTOR RLStormNuclearPlasmaPistolBallASharpshooter : RLStormNuclearPlasmaPistolBallSharpshooter
{
  Speed 35
}

ACTOR RLStormNuclearPlasmaPistolBallSSharpshooter : RLStormNuclearPlasmaPistolBallSharpshooter
{
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_JumpIf(CallACS("DRLA_FancyProjectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PLSS AB 4 Bright A_ScaleVelocity(1.10)
			Loop
		Spawn.Fancy:
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			
			Loop
	}
}

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

Actor RLStormNuclearPlasmaPistolSelected : RLPermanentInventory {}
Actor RLStormNuclearPlasmaPistolModLimit : RLAdvancedAssemblyModAmount {}
Actor RLStormNuclearPlasmaPistolPowerMod : RLAdvancedAssemblyModAmount {}
Actor RLStormNuclearPlasmaPistolBulkMod : RLAdvancedAssemblyModAmount {}
Actor RLStormNuclearPlasmaPistolAgilityMod : RLAdvancedAssemblyModAmount {}
Actor RLStormNuclearPlasmaPistolFirestormMod : RLAdvancedAssemblyModAmount {}
Actor RLStormNuclearPlasmaPistolSniperMod : RLAdvancedAssemblyModAmount {}

ACTOR RLStormNuclearPlasmaPistolClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 31
   Inventory.Icon ""
}

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

ACTOR RLStormNuclearPlasmaPistolPickup : RLAdvancedAssembledWeaponPickup 17626
{
	//$Sprite NUSPX0
	Tag "Storm Nuclear Plasma Pistol [Pickup]"
	States
	{
	SpawnFrame:
		NUSP 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/gundropsmall")
		"####" "#" 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("RLStormNuclearPlasmaPistol",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 ACS_NamedExecuteWithResult("RLNuclearSetBonusCheck", 1) // Checks for all parts of the set bonus, gives or removes it accordingly - argument is tic delay before checking
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLStormNuclearPlasmaPistol",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvStorm Nuclear Plasma Pistol.")
		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("\cv= Storm Nuclear Plasma Pistol =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/StormNukePlasmaPistolpickup")
		Stop
/*	SetBonusStart:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusWeapon",1)
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,"SetBonusCheck")
		"####" "#" 0 A_Print("\ccPicked up a \cvStorm Nuclear Plasma Pistol.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	SetBonusCheck:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusActive",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvStorm Nuclear Plasma Pistol.\n\c-= FURIOUS FUSION =\n\ccNuclear weaponry recharges twice as fast", 8, "CONFONT")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon*/
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLStormNuclearPlasmaPistolPickupModded : RLStormNuclearPlasmaPistolPickup
{
	+INVENTORY.TRANSFER
	+DONTGIB
	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:
		NUSP 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("RLStormNuclearPlasmaPistol",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Storm Nuclear Plasma Pistol =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLStormNuclearPlasmaPistolModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Storm Nuclear Plasma Pistol =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Storm Nuclear Plasma Pistol =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
/*	SetBonusStart:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusWeapon",1)
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,"SetBonusCheck")
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvStorm Nuclear Plasma Pistol.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon*/
	}
}
