Actor SwatSniperRifle: Weapon
{
	Weapon.AmmoUse 1
	Weapon.AmmoGive 10
	Weapon.AmmoType "SwatSniperRifleAmmo"
	Weapon.SelectionOrder 1500
	Obituary "%o was sniped by %k's Sniper Rifle."
	Inventory.PickupMessage "You got The Sniper Rifle!"
	Tag "Sniper Rifle"
	+WEAPON.NOALERT
	Decal BulletChip
	Inventory.RestrictedTo "SwatClass"
	+NoAutoAim
	States
	{
	Spawn:
		SNIR W -1
		Stop
	Ready:
		SNIR TSRQPONMLK 1
		SNIR K 1 A_WeaponReady(WRF_ALLOWZOOM)
		Goto Ready+10
	ReadyScoped:
		SNIR V 1 Bright A_WeaponReady(1)
		Loop
	Deselect:
		"####" "#" 0 A_TakeInventory("SniperRifleZoomCheck",1)
		"####" "#" 0 A_ZoomFactor(1.0)
		SNIR L 1 A_Lower
		Loop
	Select:
		SNIR K 0 A_Raise
		Loop
	Fire:
		"####" "#" 0 A_JumpIfInventory("SniperRifleZoomCheck",1,"FireScoped")
		SNIR K 0 A_AlertMonsters
		SNIR K 0 A_PlayWeaponSound("Weapon/SniperFire")
		SNIR K 0 A_GunFlash
		SNIR K 4 Bright A_RailAttack(600, 0, 1, "NONE", "FFFFFF", RGF_SILENT, 0, "SniperRiflePuff", 0, 0, 8192, 0, 0, 0)
		SNIR K 2 A_CheckReload
		SNIR BCDEFGHIJ 2
		SNIR J 2 A_PlayWeaponSound("Weapon/SniperCharge")
		SNIR IHGFEDCBA 2
		SNIR A 0 A_Refire
		Goto Ready+10
	FireScoped:
		SNIR V 0 Bright A_AlertMonsters
		SNIR V 0 Bright A_PlayWeaponSound("Weapon/SniperFire")
		SNIR V 0 Bright A_GunFlash
		SNIR V 4 Bright A_RailAttack(600, 0, 1, "NONE", "FFFFFF", RGF_SILENT, 0, "SniperRiflePuff", 0, 0, 8192, 0, 0, 0)
		SNIR V 2 Bright A_CheckReload
		SNIR V 18 Bright
		SNIR V 20 Bright A_PlayWeaponSound("Weapon/SniperCharge")
		SNIR V 0 Bright A_Refire
		Goto ReadyScoped
	AltFire:
		"####" "#" 0 A_JumpIfInventory("SniperRifleZoomCheck",1,"AltFireUncheck")
		SNIR V 1 Bright A_ZoomFactor(3.0)
		SNIR V 14 Bright A_GiveInventory("SniperRifleZoomCheck",1)
		Goto ReadyScoped
	AltFireUncheck:
		SNIR V 0 Bright A_ZoomFactor(1.0)
		SNIR V 1 Bright A_TakeInventory("SniperRifleZoomCheck",1)
		SNIR K 14
		Goto Ready+10
	Flash:
		TNT1 A 0 A_JumpIfInventory("SniperRifleZoomCheck",1,"FlashScoped")
		SNIR U 3 Bright A_Light2
		SNIR U 3 Bright A_Light1
		SNIR U 0 Bright A_Light0
		Goto LightDone
	FlashScoped:
		TNT1 A 3 Bright A_Light2
		TNT1 A 3 Bright A_Light1
		TNT1 A 0 Bright A_Light0
		Goto LightDone
  Zoom:
    TNT1 A 0 A_JumpIfInventory("HasSwatGrenades", 1, "CheckAmmo")
    Goto DontThrow
  CheckAmmo:
    TNT1 A 0 A_JumpIfInventory("SwatGrenadeAmmo", 1, "DoThrow")
    Goto DontThrow
  DoThrow:
    TNT1 A 0
    Goto ThrowFrag
	ThrowFrag:
	FGGN BCD 2
	TNT1 A 0 A_TakeInventory("SwatGrenadeAmmo", 1) // ONLY grenade ammo removed
	FGGN E 2 A_PlaySound("weapons/grnpullpin")
	FGGN FGHH 2
	FGGN J 0 A_FireCustomMissile("ThrownGrenade30", 0, 0, 0, 0)
	FGGN J 0 A_PlaySound("weapons/grntoss")
	FGGN JKLMNOPQ 2
	FGGN A 0
	NULL A 12 A_CheckReload
		Goto RaiseAfterThrow
	RaiseAfterThrow:
    SNIR K 1 Offset(0, 50)
    SNIR K 1 Offset(0, 40)
    SNIR K 1 Offset(0, 30)
		Goto Ready+10
	DontThrow:
		SNIR K 1
		Goto Ready+10
	}
}

Actor SniperRifleZoomCheck : Inventory
{
	Inventory.MaxAmount 1
	-INVENTORY.INVBAR
}

Actor SniperRiflePuff : BulletPuff
{
	Decal BulletChip
	+PUFFONACTORS
}

Actor SwatSniperRifleAmmo : Ammo
{
	Inventory.Amount 5
	Inventory.MaxAmount 25
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 50
	Inventory.PickupMessage "Picked up a box of sniper bullets."
}
