ACTOR TWINEDelta900Mag : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
    Weapon.Ammotype1 "Delta900MagClip"
  Weapon.Ammotype2 "TWINESmallCrossbowBoltAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 2
  +WEAPON.AMMO_OPTIONAL
  Tag "Delta 900 Mag"
  Inventory.PickupMessage "Delta 900 Mag"
  Obituary  "%k's Delta 900 Mag gut-shot forced %o to his knees."
  	Inventory.PickupSound "TWINE/Items/Pickup"
  States
  {
  Spawn:
    TKA1 D -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/WeaponupPSX","Weapon")
    TK43 A 2 
    TK43 B 2
    TK43 C 2
    TK43 D 2
    TK43 EFGHI 2
    TK43 J -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK43 J 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+10
	
	  ReloadCheck:
	 KF7S A 0 A_JumpIfInventory("Delta900MagClip",5,2)
	 KF7S A 0 A_JumpIfInventory("TWINESmallCrossbowBoltAmmo",1,"ReloadAboutToBegin")
	 KF7S A 0
	 Goto Ready+10
	 
	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:
	 TK44 DEFGHIJKLMNOPQRSTUVXYZ 1
	 TK45 ABCDEFGHIJKLM 1
	    TK43 A 0 A_PlayWeaponSound("TWINE/Weapons/MagReload3")
	 TK45 NOPQRSTUVXYZ 1
	 TK43 A 0 A_PlayWeaponSound("TWINE/Weapons/MagReload4")
	 TK46 ABCDEFGHIJKLMNOPQRST 1
	 TNT1 A 0
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("TWINESmallCrossbowBoltAmmo",1)
	 TNT1 A 0 A_GiveInventory("Delta900MagClip",1)
	 TNT1 A 0 A_JumpIfInventory("Delta900MagClip",5,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("TWINESmallCrossbowBoltAmmo",1,"ReloadAmmo")
	 goto ReloadDone

  ReloadDone:
	 TNT1 A 0
	 TK46 UVXYZ 1
	 TK47 ABCDEFGHIJKLMNOPQRS 1
	 TK47 TUVXYZ 1
	 TK48 ABCDEFGHIJKLMN 1
	 TK48 OPQRSTUVXYZ 1
	 TK49 ABC 1
	 Goto Ready+10
	 
  Deselect:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/Switch","Weapon")
    TK43 IHGF 2
    TK43 EDCBA 2
    TK43 A 0 A_Lower
    wait
  Select: 
    TK43 A 0 A_Raise 
    Loop  
  Fire: 
	TK43 A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/Mag","Weapon")
	TK43 K 1
    TK43 L 1 A_FireBullets(1.0, 1, 1, 40, "BulletPuff")
	TK43 MNOPQRSTUVXYZ 1
	TK44 ABC 1
    Goto Ready+10
	Reload:
		TK43 A 0
		goto ReloadCheck
  }
}

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

ACTOR TWINEDelta900MagPickup : Custominventory
{
   Scale 0.1
  Inventory.PickupMessage "Delta 900 Mag"
  	Inventory.PickupSound "TWINE/Items/Pickup"
   States
   {
   Spawn:
	  TKA1 D -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("TWINEDelta900Mag")
	   TNT1 A 0 A_JumpIfInventory("PlayingasEllis",1,"PickupEllis")
	   TNT1 A 0 A_JumpIfInventory("PlayingasCoach",1,"PickupCoach")
       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/takemelee")
		Stop
		PickupCoach:
	 	TNT1 A 0 A_PlaySound ("L4D/Coach/takemelee")
		Stop
		PickupNick:
	 	TNT1 A 0 A_PlaySound ("L4D/Nick/takemelee")
		Stop
    	PickupRochelle:
	 	TNT1 A 0 A_PlaySound ("L4D/Rochelle/takemelee")
		Stop
   }
}
