
ACTOR RLNuclearBiggestFuckingGun : RLHeavyWeapon
{
  Obituary "%o was completely overkilled by %k's Biggest Fucking Gun."
  Tag "Biggest Fucking Nuclear Gun"
  Weapon.SelectionOrder 3900
  Weapon.SlotNumber 7
  Weapon.AmmoUse1 50
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLNuclearBiggestFuckingGunClip"
  Inventory.Icon "BFGXICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/nukebfgxidle", 6, 1, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,3)
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip", 100, "ReadyCantAltFire")
	TNT1 A 0 A_Jump (256, 2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip", 50, "ReadyCantAltFire")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyCanAltFire")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyCanAltFire")
	TNT1 A 0 A_TakeInventory("RLNuclearBiggestFuckingGunCharged",1)
    PRCG ABCABC 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
	Goto ReadyCycleCharging
  ReadyCanAltFire:
	TNT1 A 0 A_TakeInventory("RLNuclearBiggestFuckingGunCharged",1)
    PRCG ABCABC 1 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_TakeInventory("RLNuclearBiggestFuckingGunCharged",1)
    PRCG ABCABC 1 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
  ReadyCanFire:
    PRCG ABCABC 1 A_WeaponReady (WRF_ALLOWZOOM)
	Goto ReadyCycleCharged
//=================================================================================
  ReadyCycleCharging:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip", 100, "ReadyBeep")
	Goto ReadyChargingAmmo
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip", 50, "ReadyBeep")
	Goto ReadyChargingAmmo
  ReadyChargingAmmo:
	PRCG A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLNuclearBiggestFuckingGunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyChargingAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyChargingAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 7)
    PRCG ABCABC 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    PRCG ABC 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
  ReadyChargingAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 7)
    PRCG ABCABC 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
    PRCG ABC 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharging
//=================================================================================
  ReadyCycleCharged:
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip", 100, "Ready")
	Goto ReadyChargedAmmo
  ReadyChargedAmmo:
	PRCG A 0 A_JumpIfInventory("RLRestrictionNoRecharge",1,"RechargeRestricted") // Cannot recharge in levels that restrict it
	TNT1 A 0 A_GiveInventory("RLNuclearBiggestFuckingGunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop", 1, "ReadyChargedAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate", 1, "ReadyChargedAmmo2")
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 7)
    PRCG ABCABC 1 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    PRCG ABC 1 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
  ReadyChargedAmmo2:
	TNT1 A 0 A_JumpIfInventory("RLNuclearWeaponSetBonusActive", 1, 7)
    PRCG ABCABC 1 A_WeaponReady (WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
    PRCG ABC 1 A_WeaponReady (WRF_ALLOWZOOM)
    Goto ReadyCycleCharged
//=================================================================================
  ReadyBeep:
	TNT1 A 0 A_GiveInventory("RLNuclearBiggestFuckingGunCharged",1)
	TNT1 A 0 A_PlaySound("weapons/nukebfgxbeep", 7)
    TNT1 A 0
    Goto ReadyCycleCharged
	
  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_PlaySound("weapons/nukebfgxoff", 6, 1, 0)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
	TNT1 A 0 A_SpawnItemEx("RLNuclearBiggestFuckingGunPickup", 0, 0, 40, 8, 0, 0, 0, SXF_SETMASTER)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLNuclearBiggestFuckingGunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLNuclearBiggestFuckingGun",1)
	Stop
  AfterModDrop:
    PRCG ABCABCABC 1 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    PRCG ABC 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(CHAN_WEAPON)
    TNT1 A 0 A_PlaySound("weapons/nukebfgxoff", 6, 1, 0)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLNuclearBiggestFuckingGunSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    PRCG A 1 A_Lower
    Loop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLMasterAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearAmmoWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLNuclearBiggestFuckingGunSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianMasterDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    PRCG A 1 A_Raise
    Loop
	
  Fire:
	PRCG A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	PRCG A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	PRCG A 0 A_JumpIfInventory("RLRestrictionNoBoom",1,"NoBoomRestricted") // Cannot fire in levels that restrict it
	PRCG A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	PRCG A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,2)
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip",100, 2)
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("RLNuclearBiggestFuckingGunClip",50, 1)
	Goto Ready
	TNT1 A 0 A_AlertMonsters
    TNT1 A 0 A_PlaySound("weapons/nukebfgxcharge", CHAN_WEAPON)
	PRCG DEDEDEDEDE 3 Bright
    TNT1 A 0 A_PlaySound("weapons/nuclearbfgxalarm", 5, 1, 0, 0.5)
	TNT1 A 0 A_AlertMonsters
	PRCG DEDEDEDEDE 3 Bright
	PRCG DEDEDEDEDEDEDEDEDEDE 2 Bright
	TNT1 A 0 A_AlertMonsters
	PRCG DEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDE 1 Bright
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_GunFlash
	TNT1 A 0 A_FireCustomMissile ("RLBiggestFuckingGunBall", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLNuclearBiggestFuckingGunClip", 50, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLBFG9000Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PRCG FGH 2 Bright
    PRCG ED 4 Bright
    PRCG CB 6
    PRCG A 6 A_Refire
    Goto Ready
  Flash:
	TNT1 A 2 Bright A_Light(5)
	TNT1 A 2 Bright A_Light2
	TNT1 A 2 Bright A_Light1
	Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLNuclearBiggestFuckingGunPickup",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
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLBiggestFuckingGunAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLNuclearBiggestFuckingGunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 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,3,4)
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLFirestormMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLFirestormMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLNuclearBiggestFuckingGun",1)
	Stop
  }
}

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

Actor RLNuclearBiggestFuckingGunSelected : RLPermanentInventory {}
Actor RLNuclearBiggestFuckingGunCharged : RLPermanentInventory {}

ACTOR RLNuclearBiggestFuckingGunClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 130
   Inventory.Icon ""
}

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

ACTOR RLNuclearBiggestFuckingGunPickup : RLMasterAssembledWeaponPickup
{
	//$Sprite PRCGX0
	Tag "Biggest Fucking Nuclear Gun [Pickup]"
	States
	{
	SpawnFrame:
		PRCG 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/gundropbigger")
		"####" "#" 0 A_ScaleVelocity (0.15)
		"####" "#" 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("RLNuclearBiggestFuckingGun",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("RLNuclearBiggestFuckingGun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up the \cvNuclear Biggest Fucking Gun.")
		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= Nuclear Biggest Fucking Gun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/Nukebfgxpickup")
		Stop
/*	SetBonusStart:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusWeapon",1)
		"####" "#" 0 A_JumpIfInventory("RLNuclearWeaponSetBonusArmor",1,"SetBonusCheck")
		"####" "#" 0 A_Print("\ccPicked up the \cvNuclear Biggest Fucking Gun.")
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	SetBonusCheck:
		"####" "#" 0 A_GiveInventory("RLNuclearWeaponSetBonusActive",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvNuclear Biggest Fucking Gun.\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
	SuperweaponStuff:
		"####" "#" 0 A_Jump(256, "NoSpecialStartsStuff")
		Goto NoSpecialStartsStuff
	}
}

ACTOR RLNuclearBiggestFuckingGunWorldSpawnPickup : RLNuclearBiggestFuckingGunPickup 17831
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_JumpIf(CallACS("DRLA_opengl"), 3) // If enabled, rarity beam will be cyan, rather than blue
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorld", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorldDRPG", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	SpawnFrame:
		PRCG X 4
		"####" "#" 0 A_GiveInventory("RLMasterItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/masterspawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/Nukebfgxpickup")
		"####" "#" 0 A_GiveInventory("RLDangerLevelMasterGiver",1, AAPTR_PLAYER1)
		Stop
	}
}
