
ACTOR RLHuntingShotgun : RLWeapon
{
  Obituary "%o was discombobulated by %k's hunting shotgun."
  Decal BulletChip
  Tag "Hunting Shotgun"
  Weapon.SelectionOrder 1500
  Weapon.SlotNumber 3
  Weapon.AmmoUse1 2
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLHuntingShotgunClip"
  Weapon.AmmoType2 "Shell"
  Inventory.Icon "HUNTICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunNanoMod",1,2)
    HUNT A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  NanoRegenCheck:
    HUNT A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunClip", 2, "Ready")
    HUNT A 34 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunClip", 2, "Ready")
  NanoRegen:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunNanoMod",2,2)
    HUNT A 17 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLHuntingShotgunClip", 2)
    Goto NanoRegenCheck
    HUNT A 9 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_GiveInventory("RLHuntingShotgunClip", 2)
    Goto NanoRegenCheck
	
  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_JumpIfInventory("RLHuntingShotgunModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLHuntingShotgunPickup", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLHuntingShotgunPickupModded", 0, 0, 40, 12, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunNanoMod", 2)
	TNT1 A 0 A_TakeInventory("RLHeavyHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHuntingShotgunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLHuntingShotgun",1)
	Stop
	
  AfterModDrop:
    HUNT A 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    HUNT 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("RLHuntingShotgunSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 A 0 A_Lower
    HUNT 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("RLShotgunTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLSuperiorWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLHuntingShotgunSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    HUNT A 1 A_Raise
    Loop
	
  Fire:
	TNT1 A 0 A_JumpIfInventory("RLHeavyHuntingShotgunConfirm",1, "AssembleHeavyHuntingShotgun")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",1, "AssemblePlasmaticShrapnelHuntingShotgun")
	
	HUNT A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	HUNT A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	HUNT A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	HUNT A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	HUNT A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunClip", 2, 1)
	Goto Reload
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunAgilityMod",1,"FireA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegade")
	TNT1 A 0 A_FireBullets (4, 2, 20, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 2, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",2,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 2, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegade:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",2,4)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,2)
	TNT1 A 0 A_FireBullets (4, 2, 30, 6, "RLBulletPuff", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 33, 6, "RLBulletPuff", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 36, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunPowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunAgilityMod",1,"FirePA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeP")
	TNT1 A 0 A_FireBullets (4, 2, 20, 7, "RLBulletPuff", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 2, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeP:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,2)
	TNT1 A 0 A_FireBullets (4, 2, 30, 7, "RLBulletPuff", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 33, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunPowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunAgilityMod",2,"FireAA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeA")
	TNT1 A 0 A_FireBullets (3.5, 1.5, 20, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3.5, 1.5, 2, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeA:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,2)
	TNT1 A 0 A_FireBullets (3.5, 1.5, 30, 6, "RLBulletPuff", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3.5, 1.5, 33, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FirePP:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadePP")
	TNT1 A 0 A_FireBullets (4, 2, 20, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadePP:
	TNT1 A 0 A_FireBullets (4, 2, 30, 8, "RLBulletPuff", 0)
    Goto FireFinish
  FirePA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadePA")
	TNT1 A 0 A_FireBullets (3.5, 1.5, 20, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadePA:
	TNT1 A 0 A_FireBullets (3.5, 1.5, 30, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireAA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeAA")
	TNT1 A 0 A_FireBullets (3, 1, 20, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeAA:
	TNT1 A 0 A_FireBullets (3, 1, 30, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunPowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunAgilityMod",1,"FireSA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeS")
	TNT1 A 0 A_FireBullets (2, 0, 19, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 0, 2, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeS:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,3)
	TNT1 A 0 A_FireBullets (2, 0, 29, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLBulletPuff", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 0, 32, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireSS:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeSS")
	TNT1 A 0 A_FireBullets (0, 0, 20, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeSS:
	TNT1 A 0 A_FireBullets (0, 0, 30, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireSP:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeSP")
	TNT1 A 0 A_FireBullets (2, 0, 19, 7, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeSP:
	TNT1 A 0 A_FireBullets (2, 0, 29, 7, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 7, "RLBulletPuff", 0)
    Goto FireFinish
  FireSA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeSA")
	TNT1 A 0 A_FireBullets (1.5, 0, 19, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireRenegadeSA:
	TNT1 A 0 A_FireBullets (1.5, 0, 29, 6, "RLBulletPuff", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLBulletPuff", 0)
    Goto FireFinish
  FireF:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunFirestormMod",2,"FireFF")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunSniperMod",1,"FireFS")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunPowerMod",1,"FireFP")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunAgilityMod",1,"FireFA")
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeF")
	TNT1 A 0 A_FireBullets (0, 0, 1, 30, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (4, 2, 20, 6, "RLShotgunPuffF", 0)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,1)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (4, 2, 2, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireRenegadeF:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunBulkMod",1,3)
	TNT1 A 0 A_FireBullets (0, 0, 1, 30, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (4, 2, 30, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0, 0, 1, 30, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (4, 2, 33, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireFF:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeFF")
	TNT1 A 0 A_FireBullets (0, 0, 1, 60, "RLShotgunPuffCloseRange", FBF_NORANDOM, 128)
	TNT1 A 0 A_FireBullets (4, 2, 20, 6, "RLShotgunPuffFF", 0)
    Goto FireFinish
  FireRenegadeFF:
	TNT1 A 0 A_FireBullets (0, 0, 1, 60, "RLShotgunPuffCloseRange", FBF_NORANDOM, 128)
	TNT1 A 0 A_FireBullets (4, 2, 30, 6, "RLShotgunPuffFF", 0)
    Goto FireFinish
  FireFP:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeFP")
	TNT1 A 0 A_FireBullets (0, 0, 1, 35, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (4, 2, 20, 7, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireRenegadeFP:
	TNT1 A 0 A_FireBullets (0, 0, 1, 35, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (4, 2, 30, 7, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireFA:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeFA")
	TNT1 A 0 A_FireBullets (0, 0, 1, 30, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (3.5, 1.5, 20, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireRenegadeFA:
	TNT1 A 0 A_FireBullets (0, 0, 1, 30, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (3.5, 1.5, 30, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireFS:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeFS")
	TNT1 A 0 A_FireBullets (0, 0, 1, 25, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (2, 0, 19, 6, "RLShotgunPuffF", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLShotgunPuffF", 0)
    Goto FireFinish
  FireRenegadeFS:
	TNT1 A 0 A_FireBullets (0, 0, 1, 25, "RLShotgunPuffCloseRange", FBF_NORANDOM, 96)
	TNT1 A 0 A_FireBullets (2, 0, 29, 6, "RLShotgunPuffF", 0)
	TNT1 A 0 A_FireBullets (0, 0, 1, 6, "RLShotgunPuffF", 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, 2)
    TNT1 A 0 A_TakeInventory ("RLHuntingShotgunClip", 2)
    TNT1 A 0 A_TakeInventory ("RLRenegadeExtraShot", 1)
    TNT1 A 0 A_PlaySound("weapons/huntingshotgun", CHAN_WEAPON, 1, 0, 0.6)
    TNT1 A 0 A_PlaySound("weapons/huntingshotgun", 7, 0.05, 0, 0.20)
    HUNT B 4 Bright A_GunFlash
    HUNT C 3 Bright
    HUNT D 2
	TNT1 A 0 A_JumpIf(CallACS("DRLA_AutoReload"), "Reload")
    Goto Ready
	
  Reload:
	TNT1 A 0 A_JumpIfInventory("Shell",2,1)
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunClip",2,"Ready")
	HUNT A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunTechnicalMod",2,"Reload2")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunTechnicalMod",1,"Reload1")
    HUNT E 2
    HUNT F 2
    HUNT G 2
    HUNT H 2
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadDownRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT I 2
    HUNT J 2
    HUNT K 2
	TNT1 A 0 A_PlaySound("weapons/huntingshotgunopen", CHAN_ITEM)
	TNT1 A 4
    HUNT L 2
    HUNT M 2
    HUNT N 2
	Goto ReloadWorking
  Reload1:
    HUNT E 2
    HUNT F 2
    HUNT G 2
    HUNT H 2
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadDownRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT I 2
    HUNT J 2
    HUNT K 2
	TNT1 A 0 A_PlaySound("weapons/huntingshotgunopen", CHAN_ITEM)
	TNT1 A 4
    HUNT L 1
    HUNT M 1
    HUNT N 1
	Goto ReloadWorking
  Reload2:
    HUNT E 2
    HUNT F 2
    HUNT G 2
    HUNT H 2
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadDownRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT I 2
    HUNT J 2
    HUNT K 2
	TNT1 A 0 A_PlaySound("weapons/huntingshotgunopen", CHAN_ITEM)
	TNT1 A 1
    HUNT L 1
    HUNT M 1
    HUNT N 1
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Shell", 2, TIF_NOTAKEINFINITE)
	TNT1 A 0 A_GiveInventory("RLHuntingShotgunClip", 2)
	TNT1 A 0
  ReloadFinish:
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunTechnicalMod",2,"ReloadFinish2")
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunTechnicalMod",1,"ReloadFinish1")
    HUNT O 2 A_PlaySound("weapons/huntingshotgunload", CHAN_WEAPON)
    HUNT P 2
	TNT1 A 4
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadUpRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT K 2 A_PlaySound("weapons/huntingshotgunclose", CHAN_ITEM)
    HUNT J 2
    HUNT I 2
    HUNT H 2
    HUNT G 2
    HUNT F 2
    HUNT E 1
    HUNT Q 1
    HUNT A 3
    HUNT A 7 A_ReFire
	Goto Ready
  ReloadFinish1:
    HUNT O 2 A_PlaySound("weapons/huntingshotgunload", CHAN_WEAPON)
    HUNT P 2
	TNT1 A 4
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadUpRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT K 2 A_PlaySound("weapons/huntingshotgunclose", CHAN_ITEM)
    HUNT J 2
    HUNT I 2
    HUNT H 1
    HUNT G 1
    HUNT F 1
    HUNT E 1
    HUNT Q 1
    HUNT A 3
    HUNT A 7 A_ReFire
	Goto Ready
  ReloadFinish2:
    HUNT O 2 A_PlaySound("weapons/huntingshotgunload", CHAN_WEAPON)
    HUNT P 2
	TNT1 A 4
    TNT1 A 0 A_SpawnItemEx ("RLDoubleShotgunReloadUpRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    HUNT K 1 A_PlaySound("weapons/huntingshotgunclose", CHAN_ITEM)
    HUNT J 1
    HUNT I 1
    HUNT H 1
    HUNT G 1
    HUNT F 1
    HUNT E 1
    HUNT Q 1
    HUNT A 3
    HUNT A 7 A_ReFire
	Goto Ready
	
  Flash:
    TNT1 A 4 A_Light1
    TNT1 A 3 A_Light2
    TNT1 A 0 A_Light0
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLHuntingShotgunPickup",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("RLHeavyHuntingShotgunConfirm",1, "CancelAssembly")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",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("RLHeavyHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",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 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHeavyHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLHuntingShotgunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLHuntingShotgunModLimit",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("RLHuntingShotgunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHeavyHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",1)
	TNT1 A 0 A_TakeInventory("RLHuntingShotgunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_GiveInventory("RLEmitScavengedModSuperior", 1) // Determines what mods this can generate when scavenged.
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLHuntingShotgun",1)
	Stop
  AssembleHeavyHuntingShotgun:
	TNT1 A 0 A_JumpIfInventory("RLHeavyHuntingShotgun",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_rngcurse") == 1, 2) // Increases Danger Level given by assembling
	TNT1 A 0 A_Jump(256, 2)
	TNT1 A 0 A_GiveInventory("RLDangerLevelBasicGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvHeavy Hunting Shotgun \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLHuntingShotgunSelected", 1)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHeavyHuntingShotgunConfirm",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("RLHeavyHuntingShotgun",1)
	TNT1 A 0 A_SelectWeapon("RLHeavyHuntingShotgun")
	TNT1 A 0 A_TakeInventory("RLHuntingShotgun",1)
	Stop
  AssemblePlasmaticShrapnelHuntingShotgun:
	TNT1 A 0 A_JumpIfInventory("RLPlasmaticShrapnelHuntingShotgun",1, "AlreadyHaveAssembly")
	TNT1 A 0 A_GiveInventory("RLDangerLevelBasicGiver",1, AAPTR_PLAYER1)
	TNT1 A 0 A_Print("\cvPlasmatic Hunting Shotgun \c-assembled.")
    TNT1 A 0 A_PlaySound("weapons/assembly", CHAN_ITEM)
	TNT1 A 0 A_TakeInventory("RLHuntingShotgunSelected", 1)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHuntingShotgunNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaticShrapnelHuntingShotgunConfirm",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("RLPlasmaticShrapnelHuntingShotgun",1)
	TNT1 A 0 A_SelectWeapon("RLPlasmaticShrapnelHuntingShotgun")
	TNT1 A 0 A_TakeInventory("RLHuntingShotgun",1)
	Stop
  }
}

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

Actor RLHuntingShotgunSelected : RLPermanentInventory {}
Actor RLHuntingShotgunModLimit : RLSuperiorModAmount {}
Actor RLHuntingShotgunPowerMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunBulkMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunAgilityMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunTechnicalMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunNanoMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunFirestormMod : RLSuperiorModAmount {}
Actor RLHuntingShotgunSniperMod : RLSuperiorModAmount {}

ACTOR RLHuntingShotgunClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 2
   Inventory.Icon ""
}

ACTOR RLHuntingShotgunPickup : RLSuperiorWeaponPickup 17005
{
	//$Sprite HUNTX0
	Tag "Hunting Shotgun [Pickup]"
	States
	{
	SpawnFrame:
		HUNT 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("RLSynthFireReload",1,"AmmoPickup") // If the player is holding reload, pickup the gun for ammo.
		"####" "#" 0 A_JumpIfInventory("RLHuntingShotgun",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("RLHuntingShotgun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \ciHunting Shotgun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_Jump(256, "NotPickupNothing")
		Goto NotPickupNothing
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("Shell",0,"NotPickupNothing")
		Goto AmmoPickup
	NotPickupNothing:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\ci= Hunting Shotgun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	AmmoPickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("Shell",0,"NotPickupNothing")
		"####" "#" 1 A_GiveInventory("Shell",4)
		Goto PickupSound
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/HuntingShotgunpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLHuntingShotgunPickupModded : RLHuntingShotgunPickup
{
	+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:
		HUNT 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
		
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLHuntingShotgun",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("RLHuntingShotgun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \ciHunting Shotgun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\ci= Hunting Shotgun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLHuntingShotgunModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\ci= Hunting Shotgun =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Shell",4)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\ci= Hunting Shotgun =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
