ACTOR Weapon_Kar98k : Weapon_Base
{
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 30
  Weapon.AmmoType1 "Weapon_Kar98k_Mag"
  Obituary "$OB_MPPISTOL"
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOAUTOFIRE
  
  Weapon.SlotNumber 4
  
  States
  {
  Ready:
	PISG A 0
	PISG A 0 A_PlaySound("weapons/equip",CHAN_6)
	  PISG A 1 Offset(0,8)
	  PISG A 1 Offset(0,12)
	  PISG A 1 Offset(0,18)
	  PISG A 1 Offset(0,24)
	  PISG A 1 Offset(0,28)
	  PISG A 0 Offset(0,32)
	  PISG A 1 A_WeaponReady
	  Goto Idle
  
  Idle:
	PISG A 0 A_GiveInventory("YouPlayer_HoldingRifle",1)
    PISG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Loop
	
	Empty:
	PISG A 1
	PISG A 0 A_PlaySound("weapons/empty",CHAN_VOICE)
	Goto Reload
	
  Fire:
	PISG A 0 A_JumpIfNoAmmo("Empty")
    PISG A 0
	PISG A 0 A_FireBullets (0, 0, 1, 35, "BulletPuff")
	PISG A 0 A_PlaySound("weapons/kar98k/fire", CHAN_WEAPON, 1.0, false, 0.8)
	PISG A 0 A_FireCustomMissile ("SmokeFlash_RifleHandler",0,false,13,5)
	PISG A 0 A_FireCustomMissile ("MuzzleFlash_RifleHandler",0,false,13,5)
	PISG A 0 A_SetPitch(pitch-4.5,SPF_INTERPOLATE)
	PISG A 0 A_JumpIfNoAmmo("Fire2")
	PISG A 0 A_PlaySound ("weapons/kar98k/bolt",CHAN_7)
	
    MDL1 FGHIJK 1
	MDL1 LMN 2
	//OPQRSTU
	MDL2 A 2
	MDL2 BCDE 1
	MDL2 FGH 2
	MDL2 IJK 1
	MDL2 LMNOP 2
	MDL2 QRSTUVWXYZ 2 A_WeaponReady(WRF_ALLOWRELOAD)
	MDL3 ABC 2 A_WeaponReady(WRF_ALLOWRELOAD)
    PISG A 0
    Goto Idle
	
	Fire2:
    MDL1 FGHIJK 1 A_WeaponReady(WRF_NOFIRE)
	MDL1 LMNOPQRSTU 2 A_WeaponReady(WRF_ALLOWRELOAD)
	Goto Reload
	
	Reload:
	PISG A 1 A_WeaponReady
	PISG A 0 A_JumpIfInventory("Weapon_Kar98k_Mag",0,"Idle")
	PISG A 0 A_JumpIfInventory("Weapon_Kar98k_Ammo",1,"ReloadYes")
	Goto Idle
	ReloadYes:
	PISG A 0
	//PISG A 0 A_PlaySound ("weapons/ak47/reload/foley",CHAN_6,1.0,false,5.0)
	PISG A 0 A_PlaySound ("weapons/kar98k/reload",CHAN_7)
	MDL3 GHIJKLMNOPQRSTUVWXYZ 2 A_WeaponReady(WRF_NOFIRE)
	MDL4 ABCDEFGHIJKLMNOPQRSTUVWXYZ 2 A_WeaponReady(WRF_NOFIRE)
	MDL5 A 0 A_GunFlash("ReloadSystem",GFF_NOEXTCHANGE)
	MDL5 ABCDEFGHI 2 A_WeaponReady
	PISG A 0
	Goto Idle
	
	ReloadSystem:
	TNT1 A 0 A_JumpIfInventory("Weapon_Kar98k_Mag",0,"ReloadSystemEND")
	TNT1 A 0 A_JumpIfInventory("Weapon_Kar98k_Ammo",1,"ReloadSystemConfirm")
	Goto ReloadSystemEND
	ReloadSystemConfirm:
	TNT1 A 0 A_GiveInventory("Weapon_Kar98k_Mag",1)
	TNT1 A 0 A_TakeInventory("Weapon_Kar98k_Ammo",1)
	Goto ReloadSystem
	
	ReloadSystemEND:
	TNT1 A 1
	Stop
	
  Flash:
    PISF A 7 Bright A_Light1
    Goto LightDone
    PISF A 7 Bright A_Light1
    Goto LightDone
	Done:
	MDL1 A 0
	MDL2 A 0
	MDL3 A 0
	MDL4 A 0
	MDL5 A 0
	MDL6 A 0
	MDL7 A 0
	MDL8 A 0
	MDL9 A 0
	Stop
  Spawn:
    PIST A -1
    Stop
  }
}

ACTOR Weapon_Kar98k_Mag : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 6
}

ACTOR Weapon_Kar98k_Ammo : Ammo
{
	Inventory.Amount 6
	Inventory.MaxAmount 60
}

ACTOR AmmoPkup_Kar98k_single : CustomInventory Replaces RocketBox
{
	Scale 0.5
	+QUIET
	+COUNTITEM
	States
	{
	Spawn:
	AMMO F -1
	Stop
	Pickup:
	TNT1 A 0 A_JumpIfInventory("Weapon_Kar98k_Ammo",0,"FailPickup")
	TNT1 A 0 A_GiveInventory("Weapon_Kar98k_Ammo",6)
	TNT1 A 0 ACS_NamedExecute("PlayerPickupMessage",0,12)
	Stop
	FailPickup:
	TNT1 A 1
	Fail
	}
}

ACTOR GunPkup_Kar98k : CustomInventory Replaces RocketLauncher
{
	Scale 0.5
	+QUIET
	+COUNTITEM
	States
	{
	Spawn:
	GUNN E -1
	Stop
	Pickup:
	TNT1 A 0 A_JumpIfInventory("Weapon_Kar98k",0,"FailPickup")
	TNT1 A 0 A_GiveInventory("Weapon_Kar98k",1)
	TNT1 A 0 ACS_NamedExecute("PlayerPickupMessage",0,11)
	Fail
	FailPickup:
	TNT1 A 1
	Fail
	}
}