
ACTOR RLGatlingGun : RLWeapon
{
  Obituary "%o was riddled by %k's gatling."
  Decal BulletChip
  Tag "Gatling Gun"
  Weapon.Kickback 120
  Weapon.SelectionOrder 1800
  Weapon.SlotNumber 4
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLGatlingGunClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "GATLICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunNanoMod",1,2)
    DGTG C 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready+1
  NanoRegenCheck:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip",1,2)
    DGTG A 70 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin
  NanoRegenCheckBegin:
    DGTG C 70 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 90, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 117, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 144, "Ready")
  NanoRegen:
	TNT1 A 0 A_GiveInventory("RLGatlingGunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunNanoMod",2,2)
    DGTG C 17 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin+1
    DGTG C 9 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin+1
	
  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("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLGatlingGunPickup", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLGatlingGunPickupModded", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLGatlingGunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGatlingGunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLGatlingGun",1)
	Stop
	
  AfterModDrop:
    DGTG C 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    DGTG C 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_ClearRefire
	TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLGatlingGunSelected", 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
    DGTG C 1 A_Lower
    Loop
  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("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLGatlingGunSelected", 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
    DGTG C 1 A_Raise
    Loop
	
  Fire:
	DGTG A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	DGTG A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	DGTG A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	DGTG A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	DGTG A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	DGTG D 2 A_PlaySound("weapons/gatlingwindup", 6)
	DGTG AB 2
	DGTG CD 1
  FireSpin:
	DGTG ABCD 1
	DGTF A 0 A_PlaySound("weapons/gatlingspin", 6, 0.5, 1)
  Hold:
	TNT1 A 0 A_JumpIfNoAmmo("FinishSpin")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3, 2, -1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 2, -1, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunPowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAgilityMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3, 2, -1, 9, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 2, -1, 9, "RLBulletPuff", 0)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunPowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAgilityMod",2,"FireAA")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FirePP:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3, 2, -1, 10, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3, 2, -1, 10, "RLBulletPuff", 0)
    Goto FireFinish
  FirePA:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 9, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 9, "RLBulletPuff", 0)
    Goto FireFinish
  FireAA:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (2, 1, -1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 1, -1, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunPowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAgilityMod",1,"FireSA")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (1, 0, 1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1, 0, 1, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FireSS:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (0, 0, 1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0, 0, 1, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FireSP:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (1, 0, 1, 9, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1, 0, 1, 9, "RLBulletPuff", 0)
    Goto FireFinish
  FireSA:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (0.5, 0, 1, 8, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0.5, 0, 1, 8, "RLBulletPuff", 0)
    Goto FireFinish
	
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLChaingunRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/gatlingfire", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/gatlingfire", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunState",1,"FireState")
	TNT1 A 0 A_GiveInventory("RLGatlingGunState",1)
    DGTG J 1 Bright A_GunFlash
    Goto FireFinishMain
  FireState:
	TNT1 A 0 A_TakeInventory("RLGatlingGunState",1)
    DGTG K 1 Bright A_GunFlash
    Goto FireFinishMain
  FireFinishMain:
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunFirestormMod",2,"FireFinishFF")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunFirestormMod",1,"FireFinishF")
    DGTG BCD 1
    Goto FireFinishContinue
  FireFinishF:
    DGTG BD 1
    Goto FireFinishContinue
  FireFinishFF:
    DGTG C 1
    Goto FireFinishContinue
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunAmmochain",0,2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_TakeInventory("RLGatlingGunAmmochain",0)
    Goto StateEndCheck
	TNT1 A 0 A_GiveInventory("RLGatlingGunAmmochain",1)
    Goto StateEndCheck
  StateEndCheck:
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunState",1,2)
	TNT1 A 0 A_JumpIfNoAmmo ("FinishSpin")
    Goto Hold
	TNT1 A 0 A_ReFire
    Goto FinishSpin
  FinishSpin:
	DGTG ABCD 1
	TNT1 A 0 A_ReFire
  WindDown:
	TNT1 A 0 A_ClearRefire
	DGTG A 2 A_PlaySound("weapons/gatlingwinddown", 6)
	DGTG BC 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSWITCH)
	DGTG D 2
	DGTG ABC 3
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOSWITCH)
	DGTG DAB 4
	DGTG C 2
	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("RLGatlingGunFirestormMod",1,"FireFinishFF")
	Goto FireFinishF
//-------------------------------------------------------------------------------------------------
  
	
  Reload:
	DGTG C 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 90, "Ready")
	Goto ReloadStartCheck
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 117, "Ready")
	Goto ReloadStartCheck
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip", 144, "Ready")
  ReloadStartCheck:
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 A_ClearRefire
	TNT1 A 0 A_StopSound(6)
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunTechnicalMod",2,"Reload2")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunTechnicalMod",1,"Reload1")
    DGTG E 5
    DGTG F 5
    DGTG G 5
    DGTG H 5
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    DGTG H 5 A_PlaySound("weapons/gatlinggununload", CHAN_ITEM)
	Goto ReloadWorking
  Reload1:
    DGTG E 4
    DGTG F 4
    DGTG G 4
    DGTG H 5
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    DGTG H 5 A_PlaySound("weapons/gatlinggununload", CHAN_ITEM)
	Goto ReloadWorking
  Reload2:
    DGTG E 3
    DGTG F 4
    DGTG G 4
    DGTG H 4
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    DGTG H 4 A_PlaySound("weapons/gatlinggununload", CHAN_ITEM)
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLGatlingGunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip",90,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip",117,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunClip",144,"ReloadFinish")
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunTechnicalMod",2,"ReloadFinish2")
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunTechnicalMod",1,"ReloadFinish1")
    DGTG I 12 A_PlaySound("weapons/gatlinggunload", 7)
    DGTG H 3
    DGTG H 3
    DGTG G 3
    DGTG F 3
    DGTG E 3
	DGTG D 2 A_PlaySound("weapons/gatlingwinddown", 6)
	DGTG A 3
	DGTG B 3
	DGTG C 3
	DGTG D 4
	DGTG A 4
	DGTG B 4
	DGTG C 2
	Goto Ready
  ReloadFinish1:
    DGTG I 12 A_PlaySound("weapons/gatlinggunload", 7)
    DGTG H 3
    DGTG H 3
    DGTG G 3
    DGTG F 3
    DGTG E 3
	DGTG D 2 A_PlaySound("weapons/gatlingwinddown", 6)
	DGTG A 3
	DGTG B 3
	DGTG C 3
	DGTG D 3
	DGTG A 3
	DGTG B 3
	DGTG C 2
	Goto Ready
  ReloadFinish2:
    DGTG I 12 A_PlaySound("weapons/gatlinggunload", 7)
    DGTG H 2
    DGTG H 2
    DGTG G 2
    DGTG F 3
    DGTG E 3
	DGTG D 2 A_PlaySound("weapons/gatlingwinddown", 6)
	DGTG A 3
	DGTG B 3
	DGTG C 3
	DGTG D 3
	DGTG A 3
	DGTG B 3
	DGTG C 2
	Goto Ready
  Flash:
    TNT1 A 1 A_Light2
    TNT1 A 1 A_Light1
    TNT1 A 0 A_Light0
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLGatlingGunPickup",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 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_TakeInventory("RLGatlingGunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGatlingGunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLGatlingGunAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLGatlingGunModLimit",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("RLGatlingGunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLGatlingGunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGatlingGunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLGatlingGun",1)
	Stop
  }
}

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

Actor RLGatlingGunSelected : RLPermanentInventory {}
Actor RLGatlingGunFiring : RLPermanentInventory {}
Actor RLGatlingGunState : RLPermanentInventory {}
Actor RLGatlingGunAmmochain : RLAmmochainDefault {}
Actor RLGatlingGunModLimit : RLBasicAssemblyModAmount {}
Actor RLGatlingGunPowerMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunBulkMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunAgilityMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunTechnicalMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunFirestormMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunNanoMod : RLBasicAssemblyModAmount {}
Actor RLGatlingGunSniperMod : RLBasicAssemblyModAmount {}

ACTOR RLGatlingGunClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 144
   Inventory.Icon ""
}

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

ACTOR RLGatlingGunPickup : RLBasicAssembledWeaponPickup 17443
{
	//$Sprite DGTGX0
	Tag "Gatling Gun [Pickup]"
	States
	{
	SpawnFrame:
		DGTG 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("RLGatlingGun",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("RLGatlingGun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvGatling 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= Gatling Gun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/GatlingGunpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLGatlingGunPickupModded : RLGatlingGunPickup
{
	+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:
		DGTG 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("RLGatlingGun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvGatling Gun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Gatling Gun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLGatlingGunModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Gatling Gun =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Clip",60)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Gatling Gun =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
