ACTOR TWINEDeutscheM95 : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
  
     Weapon.Ammotype1 "TWINEDeutscheM95Clip"
  Weapon.Ammotype2 "TWINESmall9mmAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 50
  +WEAPON.AMMO_OPTIONAL
  Tag "Deutsche M95"
  Inventory.PickupMessage "Deutsche M95"
  Obituary  "%k's Deutsche M95 dropped %o where he stood."
  	Inventory.PickupSound "TWINE/Items/Pickup"
  States
  {
  Spawn:
    TKA1 O -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/WeaponupPSX","Weapon")
    TK65 A 2 
    TK65 B 2
    TK65 C 2
    TK65 DEF 2
    TK65 G -1  A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK65 G -1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
			  ReloadCheck:
	 KF7S A 0 A_JumpIfInventory("TWINEDeutscheM95Clip",30,2)
	 KF7S A 0 A_JumpIfInventory("TWINESmall9mmAmmo",1,"ReloadAboutToBegin")
	 KF7S A 0
	 Goto Ready+7
	 
	ReloadAboutToBegin:
  TNT1 A 0 A_JumpIfInventory("PlayingasEllis",1,"ReloadSoundEllis")
  TNT1 A 0 A_JumpIfInventory("PlayingasCoach",1,"ReloadSoundCoach")
  TNT1 A 0 A_JumpIfInventory("PlayingasFrancis",1,"ReloadSoundFrancis")
    TNT1 A 0 A_JumpIfInventory("PlayingasBill",1,"ReloadSoundBill")
  TNT1 A 0 A_JumpIfInventory("PlayingasLouis",1,"ReloadSoundLouis")
  TNT1 A 0 A_JumpIfInventory("PlayingasZoey",1,"ReloadSoundZoey")
    TNT1 A 0 A_JumpIfInventory("PlayingasNick",1,"ReloadSoundNick")
  TNT1 A 0 A_JumpIfInventory("PlayingasRochelle",1,"ReloadSoundRochelle")
	 goto ReloadStart
	 
    	ReloadSoundEllis:
	 	TNT1 A 0 A_PlaySound ("L4D/Ellis/Reload","Weapon")
	 goto ReloadStart
	 
	  ReloadSoundCoach:
	 	TNT1 A 0 A_PlaySound ("L4D/Coach/Reload","Weapon")
	 goto ReloadStart
	 
	 ReloadSoundFrancis:
	 	TNT1 A 0 A_PlaySound ("L4D/Francis/Reload","Weapon")
	 goto ReloadStart
	 
	 	 ReloadSoundBill:
	 	TNT1 A 0 A_PlaySound ("L4D/Bill/Reload","Weapon")
	 goto ReloadStart
	 
	 	 ReloadSoundLouis:
	 	TNT1 A 0 A_PlaySound ("L4D/Louis/Reload","Weapon")
	 goto ReloadStart
	 
	 	 ReloadSoundZoey:
	 	TNT1 A 0 A_PlaySound ("L4D/Zoey/Reload","Weapon")
	 goto ReloadStart
	 
	 	 ReloadSoundNick:
	 	TNT1 A 0 A_PlaySound ("L4D/Nick/Reload","Weapon")
	 goto ReloadStart
	 
	 	 ReloadSoundRochelle:
	 	TNT1 A 0 A_PlaySound ("L4D/Rochelle/Reload","Weapon")
	 goto ReloadStart

  ReloadStart:
	 TK66 BCDEFGHIJLMNOPQRSTU 1
	 TNT1 A 0 A_PlaySound ("TWINE/Weapons/M95Reload1","Weapon")
	 TK66 VXYZ 1
	 TK67 ABCDEFGHIJLMNOPQRS 1
	 TNT1 A 0
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("TWINESmall9mmAmmo",1)
	 TNT1 A 0 A_GiveInventory("TWINEDeutscheM95Clip",1)
	 TNT1 A 0 A_JumpIfInventory("TWINEDeutscheM95Clip",30,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("TWINESmall9mmAmmo",1,"ReloadAmmo")
	 goto ReloadDone

  ReloadDone:
	 TNT1 A 0
	 TNT1 A 0 A_PlaySound ("TWINE/Weapons/M95Reload2","Weapon")
	 TK67 TUVXYZ 1
	 TK68 ABCDEFGHIJ 1
	 Goto Ready+7
	 
  Deselect:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/Switch","Weapon")
    TK65 V 2
    TK65 XYZ 2
	TK65 A 2
    TK65 E 0 A_Lower
    wait
  Select: 
    TK65 A 0 A_Raise 
    Loop  
  Fire: 
   TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/M95","Weapon")
	TNT1 A 0 A_SpawnItemEx("TWINEBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TK65 H 2 BRIGHT A_FireBullets(0, 1, 1, 10, "BulletPuff")
	TK65 I 2
	TK65 J 2 BRIGHT A_FireBullets(0, 1, 1, 10, "BulletPuff")
	TNT1 A 0 A_SpawnItemEx("TWINEBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
	TK65 K 2
	TK65 L 2 BRIGHT A_FireBullets(0, 1, 1, 10, "BulletPuff")
	TNT1 A 0 A_SpawnItemEx("TWINEBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
	TK65 M 2 
	TK65 NOPQR 2
	TK65 STU 2 A_REFIRE
    Goto Ready+7
	 AltFire: 
   TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
    NULL A 0 A_JumpIfInventory("TWINEDeutscheM95Clip",3,1)
  Goto Ready+7
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/M95Alt","Weapon")
	TNT1 A 0 A_SpawnItemEx("TWINEBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TK65 H 2 BRIGHT A_FireBullets(0, 1, 1, 10, "BulletPuff")
	TNT1 A 0 A_TakeInventory("TWINEDeutscheM95Clip",1,TIF_NOTAKEINFINITE)
	TK65 M 2 
	TK65 NOPQR 2
	TK65 STU 2 A_REFIRE
    Goto Ready+7
	Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

ACTOR TWINEDeutscheM95Clip : Ammo
{
Inventory.MaxAmount 30 // size of the clip
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 30 //MUST be the same as Inventory.MaxAmmount
+INVENTORY.IGNORESKILL
}

ACTOR TWINEDeutscheM95Pickup : Custominventory
{
   Scale 0.1
 Inventory.PickupMessage "Deutsche M95"
  	Inventory.PickupSound "TWINE/Items/Pickup"
   States
   {
   Spawn:
    TKA1 O -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("TWINEDeutscheM95")
	   TNT1 A 0 A_JumpIfInventory("PlayingasEllis",1,"PickupEllis")
	   TNT1 A 0 A_JumpIfInventory("PlayingasCoach",1,"PickupCoach")
	   TNT1 A 0 A_JumpIfInventory("PlayingasFrancis",1,"PickupFrancis")
	   TNT1 A 0 A_JumpIfInventory("PlayingasBill",1,"PickupBill")
	   TNT1 A 0 A_JumpIfInventory("PlayingasLouis",1,"PickupLouis")
	   TNT1 A 0 A_JumpIfInventory("PlayingasZoey",1,"PickupZoey")
       TNT1 A 0 A_JumpIfInventory("PlayingasNick",1,"PickupNick")
       TNT1 A 0 A_JumpIfInventory("PlayingasRochelle",1,"PickupRochelle")
	  stop
	  PickupEllis:
	 	TNT1 A 0 A_PlaySound ("L4D/Ellis/takesubmachinegun")
		Stop
		PickupCoach:
	 	TNT1 A 0 A_PlaySound ("L4D/Coach/takesubmachinegun")
		Stop
		PickupFrancis:
	 	TNT1 A 0 A_PlaySound ("L4D/Francis/takesubmachinegun")
		Stop
		PickupBill:
	 	TNT1 A 0 A_PlaySound ("L4D/Bill/takesubmachinegun")
		Stop
		PickupLouis:
	 	TNT1 A 0 A_PlaySound ("L4D/Louis/takesubmachinegun")
		Stop
		PickupZoey:
	 	TNT1 A 0 A_PlaySound ("L4D/Zoey/takesubmachinegun")
		Stop
	    PickupNick:
	 	TNT1 A 0 A_PlaySound ("L4D/Nick/takesubmachinegun")
		Stop
		PickupRochelle:
	 	TNT1 A 0 A_PlaySound ("L4D/Rochelle/takesubmachinegun")
		Stop
   }
}