ACTOR OrderDualLeft : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 26
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
}

ACTOR OrderDualRight : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 26
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
}

ACTOR OrderDualSecondary : Ammo
{
  Inventory.PickupMessage "You picked up a mag of Order Pistol ammunition." // "Picked up a clip."
  Inventory.PickupSound "bullpup/magin"
  Inventory.Amount 10
  Inventory.MaxAmount 120
  Ammo.BackpackAmount 30
  Ammo.BackpackMaxAmount 120
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
  States
  {
  Spawn:
    CLIP A -1
    Stop
  }
}

ACTOR DualOrderPistols : Weapon
{
  +WEAPON.NOAUTOAIM
  Weapon.AmmoUse 0
  Weapon.AmmoGive 0
  Weapon.AmmoGive2 0
  Weapon.BobStyle Smooth
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.3
  Weapon.AmmoType "OrderDualLeft"
  Weapon.AmmoType2 "OrderDualRight"
  Obituary "\cJ%k \cG> \cKOrder Pistol \cG> \cJ%o"
  Inventory.Pickupmessage "You picked up the Order Pistol."
  Inventory.PickupSound "ppsh/pickup"
	//$Category ZT2 - Weapons
	//$Title PPSH-41
	//$Sprite PPSHF0
  Tag "Dual Order Pistols"
  Scale 0.75
  +WEAPON.NOAUTOFIRE
  States
  {
  //=================================================================
  // GUN FLASHES - USED FOR DUAL WIELDING
  //------------------------------------------------
  DualPistols:
	DPIR A 0
  RIdle:
	DPIR A 0 A_JumpIfInventory("ReloadingR",1,"ReloadCheckR")
	DPIR A 0 A_JumpIfInventory("SynthFireRight",1,"Fire")
	DPIR A 1
    Loop
  RSelect:
	DPIQ ABC 1
	Goto RIdle
  RDeselect:
	DPIQ CBA 1
	Goto Stop
  RReload:
	DPIS A 0 A_TakeInventory("ReloadingR",1)
	DPIS ABCDEF 1
	ORRL F 0 A_PlaySoundEx("orderpistol/magout","SoundSlot6")
	DPIS GHI 1
	BPSS A 0 A_FireCustomMissile("PistolMagShooter",5,0,16,-3)
	DPIS JKLMNOP 1
	TNT1 A 5
	DPIS R 1
	ORRL R 0 A_PlaySoundEx("cloth/knife","SoundSlot6")
	DPIS ST 1
	DPIS U 2
	DPIS V 3
	ORRL R 0 A_PlaySoundEx("orderpistol/magin","SoundSlot6")
	DPIS WWX 1
	DPIS YZ 1
	DPIT ABCDEF 1
	DPIT G 0 A_Takeinventory("ReloadingR",1)
	Goto CalculateCheckR
	
//======================================================
// -- RELOAD CHECKS
  ReloadCheckR:
	 TNT1 A 0 A_TakeInventory("ReloadingR",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"ReloadCheckRPerk")
	 TNT1 A 0 A_JumpIfInventory("OrderDualRight",10,"ToReadyR")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"RReload")
	 Goto ToReadyR
	
  ReloadCheckRPerk:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"ReloadCheckRPerk10")
	 TNT1 A 0 A_JumpIfInventory("OrderDualRight",15,"ToReadyR")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"RReload")
	 Goto ToReadyR
	 
  ReloadCheckRPerk10:
	 TNT1 A 0 A_JumpIfInventory("OrderDualRight",20,"ToReadyR")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"RReload")
	 Goto ToReadyR
	 
  ReloadCheckL:
	 TNT1 A 0 A_TakeInventory("ReloadingL",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"ReloadCheckLPerk")
	 TNT1 A 0 A_JumpIfInventory("OrderDualLeft",10,"ToReadyL")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"LReload")
	 Goto ToReadyL
	
  ReloadCheckLPerk:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"ReloadCheckLPerk10")
	 TNT1 A 0 A_JumpIfInventory("OrderDualLeft",15,"ToReadyL")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"LReload")
	 Goto ToReadyL
	 
  ReloadCheckLPerk10:
	 TNT1 A 0 A_JumpIfInventory("OrderDualLeft",20,"ToReadyL")
	 TNT1 A 0 A_JumpIfInventory("OrderDualSecondary",1,"LReload")
	 Goto ToReadyL
	 
  ToReadyR:
	TNT1 A 0
	Goto RIdle
	
  ToReadyL:
	TNT1 A 0
	Goto LIdle
	
//======================================================
// -- AMMO CALCULATIONS

  CalculateCheckR:
	 TNT1 A 0
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"LevelCheckR")			// If we're a rifleman then give us an ammo boost
	 Goto CalcR
  LevelCheckR:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalcRPerk10")
	 Goto CalcRPerk
	 
  CalcR:
	DPIS A 0 A_JumpIfInventory("OrderDualRight",10,"RIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto RIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualRight",1)
	Loop
	
  CalcRPerk:
	DPIS A 0 A_JumpIfInventory("OrderDualRight",15,"RIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto RIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualRight",1)
	Loop
	
  CalcRPerk10:
	DPIS A 0 A_JumpIfInventory("OrderDualRight",20,"RIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto RIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualRight",1)
	Loop
	
	
  CalculateCheckL:
	 TNT1 A 0
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"LevelCheckL")			// If we're a rifleman then give us an ammo boost
	 Goto CalcL
  LevelCheckL:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalcLPerk10")
	 Goto CalcLPerk
  CalcL:
	DPIS A 0 A_JumpIfInventory("OrderDualLeft",10,"LIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto LIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualLeft",1)
	Loop
  CalcLPerk:
	DPIS A 0 A_JumpIfInventory("OrderDualLeft",15,"LIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto LIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualLeft",1)
	Loop
  CalcLPerk10:
	DPIS A 0 A_JumpIfInventory("OrderDualLeft",20,"LIdle")
	DPIS A 0 A_JumpIfInventory("OrderSecondary",1,1)
	Goto LIdle
	DPIS A 0 A_TakeInventory("OrderDualSecondary",1)
	DPIS A 0 A_GiveInventory("OrderDualLeft",1)
	Loop
//======================================================

  LReload:
	DPIS A 0 A_TakeInventory("ReloadingL",1)
	DPIM ABCDEFGHI 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	ORRL F 0 A_PlaySoundEx("orderpistol/magout","SoundSlot6")
	DPIM JKLM 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	BPSS A 0 A_FireCustomMissile("PistolMagShooter",5,0,-16,-3)
	DPIM NOPQRSTUV 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	TNT1 A 5 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	DPIM X 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	ORRL R 0 A_PlaySoundEx("cloth/knife","SoundSlot6")
	DPIM YZ 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	DPIN A 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	ORRL F 0 A_PlaySoundEx("orderpistol/magin","SoundSlot6")
	DPIN BCC 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	DPIN DEFGHIJKLM 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	DPIT G 0 A_Takeinventory("ReloadingL",1)
	Goto CalculateCheckL
  //------------------------------------------------
  // DRY FIRES
  //------------------------------------------------
  DryFireR:
	TNT1 A 0 A_TakeInventory("SynthFireRight",1)
	TNT1 A 0 A_JumpIfInventory("OrderDualPrimary",1,"RIdle")
	NULL A 0 A_PlaySoundEx("orderpistol/dryfire","SoundSlot6")
	Goto RIdle
  GiveBothReload:
	TNT1 A 0 A_TakeInventory("IsReloading",1)
	TNT1 A 0 A_GiveInventory("ReloadingL",1)
	TNT1 A 0 A_GiveInventory("ReloadingR",1)
	Goto LIdle
  //=================================================================
  Ready:
	PPSS A 0
	PPSS A 0 A_TakeInventory("SynthFireLeft",1)
	PPSS A 0 A_TakeInventory("SynthFireRight",1)
	Goto LIdle
  LIdle:
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"GiveBothReload")
	PPSS A 0 A_JumpIfInventory("ReloadingL",1,"ReloadCheckL")
	PPSS A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
    PPSS A 0 A_JumpIfInventory("PendingQuickness",1,"ToQuick")
	//PPSS A 0 A_JumpIfInventory("ReloadingL",1,"LReload")
	PPSS A 0 A_TakeInventory("BackToEmpty",1)
    DPIL A 1 A_WeaponReady(12)
    Loop
  ToQuick:
	TNT1 A 0 ACS_NamedExecute("ProcessQuick",0,0,0,0)
	GoTo LIdle+4
  Profanity:
	9MRL A 0 ACS_ExecuteAlways(820,0,2,0,0)
	ORFU ABC 2
	ORFU D 26
	ORFU CBA 2
	PPFU A 0 A_TakeInventory("FuckYou",1)
	Goto Ready
  QuickMelee:
	ORDM A 0 A_JumpIfInventory("OrderDualPrimary",1,1)
	Goto QMEmpty
	ORDM A 0 A_PlaySoundEx("fist/swing","Weapon")
	ORDM ABCDF 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PPBL D 0 A_CustomPunch (random(4,5),1,0,"BlockPuff")
	ORDM HIJKL 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	TNT1 A 2
	ORDS ABCD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PPBL A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready
  QMEmpty:
	ORDN A 0 A_PlaySoundEx("fist/swing","Weapon")
	ORDN ABCDF 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PPBL D 0 A_CustomPunch (random(4,5),1,0,"BlockPuff")
	ORDN HIJKL 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	TNT1 A 2
	ORDS EFGH 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PPBL A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready
  ToReady:
	NULL A 0
	Goto Ready
	NULL AAA 0
	NULL A 0 A_PlaySoundEx("orderpistol/dryfire","SoundSlot6")
	Goto Ready
  NullFlash:
	TNT1 A 0
	Stop
  Deselect:
	 TNT1 A 0 A_GunFlash("RDeselect")
	 DPIK CBA 1
	 TNT1 A 0 A_TakeInventory("SynthFireActive",1)
     TNT1 AAAAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
	 TNT1 A 1 A_Lower
     Goto Deselect+13
  DeselectEmpty:
	 ORDS HGFE 1
     TNT1 AAAAAAAAAA 0 A_Lower
	 TNT1 A 1 A_Lower
     Goto DeselectEmpty+5
  Select:
	 TNT1 A 0 A_SetCrosshair(15)
	 TNT1 AA 0 A_Raise
	 TNT1 A 0 A_GiveInventory("SynthFireActive",1)
	 TNT1 A 1 A_WeaponReady
	 TNT1 A 0 A_PlaySoundEx("orderpistol/select","SoundSlot6")
	 Goto SelectAnim
  SelectAnim:
	ORDS A 0 A_GunFlash("RSelect")
	DPIK ABC 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	TNT1 A 0 ACS_ExecuteAlways(562,0,0,0,0)
	TNT1 A 0 ACS_ExecuteAlways(563,0,0,0,0)
	//TNT1 A 0 A_Gunflash("DualPistols")
	Goto Ready
  AltFire:
	Stop
  Fire:
     PPFI A 0 A_TakeInventory("SynthFireLeft",1)
	 PPFI A 0 A_JumpIfInventory("OrderDualRight",1,1)
	 Goto DryFireR
	 PPfI A 0
	 PPFI A 0 A_JumpIfInventory("Order Pistol Explosive",1,"FireBoom")
	 PPFI A 0 A_FireBullets (ACS_ExecuteWithResult(566,3,0,0), ACS_ExecuteWithResult(566,3,0,0), 1, 10, "BulletPuff2")
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,16,-3)
	 PPFI A 0 A_PlaySound("orderpistol/fire", CHAN_WEAPON)
	 Goto FireEnd
  FireBoom:
	 PPFI A 0 A_FireCustomMissile("PistolBoomProjectile",random(-2,2),1,0,0,0,random(-2,2))
	 BPSS A 0 A_FireCustomMissile("ExplosiveCaseSpawn",5,0,16,-3)
	 PPFI A 0 A_PlaySound("orderpistol/fireboom", CHAN_WEAPON)
	 Goto FireEnd
  FireEnd:
	 PPFI A 0 A_TakeInventory("OrderDualRight",1)
	 PPFI A 0 A_AlertMonsters
	 PPFI A 0 A_FireCustomMissile("MuzzleSmokeFX",0,0,16,0)
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_SetPitch(pitch-1.0)
	 DPIR B 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPFI A 0 A_SetPitch(pitch+0.6)
	 DPIR CDE 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 Goto RIdle
  LFire:
     PPFI A 0 A_TakeInventory("SynthFireLeft",1)
	 PPFI A 0 A_JumpIfInventory("OrderDualLeft",1,1)
	 Goto ToReady+2
	 PPFI A 0
	 PPFI A 0 A_JumpIfInventory("Order Pistol Explosive",1,"LFireBoom")
	 PPFI A 0 A_FireBullets (ACS_ExecuteWithResult(566,3,0,0), ACS_ExecuteWithResult(566,3,0,0), 1, 10, "BulletPuff2")
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,-16,-3)
	 PPFI A 0 A_PlaySound("orderpistol/fire", CHAN_WEAPON)
	 Goto LFireEnd
  LFireBoom:
	 PPFI A 0 A_FireCustomMissile("PistolBoomProjectile",random(-2,2),1,0,0,0,random(-2,2))
	 BPSS A 0 A_FireCustomMissile("ExplosiveCaseSpawn",5,0,-16,-3)
	 PPFI A 0 A_PlaySound("orderpistol/fireboom", CHAN_WEAPON)
	 Goto LFireEnd
  LFireEnd:
	 PPFI A 0 A_TakeInventory("OrderDualLeft",1)
	 PPFI A 0 A_AlertMonsters
	 PPFI A 0 A_FireCustomMissile("MuzzleSmokeFX",0,0,-16,0)
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_SetPitch(pitch-1.0)
	 DPIL B 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPFI A 0 A_SetPitch(pitch+0.6)
	 DPIL CDE 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 Goto LIdle
  Spawn:
    PPSH F -1
    Stop
  }
}