Actor StartAmmoRG : Inventory
{
Inventory.MaxAmount 1
}

// --------------------------------------------------------------------------
//
//	RailGun
//
// --------------------------------------------------------------------------

ACTOR U_Railgun : Baseweapon replaces Railgun
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 8
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "RailCore"
	Weapon.AmmoType2 "RailAmmo"
	Weapon.SelectionOrder 6000
scale 0.85
	-WEAPON.CHEATNOTWEAPON
	Inventory.PickupSound "PLSDRAW"
	Inventory.PickupMessage "You got the RailGun!"
	Obituary "%o was shot down by %k's RailGun."
	Tag "RailGun"
//damagetype "Railgun"
	States
	{
	Spawn:
		RGNW ABCBACBCACBACABACB 1
		Loop

	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1001,5)==0,"PuristGun")
TNT1 A 0 A_JumpIfInventory("StartAmmoRG",1,"Selected")
TNT1 A 0 A_GiveInventory("RailAmmo",8)
Selected:
TNT1 A 0 A_GiveInventory("StartAmmoRG",1)

		TNT1 A 0 A_Giveinventory("RailGunSelected",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("TossGrenade",1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		TNT1 A 0 A_Takeinventory("Taunting",1)
		//TNT1 A 0 A_Takeinventory("IdleCounter",200)
		TNT1 A 4
		TNT1 A 0 A_Raise
		Wait






	CheckSprint:
		RGNF A 1 A_WeaponReady(WRF_NOFIRE)
		UNHG A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		UNHG A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		RGNF A 1 A_WeaponReady(WRF_NOFIRE)
		UNHG A 0 A_Takeinventory("Zoomed",1)
		UNHG A 0 A_Takeinventory("ADSmode",1)
		UNHG A 0 A_ZoomFactor(1.0)
		UNHG A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		UNHG A 0 offset(-9,32) 
		UNHG A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		UNHG A 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		UNHG A 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
		UNHG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 12)
		UNHG A 0 offset(-9,32)
		RGNF A 1 offset(-9,34) A_SetPitch(pitch -0.25) //-0.5
		RGNF A 1 offset(-6,36) A_SetPitch(pitch -0.25)
		RGNF A 1 offset(-3,38) A_SetPitch(pitch -0.25)
		RGNF A 1 offset(0,38) A_SetPitch(pitch -0.25)
		RGNF A 1 offset(3,36) A_SetPitch(pitch -0.25)
		RGNF A 1 offset(6,34) A_SetPitch(pitch -0.25)
		RGNF A 1 offset(9,32) A_SetPitch(pitch -0.25)
		UNHG A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		UNHG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        UNHG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        UNHG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		UNHG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 12)
		UNHG A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		RGNF A 1 offset(9,34) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(6,36) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(3,38) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(0,38) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		RGNF A 1 offset(-9,32) A_SetPitch(pitch +0.5)
		UNHG A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		UNHG A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		RGNF A 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		UNHG A 0 A_PlaySound("Tired", 2)
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		RGNF A 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		RGNF A 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		RGNF A 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		RGNF A 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		RGNF A 5 A_WeaponReady
		Goto Ready2
	StopSprint:
		RGNF A 1
		UNHG A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready2












	Deselect:
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_Takeinventory("PowerInfiniteAmmo",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2)
		TNT1 A 0 A_Jump(256,4)
		RGNZ CBA 1
		TNT1 A 0 A_TakeInventory("Zoomed",1)
		TNT1 A 0 A_SetCrosshair(0)
		RGNS ABCDEF 1
		TNT1 A 0 A_Takeinventory("RailGunSelected",1)
		TNT1 A 0 A_Lower
		Wait

	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("PLSDRAW")
	Ready1:
		RGNS FEDCBA 1
		RGNF A 4
	Ready2:
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,2)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto ReadyEmpty
		TNT1 A 0 A_PlaySound("RailIdle",5,1,1)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,"PowerReady")
	Ready3:
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //R
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"PowerToggle")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"PowerToggle")
		RGNI ABCD 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //R
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"PowerToggle")
//		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"PowerToggle")
		RGNI ACBD 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //R
		
TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")		
TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"PowerToggle")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"PowerToggle")
	//	TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		RGNI BADC 1 A_WeaponReady
		TNT1 A 0 A_Jump(243,"Ready3")//5% chanse that bots will change into/from charged mode
		TNT1 A 0 A_JumpIfInventory("PlayerIsABot",1,"PowerToggle")
		Loop

	PowerReady:
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,2)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",2,1)
		Goto ReadyEmpty
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //R
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")		
TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"PowerToggle")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"PowerToggle")
		RGNF M 1 A_WeaponReady
		TNT1 A 0 A_Jump(64,1,3,6,10)
		Loop
		RGNI HE 1 A_WeaponReady
		Loop
		RGNI FGH 1 A_WeaponReady
		Loop
		RGNI EGFH 1 A_WeaponReady
		Loop
		RGNI GEF 1 A_WeaponReady
		Loop

	ReadyEmpty:
		TNT1 A 0 A_StopSound(5)
	ReadyEmpty2:
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //R
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")
		RGNF L 4 A_WeaponReady(WRF_NOSECONDARY)
		Loop
		
	ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"NightvisionToggle")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"NightvisionToggle")
TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"PowerToggleZoom")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"ZoomOut")
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1029)==1,2)
		RGNZ D 1 BRIGHT A_WeaponReady
		Loop
		TNT1 A 0 A_WeaponReady(WRF_NOSECONDARY)
		RGNZ D 1 BRIGHT A_JumpIfInventory("FiredPrimary",1,"Fire")
		TNT1 A 0 A_JumpIfInventory("FiredSecondary",1,"ReadyZoom")
		Goto ZoomOut

// --------------------------------------------------------------------------
//
//	Fire
//
// --------------------------------------------------------------------------

	Fire:
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,"PowerFire")
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto Reload
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_PlaySound("RailCharge",5)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"FireZoom")
		RGNF BCDEF 1
		TNT1 A 0 A_PlaySound("plsm4",5)
		TNT1 A 0 A_PlaySound("RailFire",1)
		TNT1 A 0 A_PlaySound("RAILF1",6,0.2)
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_SetPitch(-0.5 + pitch)
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1020,1)==0,3)
		TNT1 A 0 A_RailAttack(1,0,0,none,none,RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0,0,0,0,0,"PlasmaRailBall")
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_RailAttack(1,0,0,"00 99 ff","66 cc ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0)
		TNT1 A 0 A_SetPitch(0.5 + pitch)
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff2")
		TNT1 A 0 A_ZoomFactor(0.9)
		TNT1 A 0 A_SetPitch(-6.0 + pitch)
		RGNF G 1 BRIGHT A_AlertMonsters
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("RailAmmo",1)
		//TNT1 A 0 A_PlaySound("RAILR1",5)
		RGNF HIJKL 1 A_SetPitch(1.2 + pitch)
		RGNF LLLL 3 A_FireCustomMissile("SmokeSpawner",0,0,0,2)
		TNT1 A 0 A_StopSound(6)
		RGNF L 3 A_FireCustomMissile("SmokeSpawner",0,0,0,2)
		TNT1 A 0 A_ReFire
		Goto Ready2
		
	FireZoom:
		RGNZ D 5 BRIGHT
		TNT1 A 0 A_PlaySound("plsm4",5)
		TNT1 A 0 A_PlaySound("RailFire",1)
		TNT1 A 0 A_PlaySound("RAILF1",6,0.2)
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff1")
		TNT1 A 0 A_SetPitch(-0.5 + pitch)
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1020,1)==0,3)
		TNT1 A 0 A_RailAttack(1,12,0,none,none,RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0,0,0,0,0,"PlasmaRailBall")
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_RailAttack(1,12,0,"00 99 ff","66 cc ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0)
		TNT1 A 0 A_SetPitch(0.5 + pitch)
		TNT1 A 0 A_FireBullets(0,0,-1,28,"PlasmaRailPuff2")
		TNT1 A 0 A_ZoomFactor(1.8)
		TNT1 A 0 A_SetPitch(-4.0 + pitch)
		RGNZ D 1 BRIGHT A_AlertMonsters
		TNT1 A 0 A_ZoomFactor(2.0)
		TNT1 A 0 A_Takeinventory("RailAmmo",1)
		RGNZ DDDDD 1 BRIGHT A_SetPitch(0.8 + pitch)
		RGNZ DDDD 3 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,2)
		TNT1 A 0 A_StopSound(6)
		RGNZ D 3 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,2)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,2)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto ZoomOut
		TNT1 A 0 A_ReFire
		Goto ReadyZoom

	PowerFire:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",2,1)
		Goto Reload
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_PlaySound("plsm4",5)
		TNT1 A 0 A_PlaySound("RailFire",1)
		TNT1 A 0 A_PlaySound("RAILF1",6,0.8)
		TNT1 A 0 A_FireCustomMissile("RailgunProjectile",0,1,0,0)
		TNT1 A 0 A_RailAttack(500,0,0,none,none,0,1,"RailgunPuff2")
		TNT1 A 0 A_SetPitch(-0.5 + pitch)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ZoomedPowerFire")
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1020,1)==0,3)
		TNT1 A 0 A_RailAttack(1,0,0,none,none,RGF_CENTERZ,0,"none",0,0,0,0,2,0,"PlasmaRailBall2")
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_RailAttack(1,0,0,"00 99 ff","66 cc ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0)
		TNT1 A 0 A_RailAttack(1,0,0,"66 cc ff","00 99 ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0,0,45,0,0.8)
		TNT1 A 0 A_SetPitch(0.5 + pitch)
		TNT1 AAAAA 0 A_FireBullets (0,0,1,5,"PlasmaRailPuff1")
		TNT1 AA 0 A_FireBullets (0,0,1,5,"PlasmaRailPuff2")
		TNT1 A 0 A_SetPitch(-8.0 + pitch)
		TNT1 A 0 A_ZoomFactor(0.7)
		RGNF N 1 A_AlertMonsters
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetPitch(1.0 + pitch)
		TNT1 A 0 A_Takeinventory("RailAmmo",2)
		RGNF OPQRMMMMMM 1 A_SetPitch(0.7 + pitch)
		RGNF MMM 1 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		RGNF MMMMM 2 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		RGNF MMMMMMM 3 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,2)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",2,1)
		Goto ReadyEmpty
		TNT1 A 0 A_PlaySound("RailCharge",5,0.7)
		RGNF NOPQR 3
		TNT1 A 0 A_Refire
		Goto Ready2
		
	ZoomedPowerFire:
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1020,1)==0,3)
		TNT1 A 0 A_RailAttack(1,12,0,none,none,RGF_CENTERZ,0,"none",0,0,0,0,2,0,"PlasmaRailBall2")
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_RailAttack(1,12,0,"00 99 ff","66 cc ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0)
		TNT1 A 0 A_RailAttack(1,12,0,"66 cc ff","00 99 ff",RGF_FULLBRIGHT | RGF_NOPIERCING | RGF_CENTERZ,0,"none",0,0,0,45,0,0.8)
		TNT1 A 0 A_SetPitch(0.5 + pitch)
		TNT1 AAAAA 0 A_FireBullets (0,0,1,0,"PlasmaRailPuff1")
		TNT1 AA 0 A_FireBullets (0,0,1,0,"PlasmaRailPuff2")
		TNT1 A 0 A_SetPitch(-8.0 + pitch)
		TNT1 A 0 A_ZoomFactor(1.4)
		RGNZ D 1 BRIGHT A_AlertMonsters
		TNT1 A 0 A_ZoomFactor(2.0)
		TNT1 A 0 A_SetPitch(1.0 + pitch)
		TNT1 A 0 A_Takeinventory("RailAmmo",2)
		RGNZ DDDDDDDDDD 1 BRIGHT A_SetPitch(0.7 + pitch)
		RGNZ DDD 1 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		RGNZ DDDDD 2 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		RGNZ DDDDDDD 3 BRIGHT A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_StopSound(3)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,2)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",2,1)
		Goto ZoomOut
		TNT1 A 0 A_PlaySound("RailCharge",5,0.7)
		RGNZ DDDDD 3 BRIGHT
		TNT1 A 0 A_Refire
		Goto Ready2		
				
	AltFire:
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ZoomOut")
		TNT1 A 0 A_GiveInventory("Zoomed",1)
		TNT1 A 0 A_Giveinventory("ADSmode",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		RGNZ ABC 1
		TNT1 A 0 A_JumpIfInventory("RailgunNightvisionOn",1,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_Giveinventory("RailgunInfrared",1)
		TNT1 A 0 A_SetCrosshair(41)
		RGNZ D 2 BRIGHT A_ZoomFactor(2.0,ZOOM_INSTANT)
		Goto Ready2
		
	ZoomOut:
		TNT1 A 0 A_TakeInventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		RGNZ D 1 BRIGHT A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Takeinventory("PowerInfiniteAmmo",1)
		RGNZ CBA 1
		Goto Ready2

// --------------------------------------------------------------------------
//
//	Reload
//
// --------------------------------------------------------------------------

	Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("RailAmmo",8,"Ready2")
		TNT1 A 0 A_JumpIfInventory("RailCore",1,1)
		Goto Ready2


TNT1 A 0 A_JumpIfInventory("NoMagReload",1,"NoMagReloading")
TNT1 A 0 A_Takeinventory("RailAmmo")
NoMagReloading:


		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"TurboReloadLoop")
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2)
		TNT1 A 0 A_Jump(256,8)
		TNT1 A 0 A_TakeInventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		RGNZ D 1 BRIGHT A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_Takeinventory("PowerInfiniteAmmo",1)
		RGNZ CBA 1
		RGNF L 1
		RGNR ABCDEF 1
		TNT1 A 0 A_PlaySound("PLREADY",1)
		RGNR G 3
		TNT1 A 0 A_FireCustomMissile("EmptyCore",-210,0,20,-20)
		RGNR G 13
		RGNR HI 1 A_SetPitch(-0.2 + pitch)
		RGNR IH 1 A_SetPitch(+0.2 + pitch)
		RGNR G 10
		RGNR FEDCBA 1
		TNT1 A 0 A_StopSound(1)

	ReloadLoop:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",8,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("RailCore",1,1)
		Goto ReloadDone
		TNT1 A 0 A_Giveinventory("RailAmmo",1)
		TNT1 A 0 A_Takeinventory("RailCore",1)
		Goto ReloadLoop

	ReloadDone:
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,1)
		Goto Ready2
		TNT1 A 0 A_PlaySound("RailCharge",5,0.7)
		RGNF BCDEF 3
		Goto Ready2

	TurboReloadLoop:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",8,5)
		TNT1 A 0 A_JumpIfInventory("RailCore",1,2)
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_Giveinventory("RailAmmo",1)
		TNT1 A 0 A_Takeinventory("RailCore",1)
		Goto TurboReloadLoop
		TNT1 A 0 A_Refire
		Goto Ready2



	Unload:
		TNT1 A 0 A_Takeinventory("Unloading",1)
		//TNT1 A 0 A_Giveinventory("Unloaded",1)
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2)
		TNT1 A 0 A_Jump(256,8)
		TNT1 A 0 A_TakeInventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		RGNZ D 1 BRIGHT A_ZoomFactor(1.0,ZOOM_INSTANT)
		TNT1 A 0 A_Takeinventory("PowerInfiniteAmmo",1)
		RGNZ CBA 1
		RGNF L 1
		RGNR ABCDEF 1
		TNT1 A 0 A_PlaySound("PLREADY",1)
		RGNR G 3

		RGNR G 13
		RGNR HI 1 A_SetPitch(-0.2 + pitch)
		RGNR IH 1 A_SetPitch(+0.2 + pitch)
		RGNR G 10
		RGNR FEDCBA 1
		TNT1 A 0 A_StopSound(1)

	unloadLoop:
		TNT1 A 0 A_takeinventory("RailAmmo",1)
		TNT1 A 0 A_giveinventory("RailCore",1)
TNT1 A 0 A_JumpIfInventory("RailAmmo",1,"unloadloop")		

	unloadDone:
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,1)
		Goto Ready2
		TNT1 A 0 A_PlaySound("RailCharge",5,0.7)
		RGNF BCDEF 3
		Goto Ready2

// --------------------------------------------------------------------------
//
//	Misc.
//
// --------------------------------------------------------------------------

	NightvisionToggle:
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
TNT1 A 0 A_Takeinventory("StartDualWield",1)
		//TNT1 A 0 A_PlayWeaponSound("BEP")
		TNT1 A 0 A_PlayWeaponSound("RailClick")
		TNT1 A 0 A_JumpIfInventory("RailgunNightvisionOn",1,3)
		TNT1 A 0 A_Giveinventory("RailgunNightvisionOn",1)
		TNT1 A 0 A_Giveinventory("RailgunInfrared",1)
		Goto Ready2
		TNT1 A 0 A_Takeinventory("RailgunNightvisionOn",1)
		TNT1 A 0 A_Takeinventory("PowerInfiniteAmmo",1)
		Goto Ready2

	PowerToggle:
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_PlayWeaponSound("BEP")
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,8)
		RGNF L 2 A_Giveinventory("RailgunPowerMode",1)
		TNT1 A 0 A_PlaySound("RailCharge",5,0.7)
		RGNF BCDEF 3
		Goto Ready2
		RGNF LL 5
		RGNF A 4 A_Takeinventory("RailgunPowerMode",1)
		Goto Ready2


PowerToggleZoom:
		TNT1 A 0 A_StopSound(5)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
TNT1 A 0 A_Takeinventory("StartDualWield",1)
	//	TNT1 A 0 A_PlayWeaponSound("BEP")
		TNT1 A 0 A_JumpIfInventory("RailgunPowerMode",1,"next")
		RGNZ D 2 A_Giveinventory("RailgunPowerMode",1)
		RGNZ D 0 A_PlaySound("RailCharge",5,0.7)
		RGNZ DDDD 3 //BRIGHT
//TNT1 A 0 A_GunFlash
		RGNZ D 0 A_JumpIfInventory("TurboReload",1,2)
		RGNZ D 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto ReadyEmpty
		RGNZ D 0 A_PlaySound("RailIdle",5,1,1)
		Goto ReadyZoom
		Next:	
	RGNZ D 3 A_PlayWeaponSound("BEP")	
//TNT1 A 0 A_GunFlash
		RGNZ D 0 A_JumpIfInventory("TurboReload",1,2)
		RGNZ D 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto ReadyEmpty
		RGNZ D 0 A_PlaySound("RailIdle",5,1,1)
//		TNT1 AA 5
		RGNZ D 4 A_Takeinventory("RailgunPowerMode",1)
		Goto ReadyZoom


	PuristGun:
		TNT1 A 0 A_TakeInventory("Railgun",1)
		TNT1 A 1
		Goto Ready

// --------------------------------------------------------------------------
//
//	End stuff
//
// --------------------------------------------------------------------------

	TauntFlash:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto TauntFlash2
		RGNK ABCD 1
		RGNK EFGHEGFEHFHGEFHGFEGHEGHFGEFHFGEHGFH 1						
		RGNK DCBA 1
		RGNI D 1
		Stop
		
	TauntFlash2:
		RGNK IJKL 1
		RGNK M 35
		RGNK LKJI 1
		RGNF L 1
		Stop

	KickFlash:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto KickFlash2
		RGNK ABCD 1
		RGNK EFGHEFGH 1
		RGNK DCBA 1
		RGNI D 1
		Stop

	KickFlash2:
		RGNK IJKL 1
		RGNK M 8
		RGNK LKJI 1
		RGNF L 1
		Stop

	AirKickFlash:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto AirKickFlash2
		RGNK ABCD 1
		RGNK EFGHEFGHEF 1
		RGNK DCBA 1
		RGNI D 1
		Stop

	AirKickFlash2:
		RGNK IJKL 1
		RGNK M 10
		RGNK LKJI 1
		RGNF L 1
		Stop
		
	SlideKickStartFlash:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto SlideKickStartFlash2
		RGNK ABCD 1
		RGNK EFGHEGFEHFHGEFHGF 1
		Stop

	SlideKickStartFlash2:
		RGNK IJKL 1
		RGNK M 17
		Stop

	SlideKickEndFlash:
		TNT1 A 0 A_JumpIfInventory("RailAmmo",1,1)
		Goto SlideKickEndFlash2
		RGNK EGDCBA 2
		RGNI D 1
		Stop

	SlideKickEndFlash2:
		RGNK MLKJI 2
		RGNF L 1
		Stop

	GrenadeFlash:
		RGNS ABCDEF 1
		Stop
	}
}

ACTOR RailgunNightvisionOn : Inventory { Inventory.MaxAmount 1 }
ACTOR RailgunPowerMode : Inventory { inventory.maxamount 1 }

ACTOR RailAmmo : Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 8
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 8
   	Inventory.Icon "RGNWA0"
}

Actor PlasmaRailPuff1
{
	Renderstyle Translucent
	Alpha 0.4
	Scale 1.5
	Radius 0
	Height 0
	Gravity 0.01
	DamageType Railgun //Blast
	//Decal "Scorch"
	+NOBLOCKMAP
	+NOGRAVITY
	+NOEXTREMEDEATH
	+FORCEXYBILLBOARD
	+DONTSPLASH
	+PUFFONACTORS
	-EXPLODEONWATER
	States
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 AAAAAAAAAAA 0 A_CustomMissile("BluePlasmaParticle",0,0,random (0,360),2,random (0,360))
		TNT1 A 1 A_Explode(6,90,0)
		TNT1 A 2
		TNT1 AAAAAA 7 A_CustomMissile("PlasmaSmoke",1,0,random (0,360),2,random (0,160))
		stop
	}
}

Actor PlasmaRailPuff2
{
	Renderstyle Translucent
	Alpha 0.4
	Scale 1.5
	Radius 0
	Height 0
	Gravity 0.01
	DamageType Plasma
	Decal "Scorch"
	+NOBLOCKMAP
	+NOGRAVITY
	+NOEXTREMEDEATH
	+FORCEXYBILLBOARD
	+DONTSPLASH
	+PUFFONACTORS
	+EXPLODEONWATER
	states
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 A 0 A_SpawnItemEx("DetectFloorCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx("DetectCeilCraterSmall",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_CustomMissile("BluePlasmaFire",0,0,random (0,360),2,random (0,360))
		TNT1 AAAAAAAAAAA 0 A_CustomMissile("BluePlasmaParticle",0,0,random (0,360),2,random (0,360))
		TNT1 A 0 A_CustomMissile("PlamaRailBoom",0,0,random (0,360),2,random (0,360))
		TNT1 A 1 A_Explode(6,90,0)
		TNT1 A 4
		TNT1 AAAAAAAAAAAA 9 A_CustomMissile("PlasmaSmoke",1,0,random (0,360),2,random (0,160))
		stop
	}
}

Actor PlasmaRailBall
{
	Renderstyle Add
	Radius 1
	Height 1
	Mass 1
	Damage 0
	Alpha 0.8
	Scale 0.05
	+NOBLOCKMAP
	+MOVEWITHSECTOR
	+NOGRAVITY
	+DROPOFF
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOTDMATCH
	+GHOST
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItem("PlamaRailFlare")
		FIR5 ABC 1 Bright A_FadeOut(0.01)
		FIR5 DDEE 1 Bright A_FadeOut(0.04)
		FIR5 FFGGHHIIJJKKLLMMNNOOPPPPPPPPPPPPPPPP 1 Bright A_FadeOut(0.05)
		TNT1 A 1
		stop
	}
}

Actor PlasmaRailBall2 : PlasmaRailBall
{
	Alpha 1.0
	Scale 0.08
	states
	{
	Spawn:
		TNT1 A 0
		
		TNT1 A 0 A_Jump(128,2)
		TNT1 A 0 A_SetScale(-1 * scaleX,scaleY)
		TNT1 A 0 A_Jump(128,2)
		TNT1 A 0 A_SetScale(scaleX,-1 * scaleY)
		
		TNT1 A 0 A_SpawnItemEx("PlamaRailFlare2",0,frandom(-2,2),frandom(-2,2),0,0,0,0,SXF_NOCHECKPOSITION,0)
		FIR5 ABC 1 Bright A_FadeOut(0.01)
		FIR5 DDEE 1 Bright A_FadeOut(0.04)
		FIR5 FFGGHHIIJJKKLLMMNNOOPPPPPPPPPPPPPPPP 1 Bright A_FadeOut(0.05)
		TNT1 A 1
		stop
	}
}

Actor PlamaRailFlare : PlasmaRailBall
{
	alpha 0.7
	scale 0.03
	+NOINTERACTION
	+NOCLIP
	states
	{
	Spawn:
		TNT1 A 0
		LENB AAAAAAAAAAAA 1 bright A_FadeOut(0.05)
		LENB AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 bright A_FadeOut(0.007)
	Death:
		TNT1 A 0
		stop
	}
}

Actor PlamaRailFlare2 : PlamaRailFlare
{
	alpha 0.8
	scale 0.05
}

Actor PlamaRailBoom : PlamaRailFlare
{
	alpha 0.3
	scale 2.0
	translation "112:127=192:207"
	states
	{
	Spawn:
		TNT1 A 1
		SHOK CEGIKMOQ 1 bright A_FadeOut(0.04)
	Death:
		TNT1 A 0
		stop
	}
}

ACTOR RailgunInfrared : PowerupGiver
{
	-COUNTITEM
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	Inventory.MaxAmount 0
	Powerup.Type PowerInfiniteAmmo
	Powerup.Duration -999
	Powerup.Colormap 0.0,0.0,0.05,0.0,1.0,0.5
	States
	{
	Spawn:
		TNT1 A -1
		Loop
	}
}