
ACTOR RLBurstCannonMinigun : RLWeapon
{
  Obituary "%o was transformed into a fine spray by %k's minigun."
  Decal BulletChip
  Tag "Burst Minigun"
  Weapon.SelectionOrder 25
  Weapon.SlotNumber 4
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLBurstCannonMinigunClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "MINIICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunNanoMod",1,3)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",1,"ReadySpin")
    AMIN A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",1,"ReadySpin")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip",1,2)
    AMIN A 70 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin
  NanoRegenCheckBegin:
    AMIN A 70 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip", 400, "Ready")
	Goto NanoRegenCheckAmmo
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip", 520, "Ready")
	Goto NanoRegenCheckAmmo
  NanoRegenCheckAmmo:
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunClip", 1)
    AMIN A 16 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin+1
	
  ReadyNoFire:
    AMIN A 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    Goto Ready
	
//=================================================================================
//Dear god I came here and looked at this before and I have no fucking clue what I wrote, but it was horrible and now it is dead. Good riddance.
//=================================================================================
  ReadySpin:
    TNT1 A 0 A_PlaySound("weapons/burstminigunspin", 6, 0.15, 1)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunState",1,"ReadySpinA")
	Goto ReadySpinC
  ReadySpinC:
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunState",1)
    AMIN C 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunFirestormMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",14,"ReadySpinActive")
    Goto ReadySpin
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",7,"ReadySpinActive")
    Goto ReadySpin
  ReadySpinA:
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunState",1)
    AMIN A 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunFirestormMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",14,"ReadySpinActive")
    Goto ReadySpin
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",7,"ReadySpinActive")
    Goto ReadySpin
  ReadySpinActive:
    TNT1 A 0 A_PlaySound("weapons/burstminigunspin", 6, 0.15, 1)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunState",1,"ReadySpinActiveA")
	Goto ReadySpinActiveC
  ReadySpinActiveC:
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunState",1)
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ReadySpinActiveAltC")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ReadySpinActiveAltC")
    AMIN C 1 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD | WRF_ALLOWZOOM | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",0,"WindDown")
    Goto ReadySpinActive
  ReadySpinActiveAltC:
    AMIN C 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",0,"WindDown")
    Goto ReadySpinActive
  ReadySpinActiveA:
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunState",1)
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ReadySpinActiveAltA")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ReadySpinActiveAltA")
    AMIN A 1 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD | WRF_ALLOWZOOM | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",0,"WindDown")
    Goto ReadySpinActive
  ReadySpinActiveAltA:
    AMIN A 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM | WRF_NOBOB)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",0,"WindDown")
    Goto ReadySpinActive
	
//=================================================================================
  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 A_StopSound(6)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLBurstCannonMinigunPickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLBurstCannonMinigunPickupModded", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLBurstCannonMinigun",1)
	Stop
	
  AfterModDrop:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",1,"AfterModDropSpin")
    AMIN A 8 A_WeaponReady (16)
    Goto Ready
  AfterModDropSpin:
    AMIN ACACACAC 1 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    AMIN 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("RLBurstCannonMinigunSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
    TNT1 A 0 A_JumpIfInventory("RLAssaultRifleMinigunSpin", 1, "DeselectSpinning")
	Goto DeselectLoop
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    AMIN A 1 A_Lower
    Loop
  DeselectSpinning:
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSpin",0)
	TNT1 A 0 A_PlaySound("weapons/burstminigunwinddown", 6, 0.15)
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
	AMIN A 2 A_Lower
	AMIN BCDABC 2 A_Lower
  DeselectSpinningLoop:
	AMIN ABCD 2 A_Lower
    Loop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLAdvancedAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianAdvancedDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    AMIN A 1 A_Raise
    Loop
	
  FireSpinCheck:
	TNT1 A 0 A_JumpIfNoAmmo("WindDown")
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSpin",0)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
    Goto FireStart
  Fire:
	AMIN A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	AMIN A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	AMIN A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	AMIN A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	AMIN A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",1,"FireSpinCheck")
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
  FireWindUp:
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunSpin",1)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunFirestormMod",1,"FireWindUp1")
	AMIN B 4 A_PlaySound("weapons/burstminigunwindup", 6, 0.15)
	AMIN CD 3
	AMIN AB 3
	AMIN CD 2
	AMIN ABCD 1
    Goto FireStart
  FireWindUp1:
	AMIN B 3 A_PlaySound("weapons/burstminigunwindup", 6, 0.15)
	AMIN CD 2
	AMIN AB 2
	AMIN CD 1
    Goto FireStart
  FireStart:
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (8, 8, -1, 12, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (8, 8, -1, 12, "RLBulletPuff", 0)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (8, 8, -1, 20, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (8, 8, -1, 20, "RLBulletPuff", 0)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (7.5, 7.5, -1, 12, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (7.5, 7.5, -1, 12, "RLBulletPuff", 0)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (6, 6, -1, 12, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (6, 6, -1, 12, "RLBulletPuff", 0)
    Goto FireFinish
	
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLMinigunRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunState",1,"FireState")
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunState",1)
    TNT1 A 0 A_PlaySound("weapons/burstminigun", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/burstminigun", 7, 0.05, 0, 0.20)
    AMIN E 1 Bright A_GunFlash ("Flash")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunBurst",1)
    Goto Fire
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBurst",0)
    Goto Ready
  FireState:
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunState",1)
    TNT1 A 0 A_PlaySound("weapons/burstminigun", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/burstminigun", 7, 0.05, 0, 0.20)
    AMIN F 1 Bright A_GunFlash ("Flash2")
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBurst",0,2)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunBurst",1)
    Goto Fire
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBurst",0)
    Goto Ready
	
  WindDown:
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSpin",80)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunFirestormMod",1,"WindDown1")
	AMIN A 2 A_PlaySound("weapons/burstminigunwinddown", 6, 0.15)
	AMIN BC 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSECONDARY | WRF_NOSWITCH)
	AMIN D 2
	AMIN ABC 3
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSECONDARY | WRF_NOSWITCH)
	AMIN DAB 4
	AMIN CD 2
	Goto Ready
  WindDown1:
	AMIN A 1 A_PlaySound("weapons/burstminigunwinddown", 6, 0.15)
	AMIN BC 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSECONDARY | WRF_NOSWITCH)
	AMIN D 2
	AMIN ABC 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSECONDARY | WRF_NOSWITCH)
	AMIN D 3
	Goto Ready
	
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunSpin",1,"WindDown")
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto ReadyNoFire
	AMIN A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSpin",80)
	TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip", 400, "Ready")
	Goto ReloadStartCheck
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip", 520, "Ready")
  ReloadStartCheck:
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunTechnicalMod",1,"Reload1")
    AMIN G 3
    AMIN H 3
    AMIN I 3
    AMIN J 3
    AMIN K 3
    AMIN L 3
    TNT1 A 0 A_PlaySound("weapons/burstminigununload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    AMIN L 34
	Goto ReloadWorking
  Reload1:
    AMIN G 2
    AMIN H 2
    AMIN I 2
    AMIN J 3
    AMIN K 3
    AMIN L 3
    TNT1 A 0 A_PlaySound("weapons/burstminigununload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    AMIN M 34
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLBurstCannonMinigunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip",400,3)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunClip",520,2)
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip",1,2)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBurst", 0)
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadFinish:
    TNT1 A 0 A_PlaySound("weapons/burstminigunload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunTechnicalMod",1,"ReloadFinish1")
    AMIN M 5
    AMIN L 3
    AMIN L 3
    AMIN K 3
    AMIN J 3
    AMIN I 3
    AMIN H 3
    AMIN G 3
	Goto ReloadSpin
  ReloadFinish1:
    AMIN M 5
    AMIN L 3
    AMIN L 3
    AMIN K 3
    AMIN J 3
    AMIN I 2
    AMIN H 2
    AMIN G 2
	Goto ReloadSpin
  ReloadSpin:
	TNT1 A 0 A_PlaySound("weapons/burstminigunwinddown", 6, 0.15)
	AMIN A 3
	AMIN B 3
	AMIN C 3
	AMIN D 4
	AMIN A 4
	AMIN B 4
	AMIN C 5
	AMIN D 5
	Goto Ready
	
  Flash:
    TNT1 A 1 A_Light2
    Goto LightDone
  Flash2:
    TNT1 A 1 A_Light1
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLBurstCannonMinigunPickup",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("RLBurstCannonMinigunSpin",1,"WindDown")
	Goto Ready
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLBurstCannonAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLBurstCannonMinigunModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLBurstCannonMinigunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	TNT1 A 0 A_Jump(256,1,2,3)
	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("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLBurstCannonMinigun",1)
	Stop
  }
}

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

Actor RLBurstCannonMinigunSelected : RLPermanentInventory {}
Actor RLBurstCannonMinigunState : RLPermanentInventory {}
Actor RLBurstCannonMinigunSpin : RLPermanentInventory
{
inventory.maxamount 80 // Length of time the Minigun continues to spin after firing.
}

Actor RLBurstCannonMinigunBurst : RLBurstCannonDefault {}
Actor RLBurstCannonMinigunModLimit : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunPowerMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunBulkMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunAgilityMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunTechnicalMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunFirestormMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunNanoMod : RLAdvancedAssemblyModAmount {}
Actor RLBurstCannonMinigunSniperMod : RLAdvancedAssemblyModAmount {}

ACTOR RLBurstCannonMinigunClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 520
   Inventory.Icon ""
}

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

ACTOR RLBurstCannonMinigunPickup : RLAdvancedAssembledWeaponPickup 17610
{
	//$Sprite ZGGGX0
	Tag "Burst Minigun [Pickup]"
	States
	{
	SpawnFrame:
		ZGGG 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/gundropbig")
		"####" "#" 0 A_ScaleVelocity (0.25)
		"####" "#" 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("RLBurstCannonMinigun",1,"NotPickup") // If the player already has this weapon, they are not given the weapon
		"####" "#" 0 A_JumpIfInventory("RLWeaponLimit",0,"NotPickupLimit") // The absolute max limit check for weapons
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLBurstCannonMinigun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvBurst Minigun.")
		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= Burst Minigun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/BurstMinigunpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLBurstCannonMinigunPickupModded : RLBurstCannonMinigunPickup
{
	+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:
		ZGGG 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("RLBurstCannonMinigun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvBurst Minigun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Burst Minigun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLBurstCannonMinigunModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Burst Minigun =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Clip",400)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Burst Minigun =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
