// Sniper rifle
actor SniperRifle : AOWWeapon {
    Weapon.BobSpeed 1.75
    Weapon.BobRangeX 0.2
    Weapon.BobRangeY 0.4
    Weapon.BobStyle Alpha
	obituary "$OB_SNIPER" // "%o was picked off by %k's Sniper Rifle."
	attacksound "rc50/fire"
	weapon.selectionorder 3
	weapon.kickback 80
	weapon.Ammotype "SniperBolt"
	Weapon.AmmoType2 "SniperAmmo"
	weapon.ammouse 1
	Weapon.AmmoGive2 5
	inventory.pickupmessage "You got the sniper rifle!"
	Weapon.PreferredSkin "MarineSniper"
	Weapon.UpSound "weapons/up/sniper"
	decal "BulletChipBig"
	+WEAPON.AMMO_OPTIONAL
	states {
    Select:
		SNIE A 1 offset (-90,100)
		SNIE A 1 offset (-80,89)
		SNIE A 1 offset (-70,79)
		SNIE A 1 offset (-60,70)
		SNIE A 1 offset (-50,62)
		SNIE A 1 offset (-40,55)
		SNIE A 1 offset (-30,49)
		SNIE A 1 offset (-20,44)
		SNIE A 1 offset (-15,40)
		SNIE A 1 offset (-10,37)
		SNIE A 1 offset (-5,34)
		SNIE A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
	Deselect:
		SNIE AA 0 A_JumpIfInventory ("IsZoomed", 1, "AltFireOff")
	    TNT1 A 0 A_TakeInventory("ActionFragGrenade",1)	
        TNT1 A 0 A_TakeInventory("ActionFlashbang",1)
        TNT1 A 0 A_TakeInventory("ActionRemoteC4",1)	
        TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		TNT1 A 0 A_TakeInventory("ActionReload",1)
		SNIE A 1 offset (-4,34)
		SNIE A 1 offset (-8,40)
		SNIE A 1 offset (-16,49)
		SNIE A 1 offset (-24,62)
		SNIE A 1 offset (-32,79)
		SNIE A 1 offset (-40,100)
		TNT1 A 0 offset (-1, 33)
		TNT1 A 0 A_Lower
		wait
	Ready:
		SNIE AA 0 A_JumpIfInventory ("IsZoomed", 1, "ReadyZoomed")
		TNT1 A 0 A_JumpIfInventory("SelectAnimation",1,"Select")
	    TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_JumpIfInventory("ActionReload",1,"Reload")
		SNIE A 1 A_WeaponReady
		loop
	ReadyZoomed:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("InMenu", 1, "AltFireOff")
		TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"AltFireOff")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"AltFireOff")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"AltFireOff")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"AltFireOff")
		TNT1 A 0 A_JumpIfInventory("ActionReload",1,"ReloadZoomed")
		TNT1 A 1 A_WeaponReady
		loop
	Fire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
	    TNT1 A 0 A_JumpIfNoAmmo("Empty")
		TNT1 A 0 A_JumpIfInventory ("IsSniper", 1, "FireClass")
        TNT1 A 0 A_JumpIfInventory("SniperBolt",1,1)
        Goto Empty
		SNIE AA 0 A_JumpIfInventory ("IsZoomed", 1, "FireZoomed")
		SNIP F 0 A_GunFlash
		SNIF F 0 A_PlayWeaponSound("rc50/fire")
		SNIF F 0 A_FireBullets (5.0, 5.0, -1, 17, "RiflePuff")
		SNIF F 2 BRIGHT
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SNIE AA 4 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		goto Reload
	FireClass:
        TNT1 A 0 A_JumpIfInventory("SniperBolt",1,1)
        Goto Empty
		TNT1 A 0 A_JumpIfInventory ("IsZoomed", 1, "FireZoomedClass")
		SNIE A 0 A_GunFlash
		SNIF F 0 A_PlayWeaponSound("rc50/fire")
		SNIF F 0 A_FireBullets (5.0, 5.0, -1, 25, "RiflePuff")
		SNIF F 2 BRIGHT
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SNIE AA 4 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		goto Reload
     Empty:
        TNT1 A 0 A_JumpIfInventory("IsZoomed",1,"Empty2")
        SNIE A 10 A_PlaySound("weapons/empty1")
	 Reload:
	    TNT1 A 0 A_TakeInventory("ActionReload",1)
        TNT1 A 0 A_JumpIfInventory("SniperBolt",1,2)
        TNT1 A 0 A_JumpIfInventory("SniperAmmo",1,2)
	    TNT1 A 0
	    Goto Ready
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SNIR ABCDE 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SNIR FGHIJ 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SNIR C 5 offset (0, 40) A_PlaySound ("rc50/boltopen")
		SNIR C 5 offset (0, 35) A_SpawnItemEx("RifleShellCasing",3,15,30,random(-2,-4),random(2,3),random(0,-1),random(45,60),128)
		TNT1 A 0 A_PlaySound ("rc50/boltclose")
		SNIR C 10 offset (0, 33)
		SNIR BA 3
		TNT1 A 0 A_TakeInventory("SniperAmmo",1)
	    TNT1 A 0 A_GiveInventory("SniperBolt",1)
		SNIE A 1 A_ReFire
		goto Ready
	FireZoomed:
		TNT1 A 0 A_ZoomFactor (5.8)
		TNT1 A 0 A_RailAttack (50, 0, 0, none, none, 1, 0, "RiflePuff")
		TNT1 A 2 bright A_FireBullets (0.0, 0.0, 1, 0, "RiflePuff", FBF_USEAMMO, 16384)
		TNT1 A 0 A_ZoomFactor (6.00)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 AA 4 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		goto ReloadZoomed
	FireZoomedClass:
		TNT1 A 0 A_ZoomFactor (5.8)
		TNT1 A 0 A_RailAttack (75, 0, 0, none, none, 1, 0, "RiflePuff", 0, 0, 16384)
		TNT1 A 2 bright A_FireBullets (0.0, 0.0, 1, 0, "RiflePuff", FBF_USEAMMO, 16384)
		TNT1 A 0 A_ZoomFactor (6.00)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 AA 4 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		goto ReloadZoomed
    Empty2:
        TNT1 A 10 A_PlaySound("weapons/empty1")
	ReloadZoomed:
	    TNT1 A 0 A_TakeInventory("ActionReload",1)
        TNT1 A 0 A_JumpIfInventory("SniperBolt",1,2)
        TNT1 A 0 A_JumpIfInventory("SniperAmmo",1,2)
	    TNT1 A 0
	    Goto Ready
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 AAAAA 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 AAAAA 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 A 5 offset (0, 40) A_PlaySound ("rc50/boltopen")
		TNT1 A 5 offset (0, 35) A_SpawnItemEx("RifleShellCasing",3,15,30,random(-2,-4),random(2,3),random(0,-1),random(45,60),128)
		TNT1 A 0 A_PlaySound ("rc50/boltclose")
		TNT1 A 10 offset (0, 33)
		TNT1 A 6
		TNT1 A 0 A_TakeInventory("SniperAmmo",1)
	    TNT1 A 0 A_GiveInventory("SniperBolt",1)
		TNT1 A 1 A_ReFire
		goto Ready
	AltFire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		SNIE A 1 A_JumpIfInventory ("IsZoomed", 1, "AltFireOff")
		SNIE A 0 ACS_ExecuteAlways (916, 0, 0)
		SNIE A 0 A_GiveInventory ("IsZoomed", 1)
		SNIE A 0 A_PlaySound ("rc50/zoomin")
		SNIE A 7
		TNT1 A 10 A_ZoomFactor (6.0)
		goto Ready
	AltFireOff:
		TNT1 A 0 A_TakeInventory ("IsZoomed", 1)
		TNT1 A 0 A_PlaySound ("rc50/zoomin")
		TNT1 A 3 A_ZoomFactor (1.0)
		TNT1 A 7 ACS_ExecuteAlways (916, 0, 0)
		SNIE A 10
		goto Ready
	Spawn:
		SNIP X -1
		stop
	Flash:
		TNT1 A 2 A_Light1
		TNT1 A 2 A_Light2
		TNT1 A 0 A_Light0
		stop
	}
}

actor IsZoomed : Inventory {}

actor SniperBolt : Ammo {
	inventory.amount 0
	inventory.maxamount 1
	ammo.backpackamount 0
	ammo.backpackmaxamount 1
}
