
ACTOR RLSniperRifle : RLWeapon
{
  Obituary "%o was bullseyed by %k's sniper rifle."
  Decal BulletChip
  Tag "Sniper Rifle"
  Weapon.SelectionOrder 25
  Weapon.SlotNumber 4
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLSniperRifleClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "SNPRICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleNanoMod",1,"NanoRegenCheck")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
    ZOOM A 1 Bright A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM | WRF_NOBOB)
    Goto Ready
	
  NanoRegenCheck:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",1,"NanoRegenCheckBegin")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 70 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin
    ZOOM B 70 Bright A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
	Goto NanoRegenCheckBegin
  NanoRegenCheckBegin:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 70 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin2
    ZOOM A 70 Bright A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
	Goto NanoRegenCheckBegin2
  NanoRegenCheckBegin2:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 8, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 10, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 12, "Ready")
	Goto NanoRegen
  NanoRegen:
	TNT1 A 0 A_GiveInventory("RLSniperRifleClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleNanoMod",2,"NanoRegen2")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 17 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin2
    ZOOM A 17 Bright A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
    Goto NanoRegenCheckBegin2
  NanoRegen2:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 9 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin2
    ZOOM A 9 Bright A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD | WRF_NOBOB)
    Goto NanoRegenCheckBegin2
	
  ScavengerDrop:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"WeaponDropConfirm")
	TNT1 A 0 A_GiveInventory("RLScavengerDrop",1)
	TNT1 A 0 A_Print("Press again to drop current weapon,\nor press \crAlt Fire\c- to scrap it to retrieve a Mod Pack.")
	Goto AfterModDrop
  WeaponDropConfirm:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLSniperRiflePickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLSniperRiflePickupModded", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLSniperRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLSniperRifle",1)
	Stop
	
  AfterModDrop:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,2)
    SNPR A 8 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD)
    Goto Ready
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleNanoMod",1,2)
    ZOOM A 8 Bright A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD | WRF_NOBOB)
    Goto Ready
    ZOOM A 8 Bright A_WeaponReady (WRF_NOSECONDARY | WRF_NOBOB)
    Goto Ready
  MisfirePrevention:
    SNPR A 1 A_WeaponReady (WRF_NOFIRE | WRF_NOBOB)
    TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 A 0 A_Lower
    SNPR A 1 A_Lower
    Loop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLBasicAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLSniperRifleSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianBasicDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    SNPR A 1 A_Raise
    Loop
  Fire:
	SNPR A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	SNPR A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	SNPR A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	SNPR A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	SNPR A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBoltToken",1,"BoltCheck")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLSniperRiflePowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleAgilityMod",1,"FireA")
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(4,6)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLSniperRiflePowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleAgilityMod",1,"FirePA")
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(4,6)*48), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLSniperRiflePowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleAgilityMod",2,"FireAA")
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(4,6)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FirePP:
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(4,6)*64), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FirePA:
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(4,6)*48), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireAA:
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(4,6)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLSniperRiflePowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleAgilityMod",1,"FireSA")
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*16), "RLPiercingPuff", FBF_NORANDOM)
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*16), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireSS:
	TNT1 A 0 A_FireBullets (0, 0, 3, (random(4,6)*8), "RLPiercingPuff", FBF_NORANDOM)
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*8), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireSP:
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*24), "RLPiercingPuff", FBF_NORANDOM)
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*24), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireSA:
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*16), "RLPiercingPuff", FBF_NORANDOM)
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(4,6)*16), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireF:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleFirestormMod",2,"FireFF")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleSniperMod",1,"FireFS")
	TNT1 A 0 A_JumpIfInventory("RLSniperRiflePowerMod",1,"FireFP")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleAgilityMod",1,"FireFA")
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(6,9)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireFF:
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(8,12)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireFS:
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(6,9)*16), "RLPiercingPuff", FBF_NORANDOM)
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(6,9)*16), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireFP:
	TNT1 A 0 A_FireBullets (0.5, 0.5, -1, (random(6,9)*48), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireFA:
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(6,9)*32), "RLPiercingPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLPistolRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/sniperrifle", CHAN_WEAPON, 1, 0, 0.5)
    TNT1 A 0 A_PlaySound("weapons/sniperrifle", 7, 0.05, 0, 0.10)
	TNT1 A 0 A_GiveInventory("RLSniperRifleBoltToken",1)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"FireFinishScoped")
    SNPR B 2 Bright A_GunFlash
    SNPR C 2 Bright
    SNPR DEA 3
    Goto BoltCheck
  FireFinishScoped:
    ZOOM B 10 Bright A_GunFlash
    Goto BoltCheckScoped
  BoltCheck:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"BoltCheckScoped")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",1,2)
    SNPR A 4
    Goto Ready
    TNT1 A 0 A_SpawnItemEx ("RLShotgunPumpRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/sniperriflebolt", CHAN_ITEM)
    SNPR FGHIJ 2
	TNT1 A 0 A_TakeInventory("RLSniperRifleBoltToken",1)
    SNPR KLMNO 2
    SNPR A 4
    Goto Ready
  BoltCheckScoped:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",1,2)
    ZOOM B 4 Bright
    Goto Ready
    TNT1 A 0 A_SpawnItemEx ("RLShotgunPumpRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/sniperriflebolt", CHAN_ITEM)
    ZOOM B 10 Bright
	TNT1 A 0 A_TakeInventory("RLSniperRifleBoltToken",1)
    ZOOM B 10 Bright
    ZOOM B 4 Bright
    Goto Ready
	
  ReloadCheckZoomed:
	ZOOM B 1 Bright A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	Goto ReloadCheckZoomedDone
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ReloadCheckZoomed")
	SNPR A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
  ReloadCheckZoomedDone:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 8, "Ready")
	Goto ReloadClipCheck
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 10, "Ready")
	Goto ReloadClipCheck
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip", 12, "Ready")
  ReloadClipCheck:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk", 1, 2)
	TNT1 A 0 A_JumpIfInventory("Clip", 2, "ReloadClipCheckDone")
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("Clip", 1, "ReloadClipCheckDone")
	Goto Ready
  ReloadClipCheckDone:
	TNT1 A 0 A_JumpIf(CallACS("DRLA_ScopeStay"), 2)
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleTechnicalMod",2,"Reload2")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleTechnicalMod",1,"Reload1")
    SNP2 A 2
    SNP2 B 2
    SNP2 C 2
    SNP2 D 2
    SNP2 E 2
    SNP2 F 2
    SNP2 G 2
    SNP2 H 2
    SNP2 I 2
    TNT1 A 0 A_PlaySound("weapons/sniperrifleunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SNP2 J 2
    SNP2 K 2
    SNP2 L 18
	Goto ReloadWorking
  Reload1:
    SNP2 A 2
    SNP2 B 2
    SNP2 C 2
    SNP2 D 2
    SNP2 E 2
    SNP2 F 2
    SNP2 G 2
    SNP2 H 2
    SNP2 I 2
    TNT1 A 0 A_PlaySound("weapons/sniperrifleunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SNP2 J 2
    SNP2 K 2
    SNP2 L 15
	Goto ReloadWorking
  Reload2:
    SNP2 A 2
    SNP2 B 2
    SNP2 C 2
    SNP2 D 2
    SNP2 E 2
    SNP2 F 2
    SNP2 G 2
    SNP2 H 2
    SNP2 I 2
    TNT1 A 0 A_PlaySound("weapons/sniperrifleunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    SNP2 J 2
    SNP2 K 2
    SNP2 L 12
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk", 1, 2)
	TNT1 A 0 A_TakeInventory("Clip", 2)
	Goto ReloadWorkingClipTaken
	TNT1 A 0 A_TakeInventory("Clip", 1)
	Goto ReloadWorkingClipTaken
  ReloadWorkingClipTaken:
	TNT1 A 0 A_GiveInventory("RLSniperRifleClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",8,6)
	Goto ReloadWorkingClipCheck
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",10,4)
	Goto ReloadWorkingClipCheck
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleClip",12,3)
  ReloadWorkingClipCheck:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk", 1, "ReloadWorkingClipCheck2")
	TNT1 A 0 A_JumpIfInventory("Clip",2,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadWorkingClipCheck2:
	TNT1 A 0 A_JumpIfInventory("Clip",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
    TNT1 A 0 A_PlaySound("weapons/sniperrifleload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleTechnicalMod",2,"ReloadFinish2")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleTechnicalMod",1,"ReloadFinish1")
    SNP2 M 5
    SNP2 L 4
    SNP2 K 2
    SNP2 J 2
    SNP2 I 2
    SNP2 H 2
    SNP2 G 2
    SNP2 F 2
    SNP2 E 2
    SNP2 D 2
    SNP2 C 2
    SNP2 B 2
    SNP2 A 2
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",2,"ZoomInReload")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ZoomInMoarReload")
	Goto Ready
  ReloadFinish1:
    SNP2 M 5
    SNP2 L 4
    SNP2 K 2
    SNP2 J 2
    SNP2 I 2
    SNP2 H 2
    SNP2 G 2
    SNP2 F 2
    SNP2 E 2
    SNP2 D 2
    SNP2 C 2
    SNP2 B 2
    SNP2 A 2
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",2,"ZoomInReload")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ZoomInMoarReload")
	Goto Ready
  ReloadFinish2:
    SNP2 M 5
    SNP2 L 4
    SNP2 K 2
    SNP2 J 2
    SNP2 I 2
    SNP2 H 2
    SNP2 G 2
    SNP2 F 2
    SNP2 E 2
    SNP2 D 2
    SNP2 C 2
    SNP2 B 2
    SNP2 A 2
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",2,"ZoomInReload")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ZoomInMoarReload")
	Goto Ready
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 2 A_Light1
    TNT1 A 0 A_Light0
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLSniperRiflePickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION, 0, tid)
    Stop
  Altfire:
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ArmorModConversion")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ScavengerTime")
	TNT1 A 0 A_JumpIfInventory("RLWeaponZoomCooldown",1,"Ready")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleSniperMod",1,"ZoomOptionsExpanded")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ZoomOutLeetle")
	Goto ZoomIn
  ZoomOptionsExpanded:
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",2,"ZoomOut")
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleZoom",1,"ZoomInMoar")
	Goto ZoomIn
  ZoomIn:
	TNT1 A 0 A_GiveInventory("RLWeaponZoomCooldown",1)
	TNT1 A 0 A_GiveInventory("RLSniperRifleZoom",1)
  ZoomInReload:
    TNT1 A 0 A_SetCrosshair (83)
    TNT1 A 0 A_PlaySound("weapons/sniperriflezoomin", CHAN_ITEM, 1, 0, 4)
	ZOOM B 1 Bright A_ZoomFactor(1.5)
	ZOOM B 1 Bright A_ZoomFactor(2.0)
	ZOOM B 1 Bright A_ZoomFactor(2.25)
	TNT1 A 0 A_ZoomFactor(2.5)
	Goto Ready
  ZoomInMoar:
	TNT1 A 0 A_GiveInventory("RLWeaponZoomCooldown",1)
	TNT1 A 0 A_GiveInventory("RLSniperRifleZoom",1)
  ZoomInMoarReload:
    TNT1 A 0 A_SetCrosshair (83)
    TNT1 A 0 A_PlaySound("weapons/sniperriflezoomin", CHAN_ITEM, 1, 0, 4)
	ZOOM B 1 Bright A_ZoomFactor(3.25)
	ZOOM B 1 Bright A_ZoomFactor(4.0)
	ZOOM B 1 Bright A_ZoomFactor(4.25)
	TNT1 A 0 A_ZoomFactor(4.5)
	Goto Ready
  ZoomOut:
	TNT1 A 0 A_GiveInventory("RLWeaponZoomCooldown",1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
    TNT1 A 0 A_PlaySound("weapons/sniperriflezoomout", CHAN_ITEM, 1, 0, 4)
	ZOOM B 1 Bright A_ZoomFactor(3.5)
	ZOOM B 1 Bright A_ZoomFactor(2.5)
	ZOOM B 1 Bright A_ZoomFactor(1.75)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	Goto Ready
  ZoomOutLeetle:
	TNT1 A 0 A_GiveInventory("RLWeaponZoomCooldown",1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
    TNT1 A 0 A_PlaySound("weapons/sniperriflezoomout", CHAN_ITEM, 1, 0, 4)
	ZOOM B 1 Bright A_ZoomFactor(2)
	ZOOM B 1 Bright A_ZoomFactor(1.5)
	ZOOM B 1 Bright A_ZoomFactor(1.25)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	Goto Ready
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_TakeInventory("RLSniperRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLSniperRifleAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_TakeInventory("RLSniperRifleZoom",2)
	TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_SetCrosshair (0)
	TNT1 A 0 A_JumpIfInventory("RLSniperRifleModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_TakeInventory("RLSniperRifleModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRiflePowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLSniperRifleFirestormMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLSniperRifleSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_Jump(256,1,2)
	TNT1 A 0 A_FireCustomMissile("DroppedRLSniperMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLAgilityMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLSniperRifle",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		MECHANICS

Actor RLSniperRifleSelected : RLPermanentInventory {}
Actor RLSniperRifleZoom : RLPermanentInventory
{
inventory.maxamount 2
}

Actor RLSniperRifleBoltToken : RLPermanentInventory {}
Actor RLSniperRifleModLimit : RLBasicAssemblyModAmount {}
Actor RLSniperRiflePowerMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleBulkMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleAgilityMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleTechnicalMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleFirestormMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleNanoMod : RLBasicAssemblyModAmount {}
Actor RLSniperRifleSniperMod : RLBasicAssemblyModAmount {}

ACTOR RLSniperRifleClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 12
   Inventory.Icon ""
}

//-------------------------------------------------------------------
//		PICKUPS

ACTOR RLSniperRiflePickup : RLBasicAssembledWeaponPickup 17447
{
	//$Sprite SNPRX0
	Tag "Sniper Rifle [Pickup]"
	States
	{
	SpawnFrame:
		SNPR X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(Abs(VelZ) <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 1
		Loop
	FloorHit:
		"####" "#" 0 A_PlaySound("weapons/gundropbig")
		"####" "#" 0 A_ScaleVelocity (0.25)
		"####" "#" 0 A_ChangeFlag("SPECIAL", true)
		"####" "#" 0 A_ChangeFlag("THRUACTORS", false)
		"####" "#" 0 A_SetUserVar("user_floorhit", 1)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Stop
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLSniperRifle",1,"NotPickup") // If the player already has this weapon, they are not given the weapon
		"####" "#" 0 A_JumpIfInventory("RLWeaponLimit",0,"NotPickupLimit") // The absolute max limit check for weapons
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLSniperRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvSniper Rifle.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_Jump(256, "NotPickup")
		Goto NotPickup
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Sniper Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/SniperRiflepickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLSniperRiflePickupModded : RLSniperRiflePickup
{
	+INVENTORY.TRANSFER
	+DONTGIB
	States
	{
	Spawn:
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("GetWeaponMods", 0)
		TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 0, "NoSpecialStartsStuff")
		"####" "#" 0 A_Jump(256, "SpecialStartsStuff")
		Goto SpecialStartsStuff
		
	SpawnFrame:
		SNPR X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(VelZ <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 0 ACS_NamedExecuteAlways("RLWeaponModDisplay", 0)
		"####" "#" 1
		Loop
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLSniperRifle",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvSniper Rifle.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Sniper Rifle =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLSniperRifleModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Sniper Rifle =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Clip",8)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Sniper Rifle =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
