ACTOR RailGun : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 20
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "AmmoCell"
	Weapon.AmmoType2 "RailgunAmmo"
	Obituary "%o was pierced by %k's Railgun."
    Inventory.PickupSound "RAILR1"
	Inventory.Pickupmessage "$GOTRG"
	+WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.EXPLOSIVE
	+WEAPON.NOALERT
	damagetype "Railgun"
	Weapon.SelectionOrder 200
	Scale 0.8
	DropItem "RailgunSpawner"
	States
	{
	SelectAnimation:
        RAIS ABC 1 BRIGHT
		RAIL A 0 A_PlaySound("RAILR1", 2)
        TNT1 AAA 0

	Ready:
	Ready3:
		TNT1 A 0
		RAIL A 0 A_JumpIfInventory("RGUnloaded",1,"ReadyUnloaded")
		RAIL A 0 A_JumpIfInventory("Zoomed",1,"Ready2")
		RIFG A 0 A_JumpIfInventory("RailgunAmmo",1,1)
		Goto ReadyNoAmmo
		RAIL ABC 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
        RAIL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        RAIL A 0 A_JumpIfInventory("Taunting",1,"GoTaunt")
		RAIL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RAIL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RAIL A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		RAIL A 0 A_JumpIfInventory("Unloading",1,"Unload")
		RAIL A 0 A_JumpIfInventory("Zoomed",1,"Ready2")
		RLNG A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Loop

	Ready2:
		TNT1 A 0
		RIFG A 0 A_JumpIfInventory("RailgunAmmo",1,1)
		Goto ReadyNoAmmo
		SNIP A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("Unloading",1,"Unload")
		RAIL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        RAIL A 0 A_JumpIfInventory("Taunting",1,"GoTaunt")
		RAIL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RAIL A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		RAIL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Loop

	ReadyNoAmmo:
		TNT1 A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
		RAIL A 0 A_SetCrosshair(0)
	    RAIR B 1 A_WeaponReady(WRF_ALLOWRELOAD)
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RLNG A 0 A_JumpIfInventory("Unloading",1,"Unload")
        RLNG A 0 A_JumpIfInventory("Reloading",1,"Reload")
        RLNG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		RLNG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RLNG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        RLNG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RLNG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		RLNG A 0 A_JumpIfInventory("IsRunning",1,"StartSprintNoAmmo")
		Loop

	NoAmmo:
		TNT1 A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RAIL A 0 A_SetCrosshair(0)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"InsertBullets")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		RAIL A 0 A_JumpIfInventory("RGUnloaded", 1, "NoAmmo3")
	NoAmmo2:
		RAIL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        RAIL A 0 A_JumpIfInventory("Taunting",1,"GoTaunt")
		RAIL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		RAIR B 5 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"InsertBullets")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoCell",1,"Reload")
		RAIL A 0 A_JumpIfInventory("IsRunning",1,"StartSprintNoAmmo")
		Goto Ready
	NoAmmo3:
		RAIL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        RAIL A 0 A_JumpIfInventory("Taunting",1,"GoTaunt")
		RAIL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		RAIR L 5 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"InsertBullets")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoCell",1,"Reload")
		RAIL A 0 A_JumpIfInventory("IsRunning",1,"StartSprintUnloaded")
		Goto ReadyUnloaded

	ReadyUnloaded:
		TNT1 A 0
		RAIR L 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RAIL A 0 A_JumpIfInventory("IsRunning",1,"StartSprintUnloaded")
		RAIL A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        RAIL A 0 A_JumpIfInventory("Taunting",1,"GoTaunt")
		RAIL A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RAIL A 0 A_JumpIfInventory("Unloading",1,"Unload")
		RAIL A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RAIL A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		Loop

	Deselect:
        RAIS CBA 1 BRIGHT
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
		RAIL A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_TakeInventory("StartDualWield",1)
        RAIL A 0 A_ZoomFactor(1.0)
		RAIL A 0 A_SetCrosshair(0)
		TNT1 AAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait

	Select:
		RAIL A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_TakeInventory("FistsSelected", 1)
		TNT1 A 0 A_TakeInventory("ShotgunSelected", 1)
		TNT1 A 0 A_TakeInventory("MinigunSelected", 1)
		TNT1 A 0 A_TakeInventory("SSGSelected", 1)
		TNT1 A 0 A_TakeInventory("RocketLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("GrenadeLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("PlasmaGunSelected", 1)
		TNT1 A 0 A_GiveInventory("RailGunSelected", 1)
		TNT1 A 0 A_TakeInventory("RevenantLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("SubMachineGunSelected", 1)
		TNT1 A 0 A_TakeInventory("BFG10KSelected", 1)
		TNT1 A 0 A_TakeInventory("BFGSelected", 1)
		TNT1 A 0 A_TakeInventory("FlameCannonSelected", 1)
		TNT1 A 0 A_TakeInventory("SawSelected", 1)
		RAIL A 0 A_Takeinventory("HasBarrel",1)
		RAIL A 0 A_GunFlash
	    TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAAA 0 A_Raise
		Goto SelectAnimation

	Fire:
	    RAIL A 0
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",1,1)
		Goto NoAmmo
		TNT1 AAA 0
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",10,1)
		Goto Ready
		TNT1 AAA 0
		RAIL A 0 A_JumpIfInventory("Pumping",1,"Ready")//Wait for recharge
		TNT1 AAA 0
		RAIL A 0 A_Takeinventory("RailgunAmmo",10)
		TNT1 A 0 A_FireCustomMissile("Alerter",0,0)
		RAIL A 0 A_SpawnItemEx("PlasmaFlareSpawn",32,0,28)
		RAIL A 0 A_FireCustomMissile("RailgunTrailEffectMissile", 0, 0, 0, 0)
		RAIL A 0 A_FireCustomMissile("RailgunProjectile", 0, 1, 0, 0)
		RAIL A 0 A_RailAttack(400, 0, 0, "none", "none", RGF_FULLBRIGHT, 1, "RailgunPuff2")

		RAIL A 0 A_PlaySound("RAILF1", 1)

		RAIL A 0 A_JumpIfInventory("Zoomed",1,"ZoomedRecoil")

		RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		RIFG A 0 A_SetPitch(-2.0 + pitch)
		RAIL A 0 A_SetPitch(-2.0 + pitch)

        RAIF A 1 BRIGHT A_AlertMonsters
		TNT1 A 0 A_Recoil(2)
		TNT1 A 0 A_ZoomFactor(0.96)
		RAIF B 1 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_ZoomFactor(1.0)
		RAIF C 1 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)

		RAIF DEFG 1 BRIGHT
		RAIL DDDDDDDD 1 BRIGHT A_SetPitch(0.25 + pitch)
		RAIL A 0 A_PlaySound("RAILR1", 2)
		RAIL A 0 A_GiveInventory("Pumping",1)
		RAIL A 0 ACS_NamedExecuteAlways("RailgunRecharge",0,0,0,0)
		RAIL DDDDDDDDDDDDDDDDDDDDD 2 BRIGHT A_WeaponReady(WRF_NOPRIMARY | WRF_NOBOB | WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready3

	ZoomedRecoil:
		RIFG A 0
		RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		RIFG A 0 A_SetPitch(-1.0 + pitch)
		RAIL A 0 A_SetPitch(-1.0 + pitch)

		SNIP A 1 BRIGHT A_AlertMonsters
		TNT1 A 0 A_Recoil(1)
		TNT1 A 0 A_ZoomFactor(4.98)
		SNIP A 1 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_ZoomFactor(5.0)
		SNIP A 1 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		SNIP AAAA 1 BRIGHT
		SNIP AAAAAAAA 1 BRIGHT A_SetPitch(0.125 + pitch)
		RAIL A 0 A_PlaySound("RAILR1", 2)
		RAIL A 0 A_GiveInventory("Pumping",1)
		RAIL A 0 ACS_NamedExecuteAlways("RailgunRecharge",0,0,0,0)
		SNIP AAAAAAAAAAAAAAAAAAAAA 2 BRIGHT A_WeaponReady(WRF_NOPRIMARY | WRF_NOBOB | WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpifInventory("FiredSecondary", 1, "HoldAim")
		SNIP A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready2

    AltFire:
        RAIL A 0
		RAIL A 0 A_JumpIfInventory("Zoomed",1,"NoAim")
		RAIL A 0 A_Giveinventory("Zoomed",1)
        RAIL A 0 A_ZoomFactor(5.0)
		RAIL A 0 A_giveinventory("PowerLightAmp", 1)
		RAIL A 0 A_SetCrosshair(41)
        RAIZ AB 2 BRIGHT

        RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT
		RAIL A 0 A_JumpIfInventory("FiredSecondary",1,"HoldAim")
        Goto Ready2

	   HoldAim:
	    RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		SNIP A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		RAIL A 0 A_JumpIfInventory("FiredSecondary",1,"HoldAim")

	 NoAim:
        RAIZ BA 1 BRIGHT
		RAIL A 0 A_Light0
		RAIL A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        RAIL A 0 A_ZoomFactor(1.0)
		RAIL A 0 A_SetCrosshair(0)
        Goto Ready

      Reload:
	    RAIL A 0
        A12G A 0 A_Takeinventory("Reloading",1)
		A12G A 0 A_Takeinventory("ADSmode",1)
		A12G A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
		RAIL A 0 A_ZoomFactor(1.0)
		RAIL A 0 A_SetCrosshair(0)
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",50,"Ready")
        RAIL A 0 A_JumpIfInventory("AmmoCell",1,3)
        Goto Ready
        TNT1 AAAA 0

		RAIL A 0 A_JumpIfInventory("RGUnloaded",1, "PutMag")
		RAIL A 0 A_JumpIfInventory("TurboReload", 1, "InsertBullets")

		RAIR ABCDEF 1 BRIGHT A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		RAIL A 0 A_PlaySound("PLSDRAW")
		RAIL A 0 A_FireCustomMissile("EmptyCellSpawn",225,0,-10,-20)
		RAIL A 0 A_GiveInventory("RGUnloaded",1)
		RAIR GHIJKL 1 BRIGHT
		RAIR L 16 BRIGHT

	PutMag:
		TNT1 A 0
		A12G A 0 A_Takeinventory("Reloading",1)
		A12G A 0 A_Takeinventory("ADSmode",1)
		A12G A 0 A_Takeinventory("Zoomed",1)
		A12G A 0 A_Takeinventory("RGUnloaded",1)
		RAIR MNOPQRS 1 BRIGHT
		RAIR A 0 A_PlaySound("RAILR1")
		RAIL A 0 A_GiveInventory("Pumping",1)
		RAIL A 0 ACS_NamedExecuteAlways("RailgunRecharge",0,0,0,0)
		RAIR TUV 1
		RAIR V 4 BRIGHT
		RAIR WX 1 BRIGHT
		RAIL D 1 BRIGHT

	InsertBullets:
		TNT1 AAAA 0
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",50,"DontNeedToReload")
		RAIL A 0 A_JumpIfInventory("AmmoCell",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		RAIL A 0 A_Takeinventory("RGUnloaded", 1)
		RAIL A 0 A_Giveinventory("RailgunAmmo",1)
		RAIL A 0 A_Takeinventory("AmmoCell",1)
		Goto InsertBullets

	DontNeedToReload:
		TNT1 AAAA 0
		RAIL A 1 A_Takeinventory("Reloading",1)
        RAIL A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready

	Unload:
	    RAIL A 0
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        A12G A 0 A_Takeinventory("Unloading",1)
		A12G A 0 A_Takeinventory("ADSmode",1)
		A12G A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_ZoomFactor(1.0)
		RAIL A 0 A_SetCrosshair(0)
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",1,2)
		Goto Ready
        TNT1 AAAA 0

		RAIR ABCDEF 1 BRIGHT A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		RAIL A 0 A_PlaySound("PLSDRAW")
		RAIL A 0 A_GiveInventory("RGUnloaded",1)
		RAIR GHIJKL 1 BRIGHT
		RAIR L 16 BRIGHT

	RemoveBullets:
		TNT1 AAAA 0
		RAIL A 0 A_JumpIfInventory("RailgunAmmo",1,3)
		Goto ReadyUnloaded
        TNT1 AAAAAA 0
		RAIL A 0 A_Takeinventory("RailgunAmmo",1)
		RAIL A 0 A_Giveinventory("AmmoCell",1)
		Loop

 	Spawn:
		SRCG A -1
		Stop

	StartSprint:
		RAIL A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        SHTN A 0 A_ZoomFactor(1.0)
		SHTN A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_SetCrosshair(0)
		SHTN A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		Goto Sprinting

	Sprinting:
		RAIL A 1 BRIGHT offset(-9,34) A_SetPitch(pitch -0.5)
		RAIL B 1 BRIGHT offset(-6,36) A_SetPitch(pitch -0.5)
		RAIL C 1 BRIGHT offset(-3,38) A_SetPitch(pitch -0.5)
		RAIL A 1 BRIGHT offset(0,38) A_SetPitch(pitch -0.5)
		RAIL B 1 BRIGHT offset(3,36) A_SetPitch(pitch -0.5)
		RAIL C 1 BRIGHT offset(6,34) A_SetPitch(pitch -0.5)
		RAIL A 1 BRIGHT offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		RAIL C 1 BRIGHT offset(9,34) A_SetPitch(pitch +0.5)
		RAIL A 1 BRIGHT offset(6,36) A_SetPitch(pitch +0.5)
		RAIL B 1 BRIGHT offset(3,38) A_SetPitch(pitch +0.5)
		RAIL C 1 BRIGHT offset(0,38) A_SetPitch(pitch +0.5)
		RAIL A 1 BRIGHT offset(-3,36) A_SetPitch(pitch +0.5)
		RAIL B 1 BRIGHT offset(-6,34) A_SetPitch(pitch +0.5)
		RAIL C 1 BRIGHT offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		SMGG A 0 A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint

	StopSprint:
		RAIL A 0 A_JumpIfInventory("PowerStrength", 1, 2)
		RAIL A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		RAIL A 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready3

	StopSprintTired:
		RAIL A 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		RAIL A 0 A_PlaySound("Tired", 2)
		Goto Ready3

	StartSprintNoAmmo:
		RAIR B 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        SHTN A 0 A_ZoomFactor(1.0)
		SHTN A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_SetCrosshair(0)
		SHTN A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		Goto SprintingNoAmmo

	SprintingNoAmmo:
		RAIR B 1 BRIGHT offset(-9,34) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(-6,36) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(-3,38) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(0,38) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(3,36) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(6,34) A_SetPitch(pitch -0.5)
		RAIR B 1 BRIGHT offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		RAIR B 1 BRIGHT offset(9,34) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(6,36) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(3,38) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(0,38) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(-3,36) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(-6,34) A_SetPitch(pitch +0.5)
		RAIR B 1 BRIGHT offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		SMGG A 0 A_JumpIfInventory("IsRunning", 1, "SprintingNoAmmo")
		Goto StopSprintNoAmmo

	StopSprintNoAmmo:
		RAIR B 0 A_JumpIfInventory("PowerStrength", 1, 2)
		RAIL A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTiredNoAmmo")
		RAIR B 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto ReadyNoAmmo

	StopSprintTiredNoAmmo:
		RAIR B 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		RAIL A 0 A_PlaySound("Tired", 2)
		Goto ReadyNoAmmo

	StartSprintUnloaded:
		RAIR L 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        SHTN A 0 A_ZoomFactor(1.0)
		SHTN A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_SetCrosshair(0)
		SHTN A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		Goto SprintingUnloaded

	SprintingUnloaded:
		RAIR L 1 BRIGHT offset(-9,34) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(-6,36) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(-3,38) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(0,38) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(3,36) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(6,34) A_SetPitch(pitch -0.5)
		RAIR L 1 BRIGHT offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		RAIR L 1 BRIGHT offset(9,34) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(6,36) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(3,38) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(0,38) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(-3,36) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(-6,34) A_SetPitch(pitch +0.5)
		RAIR L 1 BRIGHT offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		SMGG A 0 A_JumpIfInventory("IsRunning", 1, "SprintingUnloaded")
		Goto StopSprintUnloaded

	StopSprintUnloaded:
		RAIR L 0 A_JumpIfInventory("PowerStrength", 1, 2)
		RAIL A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTiredUnloaded")
		RAIR L 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto ReadyUnloaded

	StopSprintTiredUnloaded:
		RAIR L 1 BRIGHT ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		RAIL A 0 A_PlaySound("Tired", 2)
		Goto ReadyUnloaded

	GoTaunt:
		RAIL A 0
		RAIL A 0 A_Light0
		RAIL A 0 A_Takeinventory("Zoomed",1)
		RAIL A 0 A_Takeinventory("PowerLightAmp", 1)
        RAIL A 0 A_ZoomFactor(1.0)
		RAIL A 0 A_SetCrosshair(0)
		Goto Taunt
	}
}

ACTOR RailgunProjectile
{
	Radius 2
	Height 2
	Speed 120
	Damage (random(400, 400))
    DamageType Railgun
	Decal "SmallerScorch"
	Projectile
	+RANDOMIZE
	+MISSILE
	+THRUSPECIES
	+FORCERADIUSDMG
	+BounceOnWalls
	+BounceOnFloors
	+BounceOnCeilings
	Species "Marines"
	Scale 1.0
	renderstyle ADD
	alpha 0.90
	Scale 0.10
	DeathSound "weapons/plasmax"
    SeeSound "None"
	Obituary "$OB_MPPLASMARIFLE"
	BounceFactor 1.0
	BounceCount 2
	States
	{
	Spawn:
		RAIL A 0
		RAIL A 0 A_FaceTarget
		RAIL A 0 A_SpawnItem("WhiteShockwave")
		TNT1 C 1 BRIGHT A_SpawnItem("WhiteShockwave")

	Spawn1:
        TNT1 C 1 BRIGHT A_SpawnItem("WhiteShockwave")
		RAIL A 0 A_SpawnItem("WhiteShockwave")
		RAIL A 0 A_CheckFloor("Death")
		RAIL A 0 A_CustomMissile ("OldschoolRocketSmokeTrail2", 2, 0, random (160, 210), 2, random (-30, 30))
		Loop

	Death:
	Melee:
	Xdeath:
		TNT1 AAAA 0 A_SpawnItemEx("BluePlasmaParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
		TNT1 AA 0 A_SpawnItem("WhiteShockwave")
		RAIL A 0 A_Explode(120,5, 1)
        TNT1 AAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
        TNT1 AAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAAAAAA 0 A_CustomMissile ("ExplosionParticleVeryFast", 0, 0, random (0, 360), 2, random (0, 360))
        EXPL AAAAA 0 A_CustomMissile ("ExplosionSmokeFast22", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAA 0 A_CustomMissile ("FireworkSFXType2", 2, 0, random (0, 360), 2, random (10, 80))
		RAIL A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("DetectCeilCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 ABE 0 BRIGHT A_SpawnItem("BlueFlare" ,0)
		Stop
		Stop
	}
}

actor RailgunTracerTrail
{
    Scale 0.2
    RenderStyle Add
    Alpha 0.9
    +NOINTERACTION
    +CLIENTSIDEONLY
	+FORCEXYBILLBOARD
    States
    {
    Spawn:
        PBAL A 2 BRIGHT
        stop
    }
}

Actor RailgunPenetrationParticle
{
+THRUACTORS
+CLIENTSIDEONLY
+MISSILE
+NOGRAVITY
States
	{
		Spawn:
			TNT1 A 15
			TNT1 AAAA 0 A_CustomMissile ("OldschoolRocketSmokeTrailDarker", 2, 0, random (160, 210), 2, random (-30, 30))
			Stop
	}
}

Actor RailgunTrailEffectMissile: FastProjectile
{
	damage (random(0, 0))
	Decal "Scorch"
	DamageType Railgun
	+NODAMAGETHRUST
	Radius 1
	Height 1
	Scale 0.2
	Speed 999
	-SKYEXPLODE
	+ripper
	MissileType "RailgunTrailEffect"
	States
	{
		Spawn:
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItem("RailgunTrailEffect")
		Stop

		Death:
		TNT1 A 1
		RAIL A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, 0)
		RAIL A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 AA 0 A_CustomMissile ("SparkXNoModel", 2, 0, random (0, 360), 2, random (0, 360))
		RAIL A 0 A_SpawnItem("RailgunFlameTrails")

		EXPL A 0 Radius_Quake (1, 7, 0, 1, 0)
		RAIL A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 AAA 0 A_CustomMissile ("BDExplosionparticles", 0, 0, random (0, 360), 2, random (40, 90))
		TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (40, 90))
		TNT1 AA 0 A_CustomMissile ("BDExplosionparticles3", 10, 0, random (0, 360), 2, random (40, 90))
		TNT1 AAA 0 A_CustomMissile ("ExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
		RAIL A 0 A_SpawnItemEx ("RocketExplosion",0,0,13,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 2
		RAIL A 0 A_SpawnItemEx ("LiquidExplosionEffectSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_PlaySound("FAREXPL", 3)
		TNT1 A 15
		RAIL A 0 A_PlaySound("distantexp", 5)
		Stop
	}
}

Actor RailgunTrailEffect
{
+THRUACTORS
+CLIENTSIDEONLY
+MISSILE
+NOGRAVITY
States
	{
	Spawn:
		RAIL A 0
		RAIL A 0 A_SpawnItem("RailgunFlameTrailsBlue")
		TNT1 A 12
		TNT1 AAAA 0 A_CustomMissile ("OldschoolRocketSmokeTrailDarker", 2, 0, random (160, 210), 2, random (-30, 30))
		Stop
	}
}

Actor RailgunPenetrator: MarineTracer
{
	damage (random(50, 60))
	Decal "Scorch"
	DamageType Railgun
	Radius 4
	Height 4
	Scale 0.2
	+MISSILE
	+RIPPER
	Speed 80
	-SKYEXPLODE
	MissileType "RailgunPenetrationParticle"
	States
	{
	Spawn:
		RAIL A 0
		RAIL A 0 A_CustomMissile("SpawnBulletDecalBackwards", 0, 0, 0)
		TNT1 A 10
		Stop

	Death:
	XDeath:
		RAIL A 0
		TNT1 A 1
		RAIL A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 AAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAAAAAA 0 A_CustomMissile ("ExplosionParticleVeryFast", 0, 0, random (0, 360), 2, random (0, 360))
		EXPL AAAAA 0 A_CustomMissile ("ExplosionSmokeFast22", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 0 A_Explode(50, 100)
		RAIL A 0 A_SpawnItemEx ("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_SpawnItemEx ("DetectCeilCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		RAIL A 0 A_CustomMissile ("BluePlasmaFire", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 ABCDE 2 BRIGHT A_SpawnItem("BlueFlare" ,0)
		TNT2 AAAAAAAAA 9 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		Stop
	}
}

ACTOR RailgunAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 50
   Ammo.BackpackAmount 0
   Inventory.Icon "SRCGA0"
   Ammo.BackpackMaxAmount 50
}
