ACTOR KarPrimary : Ammo
{
  Inventory.Amount 0
  Inventory.MaxAmount 10
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
}

ACTOR KarSecondary : Ammo
{
  Inventory.PickupMessage "You picked up a stripclip of Kar-98 ammo." // "Picked up a clip."
  Inventory.PickupSound "bullpup/magin"
  Inventory.Amount 15
  Inventory.MaxAmount 80
  Ammo.BackpackAmount 15
  Ammo.BackpackMaxAmount 80
  Inventory.Icon "CLIPA0"
  +INVENTORY.IGNORESKILL
  States
  {
  Spawn:
    CLIP A -1
    Stop
  }
}

ACTOR "Kar-98k Rifle" : Weapon 11509
{
  +WEAPON.NOAUTOAIM
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 70
  Weapon.AmmoType "KarPrimary"
  Weapon.AmmoType2 "KarSecondary"
  Obituary "\cJ%k \cG> \cKKar-98 \cG> \cJ%o"
  Inventory.Pickupmessage "You picked up the Karabiner 98 Kurz."
  Inventory.PickupSound "ppsh/pickup"
  Weapon.BobStyle Smooth
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.3
	//$Category ZT2 - Weapons
	//$Title Karabiner 98 Kurz
	//$Sprite PPSHF0
  Tag "Kar-98"
  Scale 0.75
  +WEAPON.NOAUTOFIRE
  States
  {
  Ready:
	PPSS A 0 A_PlaySoundEx("kar98/select","SoundSlot6")
	K9SS ABCD 1
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	PPSS A 0 A_JumpIfInventory("PendingQuickness",1,"ToQuick")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
    K9ID A 1 A_WeaponReady
    Goto Ready+5
  ReadyIS:
    PPSS A 0 A_JumpIfInventory("DoBlocking",1,"ToHipToQuickMelee")
	PPSS A 0 A_JumpIfInventory("QuickGrenading",1,"ToHipToGrenade")
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ToHipToReload")
    LDHR S 1 bright A_WeaponReady(1)
    Loop
  ToQuick:
	TNT1 A 0 ACS_NamedExecute("ProcessQuick",0,0,0,0)
	GoTo Ready+7
  QuickMelee:
	K9SS DCBA 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
	K9SS ABCD 1
	TNT1 A 0 A_TakeInventory("DoBlocking",1)
	Goto Ready+5
  ToReady:
	NULL A 0
	Goto Ready+5
	NULL AAA 0
	NULL A 0 A_PlaySoundEx("dryfire/smg","SoundSlot6")
	Goto Ready+5
  Deselect:
	 K9SS DCBA 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+6
  Select:
	 TNT1 A 0 A_SetCrosshair(17)
	 TNT1 A 0 A_GiveInventory("HasFiringModes",1)
     TNT1 A 0 A_Raise
     Wait
  //==================================================================
  // AMMO CHECK
  //==================================================================
  ReloadCheck:
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"RCP")
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",5,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("KarSecondary",1,"ReloadAnim")
	 Goto ToReady
  RCP:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"RCP10")
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",7,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("KarSecondary",1,"ReloadAnim")
	 Goto ToReady
  RCP10:
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",10,"ToReady")
	 TNT1 A 0 A_JumpIfInventory("KarSecondary",1,"ReloadAnim")
	 Goto ToReady
  //==================================================================
  ReloadAnim:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,14,0,0)
     TNT1 A 0 A_TakeInventory("SniperZoom",2)
     9MRL A 0 ACS_ExecuteAlways(820,0,0,0,0)
	 K9CK ABCDE 1
	 K9CK F 1
	 K9CK GI 1
	 K9CK J 1
	 K9CK K 1
	 K9CK K 0 A_PlaySoundEx("kar98/boltback","SoundSlot6")
	 K9CK L 1
	 K9CK MN 1
	 K9CK O 3
	 K9CK P 1
	 K9CK Q 2
	 K9CK R 6
	 K9RL ABCDEFGH 1
	 K9RL I 8
	 K9RL JKLM 1
	 K9RL N 2
	 K9RL P 0 A_PlaySoundEx("kar98/stripin","SoundSlot6")
	 K9RL O 1
	 K9RL PQ 1
	 K9RL R 3
	 K9RL STUVWXY 1
	 K9RL Z 6
	 K9RM A 0 A_PlaySoundEx("kar98/stripclip","SoundSlot6")
	 K9RM AB 1
	 K9RM AB 2
	 K9RM C 4
	 K9RM D 6
	 K9RM EF 1
	 K9RM G 8
	 K9RL P 0 A_PlaySoundEx("kar98/stripout","SoundSlot6")
	 K9RM HIJKLM 1
	 K9RM N 4
	 K9RM OP 1
	 K9RL IHGFEDCBA 1
	 K9CK R 6
	 K9CK K 0 A_PlaySoundEx("kar98/boltfwd","SoundSlot6")
	 K9CK QPO 1
	 K9CK NM 2
	 K9CK L 1
	 K9CK J 3
	 K9CK IHG 1
	 K9CK F 2
	 K9CK EDCBA 1
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 Goto CalculateAmmo
  //==================================================================
  // AMMO CHECK
  //==================================================================
  CalculateAmmo:
	 TNT1 A 0 A_JumpIfInventory("Perk_Rifleman",1,"CalculateAmmoPerk")
     TNT1 A 0 A_JumpIfInventory("KarSecondary",1,2)
	 Goto Ready+5
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",5,"ToReady")
	 TNT1 A 0 A_TakeInventory("KarSecondary",1)
	 TNT1 A 0 A_GiveInventory("KarPrimary",1)
	 Loop
  CalculateAmmoPerk:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalculateAmmoPerk10")
     TNT1 A 0 A_JumpIfInventory("KarSecondary",1,2)
	 Goto Ready+5
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",7,"ToReady")
	 TNT1 A 0 A_TakeInventory("KarSecondary",1)
	 TNT1 A 0 A_GiveInventory("KarPrimary",1)
	 Loop
  CalculateAmmoPerk10:
     TNT1 A 0 A_JumpIfInventory("KarSecondary",1,2)
	 Goto Ready+5
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("KarPrimary",10,"ToReady")
	 TNT1 A 0 A_TakeInventory("KarSecondary",1)
	 TNT1 A 0 A_GiveInventory("KarPrimary",1)
	 Loop
  //==================================================================
  AltFire:
     SNFI A 0 A_JumpIfInventory("SniperZoom",2,"ZoomOut")
	 SNFI A 0 A_JumpIfInventory("SniperZoom",1,"ZoomIn2")
	 Goto ZoomIn1
  ZoomIn1:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,0,0,0)
	 LHDR S 0 A_GiveInventory("SniperZoom",1)
	 LDHR S 0 A_ZoomFactor(3.0)
	 LDHR S 1 bright
	 Goto ReadyIS
  ZoomIn2:
     LHDR S 0 A_GiveInventory("SniperZoom",1)
	 LDHR S 0 A_ZoomFactor(5.0)
	 LDHR S 1 bright
	 Goto ReadyIS
  ZoomOut:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,14,0,0)
     LHDR S 0 A_TakeInventory("SniperZoom",2)
	 LDHR S 0 A_ZoomFactor(1.0)
	 LDHR S 1 bright
	 Goto Ready+5
  ToHipToGrenade:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,14,0,0)
     LHDR S 0 A_TakeInventory("SniperZoom",2)
	 LDHR S 0 A_ZoomFactor(1.0)
	 LDHR S 1 bright
	 Goto ToGrenade
  ToHipToQuickMelee:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,14,0,0)
     LHDR S 0 A_TakeInventory("SniperZoom",2)
	 LDHR S 0 A_ZoomFactor(1.0)
	 LDHR S 1 bright
	 Goto QuickMelee
  ToHipToReload:
	 TNT1 A 0 ACS_ExecuteAlways(82,0,14,0,0)
     LHDR S 0 A_TakeInventory("SniperZoom",2)
	 LDHR S 0 A_ZoomFactor(1.0)
	 LDHR S 1 bright
	 Goto ReloadCheck
  Fire:
	 PPFI A 0 A_JumpIfInventory("KarPrimary",1,1)
	 Goto ToReady+2
	 PPFI A 0 A_TakeInventory("KarPrimary",1)
	 PPFI A 0 A_FireBullets (0.0, 0.0, 1, 60, "BulletPuff2", 4)
	 PPFI A 0 A_FireCustomMissile("ShakeYourAss")
	 PPFI A 0 A_PlaySound("kar98/fire", CHAN_WEAPON)
	 TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	 PPFI A 0 A_SetPitch(pitch-2.5)
	 K9FI A 1 bright
	 PPFI A 0 A_SetPitch(pitch+1.0)
	 K9FI B 1
	 PPFI A 0 A_SetPitch(pitch+1.0)
	 K9FI B 1
	 K9FI C 2
	 PPFI A 0 A_JumpIfInventory("KarPrimary",1,"FireCock")
	 Goto Ready+5
  FireCock:
	 K9CK ABCDE 1
	 K9CK F 1
	 K9CK GI 1
	 K9CK J 1
	 K9CK K 1
	 K9CK K 0 A_PlaySoundEx("kar98/boltback","SoundSlot6")
	 K9CK L 1
	 K9CK MN 1
	 K9CK O 3
	 K9CK P 1
	 K9CK Q 2
	 BPSS A 0 A_FireCustomMissile("LongRifleCaseSpawn",5,0,16,-3)
	 K9CK R 6
	  K9CK K 0 A_PlaySoundEx("kar98/boltfwd","SoundSlot6")
	 K9CK QPO 1
	 K9CK NM 2
	 K9CK L 1
	 K9CK J 3
	 K9CK IHG 1
	 K9CK F 2
	 K9CK EDCBA 1
	 Goto Ready+5
  Spawn:
    PPSH F -1
    Stop
  }
}