ACTOR Walther9mm : DoomWeapon
{
  Weapon.SelectionOrder 9999
  Weapon.SlotNumber 2
  weapon.kickback 60
  Weapon.AmmoType "WaltherAmmo"
  Weapon.AmmoUse1 0
  Weapon.AmmoGive1 0
  weapon.ammotype2 "MPClip"
  weapon.ammouse2 1
  weapon.ammogive2 10
  Weapon.BobStyle InverseSmooth
	Weapon.BobSpeed 2.2
	Weapon.BobRangeY 0.5
	Weapon.BobRangeX 0.7
  Decal "BulletChip"
  Tag "Walther P-38"
  attacksound "weapons/Walther"
  Inventory.PickupMessage "You got the P-38!"
  +Ammo_Optional
  	+Alt_Ammo_Optional
	+WEAPON.PRIMARY_USES_BOTH
	+Weapon.NoAlert
  States
  {
  Ready:
		WALG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
		WALG B 0 A_Lower
		WALG B 1 A_Lower
		Loop
	Select:
		WALG A 0 A_Raise
		WALG A 1 A_Raise
		Loop
	Fire:
		WALG A 0 A_JumpIfInventory("WaltherAmmo",1,1)
		Goto Dryfire
		WALF A 0 BRIGHT A_GunFlash
		WALF A 0 A_SetPitch(pitch - 0.2)
		WALF A 0 A_PlayWeaponSound("weapons/Walther")
		WALF A 0 A_TakeInventory("WaltherAmmo",1)
		WALF A 1 BRIGHT A_FireCustomMissile("PistolTracer",frandom(-1,1),0)
		WALG B 2 A_AlertMonsters
		WALG A 0 A_SetPitch(pitch - 0.2)
		WALG A 1
		WALG A 1 Offset(0,36)
		WALG A 1 Offset(0,41)
		WALG A 1 Offset(0,35)
		WALG A 1 Offset(0,32) A_Jump(128,"Ready")
		Goto Ready
	Dryfire:
		WALG A 1
	Reload:
		WALG A 0 A_JumpIfInventory("WaltherAmmo",8,2)
		WALG A 0 A_JumpIfNoAmmo(1)
		Goto ProperReload
		WALG A 1
		Goto Ready
	ProperReload:
		TNT1 A 0 A_Jump(192,2)
		TNT1 A 0 A_PlaySound("*taunt", CHAN_VOICE)
		WALG A 1 Offset(0,35) A_PlaySound("reloads/p38",CHAN_ITEM)
		WALG A 1 Offset(0,38)
		WALG A 1 Offset(0,44)
		WALG A 1 Offset(0,52)
		WALG B 1 Offset(0,62)
		WALG B 1 Offset(0,72)
		WALG B 1 Offset(0,82)
		TNT1 A 8
	ReloadLoop:
		TNT1 A 0 A_TakeInventory("MPClip",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_GiveInventory("WaltherAmmo",1)
		TNT1 A 0 A_JumpIfInventory("WaltherAmmo",8,"ReloadFinish")
		TNT1 A 0 A_JumpIfNoAmmo("ReloadFinish")
		Goto ReloadLoop
	ReloadFinish:
		WALG B 1 Offset(0,82)
		WALG B 1 Offset(0,72)
		WALG B 1 Offset(0,62)
		WALG B 1 Offset(0,52)
		WALG A 1 Offset(0,44)
		WALG A 1 Offset(0,38)
		WALG A 1 Offset(0,35)
		WALG A 1 Offset(0,32)
		Goto Ready
	Flash:
		TNT1 A 3 A_Light2
		TNT1 A 3 A_Light1
		TNT1 A 0 A_Light0
		Goto LightDone
	Spawn:
		WALP A -1
		Stop
	}
}

ACTOR WaltherAmmo : Ammo
{
	+IGNORESKILL
	Inventory.MaxAmount 8
	Inventory.Icon "WALPA0"
}