
ACTOR RLHighPowerNuclearPlasmaRifle : RLWeapon
{
  Obituary "%o was exposed to nuclear energy by %k."
  Tag "High Power Nuclear Plasma Rifle"
  Weapon.SelectionOrder 5000
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLHighPowerNuclearPlasmaRifleClip"
  Inventory.Icon "QNPLICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/hpnukeplasmarifleidle", 6, 1, 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip", 1, "ReadyCantAltFire")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyCanAltFire")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyCanAltFire")
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	Goto ReadyCycleCharging
  ReadyCanAltFire:
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL 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 ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
  ReadyCanFire:
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
//=================================================================================
  ReadyCycleCharging:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip", 1, "ReadyCycleCharged")
	Goto ReadyChargingAmmo
  ReadyChargingAmmo:
	QNPL A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifleClip", 1)
    TNT1 A 0 A_GunFlash ("FlashAmmo", 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)
    QNPL A 6 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    QNPL A 3 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
  ReadyChargingAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    QNPL A 6 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    QNPL A 3 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
//=================================================================================
  ReadyCycleCharged:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip", 16, "Ready")
	Goto ReadyChargedAmmo
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip", 21, "Ready")
	Goto ReadyChargedAmmo
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip", 26, "Ready")
	Goto ReadyChargedAmmo
  ReadyChargedAmmo:
	QNPL A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifleClip", 1)
    TNT1 A 0 A_GunFlash ("FlashAmmo", 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)
    QNPL A 6 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    QNPL A 3 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
  ReadyChargedAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    QNPL A 6 A_WeaponReady (WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    QNPL 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 ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	Goto Ready
  ReadyDepletedCanAltFire:
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL 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_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLHighPowerNuclearPlasmaRiflePickup", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLHighPowerNuclearPlasmaRiflePickupModded", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLHighPowerNuclearPlasmaRifle",1)
	Stop
	
  AfterModDrop:
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (16)
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL 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_GunFlash ("FlashDrop", GFF_NOEXTCHANGE)
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 A 0 A_Lower
    QNPL 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("RLBasicAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearAmmoWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianBasicDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    QNPL A 1 A_Raise
    Loop
	
  Fire:
	QNPL A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	QNPL A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	QNPL A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	QNPL A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	QNPL 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("RLHighPowerNuclearPlasmaRifleSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRiflePowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBall", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBall", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRiflePowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAgilityMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRiflePowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAgilityMod",2,"FireAA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePP:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallPP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallPP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePA:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallPA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallPA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireAA:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRiflePowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAgilityMod",1,"FireSA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallS", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallS", 0, 0)
    Goto FireFinish
  FireSS:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSS", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSS", 0, 0)
    Goto FireFinish
  FireSP:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSP", 0, 0)
    Goto FireFinish
  FireSA:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLHighPowerPlasmaBallSA", 0, 0)
    Goto FireFinish
	
  FireFinish:
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,"FireFinishFF")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,"FireFinishF")
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QNPL B 1 Bright A_GunFlash ("Flash")
    QNPL C 2 Bright
    Goto FireFinishAmmochain
  FireFinishF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle2Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QNPL B 1 Bright A_GunFlash ("Flash")
    QNPL C 1 Bright
    Goto FireFinishAmmochain
  FireFinishFF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle3Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,3)
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifleState",1)
    QNPL B 1 Bright A_GunFlash ("Flash")
    Goto FireFinishAmmochain
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleState",1)
    QNPL C 1 Bright A_GunFlash ("Flash")
    Goto FireFinishAmmochain
  FireFinishAmmochain:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleAmmochain",0,3)
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifleAmmochain",1)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleAmmochain",3)
	TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
    QNPL A 5 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_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,"FireFinishFF")
	Goto FireFinishF
//-------------------------------------------------------------------------------------------------
  
	
//==============================================================================
//		Better watch out, it's the super ultra ammo flash state extravaganza!
//					Not for the faint of heart, or the sane.
//
//				I definitely did not make this just to make people cry.
//									I would never.
//==============================================================================

  FlashDrop:
    TNT1 A 0 A_Light0
    Goto LightDone

//==============================================================================
//								Firing ammo counter
  Flash:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",2,"FlashBulk2")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",1,"FlashBulk1")
    Goto FlashBulk0
	
  FlashBulk0:// 16 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",0,"FlashBulk0A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",15,"FlashBulk0B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",13,"FlashBulk0C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",10,"FlashBulk0D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",7,"FlashBulk0E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",4,"FlashBulk0F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashBulk0G")
	Goto FlashBulk0H
  FlashBulk0A:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 A 1 Bright A_Light1
    QNP2 A 3 Bright A_Light2
    Goto LightDone
    QNP1 A 1 Bright A_Light1
    QNP2 A 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 A 2 Bright A_Light1
    Goto LightDone
    QNP2 A 2 Bright A_Light2
    Goto LightDone
  FlashBulk0B:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 B 1 Bright A_Light1
    QNP2 B 3 Bright A_Light2
    Goto LightDone
    QNP1 B 1 Bright A_Light1
    QNP2 B 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 B 2 Bright A_Light1
    Goto LightDone
    QNP2 B 2 Bright A_Light2
    Goto LightDone
  FlashBulk0C:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 C 1 Bright A_Light1
    QNP2 C 3 Bright A_Light2
    Goto LightDone
    QNP1 C 1 Bright A_Light1
    QNP2 C 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 C 2 Bright A_Light1
    Goto LightDone
    QNP2 C 2 Bright A_Light2
    Goto LightDone
  FlashBulk0D:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 D 1 Bright A_Light1
    QNP2 D 3 Bright A_Light2
    Goto LightDone
    QNP1 D 1 Bright A_Light1
    QNP2 D 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 D 2 Bright A_Light1
    Goto LightDone
    QNP2 D 2 Bright A_Light2
    Goto LightDone
  FlashBulk0E:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 E 1 Bright A_Light1
    QNP2 E 3 Bright A_Light2
    Goto LightDone
    QNP1 E 1 Bright A_Light1
    QNP2 E 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 E 2 Bright A_Light1
    Goto LightDone
    QNP2 E 2 Bright A_Light2
    Goto LightDone
  FlashBulk0F:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 F 1 Bright A_Light1
    QNP2 F 3 Bright A_Light2
    Goto LightDone
    QNP1 F 1 Bright A_Light1
    QNP2 F 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 F 2 Bright A_Light1
    Goto LightDone
    QNP2 F 2 Bright A_Light2
    Goto LightDone
  FlashBulk0G:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 G 1 Bright A_Light1
    QNP2 G 3 Bright A_Light2
    Goto LightDone
    QNP1 G 1 Bright A_Light1
    QNP2 G 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 G 2 Bright A_Light1
    Goto LightDone
    QNP2 G 2 Bright A_Light2
    Goto LightDone
  FlashBulk0H:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",2,6)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 H 1 Bright A_Light1
    QNP2 H 3 Bright A_Light2
    Goto LightDone
    QNP1 H 1 Bright A_Light1
    QNP2 H 2 Bright A_Light2
    Goto LightDone
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleState",1,2)
    QNP1 H 2 Bright A_Light1
    Goto LightDone
    QNP2 H 2 Bright A_Light2
    Goto LightDone
	
  FlashBulk1:// 21 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",0,"FlashBulk1A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",20,"FlashBulk1B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",17,"FlashBulk1C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",13,"FlashBulk1D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",9,"FlashBulk1E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",4,"FlashBulk1F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashBulk1G")
	Goto FlashBulk1H
  FlashBulk1A:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 A 1 Bright A_Light1
    QNP2 A 3 Bright A_Light2
    Goto LightDone
    QNP1 A 1 Bright A_Light1
    QNP2 A 2 Bright A_Light2
    Goto LightDone
  FlashBulk1B:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 B 1 Bright A_Light1
    QNP2 B 3 Bright A_Light2
    Goto LightDone
    QNP1 B 1 Bright A_Light1
    QNP2 B 2 Bright A_Light2
    Goto LightDone
  FlashBulk1C:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 C 1 Bright A_Light1
    QNP2 C 3 Bright A_Light2
    Goto LightDone
    QNP1 C 1 Bright A_Light1
    QNP2 C 2 Bright A_Light2
    Goto LightDone
  FlashBulk1D:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 D 1 Bright A_Light1
    QNP2 D 3 Bright A_Light2
    Goto LightDone
    QNP1 D 1 Bright A_Light1
    QNP2 D 2 Bright A_Light2
    Goto LightDone
  FlashBulk1E:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 E 1 Bright A_Light1
    QNP2 E 3 Bright A_Light2
    Goto LightDone
    QNP1 E 1 Bright A_Light1
    QNP2 E 2 Bright A_Light2
    Goto LightDone
  FlashBulk1F:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 F 1 Bright A_Light1
    QNP2 F 3 Bright A_Light2
    Goto LightDone
    QNP1 F 1 Bright A_Light1
    QNP2 F 2 Bright A_Light2
    Goto LightDone
  FlashBulk1G:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 G 1 Bright A_Light1
    QNP2 G 3 Bright A_Light2
    Goto LightDone
    QNP1 G 1 Bright A_Light1
    QNP2 G 2 Bright A_Light2
    Goto LightDone
  FlashBulk1H:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleFirestormMod",1,3)
    QNP1 H 1 Bright A_Light1
    QNP2 H 3 Bright A_Light2
    Goto LightDone
    QNP1 H 1 Bright A_Light1
    QNP2 H 2 Bright A_Light2
    Goto LightDone
	
	
  FlashBulk2:// 26 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",0,"FlashBulk2A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",25,"FlashBulk2B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",21,"FlashBulk2C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",16,"FlashBulk2D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",11,"FlashBulk2E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",6,"FlashBulk2F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashBulk2G")
	Goto FlashBulk2H
  FlashBulk2A:
    QNP1 A 1 Bright A_Light1
    QNP2 A 3 Bright A_Light2
    Goto LightDone
  FlashBulk2B:
    QNP1 B 1 Bright A_Light1
    QNP2 B 3 Bright A_Light2
    Goto LightDone
  FlashBulk2C:
    QNP1 C 1 Bright A_Light1
    QNP2 C 3 Bright A_Light2
    Goto LightDone
  FlashBulk2D:
    QNP1 D 1 Bright A_Light1
    QNP2 D 3 Bright A_Light2
    Goto LightDone
  FlashBulk2E:
    QNP1 E 1 Bright A_Light1
    QNP2 E 3 Bright A_Light2
    Goto LightDone
  FlashBulk2F:
    QNP1 F 1 Bright A_Light1
    QNP2 F 3 Bright A_Light2
    Goto LightDone
  FlashBulk2G:
    QNP1 G 1 Bright A_Light1
    QNP2 G 3 Bright A_Light2
    Goto LightDone
  FlashBulk2H:
    QNP1 H 1 Bright A_Light1
    QNP2 H 3 Bright A_Light2
    Goto LightDone
	
	
//==============================================================================
//								Idle ammo counter
  FlashAmmo:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",2,"FlashAmmoBulk2")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleBulkMod",1,"FlashAmmoBulk1")
    Goto FlashAmmoBulk0
	
  FlashAmmoBulk0:// 16 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",16,"FlashAmmoBulk0A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",15,"FlashAmmoBulk0B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",13,"FlashAmmoBulk0C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",10,"FlashAmmoBulk0D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",7,"FlashAmmoBulk0E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",4,"FlashAmmoBulk0F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashAmmoBulk0G")
	Goto FlashAmmoBulk0H
  FlashAmmoBulk0A:
    QNP1 A 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0B:
    QNP1 B 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0C:
    QNP1 C 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0D:
    QNP1 D 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0E:
    QNP1 E 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0F:
    QNP1 F 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0G:
    QNP1 G 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk0H:
    QNP1 H 6 Bright A_Light0
    Goto LightDone
	
  FlashAmmoBulk1:// 21 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",21,"FlashAmmoBulk1A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",20,"FlashAmmoBulk1B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",17,"FlashAmmoBulk1C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",13,"FlashAmmoBulk1D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",9,"FlashAmmoBulk1E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",4,"FlashAmmoBulk1F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashAmmoBulk1G")
	Goto FlashAmmoBulk1H
  FlashAmmoBulk1A:
    QNP1 A 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1B:
    QNP1 B 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1C:
    QNP1 C 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1D:
    QNP1 D 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1E:
    QNP1 E 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1F:
    QNP1 F 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1G:
    QNP1 G 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk1H:
    QNP1 H 6 Bright A_Light0
    Goto LightDone
	
  FlashAmmoBulk2:// 26 shots at max capacity
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",26,"FlashAmmoBulk2A")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",25,"FlashAmmoBulk2B")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",21,"FlashAmmoBulk2C")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",16,"FlashAmmoBulk2D")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",11,"FlashAmmoBulk2E")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",6,"FlashAmmoBulk2F")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleClip",1,"FlashAmmoBulk2G")
	Goto FlashAmmoBulk2H
  FlashAmmoBulk2A:
    QNP1 A 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2B:
    QNP1 B 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2C:
    QNP1 C 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2D:
    QNP1 D 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2E:
    QNP1 E 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2F:
    QNP1 F 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2G:
    QNP1 G 6 Bright A_Light0
    Goto LightDone
  FlashAmmoBulk2H:
    QNP1 H 6 Bright A_Light0
    Goto LightDone

//==============================================================================

  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLHighPowerNuclearPlasmaRiflePickup",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 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
    TNT1 A 0 A_StopSound(6)
	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("RLHighPowerWeaponAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleModLimit",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("RLHighPowerNuclearPlasmaRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
    TNT1 A 0 A_StopSound(6)
	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)
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLHighPowerNuclearPlasmaRifle",1)
	Stop
  }
}

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

Actor RLHighPowerNuclearPlasmaRifleSelected : RLPermanentInventory {}
Actor RLHighPowerNuclearPlasmaRifleState : RLPermanentInventory {}
Actor RLHighPowerNuclearPlasmaRifleAmmochain : RLAmmochainDefault {}
Actor RLHighPowerNuclearPlasmaRifleModLimit : RLBasicAssemblyModAmount {}
Actor RLHighPowerNuclearPlasmaRiflePowerMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerNuclearPlasmaRifleBulkMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerNuclearPlasmaRifleAgilityMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerNuclearPlasmaRifleFirestormMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerNuclearPlasmaRifleSniperMod : RLBasicAssemblyModAmount {}

ACTOR RLHighPowerNuclearPlasmaRifleClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 26
   Inventory.Icon ""
}

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

ACTOR RLHighPowerNuclearPlasmaRiflePickup : RLBasicAssembledWeaponPickup 17421
{
	//$Sprite QNPLX0
	Tag "High Power Nuclear Plasma Rifle [Pickup]"
	States
	{
	SpawnFrame:
		QNPL 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("RLHighPowerNuclearPlasmaRifle",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("RLHighPowerNuclearPlasmaRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvHigh Power Nuclear Plasma 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("\cv= High Power Nuclear Plasma Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/hpnukePlasmaRiflepickup")
		Stop
/*	SetBonusStart:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusWeapon",1)
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,"SetBonusCheck")
		"####" "#" 0 A_Print("\ccPicked up a \cvHigh Power Nuclear Plasma Rifle.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	SetBonusCheck:
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,2)
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusActive",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvHigh Power Nuclear Plasma Rifle.\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 RLHighPowerNuclearPlasmaRiflePickupModded : RLHighPowerNuclearPlasmaRiflePickup
{
	+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:
		QNPL 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("RLHighPowerNuclearPlasmaRifle",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= High Power Nuclear Plasma Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= High Power Nuclear Plasma Rifle =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= High Power Nuclear Plasma Rifle =\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 \cvHigh Power Nuclear Plasma Rifle.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon*/
	}
}
