ACTOR DukePrimary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 12
  Inventory.Icon "SHELA0"
  +INVENTORY.IGNORESKILL
}

ACTOR DukeSecondary : Ammo
{
  Inventory.PickupMessage "You picked up a mag of Order Pistol ammunition." // "Picked up a clip."
  Inventory.PickupSound "bullpup/magin"
  Inventory.Amount 6
  Inventory.MaxAmount 120
  Ammo.BackpackAmount 12
  Ammo.BackpackMaxAmount 120
  Inventory.Icon "SHELA0"
  +INVENTORY.IGNORESKILL
  States
  {
  Spawn:
    SHEL A -1
    Stop
  }
}

ACTOR DukeDragonSecondary : Ammo
{
  Inventory.PickupMessage "You picked up some Dragon's Breath ammo." // "Picked up a clip."
  Inventory.PickupSound "bullpup/magin"
  Inventory.Amount 6
  Inventory.MaxAmount 120
  Ammo.BackpackAmount 12
  Ammo.BackpackMaxAmount 120
  Inventory.Icon "SHELB0"
  +INVENTORY.IGNORESKILL
  States
  {
  Spawn:
    CLIP A -1
    Stop
  }
}

// Dragon's breath Trenchgun round
ACTOR DragonBreathRound
{
  Radius 2
  Height 4
  Speed 55
  Damage 2
  DamageType "Dragon"
  Projectile
  +RANDOMIZE
  +RIPPER
  RenderStyle Add
  Alpha 0.25
  Scale 0.5
  DeathSound "vile/firestrt"
  Obituary "%o was set on fire by %k's Trenchgun." // "%o was melted by %k's plasma gun."
  States
  {
  Spawn:
	TRID C 0
	TRID AAA 0 A_SpawnItemEx("DragonFXFlameTiny",0,0,0,random(-1,1),random(-1,1),random(-1,1))
	TRID AA 0 A_SpawnItemEx("DragonFXSmokeTiny",0,0,0,random(-1,1),random(-1,1),random(-1,1))
    TRID C 1 Bright
    Goto Spawn+2
  Death:
    TRID A 0 A_Stop
	TRID A 0 A_SpawnItemEx("DragonFXSpawn",0,0,0)
	TNT1 A 1
    Stop
  }
}

ACTOR DragonFXSpawn
{
	+CLIENTSIDEONLY
	+NOINTERACTION
	+NOBLOCKMAP
	+NOGRAVITY
	States
	{
		Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("DragonFXExplode",0,0,0)
		TNT1 AA 0 A_SpawnItemEx("DragonFXFlameTiny",random(-1,1),random(-1,1),random(-1,1),random(-3,3),random(-3,3),random(-3,3))
		TNT1 AA 0 A_SpawnItemEx("DragonFXFlameTiny",random(-1,1),random(-1,1),random(-1,1),momx*random(0.65,0.75),random(-3,3),random(-3,3))
		TNT1 AA 0 A_SpawnItemEx("DragonFXFlameTiny",random(-1,1),random(-1,1),random(-1,1),random(-1,1),random(-1,1),random(-1,1))
		TNT1 AA 0 A_SpawnItemEx("DragonFXFlame",random(-1,1),random(-1,1),random(-1,1),random(-2,2),random(-2,2),random(-2,2))
		TNT1 A 0 A_SpawnItemEx("DragonFXSmoke",0,0,0,0,0,random(1,5))
		Stop
	}
}

ACTOR DragonFXExplode
{
	+CLIENTSIDEONLY
	+NOBLOCKMAP
	+NOGRAVITY
	Renderstyle Add
	Alpha 0.8
	Scale 0.5
	States
	{
		Spawn:
		EFIR ABCDEFGHIJKLM 1 bright A_FadeOut(0.1)
		Stop
	}
}

ACTOR DragonFXFlame
{
	+CLIENTSIDEONLY
	+NOBLOCKMAP
	+NOGRAVITY
	Renderstyle Add
	Alpha 0.8
	Scale 0.75
	States
	{
		Spawn:
		FIR2 ABCDE 2 bright A_FadeOut(0.05)
		Stop
	}
}

ACTOR DragonFXFlameTiny : DragonFXFlame
{
	Scale 0.45
}

ACTOR DragonFXSmoke
{
	+NOBLOCKMAP
	+NOGRAVITY
	+CLIENTSIDEONLY
	Renderstyle Add
	Alpha 0.75
	Scale 0.8
	States
	{
		Spawn:
		SMOK ABCDEFGHIJKLMNOPQR 1 A_FadeOut(0.1)
		Stop
	}
}

ACTOR DragonFXSmokeTiny : DragonFXSmoke
{
	Scale 0.3
}

ACTOR "Pump Shotgun Dragon" : Inventory
{
	Inventory.MaxAmount 1
}

ACTOR "DukeDragonBreath" : Inventory
{
	Inventory.MaxAmount 1
}

ACTOR DukeAmmoMode : Inventory
{
	Inventory.MaxAmount 1
}

ACTOR "Pump Shotgun" : Weapon 11507
{
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 12
  Weapon.AmmoType "DukePrimary"
  Weapon.AmmoType2 "DukeSecondary"
  Obituary "\cJ%k \cG> \cKDuke Shotgun \cG> \cJ%o"
  Inventory.Pickupmessage "You picked up the Pump Shotgun."
  Inventory.PickupSound "duke/cockback"
	//$Category ZT2 - Weapons
	//$Title Pump Shotgun
	//$Sprite DKSHI0
  Tag "Pump Shotgun"
  Scale 0.6
  +WEAPON.NOAUTOFIRE
  Weapon.Kickback 350
  States
  {
  Ready:
	PPSS A 0 A_PlaySoundEx("orderpistol/select","SoundSlot6")
	DSSS ABCD 1
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	PPSS A 0 //A_JumpIfInventory("QuickGrenading",1,"ToGrenade")
	PPSS A 0 A_JumpIfInventory("SwitchingAmmo",1,"Unload")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
    DSID A 1 A_WeaponReady
    Goto Ready+5
  ToGrenade:
	PPSS A 0 A_SelectWeapon("Type-97 Grenade")
	Goto Deselect
  QuickMelee:
	PPBL A 1
	PPBL B 0 A_PlaySoundEx("fist/swing","Weapon")
	PPBL BC 1
	PPBL D 0 A_CustomPunch (random(4,5),1,0,"BlockPuff")
	PPBL D 2
	PPBL E 4
	PPBL DCBA 2
	PPBL A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready+5
  ToReady:
	NULL A 0
	Goto Ready+5
	NULL AAA 0
	NULL A 0 A_PlaySoundEx("orderpistol/dryfire","SoundSlot6")
	Goto Ready+5
  Deselect:
	 DSSS DCBA 1
	 TNT1 A 0 A_TakeInventory("DukeDragonBreath",1)
     TNT1 AAAAAAAAAA 0 A_Lower
	 TNT1 A 1 A_Lower
     Goto Deselect+5
  Select:
	 TNT1 A 0 A_SetCrosshair(13)
	 TNT1 A 0 A_JumpIfInventory("Pump Shotgun Dragon",1,"SelectDB")
     TNT1 A 0 A_Raise
     Wait
  SelectDB:
	 TNT1 A 0 A_GiveInventory("DukeDragonBreath",1)
	 TNT1 A 0 A_Raise
     Wait
  Unload:
	TNT1 A 0 A_TakeInventory("SwitchingAmmo",1)
	TNT1 A 0 A_JumpIfInventory("Pump Shotgun Dragon",1,2)
	TNT1 A 0 A_Print("You need the Dragon's Breath upgrade for this.")
	Goto Ready+5
	TNT1 A 0 A_JumpIfInventory("DukeAmmoMode",1,"To12Gauge")
	Goto ToDragonBreath
  To12Gauge:
	TNT1 A 0 A_TakeInventory("DukeAmmoMode",1)
	TNT1 A 0 A_Print("Switched to 12 gauge shells.")
	Goto UnloadStart
  ToDragonBreath:
	TNT1 A 0 A_GiveInventory("DukeAmmoMode",1)
	TNT1 A 0 A_Print("Switched to Dragon's Breath shells.")
	Goto UnloadStart
  UnloadStart:
	TNT1 A 0 A_TakeInventory("SwitchingAmmo",1)
	TNT1 A 0 A_JumpIfInventory("DukeDragonSecondary",1,1)
	Goto Ready+5
	TNT1 A 0 A_JumpIfInventory("DukePrimary",1,1)
	Goto ReloadStart
	DSRL AA 0
	DSRL ABCDE 1
	DSRL F 2
	Goto UnloadLoop
  UnloadLoop:
	TNT1 A 0 A_JumpIfInventory("DukeDragonSecondary",1,1)
	Goto UnloadEnd
	TNT1 A 0 A_JumpIfInventory("DukePrimary",1,1)
	Goto UnloadEnd
	DSRL U 4
	DSRL V 0 A_PlaySoundEx("duke/cockback","SoundSlot6")
	DSRL V 1
	TNT1 A 0 A_FireCustomMissile("IntactShotCaseSpawn",-7,0,26,-3)
	DSRL V 0 A_TakeInventory("DukePrimary",1)
	DSRL V 0 A_JumpIfInventory("DukeAmmoMode",1,3)
	DSRL V 0 A_GiveInventory("DukeDragonSecondary",1)
	DSRL V 0 A_Jump(255,4)
	TNT1 AA 0
	DSRL V 0 A_GiveInventory("DukeSecondary",1)
	TNT1 AA 0
	DSRL W 2
	DSRL X 2
	DSRL V 0 A_PlaySoundEx("duke/cockforward","SoundSlot6")
	DSRL W 1 A_WeaponReady(1)
	DSRL V 1 A_WeaponReady(1)
	Loop
  UnloadEnd:
	DSRL GHIJK 1
	DSRL L 2
	Goto ReloadLoop
  //==============================================================================
  // PERK AMMO CHECKING
  //==============================================================================
  ReloadCheck:
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Juggernaut",1,"RCP")
	 TNT1 A 0 A_JumpIfInventory("DukePrimary",6,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("DukeSecondary",1,"BoltCheck")
	 Goto ToReady
  RCP:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"RCP10")
	 TNT1 A 0 A_JumpIfInventory("DukePrimary",9,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("DukeSecondary",1,"BoltCheck")
	 Goto ToReady
  RCP10:
	 TNT1 A 0 A_JumpIfInventory("DukePrimary",12,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("DukeSecondary",1,"BoltCheck")
	 Goto ToReady
  //==============================================================================
  BoltCheck:
	 TNT1 A 0 A_JumpIfInventory("DukePrimary",1,"ReloadStart")
	 TNT1 A 0 A_GiveInventory("PullBolt",1)
	 Goto ReloadStart
  ReloadStart:
     9MRL A 0 ACS_ExecuteAlways(820,0,0,0,0)
	 DSRL AA 0
	 DSRL ABCDE 1
	 DSRL F 2
	 DSRL GHIJK 1
	 DSRL L 6
	 Goto ReloadLoop
  ReloadLoop:
	 DSRL A 0 A_JumpIfInventory("DukeAmmoMode",1,"ReloadLoopDB")
	 DSRL A 0 A_JumpIfInventory("DukeSecondary",1,1)
	 Goto ReloadEnd
	 DSRL M 1
	 DSRL V 0 A_PlaySoundEx("duke/insert","SoundSlot6")
	 DSRL N 1
	 DSRL O 2
	 DSRL P 0 A_TakeInventory("DukeSecondary",1)
	 DSRL P 0 A_GiveInventory("DukePrimary",1)
	 DSRL P 3 A_WeaponReady(1)
	 DSRL QRST 1 A_WeaponReady(1)
	 DSRL L 4 A_WeaponReady(1)
	 Goto AmmoCheck
  //==============================================================================
  // PERK AMMO CHECKING
  //==============================================================================
  AmmoCheck:
	 DSRL L 0 A_JumpIfInventory("Perk_Juggernaut",1,"ACP")
	 DSRL L 0 A_JumpIfInventory("DukePrimary",6,"ReloadEnd")
	 Goto ReloadLoop
  ACP:
	 DSRL L 0 A_JumpIfInventory("PerkLevel",10,"ACP10")
	 DSRL L 0 A_JumpIfInventory("DukePrimary",9,"ReloadEnd")
	 Goto ReloadLoop
  ACP10:
	 DSRL L 0 A_JumpIfInventory("DukePrimary",12,"ReloadEnd")
	 Goto ReloadLoop
  //==============================================================================
  ReloadLoopDB:
	 DSRL A 0 A_JumpIfInventory("DukeDragonSecondary",1,1)
	 Goto ReloadEnd
	 DSRL M 1
	 DSRL V 0 A_PlaySoundEx("duke/insert","SoundSlot6")
	 DSRL N 1
	 DSRL O 2
	 DSRL P 0 A_TakeInventory("DukeDragonSecondary",1)
	 DSRL P 0 A_GiveInventory("DukePrimary",1)
	 DSRL P 3 A_WeaponReady(1)
	 DSRL QRST 1 A_WeaponReady(1)
	 DSRL L 4 A_WeaponReady(1)
	 DSRL L 0 A_JumpIfInventory("DukePrimary",6,"ReloadEnd")
	 Loop
  ReloadEnd:
	 DSRL KJIHG 1
	 DSRL F 2
	 DSRL F 0 A_JumpIfInventory("PullBolt",1,1)
	 Goto FireCock+15
	 TNT1 A 0
	 Goto FireCock+5
  Fire:
	 PPFI A 0 A_JumpIfInventory("DukeAmmoMode",1,"FireDB")
	 PPFI A 0 A_JumpIfInventory("DukePrimary",1,1)
	 Goto ToReady+2
	 PPFI A 0 A_TakeInventory("DukePrimary",1)
	 PPFI A 0 A_FireBullets (0, 0, 3, 17, "BP_TorsoGib",0,90)
	 DSID A 1
	 PPFI A 0 A_AlertMonsters
	 PPFI A 0 A_FireBullets (ACS_ExecuteWithResult(566,6,0,0), ACS_ExecuteWithResult(566,6,0,0), 9, 7, "BP_Shotgun")
	 PPFI A 0 A_PlaySound("duke/fire", CHAN_WEAPON)
	 PPFI A 0 A_FireCustomMissile("ShakeYourAss")
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 TNT1 A 0 A_Recoil(1)
	 FireAnim:
	 PPFI A 0 A_SetPitch(pitch-4.0)
	 DSFI A 1 bright
	 PPFI A 0 A_SetPitch(pitch+2.6)
	 DSFI B 1
	 PPFI A 0 A_SetPitch(pitch+1.6)
	 DSFI C 1
	 DSFI D 2
	 DSFI EF 1
	 ORDD G 0 A_JumpIfInventory("DukePrimary",1,"FireCock")
	 Goto Ready+5
  FireDB:
	 PPFI A 0 A_JumpIfInventory("DukePrimary",1,1)
	 Goto ToReady+2
	 PPFI A 0 A_TakeInventory("DukePrimary",1)
	 PPFI A 0 A_AlertMonsters
	 PISG BBBB 0 A_FireCustomMissile("DragonBreathRound",random(-3,3),0,random(-1,1),random(-1,1),0,random(-3,3))
	 PPFI A 0 A_PlaySound("duke/fire", CHAN_WEAPON)
	 PPFI A 0 A_FireCustomMissile("ShakeYourAss")
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 TNT1 A 0 A_Recoil(1)
	 Goto FireAnim
  FireCock:
	 DSRL ABCDE 1
	 DSRL U 2
	 DSRL V 0 A_PlaySoundEx("duke/cockback","SoundSlot6")
	 DSRL V 1
	 Goto CaseSpawn
  CaseSpawn:
	 TNT1 A 0 A_JumpIfInventory("DukeAmmoMode",1,"CaseSpawnDB")
	 TNT1 A 0 A_FireCustomMissile("ShotCaseSpawn",-7,0,26,-3)
	 Goto CockEnd
  CaseSpawnDB:
	 TNT1 A 0 A_FireCustomMissile("DragonCaseSpawn",-7,0,26,-3)
	 Goto CockEnd
  CockEnd:
	 DSRL W 2
	 DSRL X 4
	 DSRL V 0 A_PlaySoundEx("duke/cockforward","SoundSlot6")
	 DSRL W 1
	 DSRL V 1
	 DSRL U 2
	 DSRL EDCBA 1
	 DSRL A 0 A_TakeInventory("PullBolt",1)
	 Goto Ready+5
  Spawn:
    DKSH I -1
    Stop
  }
}