ACTOR SSTRailgun : Railgun replaces Railgun
{
  Tag "Railgun"
  +Weapon.AXEBLOOD
  //+BLOODSPLATTER
  damagetype "Rocket"
  SpawnID 164
  Radius 20
  Height 16
  Weapon.Selectionorder 99
  Weapon.AmmoType1 "RailShot"
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType2 "Cell"
  Weapon.AmmoUse2 0
  Weapon.AmmoGive2 100
  +NOAUTOFIRE
  //+AMMO_OPTIONAL
  +ALT_AMMO_OPTIONAL
  +NOALERT
	+FORCEXYBILLBOARD
  Inventory.Pickupmessage "$PICKUP_RAILGUN" // "You got the railgun! (Alt-fire reloads.)"
  Obituary "$OB_RAILGUN" // "%o was railed by %k."
  Weapon.preferredSkin "RailgunSkin"
  Weapon.ViewPitchStyle Full
  Weapon.ViewPitchOffset 20
  States
  {
  Ready:
    RLGG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    BG2G E 0 A_JumpIfInventory("RailShot", 1, 1)
	Goto Reload
    BG2G E 0
    Loop
  AlmostReady:
    RLGG A 1
    RLGG A 0 A_Refire
    Goto Ready
  Deselect:
    TNT1 A 0 ACS_ExecuteAlways(779,0, 2,0,0)
    TNT1 A 0
    RLGG A 1 A_Lower
    Goto DeSelect+2
  Select:
    TNT1 A 0 A_JumpIfInventory("InstantSwitch",1, "Ready")
    TNT1 A 0 ACS_ExecuteAlways(779,0, 9,0,0)
    //RLGG F 0 A_GiveInventory("SSTFist", 1) // For Instagib purposes
    TNT1 A 0
    RLGG E 1 A_Raise
    Goto Select+3
  Fire:
    RLGG E 0 A_JumpIfNoAmmo("Reload")
    BG2G E 0 A_JumpIfInventory("RailShot", 1, 1)
	Goto Reload
	RLGG A 0 A_PlaySoundEx("railgun/charge",CHAN_6)
	RLGG BC 1 BRIGHT
    RLGG E 0 A_AlertMonsters
    RLGG E 0 A_FireRailgun
    BERT B 0 A_FireBullets (0, 0, -1, 1, "SSTRailPuff",0) //SSTBulletpuff2a
    //RLGG F 0 A_TakeInventory("RailShot", 1)
    RLGG M 1 BRIGHT A_ZoomFactor(0.91)
	TNT1 A 0 A_SetPitch(pitch-random(1,2))
	TNT1 A 0 A_SetAngle(angle+random(1,2))
    //TNT1 A 0 ACS_ExecuteAlways(925,0, 425,0,0)
    RLGG N 1 BRIGHT A_ZoomFactor(0.94)
    RLGG O 1 BRIGHT A_ZoomFactor(0.97)
    RLGG P 1 BRIGHT A_ZoomFactor(1.0)
    RLGG A 6//8
    //RLGG E 0 A_JumpIfNoAmmo("PreReload")
    BG2G E 0 A_JumpIfInventory("RailShot", 1, 1)
	Goto Reload//PreReload
    //RLGG A 2
    RLGG AAA 2 A_WeaponReady(WRF_NOSECONDARY)
    RLGG F 0 A_Refire
    Goto Ready
  PreReload:
    RLGG E 4
    Goto Reload
  NoReload:
    RLGG A 1 A_WeaponReady
	Goto Ready
  Reload:
    RLGG F 0 A_JumpIfInventory("Railshot", 4, "NoReload")
    RLGG F 0 A_JumpIfInventory("Cell", 10, 1)
    Goto Ready
    RLGG E 4
    RLGG F 0 A_playsoundEx("weapons/railgunreload1", "Item")
    RLGG F 6
    RLGG GHI 6
    RLGG F 0 A_playweaponsound("weapons/railgunreload2")
    RLGG JKLA 6
  Load:
    RLGG F 0 A_JumpIfInventory("Railshot", 4, "AlmostReady")
    RLGG F 0 A_TakeInventory("Cell", 10)
    RLGG F 0 A_GiveInventory("RailShot", 1)
    RLGG F 0 A_JumpIfInventory("Cell", 10, 1)
    Goto AlmostReady
    RLGG F 0
    LOOP
  Flash:
    TNT1 A 5 bright A_Light1
    TNT1 A 5 bright A_Light2
    TNT1 A 0 bright A_Light0
    Goto LightDone
  Altfire:
    RLGG E 0 A_JumpIfInventory("Railshot", 4, "Ready")
    RLGG A 1
    Goto Reload
  Spawn:
    RAIL A -1
    Stop
  }
}

actor RailShot : Ammo
{
  +IGNORESKILL
  inventory.pickupmessage "You probably shouldn't see this."
  inventory.amount 1
  inventory.maxamount 4
  inventory.icon "CELLA0"
  ammo.backpackamount 0
  ammo.backpackmaxamount 4
}
