
ACTOR RLPlasmaRefractor : RLWeapon
{
  Obituary "%o was unable to dodge %k's plasma refractor."
  +NOAUTOAIM
  Tag "Plasma Refractor"
  Weapon.SelectionOrder 3900
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 5
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLPlasmaRefractorClip"
  Weapon.AmmoType2 "Cell"
  Inventory.Icon "PLRFICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDE 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  ReadyReload:
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDE 1 A_WeaponReady (WRF_NOFIRE | WRF_ALLOWZOOM)
    Goto Ready
	
  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_StopSound(6)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
	TNT1 A 0 A_SpawnItemEx("RLPlasmaRefractorPickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRefractorSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLPlasmaRefractor",1)
	Stop
  AfterModDrop:
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDEBCDE 1 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDEBCDE 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_StopSound(6)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRefractorSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 A 0 A_Lower
    PLRF A 1 A_Lower
    Goto DeselectLoop+2
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLMasterAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaRefractorSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianMasterDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_StopSound(6)
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    PLRF A 1 A_Raise
    Goto SelectLoop+2
	
  Fire:
	PLRF A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	PLRF A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	PLRF A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	PLRF A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	PLRF A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRefractorClip",10, 2)
	Goto Reload
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRefractorClip",5, 1)
	Goto Reload
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_AlertMonsters
    PLRF F 3 Bright A_GunFlash
	TNT1 A 0 A_JumpIfInventory("RLXaserPowerArmorToken",1,"XaserFire")
    TNT1 A 0 A_PlaySound ("weapons/plasmarefractor", 7, 1, 0, 0.8)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRefractorImpact", 0, 1)
	TNT1 A 0 A_RailAttack (0, 0, 0, "LightBlue", "None", RGF_FULLBRIGHT | RGF_SILENT, 0, "RLParticleBeamCannonPuff2", 0, 0, 0, 16, 15, 0, "RLPlasmaRefractorTrail")
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRefractorClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  XaserFire:
    TNT1 A 0 A_PlaySound ("weapons/xaserhpplasma", 7, 1, 0, 0.7)
	TNT1 A 0 A_RailAttack (0, 0, 0, "LightBlue", "None", RGF_FULLBRIGHT | RGF_SILENT, 0, "RLParticleBeamCannonPuff2", 0, 0, 0, 16, 15, 0, "RLPlasmaRefractorTrail")
	TNT1 A 0 A_RailAttack (0, 0, 0, "LightBlue", "None", RGF_FULLBRIGHT | RGF_EXPLICITANGLE | RGF_SILENT, 0, "RLParticleBeamCannonPuff2", 30, 0, 0, 16, 15, 0, "RLPlasmaRefractorTrail")
	TNT1 A 0 A_RailAttack (0, 0, 0, "LightBlue", "None", RGF_FULLBRIGHT | RGF_EXPLICITANGLE | RGF_SILENT, 0, "RLParticleBeamCannonPuff2", -30, 0, 0, 16, 15, 0, "RLPlasmaRefractorTrail")
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRefractorImpact", 0, 1)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRefractorImpact", -30, 0)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRefractorImpact", 30, 0)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRefractorClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLShotgunRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PLRF GF 3 Bright
    PLRF A 14
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDEBCDE 1
    TNT1 A 0 A_StopSound(6)
    PLRF A 6
    TNT1 A 0 A_PlaySound("weapons/plasmarefractoridle", 6, 1, 1)
    PLRF BCDEBCDEBCDEBCDE 1
    TNT1 A 0 A_StopSound(6)
    PLRF A 8
    Goto Ready
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRefractorClip", 50, "ReadyReload")
	TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
    TNT1 A 0 A_StopSound(6)
    PLRF H 4
    PLRF I 3
    PLRF J 3
    PLRF K 3
    PLRF L 3
	TNT1 A 0 A_PlaySound("weapons/plasmarefractorunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 35
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaRefractorClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRefractorClip",50,2)
	TNT1 A 0 A_JumpIfInventory("Cell",1,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadFinish:
	TNT1 A 0 A_PlaySound("weapons/plasmarefractorload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 25
    PLRF L 3
    PLRF K 3
    PLRF J 3
    PLRF I 3
    PLRF H 4
	Goto Ready
  Flash:
	TNT1 A 3 Bright A_Light1
	TNT1 A 3 Bright A_Light2
	TNT1 A 3 Bright A_Light1
	Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLPlasmaRefractorPickup",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")
	Goto ReadyReload
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLPlasmaRefractorAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRefractorSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
	TNT1 A 0 A_Jump(256,1,2,3,4)
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLSniperMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLPlasmaRefractor",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		PROJECTILES

ACTOR RLPlasmaRefractorImpact : FastProjectile
{ 
   +NOGRAVITY
   +NOBLOCKMAP
   +HITTRACER
   +SKYEXPLODE
   +FORCEXYBILLBOARD
   Height 6
   Radius 6
   Species "Player"
   Projectile
   RenderStyle Add
   Alpha 0.85
   Scale 0.6
   Speed 32000
  
  var int user_heightoffset;
  var int user_herecomestherefraction;
  var int user_ryanisabadman;
   States
   {
   Spawn:
    TNT1 A 1
	Loop
   Death:
    TNT1 A 0 A_SetUserVar("user_herecomestherefraction", 32)
    PRFB F 1 Bright
    TNT1 A 0 A_PlaySound ("weapons/plasmarefractorcharge", 7, 1, 0, 0.6)
   DeathLoop:
    TNT1 A 0 A_SetScale (scalex + 0.08)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 0 A_JumpIf (user_herecomestherefraction <= 0, "Explosion")
    TNT1 A 0 A_SetUserVar("user_herecomestherefraction", user_herecomestherefraction - 1)
    TNT1 A 0 A_SetScale (scalex + 0.08)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 0 A_JumpIf (user_herecomestherefraction <= 0, "Explosion")
    TNT1 A 0 A_SetUserVar("user_herecomestherefraction", user_herecomestherefraction - 1)
	Goto DeathLoop
	
   Explosion:
    TNT1 A 0 A_JumpIf(CheckClass("PlayerPawn", AAPTR_TRACER, TRUE), "HellserShenanigans")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") >= 2, 3)
    TNT1 A 0 A_Quake (1, 12, 0, 768, "")
    TNT1 A 0 A_Quake (3, 8, 0, 256, "")
    TNT1 A 0 A_PlaySound ("weapons/plasmarefractorhit", 7, 1, 0, 0.8)
    TNT1 A 0 A_PlaySound("weapons/plasmarefractorhit", CHAN_ITEM, 0.05, 0, 0.05)
    TNT1 A 0 A_SetScale (scalex * 2)
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRefractorShockwave", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
	TNT1 AAAAA 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
	TNT1 A 0 A_CheckCeiling ("OffsetCeiling")
	TNT1 A 0 A_CheckFloor ("OffsetFloor")
	Goto EmitProjectileRing
   OffsetCeiling:
    TNT1 A 0 A_SetUserVar("user_heightoffset", -8)
	Goto EmitProjectileRing
   OffsetFloor:
    TNT1 A 0 A_SetUserVar("user_heightoffset", 8)
	Goto EmitProjectileRing
// EMIT
   EmitProjectileRing:
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -180, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -170, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -160, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -150, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -140, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -130, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -120, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -110, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -100, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -90, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -80, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -70, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -60, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -50, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -40, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -30, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -20, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, -10, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 0, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 10, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 20, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 30, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 40, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 50, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 60, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 70, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 80, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 90, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 100, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 110, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 120, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 130, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 140, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 150, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 160, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
	TNT1 A 0 A_CustomMissile ("RLPlasmaRefractionBall", 0+user_heightoffset, 0, 170, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.1,0.1))
   EndEffect:
    PRFB C 1 Bright
	TNT1 AAA 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB C 1 Bright
	TNT1 AA 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB C 1 Bright
	TNT1 A 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB D 1 Bright
	TNT1 A 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB D 1 Bright
	TNT1 A 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB D 2 Bright
	TNT1 A 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB E 1 Bright
	TNT1 A 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    PRFB E 3 Bright
    Stop
   HellserShenanigans:
    TNT1 A 0 A_SetUserVar("user_herecomestherefraction", 6)
	TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") >= 2, 3)
    TNT1 A 0 A_Quake (1, 12, 0, 768, "")
    TNT1 A 0 A_Quake (3, 8, 0, 256, "")
    TNT1 A 0 A_PlaySound ("weapons/plasmarefractorhit", 7, 1, 0, 0.8)
    TNT1 A 0 A_PlaySound("weapons/plasmarefractorhit", CHAN_ITEM, 0.05, 0, 0.05)
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRefractorShockwave", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
// EMIT
   HellserShenanigansEmit:
	TNT1 A 0 A_CustomMissile ("RLPlasmaShotgunBallSilent", 0, 0, 0+user_ryanisabadman, CMF_AIMDIRECTION | CMF_TRACKOWNER, frandom(-0.6,0.6))
    TNT1 A 0 A_JumpIf (user_ryanisabadman >= 360, 2)
    TNT1 A 0 A_SetUserVar("user_ryanisabadman", user_ryanisabadman+10)
	Goto HellserShenanigansEmit
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRefractorShockwave", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_SetUserVar("user_ryanisabadman", 0)
    TNT1 A 0 A_JumpIf (user_herecomestherefraction <= 0, "EndEffect")
    TNT1 A 0 A_SetUserVar("user_herecomestherefraction", user_herecomestherefraction - 1)
    TNT1 A 0 A_SetScale (scalex - 0.1)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    PRFB F 1 Bright A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
    TNT1 A 1 A_Warp (AAPTR_TRACER, 5,0,0, 0, WARPF_NOCHECKPOSITION | WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION, "", 0.5)
	TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") >= 2, 3)
    TNT1 A 0 A_Quake (1, 12, 0, 768, "")
    TNT1 A 0 A_Quake (3, 8, 0, 256, "")
    TNT1 A 0 A_PlaySound ("weapons/plasmarefractorhit", 7, 1, 0, 0.8)
    TNT1 A 0 A_PlaySound("weapons/plasmarefractorhit", CHAN_ITEM, 0.05, 0, 0.05)
	Goto HellserShenanigansEmit
   }
}

ACTOR RLPlasmaRefractionBall : RLPlasmaBall
{
   Height 5
   Radius 5
   Damage (50)
   Scale 1.4
   SeeSound ""
   States
   {
   Spawn:
      PRFB AB 2 Bright
	  Loop
   Death:
      PRFB CCCDDD 1 Bright A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-90,90), random(16,96), 1, 0.2, 0, "None", random(-16,16))
      PRFB E 3 Bright
      Stop
   }
}

ACTOR RLPlasmaRefractorTrail
{
	+NOGRAVITY
	+NOCLIP
	+NOINTERACTION
	+FORCEXYBILLBOARD
	Alpha 0.98
	Scale 0.1
	RenderStyle Add
   States
   {
   Spawn:
      TNT1 A 0
      BPLX CDEFGHI 1 Bright
      Stop
   }
}

ACTOR RLPlasmaRefractorShockwave
{
   Projectile
   Radius 8
   Height 8
   Speed 0
   Scale 0.4
   Damage 0
   RENDERSTYLE ADD
   Alpha 0.75
   Translation "112:127=192:207"
   +NOCLIP
   +NOINTERACTION
   +FORCEXYBILLBOARD
   States
   {
   Spawn:
   SHOK ACEGIKMOQ 1 Bright A_SetScale (ScaleX+0.2)
   Stop
   }
}

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

Actor RLPlasmaRefractorSelected : RLPermanentInventory {}

ACTOR RLPlasmaRefractorClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 50
   Inventory.Icon ""
}

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

ACTOR RLPlasmaRefractorPickup : RLMasterAssembledWeaponPickup
{
	//$Sprite PLRFX0
	Tag "Plasma Refractor [Pickup]"
	States
	{
	SpawnFrame:
		PLRF 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("RLPlasmaRefractor",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("RLPlasmaRefractor",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvPlasma Refractor.")
		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= Plasma Refractor =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/PlasmaRefractorpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	SuperweaponStuff:
		"####" "#" 0 A_Jump(256, "NoSpecialStartsStuff")
		Goto NoSpecialStartsStuff
	}
}

ACTOR RLPlasmaRefractorWorldSpawnPickup : RLPlasmaRefractorPickup 17834
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_JumpIf(CallACS("DRLA_opengl"), 3) // If enabled, rarity beam will be cyan, rather than blue
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorld", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorldDRPG", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	SpawnFrame:
		PLRF X 4
		"####" "#" 0 A_GiveInventory("RLMasterItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/masterspawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLPlasmaRefractor",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvPlasma Refractor.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelMasterGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}
