ACTOR BeamRifle : Weapon replaces Shotgun
{
	//$Category Alphatius Weapons
	Radius 32
	Height 32
	Tag "(4) Beam Rifle"
	Decal "BeamScorch"
	//For some reason this is needed :c
	//Or is it?
	//Obituary "%k > \cnBeam Rifle\c- > %o"
    Weapon.BobRangeX 0.7
    Weapon.BobRangeY 1.0
    Weapon.BobSpeed 1.5
    Weapon.BobStyle "Alpha"  	
	Weapon.AmmoType1 "BeamEnergy"
	Weapon.AmmoType2 "BeamEnergy"
	Weapon.AmmoUse1 1
	Weapon.AmmoUse2 2
	+WEAPON.NOAUTOAIM
	+BLOODLESSIMPACT
	+SERVERNETID
	Weapon.SlotNumber 4
	Weapon.SelectionOrder 500
	Weapon.Kickback 200
	Inventory.Icon "BRFPA0"
	DamageType "BeamRifle"
	Inventory.RespawnTics 280 //8 seconds
	States
	{
	Spawn:
		BRFP A 1 bright A_SetAngle(angle + 1.0)
		Loop
	Ready:
		//TNT1 A 0 A_PlaySound("BeamRifle/FireStop", CHAN_WEAPON, 1.0, false) //These are here in case ammo runs out or the player dies while firing
		//TNT1 A 0 A_StopSound(CHAN_WEAPON)  									//These are here in case ammo runs out or the player dies while firing
		BRFR A 1 A_WeaponReady
		Loop
	Deselect:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_PlaySound("BeamRifle/FireStop", CHAN_WEAPON, 1.0, false) //These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_StopSound(CHAN_WEAPON)									//These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_PlaySound("BeamRifle/FireStop", CHAN_7, 1.0, false) //These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_StopSound(CHAN_7)									//These are here in case ammo runs out or the player dies while firing
		BRFR A 1 A_Lower
		TNT1 AA 0 A_Lower
		Loop
	Select:
		BRFR A 1 A_Raise
		TNT1 AA 0 A_Raise
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory("BeamSiphonMod", 1, "FireSiphon")
		Goto FireNormal
	FireNormal:
		TNT1 A 0 A_SpawnItemEX("LightBlueLightShoot")
		TNT1 A 0 A_PlaySound("BeamRifle/Fire", CHAN_WEAPON, 1.0, true)
		TNT1 A 0 A_PlaySound("BeamRifle/FireFar", CHAN_7, 1.0, true)
		TNT1 A 0 A_Refire("HoldNormal")
		Goto Ready
	HoldNormal:
		TNT1 A 0 ACS_NamedExecuteAlways("OnWeaponFired", 0)
		TNT1 A 0 A_Jump(256, "HoldNormalLeft", "HoldNormalUp", "HoldNormalRight", "HoldNormalDown")
	HoldNormalLeft:
		BRFR A 1 offset(-8, 32) A_RailAttack(4, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldNormal")
		Goto FireStop
	HoldNormalUp:
		BRFR A 1 offset(0, 24) A_RailAttack(4, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldNormal")
		Goto FireStop
	HoldNormalRight:
		BRFR A 1 offset(8, 32) A_RailAttack(4, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldNormal")
		Goto FireStop
	HoldNormalDown:
		BRFR A 1 offset(0, 40) A_RailAttack(4, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldNormal")
		Goto FireStop
	FireSiphon:
		TNT1 A 0 A_SpawnItemEX("LightBlueLightShoot")
		TNT1 A 0 A_PlaySound("BeamRifle/Fire", CHAN_WEAPON, 1.0, true)
		TNT1 A 0 A_PlaySound("BeamRifle/FireFar", CHAN_7, 1.0, true)
		TNT1 A 0 A_Refire("HoldSiphon")
		Goto Ready
	HoldSiphon:
		TNT1 A 0 ACS_NamedExecuteAlways("OnWeaponFired", 0)
		TNT1 A 0 A_Jump(256, "HoldSiphonLeft", "HoldSiphonUp", "HoldSiphonRight", "HoldSiphonDown")
	HoldSiphonLeft:
		BRFR A 1 offset(-8, 32) A_RailAttack(3, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailSiphonHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldSiphon")
		Goto FireStop
	HoldSiphonUp:
		BRFR A 1 offset(0, 24) A_RailAttack(3, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailSiphonHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldSiphon")
		Goto FireStop
	HoldSiphonRight:
		BRFR A 1 offset(8, 32) A_RailAttack(3, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailSiphonHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldSiphon")
		Goto FireStop
	HoldSiphonDown:
		BRFR A 1 offset(0, 40) A_RailAttack(3, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailSiphonHit", 0, 0, 560.0, 1.0, 6.0, 0, "BeamRailPuff", -1.0)
		TNT1 A 0 A_ReFire("HoldSiphon")
		Goto FireStop
	FireStop:
		BRFF FG 1
		TNT1 A 0 A_PlaySound("BeamRifle/FireStop", CHAN_WEAPON, 1.0, false) //These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_StopSound(CHAN_WEAPON)									//These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_PlaySound("BeamRifle/FireStop", CHAN_7, 1.0, false) //These are here in case ammo runs out or the player dies while firing
		TNT1 A 0 A_StopSound(CHAN_7)	
		TNT1 A 0 ACS_NamedExecuteAlways("WeaponFinishFiring", 0)								//These are here in case ammo runs out or the player dies while firing
		BRFR A 6 A_WeaponReady
		Goto Ready
	AltFire:
		TNT1 A 0 A_JumpIfInventory("BeamChargeMod", 1, "AltFireRay")
		Goto AltFireNormal
	AltFireNormal:
		TNT1 A 0 ACS_NamedExecuteAlways("OnWeaponFired", 0)
		TNT1 A 0 A_SpawnItemEX("LightBlueLightShoot")
		TNT1 A 0 A_PlaySound("BeamRifle/AltFire", CHAN_WEAPON, 1.0, false)
		TNT1 A 0 A_PlaySound("BeamRifle/AltFireFar", CHAN_7, 1.0, false)
		BRFF C 1 A_RailAttack(13, 2.5, true, "none", "none", RGF_SILENT, 0, "BeamRailHit2", 0, 0, 16384.0, 1.0, 16.0, 0, "BeamRailPuff2", -1.0)
		BRFF DEFG 1
		TNT1 A 0 ACS_NamedExecuteAlways("WeaponFinishFiring", 0)
		Goto Ready
	AltFireRay:
		TNT1 A 0 A_JumpIfInventory("AltFireDeviceCD", 1, "AltFail")
		TNT1 A 0 A_JumpIfInventory("BeamAltCD", 1, "AltFail")
		TNT1 A 0 A_PlaySound("C14/AltCharge", CHAN_WEAPON, 1.0, true)
		TNT1 A 0 A_PlaySound("C14/AltChargeFar", CHAN_7, 1.0, true)
		Goto AltFireRayCharge
	AltFireRayCharge:
		BRFF AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_GiveInventory("BeamRayCharge", 1) //35
		TNT1 A 0 A_PlaySound("BeamRifle/AltFireRay", CHAN_WEAPON, 1.0, true)
		TNT1 A 0 A_PlaySound("BeamRifle/AltFireRayFar", CHAN_7, 1.0, true)
		TNT1 A 0 A_TakeInventory("BeamRayCharge", 999)
		Goto AltFireRayCont
	AltFireRayCont:
		TNT1 A 0 ACS_NamedExecuteAlways("OnWeaponFired", 0)
		BRFF C 1 A_RailAttack(5, 2.5, true, "none", "none", RGF_SILENT, 0, "ChargeRailHit", 0, 0, 640.0, 1.0, 8.0, 0, "ChargeRailPuff", -1.0)
		TNT1 A 0 A_JumpIfInventory("BeamEnergy", 2, "AltFireRayCont")
		TNT1 A 0 ACS_NamedExecuteAlways("OnWeaponAltFired", 0)
		Goto FireStop
	AltFail:
		TNT1 A 0 ACS_NamedExecuteAlways("AltFireFail")
		BRFR A 1 A_WeaponReady(WRF_NOSECONDARY)
		Goto Ready
  }
}
Actor BeamRayCharge : Ammo
{
	+SERVERNETID
	Inventory.MaxAmount 35
}
Actor BeamRailPuff
{
	Radius 2
	Height 2
	Scale 0.3
	Renderstyle Add
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NONETID
	+BRIGHT
	States
	{
	Spawn:
	    LSPK A 1 A_FadeOut(0.25)
		Loop
	}
}
Actor BeamRailPuff2 : BeamRailPuff
{
	States
	{
	Spawn:
		LSPK A 2
	    LSPK AAAAA 1 A_FadeOut(0.2)
		stop
	}
}
Actor BeamRailHit : BulletPuff
{
	+AlWAYSPUFF
	-ALLOWPARTICLES
	+DROPOFF
	+NOCLIP
	Alpha 1.0
	Vspeed 0
	Scale 0.15
	DamageType "BeamRifle"
	ProjectileKickback 100
	Obituary "%k > \cnBeam Rifle (Lightning Beam)\c- > %o"
	+BRIGHT
	States
	{
	Spawn:
		TNT1 AAAAAAAAAAAA 0 nodelay A_SpawnItemEx("BeamHitSparks", 0.0, 0.0, 0.0, frandom(-4.0, 4.0), frandom(-4.0, 4.0), frandom (-4.0, 4.0))
	    ZAP6 ABCDE 1 A_FadeOut(0.2)
		Stop
	XDeath:
	    ZAP6 ABCDE 1 A_FadeOut(0.2)
		Stop
	}
}
Actor BeamRailHit2 : BeamRailHit
{
	DamageType "BeamRifleAlt"
	Obituary "%k > \cnBeam Rifle (Focus Lens)\c- > %o"
	ProjectileKickback 200
	+BRIGHT
	States
	{
	Spawn:
		TNT1 AAAAAAAAAAAA 0 nodelay A_SpawnItemEx("BeamHitSparks", 0.0, 0.0, 0.0, frandom(-8.0, 8.0), frandom(-8.0, 8.0), frandom (-8.0, 8.0))
	    ZAP6 ABCDE 2 A_FadeOut(0.1)
		Stop
	XDeath:
	    ZAP6 ABCDE 2 A_FadeOut(0.1)
		Stop
	}
}
Actor BeamRailSiphonHit : BulletPuff
{
	+AlWAYSPUFF
	-ALLOWPARTICLES
	+DROPOFF
	+NOCLIP
	Alpha 1.0
	Vspeed 0
	Scale 0.15
	DamageType "BeamRifle"
	ProjectileKickback 100
	Obituary "%k > \cnBeam Rifle (Siphon Beam)\c- > %o"
	+BRIGHT
	States
	{
	Spawn:
		TNT1 AAAAAAAAAAAA 0 nodelay A_SpawnItemEx("BeamHitSparks", 0.0, 0.0, 0.0, frandom(-4.0, 4.0), frandom(-4.0, 4.0), frandom (-4.0, 4.0))
	    ZAP6 ABCDE 1 A_FadeOut(0.2)
		Stop
	XDeath:
		TNT1 A 0 A_GiveToTarget("BeamEnergy", 1) //Give the player energy on successful hits.
	    ZAP6 ABCDE 1 A_FadeOut(0.2)
		Stop
	}
}
Actor BeamHitSparks
{
	Radius 1
	Height 1
	RenderStyle ADD
	Scale 0.2
	Gravity 0.8
	Speed 16
	-SOLID
	+NOCLIP
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	+NONETID
	+BRIGHT
	States
	{
		Spawn:
		ZAP6 AABBCCDDEE 1 nodelay A_SetScale(scalex * 0.8, scaley * 0.8)
		Goto Death
	}
}
Actor BeamProjectile
{
	Projectile
	Radius 6
	Height 6
	Scale 0.5
	Speed 56
	Decal RailScorchLower
	Damage (8)
	Renderstyle Add
	Obituary "%k > \cvBeam Rifle (Plasma Beam)\c- > %o"
	+BRIGHT
	//MissileType "PhotonTrail"
	//MissileHeight 8
	States
	{
	Spawn:
		SZAP ABCDEABCDE 1
		Goto FadeDeath
	FadeDeath:
		TNT1 A 1
		stop
	Death:
		//TNT1 A 0 A_FaceTarget
		TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("BeamHitSparks", 0.0, 0.0, 0.0, frandom(-4.0, 4.0), frandom(-4.0, 4.0), frandom (-4.0, 4.0))
		//TNT1 A 35 A_PlaySound("PhotonCarbine/Hit", CHAN_AUTO, 0.8)
		Stop
	}
}
Actor ChargeRailPuff
{
	Radius 2
	Height 2
	Scale 0.1
	Renderstyle Add
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NONETID
	+BRIGHT
	States
	{
	Spawn:
	    SZAP ABCDE 1 A_FadeOut(0.1)
		Loop
	}
}
Actor ChargeRailHit : BulletPuff
{
	+AlWAYSPUFF
	-ALLOWPARTICLES
	+DROPOFF
	+NOCLIP
	Alpha 1.0
	Vspeed 0
	Scale 0.2
	DamageType "BeamRifle"
	ProjectileKickback 200
	Obituary "%k > \cnBeam Rifle (Mega Ray)\c- > %o"
	+BRIGHT
	States
	{
	Spawn:
		TNT1 AAAAAAAAAAAA 0 nodelay A_SpawnItemEx("BeamHitSparks", 0.0, 0.0, 0.0, frandom(-8.0, 8.0), frandom(-8.0, 8.0), frandom (-8.0, 8.0))
	    SZAP ABCDE 1 A_FadeOut(0.1)
		Stop
	XDeath:
	    SZAP ABCDE 1 A_FadeOut(0.2)
		Stop
	}
}