
ACTOR RLNuclearPlasmaRifle : RLWeapon
{
  Obituary "%o was exposed to nuclear energy by %k."
  Tag "Nuclear Plasma Rifle"
  Weapon.SelectionOrder 5000
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLNuclearPlasmaRifleClip"
  Inventory.Icon "NUK1ICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/nuclearplasmarifleidle", 6, 1, 1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleState",1)
	TNT1 A 0 A_JumpIfNoAmmo("ForceRecharge")
    NUKP A 5 A_WeaponReady (32)
  ReadyRechargeCycle:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleClip", 24, "Ready")
	Goto ReadyRechargeAmmo
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleClip", 31, "Ready")
	Goto ReadyRechargeAmmo
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleBulkMod",3,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleClip", 38, "Ready")
	Goto ReadyRechargeAmmo
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleBulkMod",4,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleClip", 45, "Ready")
	Goto ReadyRechargeAmmo
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleClip", 52, "Ready")
	Goto ReadyRechargeAmmo
  ReadyRechargeAmmo:
	NUKP A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleClip", 1)
	TNT1 A 0 A_GunFlash ("FlashAmmo", GFF_NOEXTCHANGE)
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 2)
    NUKP A 6 A_WeaponReady (32)
    Goto ReadyRechargeCycle
    NUKP A 3 A_WeaponReady (32)
    Goto ReadyRechargeCycle
  ForceRecharge:
    NUKP A 70 A_WeaponReady (44)
    Goto ReadyRechargeCycle
	
  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_JumpIfInventory("RLNuclearPlasmaRifleModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLNuclearPlasmaRiflePickup", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLNuclearPlasmaRiflePickupModded", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleMkIIConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
	
  AfterModDrop:
    NUKP A 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    NUKP 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_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 A 0 A_Lower
    NUKP 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("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearAmmoWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLExoticWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    NUKP A 1 A_Raise
    Loop
	
  Fire:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifleConfirm",1, "AssembleHighPowerNuclearPlasmaRifle")
	TNT1 A 0 A_JumpIfInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1, "AssembleAssaultRifleNuclearPlasmaRifle")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1, "AssembleBurstCannonNuclearPlasmaRifle")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleMkIIConfirm",1, "AssembleNuclearPlasmaRifleMkII")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaShotgunConfirm",1, "AssembleNuclearPlasmaShotgun")
	
	NUKP A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	NUKP A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	NUKP A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	NUKP A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	NUKP A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Ready")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBall", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBall", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FireAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",3,"FirePPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FirePPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FirePPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FirePAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FirePAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",3,"FireAAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePPP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",4,"FirePPPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FirePPPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePPA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",3,"FirePPPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FirePPAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FirePPAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",3,"FirePAAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireAAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FirePAAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",4,"FireAAAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePPPP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPPP", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPPP", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePPPA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPPA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPPA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePPAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPPAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FirePAAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPAAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallPAAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireAAAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAAAA", frandom(-0.2,0.2), 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallAAAA", frandom(-0.2,0.2), 0)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireSA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallS", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallS", 0, 0)
    Goto FireFinish
  FireSS:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireSSP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireSSA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSS", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSS", 0, 0)
    Goto FireFinish
  FireSP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSSP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FireSPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireSPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSP", 0, 0)
    Goto FireFinish
  FireSA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSSA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireSPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FireSAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSA", 0, 0)
    Goto FireFinish
  FireSSP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FireSSPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireSSPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSP", 0, 0)
    Goto FireFinish
  FireSSA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireSSPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FireSSAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSA", 0, 0)
    Goto FireFinish
  FireSPP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSSPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",3,"FireSPPP")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",1,"FireSPPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPP", 0, 0)
    Goto FireFinish
  FireSPA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSSPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",2,"FireSPPA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",2,"FireSPAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPA", 0, 0)
    Goto FireFinish
  FireSAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleSniperMod",2,"FireSSAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRiflePowerMod",1,"FireSPAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAgilityMod",3,"FireSAAA")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSAA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSAA", 0, 0)
    Goto FireFinish
  FireSSPP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSPP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSPP", 0, 0)
    Goto FireFinish
  FireSSAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSAA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSAA", 0, 0)
    Goto FireFinish
  FireSSPA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSPA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSSPA", 0, 0)
    Goto FireFinish
  FireSPPP:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPPP", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPPP", 0, 0)
    Goto FireFinish
  FireSPPA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPPA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPPA", 0, 0)
    Goto FireFinish
  FireSPAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPAA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSPAA", 0, 0)
    Goto FireFinish
  FireSAAA:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSAAA", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaBallSAAA", 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("RLNuclearPlasmaRifleState",1,"FireState")
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleState",1)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",2,"FireFinishFF")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",1,"FireFinishF")
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP C 3 Bright A_GunFlash
	Goto FireFinishContinue
  FireFinishF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle2Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP C 2 Bright A_GunFlash ("FlashF")
	Goto FireFinishContinue
  FireFinishFF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle3Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP C 1 Bright A_GunFlash ("FlashFF")
	Goto FireFinishContinue
	
  FireState:
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleState",1)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",2,"FireStateFF")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",1,"FireStateF")
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP D 3 Bright A_GunFlash
    Goto FireFinishContinue
  FireStateF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle2Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP D 2 Bright A_GunFlash ("FlashF")
    Goto FireFinishContinue
  FireStateFF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle3Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    NUKP D 1 Bright A_GunFlash ("FlashFF")
    Goto FireFinishContinue
	
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleAmmochain",0,2)
	TNT1 A 0 A_Jump(256,3)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAmmochain",0)
    TNT1 A 0 A_ReFire
    Goto Ready
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleAmmochain",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_JumpIfInventory("RLNuclearPlasmaRifleState",1,3)
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleState",1)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",1,"FireFinishFF")
	Goto FireFinishF
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleState",1)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleFirestormMod",1,"FireStateFF")
	Goto FireStateF
//-------------------------------------------------------------------------------------------------
  
	
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 1 A_Light1
    Goto LightDone
  FlashF:
    TNT1 A 1 A_Light2
    TNT1 A 1 A_Light1
    Goto LightDone
  FlashFF:
    TNT1 A 1 A_Light (random(1,2))
    Goto LightDone
  FlashAmmo:
    NUKP B 1 Bright
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLNuclearPlasmaRiflePickup",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("RLHighPowerNuclearPlasmaRifleConfirm",1, "CancelAssembly")
	TNT1 A 0 A_JumpIfInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1, "CancelAssembly")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1, "CancelAssembly")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaShotgunConfirm",1, "CancelAssembly")
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleMkIIConfirm",1, "CancelAssembly")
	Goto Ready
  CancelAssembly:
	TNT1 A 0 A_Print("Assembly canceled.")
  CancelAssembly2:
	TNT1 A 0 A_PlaySound("hud/assemblycancel", 5)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleMkIIConfirm",1)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	Goto MisfirePrevention
  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("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleMkIIConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",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
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleModLimit",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("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleMkIIConfirm",1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",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_GiveInventory("RLEmitScavengedModExotic", 1) // Determines what mods this can generate when scavenged.
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  AssembleHighPowerNuclearPlasmaRifle:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerNuclearPlasmaRifle",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelBasicGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvHigh Power Nuclear Plasma Rifle \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, 2)
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_GiveInventory("RLHighPowerNuclearPlasmaRifle",1)
	TNT1 A 0 A_SelectWeapon("RLHighPowerNuclearPlasmaRifle")
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  AssembleAssaultRifleNuclearPlasmaRifle:
	TNT1 A 0 A_JumpIfInventory("RLAssaultRifleNuclearPlasmaRifle",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelAdvancedGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvAssault Nuclear Plasma Rifle \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLAssaultRifleNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, 2)
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_GiveInventory("RLAssaultRifleNuclearPlasmaRifle",1)
	TNT1 A 0 A_SelectWeapon("RLAssaultRifleNuclearPlasmaRifle")
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  AssembleBurstCannonNuclearPlasmaRifle:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonNuclearPlasmaRifle",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelAdvancedGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvBurst Nuclear Plasma Rifle \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonNuclearPlasmaRifleConfirm",1)
	TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, 2)
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_GiveInventory("RLBurstCannonNuclearPlasmaRifle",1)
	TNT1 A 0 A_SelectWeapon("RLBurstCannonNuclearPlasmaRifle")
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  AssembleNuclearPlasmaRifleMkII:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaRifleMkII",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelAdvancedGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvNuclear Plasma Rifle Mk. II \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleMkIIConfirm",1)
	TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, 2)
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaRifleMkII",1)
	TNT1 A 0 A_SelectWeapon("RLNuclearPlasmaRifleMkII")
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  AssembleNuclearPlasmaShotgun:
	TNT1 A 0 A_JumpIfInventory("RLNuclearPlasmaShotgun",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelAdvancedGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvNuclear Plasma Shotgun \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSelected", 1)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleModLimit", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRiflePowerMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleBulkMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleAgilityMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleTechnicalMod", 4)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifleSniperMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaShotgunConfirm",1)
	TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, 2)
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_GiveInventory("RLNuclearPlasmaShotgun",1)
	TNT1 A 0 A_SelectWeapon("RLNuclearPlasmaShotgun")
	TNT1 A 0 A_TakeInventory("RLNuclearPlasmaRifle",1)
	Stop
  }
}

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

Actor RLNuclearPlasmaRifleSelected : RLPermanentInventory {}
Actor RLNuclearPlasmaRifleFiring : RLPermanentInventory {}
Actor RLNuclearPlasmaRifleState : RLPermanentInventory {}
Actor RLNuclearPlasmaRifleAmmochain : RLAmmochainDefault {}

Actor RLNuclearPlasmaRifleModLimit : RLStandardModAmount {}
Actor RLNuclearPlasmaRiflePowerMod : RLStandardModAmount {}
Actor RLNuclearPlasmaRifleBulkMod : RLStandardModAmount {}
Actor RLNuclearPlasmaRifleAgilityMod : RLStandardModAmount {}
Actor RLNuclearPlasmaRifleTechnicalMod : RLStandardModAmount {}
Actor RLNuclearPlasmaRifleFirestormMod : RLExoticModAmount {}
Actor RLNuclearPlasmaRifleSniperMod : RLExoticModAmount {}

ACTOR RLNuclearPlasmaRifleClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 52
   Inventory.Icon ""
}

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

ACTOR RLNuclearPlasmaRiflePickup : RLExoticWeaponPickup 16913
{
	//$Sprite NUKPX0
	Tag "Nuclear Plasma Rifle [Pickup]"
	States
	{
	SpawnFrame:
		NUKP X 4
	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("RLNuclearPlasmaRifle",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("RLNuclearPlasmaRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \ctNuclear 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("\ct= Nuclear Plasma Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/NukePlasmaRiflepickup")
		Stop
/*	SetBonusStart:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusWeapon",1)
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,"SetBonusCheck")
		"####" "#" 0 A_Print("\ccPicked up a \ctNuclear Plasma Rifle.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	SetBonusCheck:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusActive",1)
		"####" "#" 0 A_Print("\ccPicked up a \ctNuclear 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 RLNuclearPlasmaRiflePickupModded : RLNuclearPlasmaRiflePickup
{
	+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:
		NUKP X 4
	SpawnLoop:
		"####" "#" 0 A_JumpIf(VelZ <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 0 ACS_NamedExecuteAlways("RLWeaponModDisplay", 0)
		"####" "#" 1
		Loop
		
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLNuclearPlasmaRifle",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("RLNuclearPlasmaRifle",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("\ct= Nuclear Plasma Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLNuclearPlasmaRifleModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\ct= 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("\ct= 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 \ctNuclear Plasma Rifle.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon*/
	}
}
