ACTOR TWINEFrinesiSpecial12 : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
  
   Weapon.Ammotype1 "FrinesiSpecial12Clip"
  Weapon.Ammotype2 "TWINESmallShotgunAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 16
  +WEAPON.AMMO_OPTIONAL
  Tag "Frinesi Special 12"
  Inventory.PickupMessage "Frinesi Special 12"
  Obituary  "%o was ruined by %k's massive Frinesi Special 12."
  	Inventory.PickupSound "TWINE/Items/Pickup"
  States
  {
  Spawn:
    TKA1 H -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/WeaponupPSX","Weapon")
    TK20 A 2 
    TK20 B 2
    TK20 C 2
    TK20 DEFGH 2
    TK20 I -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK20 I -1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+9
	
			  ReloadCheck:
	 KF7S A 0 A_JumpIfInventory("FrinesiSpecial12Clip",8,2)
	 KF7S A 0 A_JumpIfInventory("TWINESmallShotgunAmmo",1,"ReloadAboutToBegin")
	 KF7S A 0
	 Goto Ready+9
	 
	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:
	TNT1 A 0 A_JumpIfInventory("TWINEFrinesiSpecial12SpeedLoader",1,"ReloadStartSpeedLoad")
  TK04 A 0 A_PlayWeaponSound("TWINE/Weapons/ShotgunReload")
	 TK21 LMMOPQRSTUVXYZ 1
	 TK42 AB 1
	 TNT1 A 0
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("TWINESmallShotgunAmmo",1)
	 TNT1 A 0 A_GiveInventory("FrinesiSpecial12Clip",1)
	 TNT1 A 0 A_JumpIfInventory("FrinesiSpecial12Clip",1,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("TWINESmallShotgunAmmo",1,"ReloadAmmo")
	 goto ReloadDone

  ReloadDone:
	 TNT1 A 0
	 TK42 CDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK22 ABCD 1
	 Goto Ready+9
	 
	 	   ReloadStartSpeedLoad:
	    TK04 A 0 A_PlayWeaponSound("TWINE/Weapons/ShotgunReloadSpeed")
	 TK21 LMMOPQRSTUVXYZ 1
	 TK21 YZ 2
	 TK21 YZ 2
	 TK21 YZ 2
	 TK21 YZ 2
	 TK21 YZ 2
	 TK21 YZ 3
	 TK21 YZ 3
	 TNT1 A 0
	 goto ReloadAmmoSpeedLoad
	 
	   ReloadAmmoSpeedLoad:
	 TNT1 A 0 A_TakeInventory("TWINESmallShotgunAmmo",1)
	 TNT1 A 0 A_GiveInventory("FrinesiSpecial12Clip",1)
	 TNT1 A 0 A_JumpIfInventory("FrinesiSpecial12Clip",8,"ReloadDoneSpeedLoad")
	 TNT1 A 0 A_JumpIfInventory("TWINESmallShotgunAmmo",1,"ReloadAmmoSpeedLoad")
	 goto ReloadDoneSpeedLoad

  ReloadDoneSpeedLoad:
	 TNT1 A 0
	 	TK42 AB 1
	 TK42 CDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK22 ABCD 1
	 Goto Ready+9
	 
  Deselect:
  TNT1 A 0 A_PlaySound ("TWINE/Weapons/Switch","Weapon")
    TK20 H 2
    TK20 GFEDCBA 2
    TK20 A 0 A_Lower
    wait
  Select: 
    TK20 A 0 A_Raise 
    Loop  
  Fire: 
  TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/Shotgun","Weapon")
	TNT1 A 0 A_SpawnItemEx("TWINEShellCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TK20 J 2 BRIGHT A_FireBullets(3, 3, 6, 8, "BulletPuff")
	TK20 KLMNOPQRSTUVX 2
    Goto Ready+9
	  AltFire: 
  TK04 A 0 A_JumpIfNoAmmo("ReloadCheck")
   NULL A 0 A_JumpIfInventory("FrinesiSpecial12Clip",1,1)
  Goto Ready+9
 	TNT1 A 0 A_PlaySound ("TWINE/Weapons/ShotgunAuto","Weapon")
	TNT1 A 0 A_SpawnItemEx("TWINEShellCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TK20 Z 2 BRIGHT A_FireBullets(3, 3, 6, 8, "BulletPuff")
	TNT1 A 0 A_TakeInventory("FrinesiSpecial12Clip",1,TIF_NOTAKEINFINITE)
	TK21 ABCDEFGIJK 1
    Goto Ready+9
	Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR TWINEFrinesiSpecial12Pickup : Custominventory
{
   Scale 0.1
  Inventory.PickupMessage "Frinesi Special 12"
  	Inventory.PickupSound "TWINE/Items/Pickup"
   States
   {
   Spawn:
    TKA1 H -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("TWINEFrinesiSpecial12")
	   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/takeshotgun")
		Stop
	  PickupCoach:
	 	TNT1 A 0 A_PlaySound ("L4D/Coach/takeshotgun")
		Stop
		PickupFrancis:
	 	TNT1 A 0 A_PlaySound ("L4D/Francis/takeshotgun")
		Stop
	  PickupBill:
	 	TNT1 A 0 A_PlaySound ("L4D/Bill/takeshotgun")
		Stop
		PickupLouis:
	 	TNT1 A 0 A_PlaySound ("L4D/Louis/takeshotgun")
		Stop
		PickupZoey:
	 	TNT1 A 0 A_PlaySound ("L4D/Zoey/takeshotgun")
		Stop
	    PickupNick:
	 	TNT1 A 0 A_PlaySound ("L4D/Nick/takeshotgun")
		Stop
		PickupRochelle:
	 	TNT1 A 0 A_PlaySound ("L4D/Rochelle/takeshotgun")
		Stop
   }
}

ACTOR TWINEFrinesiSpecial12SpeedLoader : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 1
}



Actor TWINEShellCasing
{
Scale 0.02
radius 3
projectile
gravity 0.3
bouncefactor 0.5
wallbouncefactor 0.4
bouncecount 5
bouncetype "Doom"
BounceSound "TWINE/Weapons/Shell"
-NOGRAVITY
-NOBLOCKMAP
+FORCEXYBILLBOARD
+BOUNCEONCEILINGS
+NOTELEPORT
+DROPOFF
+FLOORCLIP
+THRUACTORS
	states
	{
	Spawn:
		TNT1 A 0 NoDelay A_Jump(255, "Spawn1", "Spawn2", "Spawn3", "Spawn4", "Spawn5")
		goto Spawn1
	Spawn1:
		TF03 C 2
		loop
	Spawn2:
		TF03 C 2
		loop
	Spawn3:
		TF03 C 2
		loop
	Spawn4:
		TF03 C 2
		loop
	Spawn5:
		TF03 C 2
		loop
	Death:
		TNT1 A 0 A_Jump(255, "Death1", "Death2")
		goto Death1
	Death1:
		TF03 C 175
		stop
	Death2:
		TF03 C 175
		stop
	}
}