ACTOR Duster : Weapon 25004
{
  Tag "D-240B Duster"
  Weapon.SelectionOrder 64
  Weapon.AmmoUse 1
  Weapon.AmmoGive2 14
  Weapon.PreferredSkin "Shotgun"
  Weapon.UpSound "Weapons/DusterUp"
  Weapon.AmmoType "DusterShells"
  Weapon.AmmoType2 "Shotgun_Ammo_X"
  decal "BlazeChip"
  Weapon.SlotNumber 3
  Scale 0.8
  weapon.bobstyle inversesmooth
   weapon.bobrangeX 0.4
   weapon.bobrangeY 0.6
   weapon.bobspeed 2.5
  Inventory.PickupMessage "You got the D-240B Duster Coach Gun! Two barrels 'o' fun for all demon kind."
  Obituary "%k Coached %o with the Duster."
  +WEAPON.AMMO_OPTIONAL
  +NOAUTOFIRE
  +NOALERT
  +NOAUTOAIM
  States
  {
  Ready:
    DBSG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    loop
  Deselect:
    TNT1 A 0 SetPlayerProperty(0,1,2)
	TNT1 A 0 A_SetCrosshair(1)
	DBSS ABCDE 1
	Goto DeselectLoop
  DeselectLoop:
    TNT1 A 1 A_Lower
    Loop
  Select:
	TNT1 A 0 A_JumpIfInventory("DusterToken",1,"Select3")
    DBSG A 0 A_JumpIfInventory("DusterFirstTime",1,1)
	goto Select2
	TNT1 A 0 A_PlaySoundEx("Weapons/DusterFirst","WeaponPickedUp",0,0)
    TNT1 A 0 SetPlayerProperty(0,0,2)
	TNT1 A 0 A_SetCrosshair(19)
    DBSS EDCBA 1
	TNT1 A 0 A_TakeInventory("DusterFirstTime",1)
    Goto SelectLoop
  Select2:
    TNT1 A 0 SetPlayerProperty(0,0,2)
	TNT1 A 0 A_SetCrosshair(19)
    DBSS EDCBA 1
    Goto SelectLoop
  Select3:
    TNT1 A 0 SetPlayerProperty(0,0,2)
	TNT1 A 0 A_SetCrosshair(19)
    DBSS EDCBA 1
    Goto SelectLoop
  SelectLoop:
    DBSG A 1 A_Raise
	Loop
 Fire:
	TNT1 A 0 A_JumpIfInventory("DusterToken", 1, "FireBoth")
 FireLeft:
	DBSG A 0 A_JumpIfInventory("DusterShells",2,1)
    Goto FireRight
	DBSG A 0 A_JumpIfInventory("DusterShells",1,1)
    Goto DryFire
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_SetPitch(pitch - 3.0)
    DBSG B 0 A_PlaySound("Duster/Add",86,0.99,0,1)
	TNT1 A 0 A_PlaySound("Duster/SingleFire",87,0.66,0,1)
	TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
	TNT1 AAAAA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
    TNT1 A 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 1, 2.5, 5, 0,random(-5, 5))
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 0, 2.5, 5, 0,random(-5, 5))
	TNT1 A 0 A_SetCrosshair(20)
    DBSF A 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
    DBSF C 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.95)
    DBSF D 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.96)
	DBSF E 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
	DBSF F 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.98)
	DBSF F 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.99)
	DBSF F 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	D3SF B 0 A_ZoomFactor(1.00)
    Goto Ready
  FireRight:
	D3SG A 0 A_JumpIfInventory("DusterShells",1,1)
    Goto DryFire
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_SetPitch(pitch - 3.0)
    DBSG B 0 A_PlaySound("Duster/Add",86,0.99,0,1)
	TNT1 A 0 A_PlaySound("Duster/SingleFire",87,0.66,0,1)
	TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
	TNT1 AAAAA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
    TNT1 A 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 1, 2.5, 5, 0,random(-5, 5))
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 0, 2.5, 5, 0,random(-5, 5))
	TNT1 A 0 A_SetCrosshair(21)
	DBSF G 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF H 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
    DBSF I 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.95)
    DBSF J 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.96)
	DBSF K 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
	DBSF L 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.98)
	DBSF L 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.99)
	DBSF L 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	D3SF B 0 A_ZoomFactor(1.00)
    Goto Ready
  FireBoth:
	D3SG A 0 A_JumpIfInventory("DusterShells",1,1)
    Goto DryFire
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_SetPitch(pitch -3.0)
    D3SG B 0 A_PlaySound("Duster/Add",86,0.99,0,1)
	TNT1 A 0 A_PlaySound("Duster/DoubleFire",87,0.66,0,1)
	TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
	TNT1 AAAAA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)
	TNT1 A 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 1, 2.5, 5, 0,random(-5, 5))
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 0, 2.5, 5, 0,random(-5, 5))
	TNT1 A 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 1, 2.5, 5, 0,random(-5, 5))
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_FireCustomMissile("p_pellet_tracer", random(-5, 5), 0, 2.5, 5, 0,random(-5, 5))
	TNT1 A 0 A_SetCrosshair(21)
	DBSF M 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF N 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
    DBSF O 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.95)
    DBSF P 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.96)
	DBSF Q 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.97)
	DBSF R 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.98)
	DBSF R 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSF B 0 A_ZoomFactor(0.99)
	DBSF R 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	D3SF B 0 A_ZoomFactor(1.00)
    Goto Ready
  AltFire: //Does checks, if you have no dummy actors, select hellfire shells
	TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
	TNT1 A 0 A_JumpIfInventory("DusterToken", 1, "AltFire2")
	TNT1 A 0 A_GiveInventory("DusterToken", 1)
	DBSG A 10 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  AltFire2: //Clears dummy actors, to use regular buckshot
	TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
	TNT1 A 0 A_TakeInventory("DusterToken", 1)
	DBSG A 10 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  DryFire:
	DBSG A 0 A_PlaySound("Shotgun/Empty",199,1.0,0,1) // Play the clicky noise.
	DBSG A 5 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  Reload:
  ReloadBeginEmpty:
    TNT1 A 0 A_JumpIfInventory("Shotgun_Ammo_X",1,1)
    Goto DryFire
    TNT1 A 0 A_JumpIfInventory("DusterShells",2,"Ready")
	TNT1 A 0 A_JumpIfInventory("DusterShells",1,"ReloadBeginHalf")
    DBSR ABCD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_PlaySound("Duster/Open",86,1.0,0,1)
	DBSR EFGH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_PlaySound("Duster/Eject",87,1.0,0,1)
	TNT1 A 0 A_FireCustomMissile("SCMITRCasing_Spawner2",0,0,5,-2)
	TNT1 A 0 A_FireCustomMissile("SCMITRCasing_Spawner2",0,0,10,-2)
	DBSR H 15 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
    Goto Ready
	goto ReloadLoop
  ReloadBeginHalf:
    TNT1 A 0 A_JumpIfInventory("Shotgun_Ammo_X",1,1)
    Goto DryFire
    TNT1 A 0 A_JumpIfInventory("DusterShells",2,"Ready")
    DBSR ABCD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_PlaySound("Duster/Open",86,1.0,0,1)
	DBSR EFGH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_PlaySound("Duster/Eject",87,1.0,0,1)
	TNT1 A 0 A_FireCustomMissile("SCMITRCasing_Spawner2",0,0,5,-2)
	DBSR H 15 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
    Goto Ready
	goto ReloadLoop
  ReloadLoop:
    TNT1 A 0 A_JumpIfInventory("Shotgun_Ammo_X",1,1)
	Goto EndReloading
	D3SR A 0 A_PlaySound("Duster/LoadShell",88,1.0,0,1)
	DBSR IJK 1 A_WeaponReady(WRF_NOSWITCH)
	DBSR LMN 2 A_WeaponReady(WRF_NOSWITCH)
    TNT1 A 0 A_TakeInventory("Shotgun_Ammo_X", 1)
    TNT1 A 0 A_GiveInventory("DusterShells", 1)
	DBSR N 7 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_JumpIfInventory("DusterShells",2,"EndReloading")
	Loop
 EndReloading:
    D3SR A 0 A_PlaySound("Duster/Close",89,1.0,0,1)
	DBSR TUVWX 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	DBSG A 5 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_SetCrosshair(19)
	Goto Ready
  Spawn:
    DBSG X -1
	Stop
  }
}

ACTOR DusterToken : Inventory {Inventory.MaxAmount 1}

ACTOR DusterFirstTime : Inventory {Inventory.MaxAmount 1 Inventory.InterHubAmount 1}

ACTOR DusterShells : Ammo
{
  Inventory.PickupMessage "You shouldn't see this!"
  Inventory.Amount 0
  Inventory.MaxAmount 2
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 2
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  }
}

ACTOR SCMITRCasing_Spawner2
{
    Radius 1
    Height 1
    Speed 18
    PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
    States
    {
    Spawn:
        TNT1 A 1
        TNT1 A 0 A_Die
        Goto Death
    Death:
        TNT1 A 0 A_CustomMissile("scmitrshell_casing",0,0,random(-80,-100),CMF_AIMDIRECTION,random(-15,15))
        Stop
    }
}