ACTOR "True Legendary Railgun" : Weapon 7777
{
//$Category Weapons/BFG20K
//$Sprite LRWPA0
//$Title "True Legendary Railgun"
  Scale 0.8
  Weapon.PreferredSkin "Railgun-Marine"
  Weapon.Selectionorder 7
  Weapon.KickBack 2000
  Weapon.AmmoUse 0
  Weapon.AmmoGive 75
  Weapon.AmmoGive2 150
  Weapon.AmmoType "LEGRailgunMagazine"
  Weapon.AmmoType2 "TrueLegendaryCell"
  Inventory.PickupSound "weapons/PlanetCracker_Cling"
  Weapon.UpSound "weapons/pickuprg"
  Inventory.Pickupmessage "True Legendary Railgun! "
  Obituary "%o was cut in half by %k's True Legendary Railgun super slug."
  Decal RailScorch
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOALERT  
  +WEAPON.NOAUTOAIM
  +INVENTORY.UNDROPPABLE
  States
  {
  Ready:
    TNT1 A 0 A_PlayWeaponSound("weapons/railselect")
	LRAL ABCDE 1
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	LRAL G 1 A_WeaponReady
    Goto Ready+6
  Deselect:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	LRAL G 1 A_Lower
    Goto Deselect+1
  Select:
	TNT1 A 0 A_Raise
    Wait
  Fire:
    TNT1 A 0 A_JumpifInventory("LEGRailgunMagazine",15,1)
	Goto Empty
    TNT1 A 0 A_AlertMonsters 
    TNT1 A 0 A_GunFlash
	TNT1 A 0 A_Light1
	TNT1 A 0 Radius_Quake(12,4,0,1,0)
	TNT1 A 0 A_FireCustomMissile("RailgunImpact",0,0)
	TNT1 A 0 A_PlaySound("truelegrail/fire")
	TNT1 A 0 A_TakeInventory("LEGRailgunMagazine",15)
    LRAL F 2 Bright A_RailAttack(Random(600,950), 0, 1, "00 00 ff", None, RGF_SILENT, 0, "TrueLegendaryRailgunPROJ", 0, 0, 8192, 35, 0.5, 0.5, "TrueLegendaryRailgunTrail")
	LRAL GHIJKJIHG 1 Bright A_Light2
	//TNT1 A 0 A_PlaySound("truelegrail/charge")
	TNT1 A 0 A_Light0
	LRAL LMN 2
	LRAL N 8
	LRAL ML 2
	LRAL G 12
    Goto Ready+6
  Empty:
   LRAL  H 15 A_PlaySound("weapons/click2")
  AltFire:
    TNT1 A 0 A_JumpIfInventory("LEGRailgunMagazine",60,2)
    TNT1 A 0 A_JumpIfInventory("TrueLegendaryCell",15,2)
	TNT1 A 0
	Goto Ready+6
	LRAL OPQ 2
	LRAL R 30
	LRAL S 3 A_FireCustomMissile("LegCellCasing", random(-13,-15), 0, 2, 1)
	LRAL R 20 A_PlaySound("truelegrail/reload")
	TNT1 A 0 A_JumpIfInventory("TrueLegendaryCell",15,"Reload")
	LRAL QPO 2	
	Goto Ready+6
  Reload:
    TNT1 A 0 A_TakeInventory("TrueLegendaryCell",15)
	TNT1 A 0 A_GiveInventory("LEGRailgunMagazine",15)
	TNT1 A 0 A_JumpIfInventory("LEGRailgunMagazine",60,"Full")
	TNT1 A 0 A_JumpIfInventory("TrueLegendaryCell",1,"Reload")
	Goto AltFire+6
  Full:
    LRAL QPO 2	
	Goto Ready+6
  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto Ready+6
  GrenadeToss:
  	TNT1 A 0
	TNT1 A 0 A_ZoomFactor(1)
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	LRAL EDCBA 1
	TNT1 A 4
	HGRN ABC 1
	HGRN D 2
	HGRN EFG 1
	HGRN HI 2
	TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN J 1
	HGRN KLM 2
	HGRN NO 1
	TNT1 A 6
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
    TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0
	Goto Ready
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto Ready+6
  MineToss:
  	TNT1 A 0 A_TakeInventory("RailgunZoomed",1)
	TNT1 A 0 A_ZoomFactor(1)
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	LRAL EDCBA 1
	TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1		
	TNT1 A 0 A_TakeInventory("MineAmmo",1)	  
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	MINE HI 1
	MINE JK 2
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
    TNT1 A 0 A_TakeInventory("Land Mine",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0
	TNT1 A 5
	Goto Ready
  Spawn:
    LRWP A -1
    Stop
    }
}

ACTOR LegCellCasing : BulletCasing
{
	Scale 0.55
	Seesound "weapons/cellcasing"
	+NOTIMEFREEZE
	States
	{
	Spawn:
	  TNT1 A 0
      TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
	  LECL ABCDEFGH 3 
	  Loop
    Death:
	  TNT1 A 0
      TNT1 A 0 A_Jump(128,3)
      LECL A 100
      LECL A 5 A_FadeOut(0.10)
      Goto Death+3
      LECL G 100
	  LECL G 5 A_FadeOut(0.10)
	  Goto Death+5
	  }
}

ACTOR LEGRailgunMagazine : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 60
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 60
   Inventory.Icon "LRWPA0"
}


ACTOR TrueLegendaryRailgunPROJ : FastProjectile
{
Radius 6
Height 6
Speed 250
Damage (Random(1000,1850))
Scale 1
DamageType "TrueLegendaryDamage"
SeeSound "monsters/darkcyberrail"
MissileType "LegendaryRailgunTrail"
Species "Player"
DeathSound "cyberrail/impact"
+RIPPER
+THRUSPECIES
+EXTREMEDEATH
+BLOODLESSIMPACT
+FOILINVUL
+NOTIMEFREEZE
+PIERCEARMOR
+DONTREFLECT
States
{
Spawn:
    LRSH A 1 Bright A_FadeOut(0.04)
    Loop
Death:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("BFGShockwaveBlue", 0, 0, 0, 0, 0, 0, 0, 128)
    TNT1 AAAA 0 A_CustomMissile("KaboomBlue2", 0, 0, random(0,360), 2, random(0,360))	
	TNT1 A 1 A_SpawnItem("RailGunImpactEffectBlue")
	Stop
	}
}

ACTOR TrueLegendaryRailgunTrail : BFG9500Trail
{
+CLIENTSIDEONLY
Scale 0.25
+NOTIMEFREEZE
States
{
Spawn:
	TNT1 A 0
	TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH ABC 2 Bright A_FadeOut(0.04)
    TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH DEF 2 Bright A_FadeOut(0.04)
	TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH GHI 2 Bright A_FadeOut(0.04)
    TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH JKL 2 Bright A_FadeOut(0.04)
	TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH MNO 2 Bright A_FadeOut(0.04)
    TNT1 A 0 bright A_SpawnItemEx("TrueLegRailParticleBlue", Random(-2,2),Random(-2,2),Random(-2,2),fRandom(-0.5,0.5),fRandom(-0.5,0.5),fRandom(-0.5,0.5),Random(-0,359),128)
	LRSH P 2 Bright A_FadeOut(0.04)
	Stop
	}
}

ACTOR TrueLegRailParticleBlue : BFGTrailParticleGreen
{
//-NOGRAVITY
//+LOWGRAVITY
+NOTIMEFREEZE
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
SPKB A 2 Bright A_FadeOut(fRandom(0.025,0.05))
TNT1 A 0 A_SetScale(ScaleX - fRandom(0.001, 0.002), ScaleY - fRandom(0.001, 0.002))
Loop
}
}

ACTOR TrueLegendaryCell : Ammo
{
Scale 0.3
Inventory.PickupMessage "True Legendary Cell"
Inventory.PickupSound "weapons/PlanetCracker_Ready"
Inventory.Amount 40
Inventory.MaxAmount 500
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 500
Inventory.Icon "TCELD0"
Scale 0.8
+NOTIMEFREEZE
States
{
  Spawn:
    TCEL ABCDCB 3
    Loop
    }
}

ACTOR TrueLegendaryCellPack : TrueLegendaryCell
{
Scale 0.6
Inventory.Amount 120
Inventory.PickupSound "weapons/PlanetCracker_Ready"
Inventory.PickupMessage "True Legendary Cell Pack"
+NOTIMEFREEZE
States
{
Spawn:
TPCL ABCDCB 4
Loop
}
}