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

ACTOR M1Secondary : Ammo
{
  Inventory.PickupMessage "You picked up some M1 Garand ammo." // "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
}

ACTOR M1Garand : Weapon 11454
{
  +WEAPON.NOAUTOAIM
  Weapon.BobStyle Smooth
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.3
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 70
  Weapon.AmmoType "M1Primary"
  Weapon.AmmoType2 "M1Secondary"
  Obituary "%o tasted the barrel of %k's M1 Garand."
  Inventory.Pickupmessage "You picked up the M1 Garand."
  Inventory.PickupSound "m1garand/boltfwd"
	//$Category ZT2 - Weapons
	//$Title PPSH-41
	//$Sprite PPSHF0
  Tag "M1 Garand"
  Scale 0.75
  +WEAPON.NOAUTOFIRE
  States
  {
  Ready:
	PPSS A 0 A_JumpIfInventory("InIronSights",1,"ReadyIS")
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	PPSS A 0 A_JumpIfInventory("QuickGrenading",1,"ToGrenade")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
    M1GR A 1 A_WeaponReady
    Goto Ready
  ReadyIS:
	PPSS A 0 A_JumpIfInventory("InIronSights",1,1)
	Goto Ready
    PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	PPSS A 0 A_JumpIfInventory("QuickGrenading",1,"ToHipToGrenade")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
    M1IS A 1 A_WeaponReady
    Loop
  ToIS:
	M1IS A 0 A_GiveInventory("InIronSights",1)
	M1IS A 0 A_ZoomFactor(1.5)
	M1IS DB 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	Goto ReadyIS
  ToHipToGrenade:
	M1IS A 0 A_TakeInventory("InIronSights",1)
	M1IS A 0 A_ZoomFactor(1.0)
	M1IS BD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	GoTo ToGrenade
  ToHipToMelee:
	M1IS A 0 A_TakeInventory("InIronSights",1)
	M1IS A 0 A_ZoomFactor(1.0)
	M1IS BD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	GoTo QuickMelee
  ToHip:
	M1IS A 0 A_TakeInventory("InIronSights",1)
	M1IS A 0 A_ZoomFactor(1.0)
	M1IS BD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	Goto Ready
  AltFire:
	TNT1 A 0 A_JumpIfInventory("InIronSights",1,"ToHip")
	Goto ToIS
  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
	M1SS LKJIHGFEDCBA 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 AAA 3
	M1SS ABCDEFGHIJKL 1
	TNT1 A 0 A_TakeInventory("QuickGrenading",999)
	Goto Ready
  QuickMelee:
	M1SS LKJIHGFEDCBA 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
	M1SS ABCDEFGHIJKL 1
	TNT1 A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready
	/*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)*/
  ToReady:
	NULL A 0
	Goto Ready
	NULL AAA 0
	NULL A 0 A_PlaySoundEx("dryfire/smg","SoundSlot6")
	Goto Ready
  Deselect:
	 PPSS A 0 A_JumpIfInventory("InIronSights",1,"DeselectIS")
  DeselectNormal:
	 M1SS LKJIHGFEDCBA 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 DeselectNormal+15
  DeselectIS:
	M1IS A 0 A_ZoomFactor(1.0)
	M1IS A 0 A_TakeInventory("InIronSights",1)
	M1IS ABD 1
     Goto DeselectNormal//+7
  Select:
	 TNT1 A 0 A_SetCrosshair(14)
	 TNT1 AA 0 A_Raise
	 TNT1 A 1 A_WeaponReady
	 TNT1 A 0 A_PlaySoundEx("m1garand/deploy","SoundSlot6")
	 Goto SelectAnim
  SelectAnim:
	 M1SS ABCDEFGHIJKL 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 Goto Ready
  //=================================================================================
  // AMMO CHECKING
  //=================================================================================
  ReloadCheck:
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Commando",1,"RCP")
	 TNT1 A 0 A_JumpIfInventory("M1Primary",8,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("M1Secondary",1,"ReloadAnim")
	 Goto ToReady
  RCP:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"RCP10")
	 TNT1 A 0 A_JumpIfInventory("M1Primary",10,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("M1Secondary",1,"ReloadAnim")
	 Goto ToReady
  RCP10:
	 TNT1 A 0 A_JumpIfInventory("M1Primary",12,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("M1Secondary",1,"ReloadAnim")
	 Goto ToReady
  //=================================================================================
  ReloadIS:
	M1IS A 0 A_TakeInventory("InIronSights",1)
	M1IS A 0 A_ZoomFactor(1.0)
	M1IS BD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	Goto ReloadAnim+2
  ReloadAnim:
     9MRL A 0 ACS_ExecuteAlways(820,0,0,0,0)
	 M1RR A 0 A_JumpIfInventory("InIronSights",1,"ReloadIS")
	 M1RR ABCDEFG 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR H 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR I 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR J 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR KLMN 1
	 M1RR O 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR O 3 A_PlaySoundEx("m1garand/boltback","SoundSlot3")//, 6, 1, 0)
	 TNT1 A 0 A_JumpIfInventory("M1Primary",1,2)
	 TNT1 A 0 A_Jump(256,2)
	 PPFI A 0 A_PlaySoundEx("m1/555ping","SoundSlot0")//, 6, 1, 0)
	 M1RR PQRS 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR T 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR U 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR V 6 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR WXY 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR O 0 A_PlaySoundEx("m1garand/tap","SoundSlot4")
	 M1RR Z 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS A 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS B 4 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR O 0 A_PlaySoundEx("m1garand/clipin","SoundSlot5")
	 M1RS CD 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS E 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS F 3 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS GHI 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS J 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS K 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RR O 0 A_PlaySoundEx("m1garand/boltfwd","SoundSlot6")
	 M1RS M 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS N 8 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS OP 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS Q 2 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1RS R 3 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("M1Secondary",1,2)
	 Goto Ready
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("M1Primary",8,"ToReady")
	 TNT1 A 0 A_TakeInventory("M1Secondary",1)
	 TNT1 A 0 A_GiveInventory("M1Primary",1)
	 Loop
  CalculateAmmoPerk:
     TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalculateAmmoPerk10")
     TNT1 A 0 A_JumpIfInventory("M1Secondary",1,2)
	 Goto Ready
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("M1Primary",10,"ToReady")
	 TNT1 A 0 A_TakeInventory("M1Secondary",1)
	 TNT1 A 0 A_GiveInventory("M1Primary",1)
	 Loop
  CalculateAmmoPerk10:
     TNT1 A 0 A_JumpIfInventory("M1Secondary",1,2)
	 Goto Ready
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("M1Primary",12,"ToReady")
	 TNT1 A 0 A_TakeInventory("M1Secondary",1)
	 TNT1 A 0 A_GiveInventory("M1Primary",1)
	 Loop
  //=================================================================================
  Fire:
	 PPFI A 0 A_JumpIfInventory("M1Primary",1,1)
	 Goto ToReady+2
	 PPFI A 0 A_TakeInventory("M1Primary",1)
	 Goto Casing
  Casing:
	 PPFI A 0 A_JumpIfInventory("InIronSights",1,"CasingIS")
	 PPFI A 0 A_JumpIfInventory("M1Primary",1,1)
	 Goto EmptyCasing
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,16,-3)
	 PPFI A 0 A_PlaySound("m1garand/fire", CHAN_WEAPON)
	 Goto FireEnd
  EmptyCasing:
	 BPSS A 0 A_FireCustomMissile("M1ClipShooter",5,0,16,-3)
	 PPFI A 0 A_PlaySound("m1garand/clipfire", CHAN_WEAPON)
	 Goto FireEnd
  FireEnd:
	 PPFI A 0 A_FireBullets (0.2, 0.2, 1, 20, "BulletPuff2")
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_FireCustomMissile("ShakeYourAss")
	 PPFI A 0 A_SetPitch(pitch-3.0)
	 M1GR B 1 bright A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+0.5)
	 M1GR C 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+0.7)
	 M1GR D 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+1.0)
	 M1GR EFGH 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 Goto Ready
  CasingIS:
	 PPFI A 0 A_JumpIfInventory("M1Primary",1,1)
	 Goto EmptyCasingIS
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,5,-3)
	 PPFI A 0 A_PlaySound("m1garand/fire", CHAN_WEAPON)
	 Goto FireEndIS
  EmptyCasingIS:
	 BPSS A 0 A_FireCustomMissile("M1ClipShooter",5,0,5,-3)
	 PPFI A 0 A_PlaySound("m1garand/clipfire", CHAN_WEAPON)
	 Goto FireEndIS
  FireEndIS:
	 PPFI A 0 A_FireBullets (0, 0, 1, 30, "BulletPuff2")
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_FireCustomMissile("ShakeYourAss")
	 PPFI A 0 A_SetPitch(pitch-0.3)
	 M1IF A 1 bright A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+0.1)
	 M1IF B 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+0.1)
	 M1IF B 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1GR C 0 A_SetPitch(pitch+0.1)
	 M1IF BC 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 M1IS AA 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 Goto ReadyIS
  Spawn:
    M1SP L -1
    Stop
  }
}