ACTOR Plasma_Gun : BrutalWeapon
{
	Weapon.SelectionOrder 110
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
    Inventory.PickupSound "PLSLOAD"
	Weapon.AmmoType1 "AmmoCell"
	Weapon.AmmoType2 "PlasmaAmmo"
	scale 0.24
	+thruactors
	+WEAPON.NOALERT
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+FORCEXYBILLBOARD
	Tag "M890 Theratorn"
	Inventory.PickupMessage "Plasma Gun"
	States
	{

	INSPECT:
		TNT1 A 10
		PLSI A 0 A_startsound("PLSINSPE", 150)
		PLSI A 0 A_takeinventory("neverfoundplasmagun",1)
		PLSI ABCDE 1 a_SETROLL(ROLL+1.5)
		PLSI FGH 1 A_InspectReady
		PLSI I 15 A_InspectReady
		PLSI A 0 A_QuakeEx(3, 1, 2, 3, 0, 64, "", 0, 0, 0, 0, 0, 0, 3)
		PLSI JKKKKLMNOPQRSTUVWXYZ 1 A_InspectReady
		PLSI A 0 A_QuakeEx(3, 1, 2, 3, 0, 64, "", 0, 0, 0, 0, 0, 0, 3)
		PLSI A 0 A_startsound("SSTEAM", 152, 0, 0.5)
		PL5I AB 1 A_AttachLightdef(2,"smallbluetorch")
		PL5I CDEFGHJ 1 A_removelight(2)
		TNT1 A 0 A_InspectReady
		PL5I KLMNO 1  a_SETROLL(ROLL-1.5)
		PLSR BCDEFGHIJKJIHIJKLMN 1 A_InspectReady
		PLSR N 10 A_InspectReady
		PLSR OPQR 1 A_InspectReady
		PLSI A 0 A_startsound("PLSLOAD", 151)
		PLSR STUV 1 A_InspectReady
		PLSI A 0 A_QuakeEx(2, 1, 1, 3, 0, 64, "", 0, 0, 0, 0, 0, 0, 3)
		PLSR WXYZ 1 A_InspectReady
		PL5R ABCDEFGHIJKLMNO 1 A_InspectReady
		PLSS FG 1
		TNT1 A 0 A_GIVEINVENTORY("AMMOCELL",30)
		goto ReloadingSequence
	
	Ready:
		SelectAnimation:
		PLSI A 0 A_startsound("PLSUNLOA", 150)
				//Inspect check
				TNT1 A 0 a_jumpif(GetCVAR("weaponinspect") == 1,2)
				TNT1 A 0 A_JumpIfInventory("neverfoundPLASMAGUN",1,"Inspect")
				//
        PLSS ABCDEF 1 A_JumpIfInventory("GoFatality", 1, "Steady")
		PLSI A 0 A_Takeinventory("StartDualWield",1)
		PLSI A 0 A_Takeinventory("plasmatemperature",100)
		goto Ready3
	Ready3:
		"####" "#" 0 A_Giveinventory("HasPlasmaWeapon",1)
		"####" "#" 0 A_JumpIfInventory("plasmatemperature", 500, "CHARGESTART")
		"####" "#" 0 A_Takeinventory("plasmatemperature",1)
        "####" "#" 0 A_JumpIfInventory("Kicking",1,"dokickplasma")
		"####" "#" 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		"####" "#" 0 A_JumpIfInventory("Zoomed",1,"ready2")
		PLSR A 0 A_JumpIfInventory("HasUnloadedPLASMA",1,2)
		PLSS G 0
		"####" "#" 0
		"####" "#" 1 { A_WeaponReadyLit; A_overlay(4,"TemperatureSmoke",1); }
		Loop
	
	TemperatureSmoke:
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 400, "smoke3")
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 250, "smoke2")
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 150, "smoke1")	
		stop
	Smoke1:
		TNT1 A 3 A_FireCustomMissile("shockSmokkSpawner",0,0,10,-30)
		TNT1 A 20
		STOP
	Smoke2:
		TNT1 AAA 5 A_FireCustomMissile("shockSmokkSpawner",0,0,10,-30)
		TNT1 A 10
		STOP
	Smoke3:
		TNT1 AAAAAA 1 A_FireCustomMissile("shockSmokkSpawner",0,0,10,-30)
		STOP
	
		
	
	
	CheckSprint:
		//PLSS G 1 A_WeaponReady(WRF_NOFIRE)
		PLSI A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		PLSI A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD, 1)
		GOTO READY3
		PLSP EDCB 1 A_WeaponReady(WRF_NOFIRE)
		PLSI A 0 A_Takeinventory("plasmatemperature",4)
		PLSI A 0 A_Takeinventory("Zoomed",1)
		PLSI A 0 A_Takeinventory("ADSmode",1)
		PLSI A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "Trip")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "Trip")
		
	Sprinting:	
		PLSP A 0 offset(-9,32) 
		PLSI A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 2000, "StopSprintTired")
		TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD, 1)
		GOTO StopSprint
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		PLSI A 0 offset(-9,32) A_JumpIfInventory("Powerstrength2", 1, 2)
		PLSI A 0 offset(-9,32) A_GiveInventory("UsedStamina", 10)
		PLSI A 0 offset(-9,32)
		PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
		PLSI A 0 A_Takeinventory("plasmatemperature",14)
		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)
		PLSI A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		PLSI A 0 A_JumpIfInventory("Kicking",1,"dokickplasma")
        PLSI A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        PLSI A 0 
		PLSI A 0 offset(-9,32) A_GiveInventory("UsedStamina", 4)
		PLSI A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		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)
		PLSI A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		PLSI A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		PLSP BCDE 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		PLSI A 0 A_PlaySound("Tired", 2)
		PLSI A 0 A_Takeinventory("plasmatemperature",4)
		TNT1 A 0 A_Jumpifhealthlower(25,"rupturesprint")												   
		PLSS G 25 
		Goto Ready3
	StopSprint:
		PLSP BCDE 1
		PLSI A 0 A_Takeinventory("plasmatemperature",4)
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready3	
		

	Deselect:
		TNT1 A 0 A_ClearOverlays(3,3)
		PLSI A 0 A_Takeinventory("plasmatemperature",500)
		RLNG A 0 A_Takeinventory("plasmagunselected",1)
		PLSI A 0 A_Takeinventory("Reloading",1)
		PLSI A 0 A_Takeinventory("HasPlasmaWeapon",1)
		TNT1 A 0 A_TakeInventory("throwtoken", 1)
		TNT1 A 0 A_TakeInventory("slashtoken", 1)
		CHAG A 0 A_TakeInventory("Flaretoken", 1)	
		PLSI A 0 A_TakeInventory("TossGrenade", 1)
		PLSI A 0 Acs_namedTERMINATE("PLASMATEMPERATURE",0)
		TNT1 A 0 A_JumpIfInventory("weaponbroke", 1, "Deselectcontinue")
        PLSS FEDCBA 1
	DESELECTCONTINUE:
		TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait
		
	goingtoaction:
		PLSI A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("throwtoken", 1)
		TNT1 A 0 A_TakeInventory("slashtoken", 1)
		CHAG A 0 A_TakeInventory("Flaretoken", 1)	
		PLSI A 0 A_TakeInventory("TossGrenade", 1)
        PLSS FEDCBA 1
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "wearanimation")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "removeanimation")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"drugshot")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"BANDAGE")
		goto repair
	
	Select: 
		TNT1 A 0  A_Overlay(-10,"FirstPersonLegsStand")
		TNT1 A 0 a_removelight(1)
		TNT1 A 0 A_removelight(2)	
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}	
		TNT1 A 0 A_SetRoll(0)
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 ACS_NAMEDEXECUTE("WEAPONSELECT",0)
		PLSI A 0 Acs_namedexecute("PLASMATEMPERATURE",0)
		PLSI A 0 A_Takeinventory("StartDualWield",1)
		PLSI A 0 A_Giveinventory("GoSpecial",1)
	    PLSI A 0 A_Giveinventory("HasPlasmaWeapon",1)
		TNT1 A 0 A_TakeInventory("throwtoken", 1)
		TNT1 A 0 A_TakeInventory("slashtoken", 1)
		CHAG A 0 A_TakeInventory("Flaretoken", 1)	
		PLSI A 0 A_TakeInventory("TossGrenade", 1)
		Select2:
		TNT1 A 0 A_Raise
		loop
		
	Fire:
		PLSI A 0 A_CheckReload
        PLSI A 0 
        PLSI A 0 A_JumpIfInventory("PlasmaAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
		
		//DURABILITY CHECK
		TNT1 A 0 A_JumpIFInventory("FirearmsdurabilityOFF", 1, 4)
		PIST F 0 A_Takeinventory("plasmaDurability",1)
		PIST F 0 A_JumpIfInventory("plasmaDurability",60, 2)
		PIST F 0 A_Jump(80, "Misfire")
		///
		
		PIST F 0 A_AlertMonsters		
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 490, "CHARGESTART")
		NULL A 0 A_WeaponOffset(random(-2,2),32+random(0,1))
		TNT1 A 0 A_JumpIFInventory("Zoomed", 1, "AimFire")
        PLSI A 0 A_PlaySound("PLSSHOT", 1)

		
		PLSI A 0 A_ZoomFactor(0.99)
		PLSI A 0 A_giveinventory("plasmatemperature",15)
		PIST F 0 A_Jump(255,"FIRE1","FIRE2","FIRE3")
		
		Fire1:
		PLSF A 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.0)
		PLSF B 1 
		NULL A 0 A_WeaponOffset(0,32)
		PLSF CDE 1
		goto finishfire
		
		Fire2:
		PLSF F 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.0)
		PLSF G 1 	
		NULL A 0 A_WeaponOffset(0,32)
		PLSF HIJ 1
		goto finishfire
		
		Fire3:
		PLSF K 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.0)
		PLSF L 1 	
		NULL A 0 A_WeaponOffset(0,32)
		PLSF MN 1
		PLSS G 1
		goto finishfire
		
		FinishFire:
		/// DURABILITY CHECK 2
		PIST F 0 A_JumpIfInventory("plasmadurability", 1, 1)
		goto weaponbreak
		TNT1 A 0
		///
		PLSI A 0 A_Takeinventory("PlasmaAmmo",1)
		PLSI A 0 a_refire
		Goto Ready3
	
/// ADS MODE
Altfire:
		BADF A 0 a_startsound("PLSADS",250)
		BADF A 0 A_Giveinventory("GoSpecial",1)
		BADF A 0 A_JumpIfInventory("Zoomed",1,"NoAim")
		BADF A 0 A_Giveinventory("Zoomed",1)
        BADF A 0 A_ZoomFactor(1.5)
		TNT1 A 0 A_SetCrosshair(41)							 
		BADF A 0 A_Giveinventory("ADSmode",1)
		TNT1 A 0 A_JumpIfInventory("hasunloadedplasma", 1, 2)
        PLSA ABCDE 1
		PLSI A 0 A_takeinventory("plasmatemperature",12)
		
		PLSA E 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK, "fire")
		
		
		BADF A 0 A_JumpIf(Getcvar("ADSMode") == 0, "Ready2")  ///////ADS MODE CHECK
		
	  HoldAim:	
		BADF A 0 A_GiveInventory("ZoomHold",1)
	    BADF A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		PLSI A 0 A_takeinventory("plasmatemperature",1)
		PLSA E 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK, "fire")
		PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_altATTACK, "holdaim")
		
      NoAim:
		BADF A 0
		BADF A 0 A_Takeinventory("Zoomed",1)
		BADF A 0 A_Takeinventory("ZoomHold",1)
        BADF A 0 A_ZoomFactor(1.0)
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}						
		BADF A 0 A_Takeinventory("ADSmode",1)
		PLSA EDCB 1
		TNT1 A 0 A_JumpIfInventory("hasunloadedplasma", 1, 2)
		PLSA A 1
		PLSI A 0 A_JumpIfInventory("jammedplasma", 1, "chargestart")
		PLSI A 0 A_JumpIfInventory("ZOOMED", 1, "noaim")
		RI2G A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		PLSI A 0 A_takeinventory("plasmatemperature",5)
		PLSI A 0 A_JumpIfInventory("Reloading",1,"Reload")
        Goto Ready3
		
	Ready2:
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 500, "CHARGESTART")
		PLSI A 0 A_takeinventory("plasmatemperature",1)
		RI2G A 0 A_JumpIfInventory("Kicking",1,"dokickplasma")
		RI2G A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		PLSA E 1 A_WeaponReadyLit
		PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
					
		BADF A 0 A_JumpIf(Getcvar("ADSMode") == 0, 3)  ///////ADS MODE CHECK
		BADF A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_altATTACK, "holdaim")
		
		BADF A 0 A_JumpIfInventory("ZoomHold", 1, "NoAim")
		TNT1 A 0
		Loop
		
	Aimfire:
		BADF A 0
//DURABILITY CHECK
		TNT1 A 0 A_JumpIFInventory("FirearmsdurabilityOFF", 1, 4)
		PIST F 0 A_Takeinventory("plasmaDurability",1)
		PIST F 0 A_JumpIfInventory("plasmaDurability",60, 2)
		PIST F 0 A_Jump(180, "Misfire")
		///
		
		PLSI A 0 A_PlaySound("PLSSHOT", 1)
		PIST F 0 A_AlertMonsters		
		PISF F 0 A_Quake(1, 3, 0, 400, "")
		PISF F 0 A_ZoomFactor(1.3)
		PLSI A 0 A_Takeinventory("PlasmaAmmo",1)
		PLSI A 0 A_giveinventory("plasmatemperature",15)
		BADF A 0 A_Jump(255,"AIMFirevariant1","AIMFirevariant2","AIMFirevariant3")
		
	AIMFIREVARIANT1:
		PLSA F 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.5)
		PLSA G 1 	
		NULL A 0 A_WeaponOffset(0,32)
		PLSA HI 1
		goto FinishFireAim
		
	AIMFIREVARIANT2:
		PLSA J 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.5)
		PLSA K 1 	
		NULL A 0 A_WeaponOffset(0,32)
		PLSA LM 1
		goto FinishFireAim
		
	AIMFIREVARIANT3:
		PLSA N 1  A_FireProjectile("Plasma_Ball",0,1,0,0,0,0)
		PLSI A 0 A_ZoomFactor(1.5)
		PLSA O 1 
		NULL A 0 A_WeaponOffset(0,32)
		PLSA PQ 1
		goto FinishFireAim
	
	FinishFireAim:
		PLSA E 1
		PIST F 0 A_JumpIfInventory("plasmadurability", 1, 1)
		goto weaponbreak
		
		BADF A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK, "fire")
		BADF A 0 A_JumpIf(Getcvar("ADSMode") == 0, 3)  ///////ADS MODE CHECK
		BADF A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_altATTACK, "holdaim")
		BADF A 0 A_JumpIfInventory("ZoomHold", 1, "NoAim")
		PLSA E 5 A_refire
        RI2G A 0
		Goto Ready2	
	

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

	ADStocharge:
		BADF A 0 A_Takeinventory("Zoomed",1)
		BADF A 0 A_Takeinventory("ZoomHold",1)
        BADF A 0 A_ZoomFactor(1.0)
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}							
		BADF A 0 A_Takeinventory("ADSmode",1)
		PLSA EDCBA 1

	ChargeStart:
		PLSI A 0 A_JumpIfInventory("Plasmatemperature",500,3)
        PLSI A 0 A_JumpIfInventory("PlasmaAmmo",10,2)
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
        Goto Ready3
        TNT1 AAA 0
		PLSI A 0 A_JumpIfInventory("Zoomed",1,"ADStoCharge")
		
		//DURABILITY CHECK
		TNT1 A 0 A_JumpIFInventory("FirearmsdurabilityOFF", 1, 4)
		PIST F 0 A_Takeinventory("plasmaDurability",1)
		PIST F 0 A_JumpIfInventory("plasmaDurability",60, 2)
		PIST F 0 A_Jump(155,"Jammedfire")
		///
		
		TNT1 A 0 A_AttachLightdef(2,"plasmaball")
		PLSC AB 1
		PLSI A 0 A_PlaySound("PLSCHARG")
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Takeinventory("PlasmaAmmo",2)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1 
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1 
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1 
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Takeinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1 
		PLSI A 0 A_PlaySound("PLSFULL", 6, 0.8, 1)


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

LoopCharge:
	PIST F 0 A_AlertMonsters(300)		
	TNT1 A 0 A_AttachLightdef(2,"plasmaball")
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC C 1  A_giveinventory("plasmatemperature",1)
	
	PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
	
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC D 1  A_giveinventory("plasmatemperature",1)
	
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC E 1  A_giveinventory("plasmatemperature",1)
	
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC C 1  A_giveinventory("plasmatemperature",1)
	
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC D 1  A_giveinventory("plasmatemperature",1)
	
	PLSI A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_attack, "Chargefire")
	PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
	PLSI A 0 A_JumpIfInventory("startdualwield",1,"Cancel")
	PLSC E 1  A_giveinventory("plasmatemperature",1)
	PLSI A 0 A_JumpIfInventory("plasmatemperature", 490, "CHARGEFIRE")
	loop

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

ChargeFire:
	TNT1 A 0 A_JumpIFInventory("FirearmsdurabilityOFF", 1, 2)
	PIST F 0 A_Takeinventory("plasmaDurability",8)
	///
	PIST F 0 A_AlertMonsters		
	PLSI A 0 A_StopSound(6)
	PLSI A 0 Acs_namedexecute("Electroflash",0)
	PLSC A 1 A_PlaySound("PLSALTF2",1)
	PLSI A 0 A_ZoomFactor(0.9)
	PLSC F 2  A_Recoil(3)
	PLSI A 0 A_StopSound(6)
	PLSI A 0 A_ZoomFactor(1.0)
	TNT1 A 0 a_explode(50,300,0,1,300,0,0,"hitpuff","shock")
	TNT1 A 0 a_radiusgive("shockcharge",200,RGF_NOSIGHT,10)
	TNT1 A 0 a_radiusgive("shockcharge",80,RGF_NOSIGHT,5)
	TNT1 A 0 a_explode(50,80,0,1,80,0,0,"hitpuff","shock")
	TNT1 A 0 A_giveinventory("plasmatemperature",50)
	TNT1 A 0 A_FireCustomMissile("plasmaexplosion",0,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_spawnitemex("plasmawave",60,-60,8, 30,-25, 0, 0, SXF_NOCHECKPOSITION)
	
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",0,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-45,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-90,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",45,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",90,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",130,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-130,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",20,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-20,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",60,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-60,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",160,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",-160,0,15,0,FPF_NOAUTOAIM,random(0,4))
	TNT1 A 0 A_FireCustomMissile("plasmashockthin",180,0,15,0,FPF_NOAUTOAIM,random(0,4))

		PLSI A 0 A_FireCustomMissile("PlasmaFlareSpawn",-5,0,0,0)
		PLSI A 0 A_SetPitch(pitch - 8.0)
		PLSC GH 1
		TNT1 A 0 A_JumpIfInventory("JAMMEDPLASMA", 1, "EXPLODE")
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 490, "Explode")
		PLSC IJKL 1 A_FireCustomMissile("shockSmokkSpawner",0,0,10,-30)
        PLSF E 1 A_FireCustomMissile("SmokeSpawner",0,0,10,5)
		PLSS GGGG 3 A_FireCustomMissile("SmokeSpawner",0,0,10,5)
		TNT1 A 0 A_removelight(2)
		/// DURABILITY CHECK 2
		PIST F 0 A_JumpIfInventory("plasmadurability", 1, 1)
		goto weaponbreak
		TNT1 A 0
		///
		
		PLSS GGG 1
        PLSI A 0 A_PlaySound("BEPBEP")
		PLSI A 0 A_PlaySound("BEPBEP", 6)
		Goto Ready3
		
		
		/// DURABILITY CHECK 2
		PIST F 0 A_JumpIfInventory("plasmadurability", 1, 1)
		goto weaponbreak
		TNT1 A 0
		///
		
        PLSI A 0 A_JumpIfInventory("PlasmaAmmo",1,2)
        Goto Reload
        TNT1 AAAA 0
        PLSI A 0 A_PlaySound("BEPBEP")
		PLSI A 0 A_PlaySound("BEPBEP", 6)
		Goto Ready3	

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

	Cancel:
		PLSI A 0 A_Takeinventory("StartDualWield",1)
		PLSI A 0 A_TakeInventory("jammedplasma",1)
		PLSI A 0 A_StopSound(6)
		PLSI A 0 A_PlaySound("PLSHEAT", 5)
		PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
		
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_PlaySound("plscool", 7)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1 
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1 
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC C 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC D 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC E 1 
		PLSC C 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC D 1  A_Giveinventory("PlasmaAmmo",1)
		PLSC E 1  A_FireCustomMissile("PlasmaFlareSpawn",0,0,0,0)
		PLSC CBA 1 A_removelight(2)
		
			PLSI A 0 A_TakeInventory("Reloading",1)
			PLSI A 0 A_PlaySound("BEPBEP", 5, 1.2)
			PLSI A 0 A_ClearReFire
		Goto Ready3

Cooldown:
		PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		PLSH ABCDEFGHI 1
		RIFG A 0 A_Takeinventory("PLASMATEMPERATURE",500)
		TNT1 A 0 A_PLAYSOUND("PLSHEAT",1,1.0)
		TNT1 A 0 A_AttachLightdef(2,"plasmaball")
		PLSH JKLM 1
		TNT1 A 0 A_REMOVELIGHT(2)
		PLSH NOPQEDCBA 1
		goto Ready3


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

	WeaponCheckOverlay:
		TNT1 A 5
		PISA D 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, 1)
		Stop
	WeaponCheck2:
		TNT1 A 1
		PISA D 0 ACS_NamedExecutealways("plasmadurabilitycheck", 0)
		PISA D 0 ACS_NamedExecutealways("plasmagunmagcheck", 0)
		PISA D 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, "WeaponCheck2")
		stop	
	NoAmmoUnload:
	    PISA D 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, 1)
		goto Noammo
		TNT1 A 0 A_Overlay(98,"WeaponCheckOverlay",false)
	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")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
	NoAmmo2:
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "goingtoaction")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "goingtoaction")
		TNT1 A 0 A_JumpIfInventory("repairtoken",1,"goingtoaction")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"goingtoaction")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"goingtoaction")
		TNT1 A 0 A_Jumpifinventory("throwtoken",1, "Quickthrow")
		PLSS G 0 A_Jumpifinventory("slashtoken",1, "Quickslash")
		TNT1 A 0 A_JumpIfInventory("flaretoken",1,"TossFlare")
		PLSS G 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER3, "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("IsRunning",1,"CheckSprint")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"dokickplasma")
		RIFG A 0
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 500, "Explode")
		PLSI A 0 A_takeinventory("plasmatemperature",3)
		TNT1 A 0 A_JumpIfInventory("hasunloadedplasma", 1, 4)
		PLSS G 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		PLSI A 0 A_overlay(4,"TemperatureSmoke",1)
		PISA D 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, "noammo2")
		goto ready3
		PLSR A 5 A_WeaponReady(WRF_ALLOWRELOAD)
		PISA D 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, "noammo2")
		GOTO READY3


    Reload:
		PIST F 0 A_JumpIfInventory("REPAIRMODE",1,"KITREPAIR")
		PLSI A 0 A_ClearReFire
		PLSI A 0 A_JumpIfInventory("PlasmaAmmo",50,"Ready3")
		PLSI A 0 A_JumpIfInventory("AmmoCell",1,6)

		PLSI A 0 A_PlaySound("BEP")
		PLSS G 4 A_WeaponReady(WRF_NOFIRE)
		PLSI A 0 A_PlaySound("BEP")
		PLSR A 4 A_WeaponReady(WRF_NOFIRE)
		PLSI A 0 A_CheckReload
        Goto Ready3
        TNT1 A 0
		PLSI A 0 A_giveinventory("Reloading",1)
		PLSI A 0 A_JumpIfInventory("Zoomed",1,"noaim")
		PLSI A 0 A_takeinventory("Reloading",1)
		
        PLSI A 0 A_PlaySound("MAGGRAB",1,0.5)
		PLSI A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
        PLSR A 1
		
		PLSI A 0 A_JumpIfInventory("HasUnloadedPLASMA",1,6)
		BADF A 0 A_JumpIfInventory("realreloadOFF",1,2)
		PIST F 0 A_JumpIfInventory("PlasmaAmmo",1,3)
		PLSI A 0 A_FireCustomMissile("PlasmaCaseSpawn",-210,0,20,-20)
		PIST F 0 A_Jump(256,2)
		RIFR C 0 ACS_NAMEDEXECUTE("DropplasmaMAG",0)
		
		PLSR BCDEFG 1
		RAIL A 0 A_JumpIfInventory("realreloadOFF",1,2)
		RAIL A 0 A_Takeinventory("Plasmaammo",50)
		PLSR HIJKJIHIJK 2
		PLSR LMN 1
        PLSR N 10
		PLSR OPQR 1
		PLSI A 0 A_startsound("PLSLOAD", 151)
		PLSR STUV 1
		PLSI A 0 A_QuakeEx(2, 1, 1, 3, 0, 64, "", 0, 0, 0, 0, 0, 0, 3)
		PLSR WXYZ 1
		PL5R ABCDEFGHIJKLMNO 1
		PLSS FG 1
		PLSI A 0 A_takeinventory("plasmatemperature",40)	
		
		
	ReloadingSequence:
		PLSI A 0 A_JumpIfInventory("PlasmaAmmo",50,"FinishReload")
		PLSI A 0 A_JumpIfInventory("AmmoCell",1,1)
		Goto FinishReload
        TNT1 A 0
		PLSI A 0 A_Giveinventory("PlasmaAmmo",1)
		PLSI A 0 A_Takeinventory("AmmoCell",1)
		Goto ReloadingSequence
	FinishReload:
		PLSI A 0 A_takeinventory("hasunloadedplasma",1)
		PLSI A 0 A_Takeinventory("Reloading",1)
        Goto Ready3
		
	TurboReload:
		PLSR BCDE 0
		Goto ReloadingSequence
	
	CheckCell:
		PL5R H 5 A_weaponready(WRF_NOFIRE | WRF_NOSWITCH)
		TNT1 A 0 A_takeinventory("plasmatemperature",5)
		TNT1 A 0 A_JumpIFInventory("FirearmsdurabilityOFF", 1, 2)
		TNT1 A 0 ACS_NAMEDEXECUTEalways("plasmaDURABILITYCHECK",0)
		TNT1 A 0 ACS_NamedExecutealways("plasmaGUNMAGCheck",0)
		TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, "CheckCell")
		
		BADF A 0 a_startsound("LNCADS1",250)
		PL5R IJKLMNO 1
		 goto Ready3	
	
	user4:
		PLSI A 0 A_Takeinventory("Zoomed",1)
		PLSI A 0 A_Takeinventory("ADSmode",1)
		PLSI A 0 A_ZoomFactor(1.0)
		PLSI A 0 A_JumpIfInventory("plasmaammo",1,2)
		PLSR A 1 A_playsound("LNCCANC")
		Goto NoammoUnload
		TNT1 AAAAA 0
		PLSI A 0 A_PlaySound("BEP")
		PLSS G 3 A_WeaponReady(WRF_NOFIRE)
		PLSI A 0 A_PlaySound("BEP")
		PLSS G 3 A_WeaponReady(WRF_NOFIRE)
        TNT1 AAAA 0
		PLSS GF 1
        PL5R ONMLKJIH 1 A_takeinventory("plasmatemperature",1)
		TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER4, "CheckCell")
		PL5R GFEDCBA 1 A_takeinventory("plasmatemperature",1)
		PLSR ZYX 1
		PLSI A 0 A_PlaySound("PLSUNLOA",1)
		PLSR WVUTSRQPONNNMLKJIHGFEDCBA 1 A_takeinventory("plasmatemperature",1)
		PLSI A 0 A_Giveinventory("hasunloadedplasma",1)
		goto UnloadingSequence
		
	UnloadingSequence:
		PLSI A 0 A_JumpIfInventory("PlasmaAmmo",1,1)
		Goto Ready3
		PLSI A 0 A_Takeinventory("PlasmaAmmo",1)
		PLSI A 0 A_Giveinventory("AmmoCell",1)
		goto UnloadingSequence
		
		
	DualWield:
		PLSI A 0 A_Takeinventory("StartDualWield",1)
		PLSI A 0 A_JumpIfInventory("plasmatemperature", 250, "Cooldown")
		GOTO CHARGESTART

	Spawn:
	    PLSI A 0
		PLAS AAAAAAAAAAAAAAAAAAAA 1 a_jumpifinventory("removeingredient",1,"Disappear")
		PLSI A 0 A_SpawnItem("DropedPlasmaGun")
		Stop
		
	Disappear:
	   TNT1 A 0
	   stop

	Misfire:
		TNT1 A 0 A_giveinventory("plasmadurability",1)
		TNT1 A 0 A_jump(50,"Jammedfire")
		TNT1 A 0 A_playsound("LNCCANC")
		PLSI A 0 A_JumpIfInventory("ZOOMED", 1, 2)
		PLSS G 5
		goto Ready3
		PLSA E 5
		goto Ready2
		
	Jammedfire:
		TNT1 A 0 A_giveinventory("jammedplasma",1)
		TNT1 A 0 A_giveinventory("plasmatemperature",100)
		PLSI A 0 A_JumpIfInventory("ZOOMED", 1, "noaim")
		goto chargestart
		
	EXPLODE:
		PLSI A 0 A_Takeinventory("Zoomed",1)
		PLSI A 0 A_Takeinventory("ADSmode",1)
		 PLSI A 0 A_ZoomFactor(1.0)
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}			
		TNT1 A 0 A_takeinventory("jammedplasma",1)
		TNT1 A 0 A_takeinventory("plasmadurability",40)
		PLSI A 0 Acs_namedTERMINATE("PLASMATEMPERATURE",0)
		PLSI A 0 A_Takeinventory("HasPlasmaWeapon",1)
		PIST F 0 A_AlertMonsters		
		//TNT1 A 0 A_firecustommissile("Plasmagundrop",1,0,0,15)
		goto Electrocuted
			
	Weaponbreak:
		PLSI A 0 Acs_namedTERMINATE("PLASMATEMPERATURE",0)
		PLSI A 0 A_Takeinventory("Zoomed",1)
		PLSI A 0 A_Takeinventory("ADSmode",1)
		PLSI A 0 A_Takeinventory("HasPlasmaWeapon",1)
		 PLSI A 0 A_ZoomFactor(1.0)
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}			
		TNT1 A 0 a_print("your Plasma Rifle has broken!")
		TNT1 A 0 a_SPAWNITEM("brokenplasmagun",0,0)
		 PLSS FEDCBA 1
		 TNT1 A 0 a_SPAWNITEM("brokenplasmagun",0,0)
		 TNT1 A 0 a_RADIUSGIVE("hasbeendropped",90, RGF_OBJECTS | RGF_NOSIGHT, 1, "brokenplasmagun")
		TNT1 A 0 A_removelight(2)
		TNT1 A 0 ACS_namedexecute("BROKENDISARM",0)
		TNT1 AAA 1 a_weaponready
		Wait
		
	KITREPAIR:
		TNT1 A 0 A_JumpIFInventory("isscientist",1, 2)
		TNT1 A 0 A_Jump(256,"RequireScience")
		TNT1 A 0 A_JumpIFInventory("survivalkituses",1, 2)
		PIST F 0 A_Jump(256,"kitbroke")
		PLSS G 5
		
		TNT1 A 0 A_JumpIFInventory("plasmaDurability",200, "NoNeedRepair")
		PIST F 0 A_JumpIfInventory("electronicparts",1, 2)
		PIST F 0 A_Jump(256,"outofmetal2")
		PIST F 0 A_JumpIfInventory("scrapmetal",1, 2)
		PIST F 0 A_Jump(256,"outofmetal2")
		
	KITREPAIR2:
		PLSI A 0 A_Takeinventory("Zoomed",1)
		PLSI A 0 A_Takeinventory("ADSmode",1)
		 PLSI A 0 A_ZoomFactor(1.0)
		TNT1 A 0 {if(GetCVAR("bd_SmartCrosshairs") == 1){A_SetCrosshair(GetCVAR("PlasmaCrosshair"));}else{A_SetCrosshair(0);}}			
		PIST F 0 A_GIVEinventory("plasmaDurability",50)
		BADF A 0 A_Takeinventory("survivalkituses",1)
		BADF A 0 A_Takeinventory("scrapmetal",1)
		BADF A 0 A_Takeinventory("electronicparts",1)
		TNT1 A 0 A_playsound("WIRECUT",1)
		 PLSS FEDCBA 1
		TNT1 A 35
		 PLSS ABCDEF 1
		PLSI A 0 A_takeinventory("plasmatemperature",500)
		TNT1 A 0 A_JumpIFInventory("survivalkituses",1, 2)
		PIST F 0 A_Jump(256,"kitbroke")
		PLSS G 2
		goto Ready3	
	
	Dokickplasma:
		TNT1 A 0 A_JumpIfInventory("isdoomguy", 1, 4)
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpifInventory("UsedStamina",95,4)
		TNT1 A 0 A_JumpifInventory("UsedStamina",1995,3)
		TNT1 A 0 A_overlay(3,"kickplasma")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3
		TNT1 A 0 A_overlay(3,"kickplasmatired")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3	
	kickplasma:
		PL5I ONM 1
		PL5I L 12 
		PL5I MNO 1 
		PLSI A 0 A_takeinventory("plasmatemperature",20)
		TNT1 A 0 A_JumpIfInventory("airkicking", 1, 2)
		TNT1 A 0 A_JumpIfInventory("isSliding", 1, 2)
		stop
		PLSS G 10
		STOP
		PLSS FEDCBA 1
		TNT1 A 4
		stop
		
	kickplasmatired:
		PL5I ONM 2 
		PL5I L 37 
		PL5I MNO 2 
		PLSI A 0 A_takeinventory("plasmatemperature",50)
		STOP	
	}
}



ACTOR PlasmaShock
{
	alpha 0.2
	height 1
	radius 1
	+thruactors
	+nogravity
		States
	{
	Spawn:
	TNT1 A 0
	PLSX ABCD 1 BRIGHT  A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	PLSX EFG 1 BRIGHT A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	TNT1 A 0 A_CustomMissile ("SHOCKsmokkspawner", 0, 0, random (70, 110), 2, 90)
	Stop
	}
}


ACTOR PlasmaShockBEEG : plasmashock {scale 1.7}
ACTOR PlasmaShocksmol : plasmashock {scale 0.3}
ACTOR PlasmaShockThin : plasmashock {xscale 2.0 yscale 0.1 speed 40 +missile}

ACTOR PlasmaExplosion
{
	height 1
	radius 1
	+thruactors
	+nogravity
	SCALE 0.6
		States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_JUMP(127,"VARIANT")
	PLSX AA 0 A_CustomMissile ("SHOCKsmokkspawner", 0, 0, random (70, 110), 2, 90)
	PLSX PQRS 1 BRIGHT A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	PLSX TUVW 1 BRIGHT  A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	TNT1 A 7
	TNT1 A 0 A_SpawnItem("PLASMASHOCKsmol")
	TNT1 A 0 A_JUMP(127,"moreshock")
	Stop
	
	VARIANT:
	TNT1 AA 0 A_CustomMissile ("SHOCKsmokkspawner", 0, 0, random (70, 110), 2, 90)
	PLSX HIJK 1 BRIGHT A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	PLSX LMNO 1 BRIGHT A_CustomMissile ("BluePlasmaParticle", 0, 0, random (0, 360), 2, random (0, 360))
	TNT1 A 2
	TNT1 A 0 A_SpawnItem("PLASMASHOCKsmol")
	TNT1 A 0 A_JUMP(127,"moreshock")
	stop
	
	moreshock:
	TNT1 A 2
	TNT1 A 0 A_JUMP(127,2)
	TNT1 A 4
	TNT1 A 0 A_JUMP(127,2)
	TNT1 A 4
	TNT1 A 0 A_JUMP(127,2)
	TNT1 A 4
	TNT1 A 0 A_SpawnItem("PLASMASHOCKsmol")
	TNT1 A 0 A_JUMP(100,"moreshock")
	stop
	
	}
}

ACTOR PLASMATEMPERATURE : Inventory { Inventory.MaxAmount 500 }

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:
	    PLSI A 0
		PLSI A 0 A_GiveInventory("AmmoCell", 50)
		Stop
}}