
ACTOR RLAutoDoubleShotgun : RLWeapon
{
  Obituary "%o was crushed by %k's auto double shotgun."
  Decal BulletChip
  Tag "Auto Double Shotgun"
  Weapon.SelectionOrder 11
  Weapon.SlotNumber 3
  Weapon.AmmoUse1 2
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLAutoDoubleShotgunClip"
  Weapon.AmmoType2 "Shell"
  Inventory.Icon "AUTDICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunNanoMod",1,"NanoRegenCheck")
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"Ready2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,"Ready2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,"Ready1")
    AUTD G 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  Ready1:
    AUTD E 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  Ready2:
    AUTD A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  NanoRegenCheck:
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",1,"NanoRegenCheckBegin")
    AUTD G 70 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin
  NanoRegenCheckBegin:
    AUTD G 70 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip", 20, "Ready")
	Goto NanoRegen
  NanoRegen:
	TNT1 A 0 A_GiveInventory("RLAutoDoubleShotgunClip", 1)
    AUTD G 17 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_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLAutoDoubleShotgunPickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLAutoDoubleShotgunPickupModded", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLAutoDoubleShotgun",1)
	Stop
	
  AfterModDrop:
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,4)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,2)
    AUTD G 8 A_WeaponReady (16)
    Goto Ready
    AUTD E 8 A_WeaponReady (16)
    Goto Ready
    AUTD A 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    AUTD 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_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,6)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,3)
    TNT1 A 0 A_Lower
    AUTD G 1 A_Lower
    Goto DeselectLoop
    TNT1 A 0 A_Lower
    AUTD E 1 A_Lower
    Goto DeselectLoop
    TNT1 A 0 A_Lower
    AUTD 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("RLAdvancedAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLShotgunTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLAutoDoubleShotgunSelected", 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")
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,6)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,3)
    TNT1 A 0 A_Raise
    AUTD G 1 A_Raise
    Goto SelectLoop
    TNT1 A 0 A_Raise
    AUTD E 1 A_Raise
    Goto SelectLoop
    TNT1 A 0 A_Raise
    AUTD A 1 A_Raise
    Goto SelectLoop
	
  Fire:
	AUTD A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	AUTD A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	AUTD A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	AUTD A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	AUTD A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunAgilityMod",1,"FireA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegade")
	TNT1 A 0 A_FireBullets (12, 7.5, 10, 5, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegade:
	TNT1 A 0 A_FireBullets (12, 7.5, 15, 5, "RLBulletPuff", 0)
    Goto FireFinish
  FireP:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeP")
	TNT1 A 0 A_FireBullets (12, 7.5, 10, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeP:
	TNT1 A 0 A_FireBullets (12, 7.5, 15, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeA")
	TNT1 A 0 A_FireBullets (11.5, 7, 10, 5, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeA:
	TNT1 A 0 A_FireBullets (11.5, 7, 15, 5, "RLBulletPuff", 0)
    Goto FireFinish
  FireS:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeS")
	TNT1 A 0 A_FireBullets (10, 5.5, 9, 5, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, -1, 5, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeS:
	TNT1 A 0 A_FireBullets (10, 5.5, 14, 5, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, -1, 5, "RLBulletPuff", 0)
    Goto FireFinish
	
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_JumpIfInventory ("RLRenegadeExtraShot", 1, "FireFinishAmmoConsumptionDoneExtra")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishAmmoConsumptionDone")
    TNT1 A 0 A_TakeInventory ("RLAutoDoubleShotgunClip", 2, TIF_NOTAKEINFINITE)
	Goto FireFinishAmmoConsumptionDone
	
  FireFinishAmmoConsumptionDoneExtra:
    TNT1 A 0 A_TakeInventory ("RLRenegadeExtraShot", 1)
  FireFinishAmmoConsumptionDone:
    TNT1 A 0 A_PlaySound("weapons/autodoubleshotgun", CHAN_WEAPON, 1, 0, 0.5)
    TNT1 A 0 A_PlaySound("weapons/autodoubleshotgun", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_CheckFloor (2)
	TNT1 A 0 A_Jump(256,4)
	TNT1 A 0 A_JumpIfInventory("RLGrapplingSteelBootsToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLGrapplingProtectiveBootsToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLGrapplingPlasteelBootsToken",1,2)
    TNT1 A 0 A_ChangeVelocity (Cos(Pitch) * -4, 0, Sin(Pitch) * 4, 1)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunFirestormMod",1,"FireFinishF")
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinish2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,"FireFinish2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,"FireFinish1")
    AUTD G 4 A_GunFlash
    AUTD G 4
    Goto FireFinishAmmochain
  FireFinish1:
    AUTD E 4 A_GunFlash
    AUTD F 2
    AUTD G 2
    Goto FireFinishAmmochain
  FireFinish2:
    AUTD A 4 A_GunFlash
    AUTD B 2
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,3)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,2)
    AUTD D 2
    Goto FireFinishAmmochain
    AUTD C 2
    Goto FireFinishAmmochain
	
  FireFinishF:
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishF2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,"FireFinishF2")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,"FireFinishF1")
    AUTD G 4 A_GunFlash ("FlashF")
    Goto FireFinishAmmochain
  FireFinishF1:
    AUTD E 2 A_GunFlash ("FlashF")
    AUTD F 1
    AUTD G 1
    Goto FireFinishAmmochain
  FireFinishF2:
    AUTD A 2 A_GunFlash ("FlashF")
    AUTD B 1
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,3)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,2)
    AUTD D 1
    Goto FireFinishAmmochain
    AUTD C 1
    Goto FireFinishAmmochain
	
  FireFinishAmmochain:
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunAmmochain",0,2)
	TNT1 A 0 A_Jump(256,3)
	TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunAmmochain",0)
    TNT1 A 0 A_ReFire
    Goto Ready
	TNT1 A 0 A_GiveInventory("RLAutoDoubleShotgunAmmochain",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("RLAutoDoubleShotgunFirestormMod",1,1)
	Goto FireFinishF2
    AUTD A 1 A_GunFlash ("FlashF")
    AUTD B 1
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,3)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,2)
    AUTD D 1
    Goto FireFinishAmmochain
    AUTD C 1
    Goto FireFinishAmmochain
//-------------------------------------------------------------------------------------------------
  
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip", 20, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip", 26, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Shell", 1, 1)
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"ReloadSecondarySequence")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",5,"ReloadSecondarySequence")
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",3,"ReloadTertiarySequence")
	TNT1 A 0 // Play the reload animation.
  ReloadMainSequence:
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunTechnicalMod",1,"Reload1")
    AUTD H 4
    AUTD I 4
    AUTD J 4
    AUTD K 4
    AUTD L 4
	TNT1 A 0 A_PlaySound("weapons/autodoubleshotgunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	Goto ReloadWorking
  Reload1:
    AUTD H 4
    AUTD I 4
    AUTD J 3
    AUTD K 3
    AUTD L 3
	TNT1 A 0 A_PlaySound("weapons/autodoubleshotgunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Shell", 1)
	TNT1 A 0 A_GiveInventory("RLAutoDoubleShotgunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",20,9)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunClip",26,7)
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Shell",1,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  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("RLAutoDoubleShotgunTechnicalMod",1,"ReloadFinish1")
    AUTD M 15
    AUTD N 4
    AUTD O 4
    AUTD P 4
    AUTD Q 4
	Goto Ready
  ReloadFinish1:
    AUTD M 15
    AUTD N 4
    AUTD O 3
    AUTD P 3
    AUTD Q 3
	Goto Ready
  ReloadSecondarySequence:
    AUTD Q 4
    AUTD P 4
    AUTD O 4
    AUTD N 4
    AUTD M 4
	TNT1 A 0 A_PlaySound("weapons/autodoubleshotgununload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    AUTD L 7
    AUTD K 4
    AUTD J 4
    AUTD I 4
    AUTD H 4
    AUTD G 20
	Goto ReloadMainSequence
  ReloadTertiarySequence:
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    AUTD E 2
    AUTD F 2
    AUTD G 2
	Goto ReloadMainSequence
	
  Flash:
    AUTD R 2 Bright A_Light1
    AUTD S 2 Bright A_Light2
    Goto LightDone
  FlashF:
    AUTD R 1 Bright A_Light1
    AUTD S 1 Bright A_Light2
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLAutoDoubleShotgunPickup",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_TakeInventory("RLAutoDoubleShotgunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSelected", 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("RLAutoshotgunAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLAutoDoubleShotgunModLimit",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("RLAutoDoubleShotgunModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLAutoDoubleShotgunSelected", 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("DroppedRLFirestormMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLAutoDoubleShotgun",1)
	Stop
  }
}

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

Actor RLAutoDoubleShotgunSelected : RLPermanentInventory {}
Actor RLAutoDoubleShotgunAmmochain : RLAmmochainDefault {}
Actor RLAutoDoubleShotgunModLimit : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunPowerMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunBulkMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunAgilityMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunTechnicalMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunNanoMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunFirestormMod : RLAdvancedAssemblyModAmount {}
Actor RLAutoDoubleShotgunSniperMod : RLAdvancedAssemblyModAmount {}

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

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

ACTOR RLAutoDoubleShotgunPickup : RLAdvancedAssembledWeaponPickup 17643
{
	//$Sprite AUTDX0
	Tag "Auto Double Shotgun [Pickup]"
	States
	{
	SpawnFrame:
		AUTD 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("RLAutoDoubleShotgun",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("RLAutoDoubleShotgun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up an \cvAuto Double Shotgun.")
		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= Auto Double Shotgun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/AutoDoubleShotgunpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLAutoDoubleShotgunPickupModded : RLAutoDoubleShotgunPickup
{
	+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:
		AUTD 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("RLAutoDoubleShotgun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvAuto Double Shotgun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Auto Double Shotgun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLAutoDoubleShotgunModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Auto Double Shotgun =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Shell",20)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Auto Double Shotgun =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
