ACTOR Plasma_Gun : BrutalWeapon
{
	Weapon.SelectionOrder 100
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
    Inventory.PickupSound "PLSDRAW"
	Weapon.AmmoType1 "AmmoCell"
	Weapon.AmmoType2 "PlasmaAmmo"
    +WEAPON.NOAUTOAIM
	+FORCEXYBILLBOARD
	Tag "Plasma Rifle"
	Inventory.PickupMessage "$GOTPLASMA"
	Scale 0.9
	DropItem "PLasmagunSpawner"
	States
	{
	PuristGun:
		TNT1 A 1
		PLSN A 0 A_GiveInventory("ClassicPlasmaRifle", 1)
		PLSN A 0 A_TakeInventory("Plasma_Gun", 1)
		PLSN A 0 A_TakeInventory("DualPlasmaRifles", 1)
		TNT1 A 10
		Goto Ready

	Ready3:
	Ready:
		RIFG A 0 A_JumpIfInventory("PlasmaAmmo",1,1)
		Goto ReadyNoAmmo
        PLSN A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
        PLSN A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        PLSN A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		PLSN A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		PLSN A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        PLSN A 0 A_JumpIfInventory("Reloading",1,"Reload")
		PLSN A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		PLSN A 0 A_JumpIfInventory("Unloading",1,"Unload")
		PLSN A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		PLSN A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Loop

	ReadyNoAmmo:
        PLSR A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
        PLSN A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        PLSN A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		PLSN A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		PLSN A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        PLSN A 0 A_JumpIfInventory("Reloading",1,"Reload")
		PLSN A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		PLSN A 0 A_JumpIfInventory("Unloading",1,"Unload")
		PLSN A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		PLSN A 0 A_JumpIfInventory("IsRunning",1,"StartSprintNoAmmo")
		Loop

	StartSprint:
		PLSN A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",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

	StartSprintNoAmmo:
		PLSR A 1 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",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:
		PLSP A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		PLSP A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		PLSP A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		PLSP A 1 offset(0,38) A_SetPitch(pitch -0.5)
		PLSP A 1 offset(3,36) A_SetPitch(pitch -0.5)
		PLSP A 1 offset(6,34) A_SetPitch(pitch -0.5)
		PLSP A 1 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")

		PLSP A 1 offset(9,34) A_SetPitch(pitch +0.5)
		PLSP A 1 offset(6,36) A_SetPitch(pitch +0.5)
		PLSP A 1 offset(3,38) A_SetPitch(pitch +0.5)
		PLSP A 1 offset(0,38) A_SetPitch(pitch +0.5)
		PLSP A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		PLSP A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		PLSP A 1 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:
		PLSP A 0 A_JumpIfInventory("PowerStrength", 1, 2)
		PLSN A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PLSP A 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready

	StopSprintTired:
		PLSP A 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		PLSN A 0 A_PlaySound("Tired", 2)
		Goto Ready

	Deselect:
		PLSN A 0 A_Takeinventory("Reloading",1)
		PLSN A 0 A_Takeinventory("HasPlasmaWeapon",1)
		PLSN A 0 A_TakeInventory("TossGrenade", 1)
		PLSN A 0 A_StopSound(6)
        PLS9 CBA 1
		TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait

	Select:
		PLSN A 0
		PLSN A 0 A_Takeinventory("StartDualWield",1)
		PLSN A 0 A_Giveinventory("GoSpecial",1)
	    DUPL A 0 A_Giveinventory("HasPlasmaWeapon",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_GiveInventory("PlasmaGunSelected", 1)
		TNT1 A 0 A_TakeInventory("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)
		PLSN A 0 A_Takeinventory("HasBarrel",1)
		PLSN A 0 A_TakeInventory("TossGrenade", 1)
		PLSN A 0 A_TakeInventory("DualPlasmaRifles", 1)
		PLSN A 0 A_GunFlash
		TNT1 A 1 A_Raise
		TNT1 AAAAAA 0 A_Raise
	    PLSN A 0 A_JumpIfInventory("IsPlayingAsPurist", 1, "PuristGun")
		PLSN A 0 A_PlaySound("PLSDRAW")
		SelectAnimation:
        PLS9 ABC 1 A_JumpIfInventory("GoFatality", 1, "Steady")
		PLSN A 0 A_Takeinventory("StartDualWield",1)
		PLSN A 0 A_GunFlash
		Goto Ready

	Fire:
		PLSN A 0
        PLSN A 0 A_JumpIfInventory("Reloading",1,"Reload")
        PLSN A 0 A_JumpIfInventory("PlasmaAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
        PLSN A 0 A_PlaySound("PLSM9", 1)
		PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSN A 0 A_TakeInventory("DoublePlasmaAmmo", 1)
		TNT1 A 0 A_FireCustomMissile("Alerter",0,0)
		PLST A 1 BRIGHT A_FireCustomMissile("Plasma_Ball", frandom(-0.6,0.6), 1, 0, 0, 0, frandom(-0.7,0.7))
		PLSN A 0 A_Takeinventory("PlasmaAmmo",1)
		TNT1 A 0 A_ZoomFactor(0.99)
		RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		RIFG A 0 A_SetPitch(-0.2 + pitch)
		PLST B 1 BRIGHT
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_JumpIfInventory("IsTacticalClass", 1, 2)//Tactical mode skips a frame, fires faster
		PLST C 1 BRIGHT
		PLST D 1 BRIGHT A_Refire
		Goto Ready

// Charging up secondary ------------------------------------------------------------

	AltFire:
        PLSN A 0 A_JumpIfInventory("Reloading",1,"Reload")
        PLSN A 0 A_JumpIfInventory("PlasmaAmmo",10,2)
        Goto NoAmmo
        TNT1 AAA 0

	PLSN A 0 A_PlaySound("PLSCHARG")
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Takeinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT

	PLSN A 0 A_PlaySound("PLSFULL", 6, 0.8, 1)

// Holding Charge ------------------------------------------------------------

AltHold:
	PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
	PLSN A 0 A_JumpIfInventory("Reloading",1,"Cancel")
	PLFA A 1 BRIGHT offset (0, 32)

	PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
	PLSN A 0 A_JumpIfInventory("Reloading",1,"Cancel")
	PLFA B 1 BRIGHT offset (0, 33)

	PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
	PLSN A 0 A_JumpIfInventory("Reloading",1,"Cancel")
	PLFA C 1 BRIGHT offset (1, 32)

	PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
	PLSN A 0 A_JumpIfInventory("Reloading",1,"Cancel")
	PLFA D 1 BRIGHT offset (-1, 32)

	PLSN A 0 A_Refire

// Let Fly --------------------------------------------------------------------------

	PLSN A 0 A_StopSound(6)
	PLST A 1 BRIGHT A_PlaySound("PLSALTFR")
	TNT1 A 0 A_ZoomFactor(0.98)
	TNT1 A 0 A_FireCustomMissile("Alerter",0,0)
	PLST B 2 BRIGHT A_Recoil(2)
	TNT1 A 0 A_ZoomFactor(1.0)
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
	PLSN A 0 A_FireCustomMissile("PlasmaBall75", frandom(-2.7,2.7), 0, 0, 0, 0, frandom(-2.8,2.8))
		PLSN A 0 A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSN A 0 A_Takeinventory("DoublePlasmaAmmo",10)
        PLSN KLKJ 1 BRIGHT
		PLSN A 0 A_SetPitch(pitch - 1.8)
        PLSN BCD 1
		PLSN EEEEEEEEEEEE 3 A_FireCustomMissile("SmokeSpawner",0,0,10,5)
		PLSN DCB 1
        PLSN A 0 A_PlaySound("BEPBEP")
		PLSN A 0 A_PlaySound("BEPBEP", 6)
		Goto Ready

// Cancel Charge --------------------------------------------------------------------------------------------

	Cancel:
		PLSN A 0 A_TakeInventory("Reloading",1)
		PLSN A 0 A_PlaySound("decharg", 5)

		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSN A 0 A_StopSound(6)
		PLSA D 1 BRIGHT A_PlaySound("plscool", 7)
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT
		PLSA A 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA B 1 BRIGHT A_Giveinventory("PlasmaAmmo",1)
		PLSA C 1 BRIGHT A_FireCustomMissile("PlasmaFlareSpawn", 0, 0, 0, 0)
		PLSA D 1 BRIGHT

			PLSN A 0 A_TakeInventory("Reloading",1)
			PLSN A 0 A_Giveinventory("DoublePlasmaAmmo",10)
			PLSN A 0 A_PlaySound("BEPBEP", 5, 1.2)
			PLSN A 0 A_ClearReFire

		Goto Ready

//  ------------------------------------------------------------------------------

	Spawn:
		PLAS A -1
		Stop

	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		PLSR A 5 BRIGHT A_PlaySound("BEP", 4)
		RIFG A 0 A_JumpIfInventory("PlasmaAmmo",1,"Ready3")//If they press AltFire with less than 10 cells
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PLSR A 5 BRIGHT A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoCell",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprintNoAmmo")
		Goto ReadyNoAmmo

    Reload:
		PLSR A 4 BRIGHT
		PLSN A 0 A_Takeinventory("Reloading",1)
		PLSN A 0 A_JumpIfInventory("PlasmaAmmo",50,"Ready")
		PLSN A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		PLSN A 0 A_JumpIfInventory("PlasmaUnloaded",1,"PutMag")
		PLSN A 0 A_JumpIfInventory("AmmoCell",1,3)
        Goto Ready
        TNT1 AAAA 0
		PLSR BCD 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PLSN A 0 A_PlaySound("PLSDRAW")
		PLSR JIHGFE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PLSN A 0 A_FireCustomMissile("EmptyCellSpawn",0,0,0,-20)
		PLSR E 8
	PutMag:
		PLSR E 8
        PLSR FGHI 1
		PLSR J 4 A_PlaySound("PLREADY")
		PLSR KLB 1
		PLSN A 4 BRIGHT
		PLSR A 0 A_TakeInventory("PlasmaUnloaded",1)

		ReloadingSequence:
		TNT1 AAAAAAAAAA 0
		PLSN A 0 A_JumpIfInventory("PlasmaAmmo",50,15)
		PLSN A 0 A_JumpIfInventory("AmmoCell",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PLSN A 0 A_Giveinventory("PlasmaAmmo",1)
		PLSN A 0 A_Giveinventory("DoublePlasmaAmmo",1)
		PLSN A 0 A_Takeinventory("AmmoCell",1)
		Goto ReloadingSequence
		TNT1 AAAAAAAA 0

		PLSN A 1 A_Takeinventory("Reloading",1)
        Goto Ready

	TurboReload:
		TNT1 A 0
		RIFG A 0 A_Takeinventory("PlasmaUnloaded",1)
		RIFG A 0 A_JumpIfInventory("AmmoCell",1,1)
		Goto Ready
		RIFG A 0
        Goto ReloadingSequence

	Unload:
		PLSN A 4 BRIGHT
		PLSN A 0 A_Takeinventory("Unloading",1)
		PLSN A 0 A_JumpIfInventory("PlasmaAmmo",1,3)
		Goto ReadyNoAmmo
		TNT1 AAAAA 0
        PLSR BCD 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PLSN A 0 A_PlaySound("PLSDRAW")
		PLSR JIHGFE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PLSR E 8

	UnloadingSequence:
		PLSN A 0
		PLSN A 0 A_Takeinventory("Unloading",1)
		PLSN A 0 A_GiveInventory("PlasmaUnloaded",1)
		PLSN A 0 A_JumpIfInventory("PlasmaAmmo",1,3)
		Goto Ready
        TNT1 AAAAAAA 0
		PLSN A 0 A_Takeinventory("PlasmaAmmo",1)
		PLSN A 0 A_Takeinventory("DoublePlasmaAmmo",1)
		PLSN A 0 A_Giveinventory("AmmoCell",1)
		Goto UnloadingSequence

	DualWield:
		PLSN A 0
		PLSN A 1 BRIGHT A_Takeinventory("StartDualWield",1)
		PLSN A 0 A_JumpIfInventory("IsTacticalClass", 1, "NoDual")//Tactical mode cant dual
		PLSN A 0 A_JumpIfInventory("HasDualPlasma", 1, "GetDual")
		PLSN A 0 A_Print("You must have two identical weapons to dual wield.")
		Goto Ready

	 GetDual:
		PLSN A 0 A_SetCrosshair(0)
		PLSN A 0 A_Takeinventory("Zoomed",1)
		PLSN A 0 A_Takeinventory("ADSmode",1)
		PLSN A 0 A_TakeInventory("TossGrenade", 1)
		PLSN A 0 A_TakeInventory("Kicking",1)
        PLSN A 0 A_TakeInventory("Taunting",1)
        PLSN A 0 A_TakeInventory("Reloading",1)
		PLSN A 0 A_TakeInventory("Unloading",1)
		PLSN A 0 A_TakeInventory("Salute1", 1)
		PLSN A 0 A_TakeInventory("Salute2", 1)
		PLSN A 0 A_GiveInventory("DualPlasmaRifles",1)
        PLSN A 0 A_ZoomFactor(1.0)
		PLSN A 0 A_SelectWEapon("DualPlasmaRifles")
		Goto Ready

	NoDual:
		PLSN A 1 BRIGHT
		PLSN A 0 A_Print("You can't dual wield plasma rifles when playing in Tactical Mode.",1)
		Goto Ready
	}
}

ACTOR Plasma_Ball
{
	Radius 10
	Height 2
	Speed 60
	Damage (random(40, 40))
    DamageType Plasma
	Decal "SmallerScorch"
	Projectile
	+RANDOMIZE
	+THRUSPECIES
	+FORCEXYBILLBOARD
	Species "Marines"
	Scale 1.0
	renderstyle ADD
	DeathSound "weapons/plasmax"
	//SeeSound "PLSM9"
    SeeSound "None"
	Obituary "$OB_MPPLASMARIFLE"
	States
	{
	Spawn:
		PLSS ABAB 1 Bright A_SpawnItem("BlueFlareSmall")
		Loop
	Death:
	    PLSN A 0
		PLSN 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 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)
		PLSE ABC 2 BRIGHT A_SpawnItem("BlueFlare")
		PLSE DE 2 Bright A_SpawnItem("BlueFlareSmall")
		TNT2 AAA 9 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		Stop

	XDeath:
	    PLSN A 0
		PLSN 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))
		PLSE ABC 2 BRIGHT A_SpawnItem("BlueFlare")
		PLSE DE 2 Bright A_SpawnItem("BlueFlareSmall")
		Stop
	}
}

ACTOR PlasmaBall75: Plasma_Ball
{
	Damage (random(50, 50))
	SeeSound "PLSM9"
}

ACTOR PlasmaBall99: Plasma_Ball
{
	Damage (random(60, 60))
	SeeSound "PLSM9"
}

ACTOR PlasmaAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 50
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 50
   Inventory.Icon "PLASA0"
}

ACTOR InvisiblePLasmaAmmo: CustomInventory
{
 scale 1.0
 radius 16
 height 4
 damage 0
   Mass 1
   Inventory.PickupMessage "Plasma Cells."
    States
    {

	 Spawn:
		CELL D -1
		Stop
	Pickup:
	    PLSN A 0
		PLSN A 0 A_GiveInventory("AmmoCell", 50)
		Stop
	}
}