ACTOR TWINESeamasterSpeargun : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
  Weapon.SelectionOrder 3000
    Weapon.Ammotype1 "SeamasterSpeargunClip"
  Weapon.Ammotype2 "TWINESmallSpearBoltAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 2
  +WEAPON.AMMO_OPTIONAL
  Tag "Seamaster Speargun"
  Inventory.PickupMessage "Seamaster Speargun"
  Obituary  "%k's Seamaster Speargun put %o into a deep sleep."
  	Inventory.PickupSound "TWINE/Items/Pickup"
  States
  {
  Spawn:
    TKA1 G -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/WeaponupPSX","Weapon")
    TK04 A 2 
    TK04 B 2
    TK04 C 2
    TK04 D 2
    TK04 EF 2
    TK04 G -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK04 G 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
	  ReloadCheck:
	 KF7S A 0 A_JumpIfInventory("SeamasterSpeargunClip",2,2)
	 KF7S A 0 A_JumpIfInventory("TWINESmallSpearBoltAmmo",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:
	 TK04 QRSTUVXYZ 1
	 TK05 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK04 A 0 A_PlayWeaponSound("TWINE/Weapons/SpeargunReload")
	 TK06 ABC 1
	 TK06 DEFGHIJKLMNOPQRSTUVXYZ 1
	 TK07 ABCD 1
	 TNT1 A 0
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("TWINESmallSpearBoltAmmo",1)
	 TNT1 A 0 A_GiveInventory("SeamasterSpeargunClip",1)
	 TNT1 A 0 A_JumpIfInventory("SeamasterSpeargunClip",2,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("TWINESmallSpearBoltAmmo",1,"ReloadAmmo")
	 goto ReloadDone

  ReloadDone:
	 TNT1 A 0
	 TK07 EFGHIJKLMNOPQ 1
	 Goto Ready+7
	 
	 
  Deselect:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/Switch","Weapon")
    TK04 F 2
    TK04 EDCBA 2
    TK04 A 0 A_Lower
    wait
  Select: 
    TK04 A 0 A_Raise 
    Loop  
  Fire: 
	TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/Speargun","Weapon")
    TK04 I 1 A_FireBullets(1.0, 1, 1, 50, "BulletPuff")
	TK04 JKLMNOP 1
	TK04 G 30
    Goto Ready+7
	Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR TWINESeamasterSpeargunPickup : Custominventory
{
   Scale 0.1
  Inventory.PickupMessage "Seamaster Speargun"
  	Inventory.PickupSound "TWINE/Items/Pickup"
   States
   {
   Spawn:
	  TKA1 G -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("TWINESeamasterSpeargun")
	   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
   }
}

