ACTOR TWINEFrinesiAuto: Weapon
{
  Weapon.Kickback 100
  Scale 0.1
  
     Weapon.Ammotype1 "TWINEFrinesiAutoClip"
  Weapon.Ammotype2 "TWINEFrinesiAutoAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 30
  +WEAPON.AMMO_OPTIONAL
  Tag "Frinesi Auto"
  Inventory.PickupMessage "Got Frinesi Auto"
  Obituary  "%o was pricked by %k's Frinesi Auto."
  	Inventory.PickupSound "TWINE/Items/Pickup"
  States
  {
  Spawn:
    TKA7 G -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/WeaponupPSX","Weapon")
    TL36 A 2 
    TL36 B 2
    TL36 C 2
    TL36 DEFGHIJKLM 2
    TL36 N -1  A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TL36 N -1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+6
	
			  ReloadCheck:
	 KF7S A 0 A_JumpIfInventory("TWINEFrinesiAutoClip",10,2)
	 KF7S A 0 A_JumpIfInventory("TWINEFrinesiAutoAmmo",1,"ReloadAboutToBegin")
	 KF7S A 0
	 goto Ready+6
	 
	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:
	 TL37 EFGHIJKLMNO 1
	 TNT1 A 0 A_PlaySound ("TWINE/Weapons/AutoReload","Weapon")
	 TL37 PQRSTUVX 1
	 TNT1 A 0 A_PlaySound ("TWINE/Weapons/AutoReload","Weapon")
	 TL37 YZ 1
	 TL38 ABCDEFGHIJKLMNOPQRSTUVX 1
	 TNT1 A 0
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("TWINEFrinesiAutoAmmo",1)
	 TNT1 A 0 A_GiveInventory("TWINEFrinesiAutoClip",1)
	 TNT1 A 0 A_JumpIfInventory("TWINEFrinesiAutoClip",10,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("TWINEFrinesiAutoAmmo",1,"ReloadAmmo")
	 goto ReloadDone

  ReloadDone:
	 TNT1 A 0
	 TL38 YZ 1
	 TL39 ABCDEFG 1
	 goto Ready+10
	 
  Deselect:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/Switch","Weapon")
    TL39 HIJKLMNOPQ 2
    TK61 E 0 A_Lower
    wait
  Select: 
    TK61 A 0 A_Raise 
    Loop  
  Fire: 
   TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/AutoFire","Weapon")
    TL36 O 1 BRIGHT A_FireBullets(3, 3, 6, 11, "BulletPuff")
	TL36 P 1
	TL36 QRSTUVXYZ 2
	TL37 AB 1 A_refire
	TL37 CD 1 A_refire
    Goto Ready+10
	Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR TWINEFrinesiAutoPickup : Custominventory
{
   Scale 0.2
  Inventory.PickupMessage "Got Frinesi Auto"
  	Inventory.PickupSound "TWINE/Items/Pickup"
   States
   {
   Spawn:
    TKA7 G -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("TWINEFrinesiAuto")
	   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/takeautoshotgun")
		Stop
	  PickupCoach:
	 	TNT1 A 0 A_PlaySound ("L4D/Coach/takeautoshotgun")
		Stop
		PickupFrancis:
	 	TNT1 A 0 A_PlaySound ("L4D/Francis/takeautoshotgun")
		Stop
	  PickupBill:
	 	TNT1 A 0 A_PlaySound ("L4D/Bill/takeautoshotgun")
		Stop
		PickupLouis:
	 	TNT1 A 0 A_PlaySound ("L4D/Louis/takeautoshotgun")
		Stop
		PickupZoey:
	 	TNT1 A 0 A_PlaySound ("L4D/Zoey/takeautoshotgun")
		Stop
	    PickupNick:
	 	TNT1 A 0 A_PlaySound ("L4D/Nick/takeautoshotgun")
		Stop
		PickupRochelle:
	 	TNT1 A 0 A_PlaySound ("L4D/Rochelle/takeautoshotgun")
		Stop
   }
}
