ACTOR GE007SniperRifle : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
   +WEAPON.NOAUTOFIRE
    Weapon.Ammotype1 "SniperRifleClip"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
	Weapon.AmmoGive2 8
	Weapon.AmmoType2 "GE007RifleAmmo"
	+WEAPON.AMMO_OPTIONAL
	tag "Sniper Rifle"
  Inventory.PickupMessage "Picked up a Sniper Rifle."
  Obituary "%k's Sniper Rifle ensured %o would never walk again."
  	Inventory.PickupSound "GE007/Weapons/WeaponSFX1"
  States
  {
  Spawn:
    TKA1 U -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("GE007/Weapons/WeaponSFX1","Weapon")
    TK52 A 1 
    TK52 B 1
    TK52 C 1
    TK52 D 1
    TK52 EFGHIJKLMNO 1
    TK52 P -1 A_WeaponReady
	goto ReloadCheck
	TK52 P 1 A_WeaponReady
    Goto Ready+6
	
		ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("SniperRifleClip",8,2)
	 KLBG A 0 A_JumpIfInventory("GE007RifleAmmo",1,"ReloadStart")
	 KLBG A 0
	 goto Ready+16

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("GE007/Weapons/Reload")
     TK52 ONMLKJIHGFEDCBA 1
	 TNT1 A 5
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("GE007RifleAmmo",1)
	 TNT1 A 0 A_GiveInventory("SniperRifleClip",1)
	 TNT1 A 0 A_JumpIfInventory("SniperRifleClip",8,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("GE007RifleAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TNT1 A 5
	 TK52 ABCDEFGHIJKLMNOP 1
	 goto Ready+16
  Deselect:
    TK52 ONMLKJIHGFEDCB 1
    TK52 A 1
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlaySound ("GE007/Weapons/PP7Slienced","Weapon")
    TK52 Q 1 BRIGHT A_FireBullets(0, 0, 1, 31, "BulletPuff",FBF_USEAMMO|FBF_NORANDOM)
	SNIP A 0 BRIGHT A_SpawnItemEx ("PointedBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
	TK52 R 1
    Goto Ready+16
		AltFire:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR GE007SniperRiflePickup : Custominventory
{
   Scale 0.2
  Inventory.PickupMessage "Picked up a Sniper Rifle."
  	Inventory.PickupSound "GE007/Weapons/WeaponSFX1"
   States
   {
   Spawn:
	  TKA4 M -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("GE007SniperRifle")
	  TNT1 A 0 A_GiveInventory("GE007RifleMelee")
	  stop
   }
}
