Actor TrueLegendaryRailgunGiver : CustomInventory
{
  Scale 0.85
  Inventory.Amount 1
  Inventory.MaxAmount 0
  Inventory.InterHubAmount 0
  Inventory.PickupSound "weapons/PlanetCracker_Cling"
  Inventory.PickupMessage "True Legendary Railgun!"
  Tag "True Legendary Railgun"
  States
  {
  Spawn:
    LRWP A 0 NoDelay ACS_NamedExecuteWithResult("WeaponListCheck",9,1)
  SpawnLoop:
	LRWP A -1
    Stop
  Pickup:
	TNT1 A 0 A_JumpIfInventory("True Legendary Railgun",1,"JustAmmo")
  All:
	TNT1 A 0 A_GiveInventory("True Legendary Railgun",1)
	TNT1 A 0 A_JumpIfInventory("TrueLegendaryRailgunGiverCheck",1,"HoldAndDestroy")
	TNT1 A 0 A_GiveInventory("TrueLegendaryRailgunGiverCheck",1)
	TNT1 A 0 A_GiveInventory("LEGRailgunMagazine",Random(8,16))
	TNT1 A 0 A_GiveInventory("TrueLegendaryCell",8)
	Stop
  JustAmmo:
    TNT1 A 0 A_JumpIfInventory("TrueLegendaryRailgunGiverCheck",1,"Null")
	TNT1 A 0 A_GiveInventory("TrueLegendaryRailgunGiverCheck",1)
	TNT1 A 0 A_GiveInventory("LEGRailgunMagazine",Random(8,16))
	TNT1 A 0 A_GiveInventory("TrueLegendaryCell",8)
	TNT1 A 0 A_SpawnItemEx("True Legendary Railgun")
	Stop
  }
}

Actor TrueLegendaryRailgunSpawnerGiver : TrueLegendaryRailgunGiver
{
  Scale 0.85
  Inventory.Amount 1
  Inventory.MaxAmount 0
  Inventory.InterHubAmount 0
  Inventory.PickupSound "weapons/PlanetCracker_Cling"
  Inventory.PickupMessage "True Legendary Railgun!"
  Tag "True Legendary Railgun"
  States
  {
  JustAmmo:
    TNT1 A 0 A_JumpIfInventory("TrueLegendaryRailgunGiverCheck",1,"Null")
	TNT1 A 0 A_GiveInventory("TrueLegendaryRailgunGiverCheck",1)
	TNT1 A 0 A_GiveInventory("LEGRailgunMagazine",Random(8,16))
	TNT1 A 0 A_GiveInventory("TrueLegendaryCell",8)
	Stop
  }
}

Actor TrueLegendaryRailgunGiverCheck : Inventory { Inventory.Amount 1 Inventory.MaxAmount 1 Inventory.InterHubAmount 0 }



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.AmmoGive1 75
  Weapon.AmmoGive2 150
  Weapon.SlotNumber 0
  Weapon.SlotPriority 2.0
  Weapon.AmmoType1 "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
  Tag "True Legendary Railgun"
  States
  {
  Ready:
	TNT1 A 0 A_PlayWeaponSound("weapons/railselect")
	LRAL ABCDE 1
  ReadyLoop:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	LRAL G 1 A_WeaponReady(WRF_ALLOWRELOAD)
	Loop
  Deselect:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	TNT1 A 0 A_Lower
	LRAL G 1 A_Lower
	Goto Deselect+1
  Select:
	TNT1 A 1 A_Raise
	TNT1 G 0 A_Raise
	Goto Select+1
  Fire:
	TNT1 A 0 A_JumpifInventory("LEGRailgunMagazine",15,1)
	Goto Empty
	TNT1 A 0 A_AlertMonsters 
	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
	//TNT1 A 0 A_PlaySound("truelegrail/charge")
	LRAL LMN 2
	LRAL N 8
	LRAL ML 2
	LRAL G 12
	Goto ReadyLoop
  Empty:
	LRAL H 15 A_PlaySound("weapons/click2")
  Reload:
	TNT1 A 0 A_JumpIfInventory("LEGRailgunMagazine",60,"ReadyLoop")
	TNT1 A 0 A_JumpIfInventory("TrueLegendaryCell",15,1)
	Goto ReadyLoop
	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,"ActualReload")
	LRAL QPO 2	
	Goto ReadyLoop
  ActualReload:
	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,"ActualReload")
	Goto Reload+5
  Full:
	LRAL QPO 2	
	Goto ReadyLoop
  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto ReadyLoop
  GrenadeToss:
	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)
	Goto Ready
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto ReadyLoop
  MineToss:
	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 5
	Goto Ready
  Spawn:
	LRWP A 0 NoDelay ACS_NamedExecuteWithResult("WeaponListCheck",9,1)
  SpawnLoop:
	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_NamedExecuteWithResult("CheckVanilla") == 1, "Vanilla")
	LECL ABCDEFGH 3 
	Loop
  Death:
	TNT1 A 0 A_Jump(128,3)
	LECL A 100
	LECL A 5 A_FadeOut(0.10)
	Goto Death+2
	LECL G 100
	LECL G 5 A_FadeOut(0.10)
	Goto Death+4
 }
}

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 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 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 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 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 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 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 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_NamedExecuteWithResult("CheckVanilla") == 1, "Vanilla")
	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
 }
}
