
ACTOR RLPlasmaRedirectionCannon : RLHeavyWeapon
{
  Inventory.Pickupsound "weapons/unique"
  Obituary "%o couldn't dodge %k's tracking plasma."
  Tag "Plasma Redirection Cannon"
  Weapon.Kickback 50
  Weapon.SelectionOrder 20
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 2
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLPlasmaRedirectionCannonClip"
  Weapon.AmmoType2 "Cell"
  Inventory.Icon "PRDCICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    PRDC A 45 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",50,"Pulse5")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",40,"Pulse4")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",30,"Pulse3")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",20,"Pulse2")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",10,"Pulse1")
    Goto Ready
  Pulse5:
    PRDC BCDEF 1 A_WeaponReady (WRF_ALLOWRELOAD)
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonpulse", 7, 0.4)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonNanoMod",1,1)
    Goto Pulse5+14
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldArmorToken",1,6)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaShieldArmorToken",1,5)
	TNT1 A 0 A_JumpIfInventory("RLBallisticShieldArmorToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLRechargeableEnergyShieldArmorToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldedVestArmorToken",1,2)
	TNT1 A 0 A_JumpIfInventory("RLFireShieldArmorToken",1,1)
    Goto Pulse5+14
	TNT1 A 0 A_GiveInventory("RLArmorRestorer100",1)
    PRDC EDCB 1 A_WeaponReady (WRF_ALLOWRELOAD)
    Goto Ready
  Pulse4:
    PRDC BCDE 1 A_WeaponReady (WRF_ALLOWRELOAD)
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonpulse", 7, 0.4)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonNanoMod",1,1)
    Goto Pulse4+13
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldArmorToken",1,6)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaShieldArmorToken",1,5)
	TNT1 A 0 A_JumpIfInventory("RLBallisticShieldArmorToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLRechargeableEnergyShieldArmorToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldedVestArmorToken",1,2)
	TNT1 A 0 A_JumpIfInventory("RLFireShieldArmorToken",1,1)
    Goto Pulse4+13
	TNT1 A 0 A_GiveInventory("RLArmorRestorer100",1)
    PRDC DCB 1 A_WeaponReady (WRF_ALLOWRELOAD)
    PRDC A 2 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto Ready
  Pulse3:
    PRDC BCD 1 A_WeaponReady (WRF_ALLOWRELOAD)
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonpulse", 7, 0.4)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonNanoMod",1,1)
    Goto Pulse3+12
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldArmorToken",1,6)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaShieldArmorToken",1,5)
	TNT1 A 0 A_JumpIfInventory("RLBallisticShieldArmorToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLRechargeableEnergyShieldArmorToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldedVestArmorToken",1,2)
	TNT1 A 0 A_JumpIfInventory("RLFireShieldArmorToken",1,1)
    Goto Pulse3+12
	TNT1 A 0 A_GiveInventory("RLArmorRestorer100",1)
    PRDC CB 1 A_WeaponReady (WRF_ALLOWRELOAD)
    PRDC A 4 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto Ready
  Pulse2:
    PRDC BC 1 A_WeaponReady (WRF_ALLOWRELOAD)
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonpulse", 7, 0.4)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonNanoMod",1,1)
    Goto Pulse2+11
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldArmorToken",1,6)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaShieldArmorToken",1,5)
	TNT1 A 0 A_JumpIfInventory("RLBallisticShieldArmorToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLRechargeableEnergyShieldArmorToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldedVestArmorToken",1,2)
	TNT1 A 0 A_JumpIfInventory("RLFireShieldArmorToken",1,1)
    Goto Pulse2+11
	TNT1 A 0 A_GiveInventory("RLArmorRestorer100",1)
    PRDC B 1 A_WeaponReady (WRF_ALLOWRELOAD)
    PRDC A 6 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto Ready
  Pulse1:
    PRDC B 1 A_WeaponReady (WRF_ALLOWRELOAD)
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonpulse", 7, 0.4)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonNanoMod",1,1)
    Goto Pulse1+10
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldArmorToken",1,6)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaShieldArmorToken",1,5)
	TNT1 A 0 A_JumpIfInventory("RLBallisticShieldArmorToken",1,4)
	TNT1 A 0 A_JumpIfInventory("RLRechargeableEnergyShieldArmorToken",1,3)
	TNT1 A 0 A_JumpIfInventory("RLEnergyShieldedVestArmorToken",1,2)
	TNT1 A 0 A_JumpIfInventory("RLFireShieldArmorToken",1,1)
    Goto Pulse1+10
	TNT1 A 0 A_GiveInventory("RLArmorRestorer100",1)
    PRDC A 8 A_WeaponReady (WRF_ALLOWRELOAD | 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(7)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLPlasmaRedirectionCannonPickup", 0, 0, 40, 8, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLPlasmaRedirectionCannonPickupModded", 0, 0, 40, 8, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLPlasmaRedirectionCannon",1)
	Stop
	
  AfterModDrop:
    PRDC A 8 A_WeaponReady (WRF_ALLOWRELOAD)
    Goto Ready
  MisfirePrevention:
    PRDC 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_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    PRDC 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("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLUniqueWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaRedirectionCannonSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    PRDC A 1 A_Raise
    Loop
	
  Fire:
	
	PRDC A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	PRDC A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	PRDC A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	PRDC A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	PRDC 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("RLPlasmaRedirectionCannonClip",4, 2)
	Goto Reload
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",2, 1)
	Goto Reload
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonAgilityMod",1,"FireA")
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRedirectionCannonBall", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRedirectionCannonClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRedirectionCannonBallP", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRedirectionCannonClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRedirectionCannonBallA", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRedirectionCannonClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRedirectionCannonBallS", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRedirectionCannonClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireF:
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaRedirectionCannonBallF", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLPlasmaRedirectionCannonClip", 2, TIF_NOTAKEINFINITE)
    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_StopSound(7)
    PRDC G 2 Bright A_GunFlash
    PRDC HI 2 Bright
    PRDC JJ 1
	PRDC KLMN 1 A_WeaponReady (WRF_NOBOB | WRF_NOSWITCH | WRF_NOSECONDARY)
    Goto Ready
	
  Reload:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip", 50, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip", 95, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
    TNT1 A 0 A_StopSound(7)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonTechnicalMod",1,"Reload1")
    PRD2 A 2
    PRD2 B 2
    PRD2 C 2
    PRD2 D 2
    PRD2 E 2
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PRD2 F 2
    PRD2 G 2
    PRD2 H 2
    PRD2 I 2
    PRD2 J 2
    PRD2 K 2
    PRD2 L 2
    PRD2 M 2
    PRD2 N 2
    PRD2 O 20
    PRD2 P 2
    PRD2 Q 2
    PRD2 R 2
	Goto ReloadWorking
  Reload1:
    PRD2 A 2
    PRD2 B 2
    PRD2 C 2
    PRD2 D 2
    PRD2 E 2
    TNT1 A 0 A_PlaySound("weapons/plasmaredirectioncannonunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PRD2 F 2
    PRD2 G 2
    PRD2 H 2
    PRD2 I 2
    PRD2 J 2
    PRD2 K 2
    PRD2 L 2
    PRD2 M 2
    PRD2 N 2
    PRD2 O 17
    PRD2 P 2
    PRD2 Q 2
    PRD2 R 2
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaRedirectionCannonClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",50,3)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonClip",95,2)
  ReloadWorkingAmmoCheck:
	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/plasmaredirectioncannonload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonTechnicalMod",1,"ReloadFinish1")
    PRD2 S 2
    PRD2 T 2
    PRD2 U 2
    PRD2 V 2
    PRD2 W 2
    PRD2 X 2
	Goto Ready
  ReloadFinish1:
    PRD2 S 2
    PRD2 T 2
    PRD2 U 2
    PRD2 V 2
    PRD2 W 2
    PRD2 X 2
	Goto Ready
  Flash:
    TNT1 A 2 A_Light1
    TNT1 A 2 A_Light2
    TNT1 A 2 A_Light (5)
    TNT1 A 0 A_Light1
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLPlasmaRedirectionCannonPickup",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 AfterModDrop
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 3
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaRedirectionCannonModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaRedirectionCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_FireCustomMissile("DroppedRLSniperMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLPlasmaRedirectionCannon",1)
	Stop
  }
}

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

ACTOR RLPlasmaRedirectionCannonBall : BFGBall
{
	Radius 13
	Height 8
	Speed 22
	Damage (120)
	DamageType "Plasma"
	Scale 0.5
	Projectile
	Species "Player"
	+THRUSPECIES
	+RANDOMIZE
	+THRUGHOST
	+SEEKERMISSILE
	+SCREENSEEKER
	+EXPLODEONWATER
	+USEBOUNCESTATE
	+FORCEXYBILLBOARD
	Translation "192:207=112:127"
	BounceType "Hexen"
	BounceFactor 1
	WallBounceFactor 1
	BounceCount 2
	RenderStyle Add
	Alpha 0.85
	Decal "BFGLightning"
	SeeSound "weapons/plasmaredirectioncannon"
	BounceSound "weapons/laserhit"
	DeathSound "weapons/plasmax"
	var int user_prcangle;
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PPCS CD 4 Bright
			Loop
		Spawn.Fancy:
			PPCS CDCD 2 Bright A_SpawnItemEx("RLPlasmaRedirectionCannonBallTrail")
			Loop
		Bounce:
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 0, 2)
			TNT1 A 0 A_SpawnItemEx("RLPlasmaRedirectionCannonBallBounce")
			
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256) 
			Goto Spawn
		Death:
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Death.Fancy")
			BBB1 ABCDE 4 Bright
			Stop
		Death.Fancy:
			BBB1 A 0 A_SetUserVar("user_prcangle", 0)
		Death.FancyLoop:
			BBB1 A 0 A_SpawnItemEx("RLPlasmaRedirectionCannonBallKaboom",0,0,0,10+cos(user_prcangle),10+sin(user_prcangle),0,user_prcangle)
			BBB1 A 0 A_SetUserVar("user_prcangle", user_prcangle+15)
			BBB1 A 0 A_JumpIf(user_prcangle > 359, "Death.Done")
			Loop
		Death.Done:
			BBB1 ABCDE 4 Bright
			Stop
	}
}

ACTOR RLPlasmaRedirectionCannonBallBounce
{
	Translation "192:207=112:127"
	Renderstyle Add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			BBB1 AB 1 Bright
			BBB1 CCDDDEEEE 2 A_FadeOut
			Stop
	}
}

ACTOR RLPlasmaRedirectionCannonBallKaboom
{
	Renderstyle Add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			PRNC AB 1 Bright
			PRNC CCDDDEEEE 2 A_FadeOut
			Stop
	}
}

ACTOR RLPlasmaRedirectionCannonBallTrail
{
	Renderstyle Add
	Scale 0.5
	Alpha 0.85
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			BFXP A 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			BFXP B 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			BFXP C 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			BFXP D 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			BFXP E 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			BFXP F 1 A_FadeOut
			TNT1 A 0 A_SetScale(scalex + 0.1)
			Stop
	}
}

ACTOR RLPlasmaRedirectionCannonBallP : RLPlasmaRedirectionCannonBall
{
  Damage (180)
}

ACTOR RLPlasmaRedirectionCannonBallA : RLPlasmaRedirectionCannonBall
{
  Speed 46
}

ACTOR RLPlasmaRedirectionCannonBallF : RLPlasmaRedirectionCannonBall
{
	-USEBOUNCESTATE
	BounceType "None"
	BounceCount 0
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PPCS CD 4 Bright
			Loop
		Spawn.Fancy:
			PPCS CDCD 2 Bright A_SpawnItemEx("RLPlasmaRedirectionCannonBallTrail")
			Loop
		Death: 
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Death.Fancy")
			TNT1 AAAAAAAA 0 A_CustomMissile ("RLPlasmaRedirectionMiniBall", random(-2,2), random(-12,12), random(0,359), CMF_TRACKOWNER)
			BBB1 ABCDE 4 Bright
			Stop
		Death.Fancy:
			BBB1 A 0 A_SetUserVar("user_prcangle", 0)
		Death.FancyLoop:
			BBB1 A 0 A_SpawnItemEx("RLPlasmaRedirectionCannonBallKaboom",0,0,0,10+cos(user_prcangle),10+sin(user_prcangle),0,user_prcangle)
			BBB1 A 0 A_SetUserVar("user_prcangle", user_prcangle+15)
			BBB1 A 0 A_JumpIf(user_prcangle > 359, "Death.Done")
			Loop
		Death.Done:
			TNT1 AAAAAAAA 0 A_CustomMissile ("RLPlasmaRedirectionMiniBall", random(-2,2), random(-12,12), random(0,359), CMF_TRACKOWNER)
			BBB1 ABCDE 4 Bright
			Stop
	}
}

ACTOR RLPlasmaRedirectionMiniBall : RLPlasmaRedirectionCannonBall
{
	Radius 13
	Height 8
	Speed 25
	Damage (5)
	DamageType "Plasma"
	Scale 0.8
	Projectile
	+RANDOMIZE
	+THRUGHOST
	+SEEKERMISSILE
	+SCREENSEEKER
	-USEBOUNCESTATE
	BounceType "None"
	BounceCount 0
	RenderStyle Add
	Alpha 0.85
	Decal "ArachnotronScorch"
	SeeSound ""
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256)
		SpawnLoop:
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			APLS AB 5 Bright
			Loop
		Spawn.Fancy:
			APLS ABAB 2 Bright A_SpawnItemEx("RLPlasmaRedirectionMiniBallTrail")
			Loop
		Death:
			APBX ABCDE 5 Bright
			Stop
	}
}

ACTOR RLPlasmaRedirectionMiniBallTrail
{
	Renderstyle Add
	Scale 0.4
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			APBX A 2 A_FadeOut
			APBX A 0 A_SetScale(scalex + 0.1)
			APBX B 2 A_FadeOut
			APBX B 0 A_SetScale(scalex + 0.1)
			APBX C 2 A_FadeOut
			APBX C 0 A_SetScale(scalex + 0.1)
			APBX D 2 A_FadeOut
			APBX D 0 A_SetScale(scalex + 0.1)
			APBX E 2 A_FadeOut
			APBX E 0 A_SetScale(scalex + 0.1)
			Stop
	}
}

ACTOR RLPlasmaRedirectionCannonBallS : RLPlasmaRedirectionCannonBall
{
	BounceCount 4
}

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

Actor RLPlasmaRedirectionCannonSelected : RLPermanentInventory {}
Actor RLPlasmaRedirectionCannonModLimit : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonPowerMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonBulkMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonAgilityMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonTechnicalMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonFirestormMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonNanoMod : RLUniqueModAmount {}
Actor RLPlasmaRedirectionCannonSniperMod : RLUniqueModAmount {}

ACTOR RLPlasmaRedirectionCannonClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 95
   Inventory.Icon ""
}

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

ACTOR RLPlasmaRedirectionCannonPickup : RLUniqueWeaponPickup
{
	//$Sprite PRDCX0
	Tag "Plasma Redirection Cannon [Pickup]"
	States
	{
	SpawnFrame:
		PRDC 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/gundropbigger")
		"####" "#" 0 A_ScaleVelocity (0.15)
		"####" "#" 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("RLPlasmaRedirectionCannon",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("RLPlasmaRedirectionCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdPlasma Redirection Cannon.")
		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("\cd= Plasma Redirection Cannon =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/PlasmaRedirectionCannonpickup")
		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 RLPlasmaRedirectionCannonWorldSpawnPickup : RLPlasmaRedirectionCannonPickup 17116
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamUniqueWorld", 0,0,0, 0,0,0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
		"####" "#" 0 A_Jump(256, "SpawnFrame")
		Goto SpawnFrame
		
	SpawnFrame:
		PRDC X 4
		"####" "#" 0 A_GiveInventory("RLUniqueItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/uniquespawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLPlasmaRedirectionCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdPlasma Redirection Cannon.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelUniqueGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}

ACTOR RLPlasmaRedirectionCannonPickupModded : RLPlasmaRedirectionCannonPickup
{
	+INVENTORY.TRANSFER
	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:
		PRDC 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("RLPlasmaRedirectionCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cdPlasma Redirection Cannon.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Plasma Redirection Cannon =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLPlasmaRedirectionCannonModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Plasma Redirection Cannon =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Cell",50)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cd= Plasma Redirection Cannon =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
