ACTOR PPSHPrimary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 100
  Ammo.BackpackAmount 1
  Ammo.BackpackMaxAmount 100
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
}

ACTOR PPSHSecondary : Ammo
{
  Inventory.PickupMessage "You picked up a drum of PPSH-41 ammunition." // "Picked up a clip."
  Inventory.PickupSound "bullpup/magin"
  Inventory.Amount 70
  Inventory.MaxAmount 420
  Ammo.BackpackAmount 140
  Ammo.BackpackMaxAmount 420
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
  States
  {
  Spawn:
    CLIP A -1
    Stop
  }
}

ACTOR "PPSH-41" : Weapon 11500
{
  +WEAPON.NOAUTOAIM
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 70
  Weapon.AmmoType "PPSHPrimary"
  Weapon.AmmoType2 "PPSHSecondary"
  Obituary "\cJ%k \cG> \cKPPSH-41 \cG> \cJ%o"
  Inventory.Pickupmessage "You picked up the PPSH-41."
  Inventory.PickupSound "ppsh/pickup"
	//$Category ZT2 - Weapons
	//$Title PPSH-41
	//$Sprite PPSHF0
  Tag "PPSH-41"
  Scale 0.75
  +WEAPON.NOAUTOFIRE
  States
  {
  Ready:
	PPSS A 0 A_PlaySoundEx("ppsh/select","SoundSlot6")
	PPSS ABCDE 1
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	PPSS A 0 //A_JumpIfInventory("QuickGrenading",1,"ToGrenade")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
    PPID A 1 A_WeaponReady
    Goto Ready+6
  /*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+6*/
  ToGrenade:
	TNT1 A 0 A_JumpIfInventory("QuickGrenading",1,2)
	TNT1 A 0 A_Print("Why the fuck are you getting this?")
	GoTo Ready
	TNT1 A 0 A_JumpIfInventory("Type97Primary", 1, 3)
	TNT1 A 0 A_TakeInventory("QuickGrenading",999)
	TNT1 A 0 A_Print("No Grenades Left!")
	GoTo Ready
	PPSS EDCBA 1
	TNT1 A 0 A_TakeInventory("QuickGrenading",999)
	TNT1 AAA 3
	97FI ABC 1
	97FI D 1
	97FI D 1 A_WeaponReady(WRF_NOPRIMARY | WRF_NOSECONDARY)
	//97FI D 0 A_JumpIfInventory("QuickGrenading",1,1)
	//97FI D 0 A_ReFire
	97FI E 0 A_PlaySoundEx("type97/pinpull","SoundSlot6")
	97FI EG 1
	97FI I 3
	97FI J 0 A_PlaySoundEx("type97/throw","SoundSlot6")
	97FI JKL 1
	TNT1 A 0 A_TakeInventory("Type97Primary",1)
	FRGN A 0 A_FireCustomMissile("Thrown97",random(-200,200)/100.00,0,0,16,0,random(-150,150)/100.00)
	TNT1 A 1 A_JumpIfInventory("QuickGrenading",1,"NadeSpam")
	TNT1 AAA 3
	PPSS ABCDE 1
	TNT1 A 0 A_TakeInventory("QuickGrenading",999)
	Goto Ready
  NadeSpam:
	TNT1 A 0 A_JumpIfInventory("Type97Primary", 1, 3)
	TNT1 A 0 A_TakeInventory("QuickGrenading",999)
	TNT1 A 0 A_Print("No Grenades Left!")
	GoTo Ready
	TNT1 A 1
	GoTo ToGrenade+16
  QuickMelee:
	PPSS EDCBA 1
	TNT1 AAA 3
	MCFI E 1
	MCFI E 0 A_PlaySoundEx("machete/fire","Weapon")
	MCFI FG 1
    MCFI H 0 A_CustomPunch(2*random(1, 10), TRUE, 0, "ZTMeleePuff")
	MCFI HIJ 1
	MCFI K 2
	TNT1 AAA 3
	PPSS ABCDE 1
	TNT1 A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready
  ToReady:
	NULL A 0
	Goto Ready+6
	NULL AAA 0
	NULL A 0 A_PlaySoundEx("dryfire/smg","SoundSlot6")
	Goto Ready+6
  Deselect:
	 PPSS EDCBA 1
	 PPFI A 0 A_TakeInventory("HasFiringModes",1)
	 PPFI A 0 A_TakeInventory("SemiAutomatic",1)
     TNT1 AAAAAAAAAA 0 A_Lower
	 TNT1 A 1 A_Lower
     Goto Deselect+7
  Select:
	 TNT1 A 0 A_SetCrosshair(17)
	 TNT1 A 0 A_GiveInventory("HasFiringModes",1)
     TNT1 A 0 A_Raise
     Wait
  //=================================================================================
  // AMMO CHECKING
  //=================================================================================
  ReloadCheck:
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Commando",1,"RCP")
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",70,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,"ReloadAnim")
	 Goto ToReady
  RCP:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"RCP10")
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",85,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,"ReloadAnim")
	 Goto ToReady
  RCP10:
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",100,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,"ReloadAnim")
	 Goto ToReady
  //=================================================================================
  ReloadAnim:
     9MRL A 0 ACS_ExecuteAlways(820,0,0,0,0)
	 PPRL ABCD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL E 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL F 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL G 0 A_PlaySoundEx("ppsh/magout","SoundSlot6")
	 PPRL GHIJK 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)

	 PPRL L 26 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)

	 PPRL MNO 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL P 0 A_PlaySoundEx("ppsh/magin","SoundSlot6")
	 PPRL P 11 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL Q 4 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL R 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL S 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL TUVWXY 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRL Z 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM ABC 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM D 8 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM E 0 A_PlaySoundEx("ppsh/boltback","SoundSlot6")
	 PPRM E 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM F 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM G 7 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM H 0 A_PlaySoundEx("ppsh/boltfwd","SoundSlot6")
	 PPRM H 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPRM IJ 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 Goto CalculateAmmo
  //=================================================================================
  // AMMO CALCULATION
  //=================================================================================
  CalculateAmmo:
	 TNT1 A 0 A_JumpIfInventory("Perk_Commando",1,"CalculateAmmoPerk")
     TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,2)
	 Goto Ready+6
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",70,"ToReady")
	 TNT1 A 0 A_TakeInventory("PPSHSecondary",1)
	 TNT1 A 0 A_GiveInventory("PPSHPrimary",1)
	 Loop
  CalculateAmmoPerk:
     TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalculateAmmoPerk10")
     TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,2)
	 Goto Ready+6
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",85,"ToReady")
	 TNT1 A 0 A_TakeInventory("PPSHSecondary",1)
	 TNT1 A 0 A_GiveInventory("PPSHPrimary",1)
	 Loop
  CalculateAmmoPerk10:
     TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,2)
	 Goto Ready+6
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",100,"ToReady")
	 TNT1 A 0 A_TakeInventory("PPSHSecondary",1)
	 TNT1 A 0 A_GiveInventory("PPSHPrimary",1)
	 Loop
  //=================================================================================
  Fire:
	 PPFI A 0 A_JumpIfInventory("PPSHPrimary",1,1)
	 Goto ToReady+2
	 PPFI A 0 A_TakeInventory("PPSHPrimary",1)
	 PPFI A 0 A_FireBullets (ACS_ExecuteWithResult(566,2,0,0), ACS_ExecuteWithResult(566,2,0,0), 1, 5, "BulletPuff2")
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,16,-3)
	 PPFI A 0 A_PlaySound("ppsh/fire", CHAN_WEAPON)
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_SetPitch(pitch+0.5)
	 PPFI A 1 bright A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPFI A 0 A_SetPitch(pitch-0.4)
	 PPFI B 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 PPFI A 0 A_JumpIfInventory("SemiAutomatic",1,"ToReady")
	 PPFI A 0 A_ReFire
	 Goto Ready+6
  AltFire:
	 PPFI A 0 A_JumpIfInventory("SemiAutomatic",1,"ToFull")
	 Goto ToSemi
  ToFull:
	 PPFI A 0 A_TakeInventory("SemiAutomatic",1)
	 TNT1 A 0 A_SetCrosshair(17)
	 PPFI A 0 A_Print("Switched to Fully Automatic mode.")
	 Goto Ready+6
  ToSemi:
	TNT1 A 0 A_SetCrosshair(18)
	 PPFI A 0 A_GiveInventory("SemiAutomatic",1)
	 PPFI A 0 A_Print("Switched to Semi Automatic mode.")
	 Goto Ready+6
  Spawn:
    PPSH F -1
    Stop
  }
}