// Plasma Gun
ACTOR PlasmaGun : AOWWeapon replaces PlasmaRifle 21087 {
	//$Category Weapons
	tag "Plasma Gun"
	Inventory.PickupMessage "You got the plasma gun!"
	Obituary "$OB_PLASMARIFLE"
	Weapon.AmmoType "PlasmaRifleAmmo"
	Weapon.AmmoGive 25
	Weapon.AmmoUse 1
	Weapon.AmmoType2 "PlasmaHeat"
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.Kickback 25
	Weapon.SelectionOrder 5
	Weapon.PreferredSkin "MarinePlasma"
	States  { 
	Spawn:
		PLAS A -1
		stop
	Ready: 
		ENRG A 0 A_JumpIfInventory("IsBlue",1,"ReadyBlue")
		ENRG A 3 A_WeaponReady
		ENRG A 0 A_TakeInventory("PlasmaHeat",2)
		ENRG A 3 A_WeaponReady
		ENRG A 0 A_TakeInventory("PlasmaHeat",2)
		ENRG A 3 A_WeaponReady
		ENRG A 0 A_TakeInventory("PlasmaHeat",2)
		ENRG A 3 A_WeaponReady
		ENRG A 0 A_TakeInventory("PlasmaHeat",2)
		Goto WarningRemove
	ReadyBlue:
		ENBG A 3 A_WeaponReady
		ENBG A 0 A_TakeInventory("PlasmaHeat",2)
		ENBG A 3 A_WeaponReady
		ENBG A 0 A_TakeInventory("PlasmaHeat",2)
		ENBG A 3 A_WeaponReady
		ENBG A 0 A_TakeInventory("PlasmaHeat",2)
		ENBG A 3 A_WeaponReady
		ENBG A 0 A_TakeInventory("PlasmaHeat",2)
		Goto WarningRemove
	Deselect:
		ENRG A 0 A_JumpIfInventory("IsBlue",1,"DeselectBlue")
		ENRG A 1 A_Lower 
		loop
	DeselectBlue:
		ENBG A 1 A_Lower
		loop
	Select:
		ENRG A 0 A_JumpIfInventory("IsBlue",1,"SelectBlue")
		ENRG A 1 A_Raise 
		loop
	SelectBlue:
		ENBG A 1 A_Raise
		loop
	Fire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		ENRG A 0 A_JumpIfInventory("PlasmaHeat",100,"Overheat")
		ENRG A 0 A_JumpIfInventory("IsBlue",1,"FireBlue")
		ENRG A 1 A_GunFlash
		ENRG A 0 A_PlaySound ("Weapons/PlasmaShot", CHAN_WEAPON)
		ENRG A 1 Offset(1,35) A_FireCustomMissile("PlasmaShotRed",0,1,2,0)
		ENRG A 1 Offset(0,37) A_GiveInventory("PlasmaHeat",random(0,3))
		ENRG A 0 A_JumpIfInventory("PlasmaHeat",75,"Warning")
		ENRG A 1 A_Refire
		Goto Ready
	FireBlue:
		ENBG A 1 A_GunFlash
		ENBG A 0 A_PlaySound ("Weapons/PlasmaShot", CHAN_WEAPON)
		ENBG A 1 Offset(1,35) A_FireCustomMissile("PlasmaShotBlue",0,1,2,0)
		ENBG A 1 Offset(0,37) A_GiveInventory("PlasmaHeat",random(0,3))
		ENBG A 0 A_JumpIfInventory("PlasmaHeat",75,"Warning")
		ENBG A 1 A_Refire
		Goto Ready
	Overheat:
		ENRG A 0 A_PlaySound ("Plasma/FailFire", 6)
		ENRG A 0 A_PlaySound ("Plasma/Vapour", 7)
		ENRG A 0 A_JumpIfInventory("IsBlue",1,"OverheatBlue")
		ENRG AAAAAAA 2 A_FireCustomMissile("OverheatSmokeSpawner",0,0,6,-2)
		ENRG AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3 A_TakeInventory("PlasmaHeat",2)
		Goto WarningRemove
	OverheatBlue:
		ENBG AAAAAAA 2 A_FireCustomMissile("OverheatSmokeSpawner",0,0,6,-2)
		ENBG AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3 A_TakeInventory("PlasmaHeat",2)
		Goto WarningRemove
	WarningRemove:
		ENRG A 0 A_TakeInventory("WarningChecker", 1)
		goto Ready
	Flash: 
		RPRL B 0 A_JumpIfInventory ("IsRed", 1, "Flash.Red")
		ENRF A 2 bright A_Light1
		ENRF B 1 bright A_Light2
		ENRF C 1 bright A_Light1
		ENRF C 0 A_Light0
		Stop
	Flash.Red:
		ENRR A 2 bright A_Light1
		ENRR B 1 bright A_Light2
		ENRR C 1 bright A_Light1
		ENRR C 0 A_Light0
		Stop
	Warning:
		ENRG A 0
		ENRG AA 0 A_JumpIfInventory("WarningChecker",1,"Ready")
		ENRG A 0 A_PlaySoundEx("Plasma/Warning","Voice",0)
		ENRG A 0 A_GiveInventory("WarningChecker",1)
		Goto Ready
	}
}

actor PlasmaShotBlue {
	PROJECTILE
	-RANDOMIZE
	Radius 12
	Height 8
	Scale 0.8
	Speed 28
	Damage (15)
	RenderStyle Add
	Alpha 0.75
	Translation "224:247=192:207"
	DeathSound "weapons/plasmax"
	DamageType "Energy"
	Decal PulseScorch
	Obituary "$OB_PLASMARIFLE"
	States {
	Spawn:
		PLSB A -1 Bright
		stop
	Death:
		PLSE A 0 A_SpawnItemEx ("PulseBallSmokePuff", 0,0,0, 0,0,1)
		PLSE ABCDE 3 Bright
		stop
	}
}

Actor PlasmaShotRed : PlasmaShotBlue {
	Translation "192:207=224:246"
	States {
		PLSR A -1 Bright
		stop
	}
}

actor PlasmaHeat : Ammo {
	+IGNORESKILL
	inventory.amount 0
	inventory.maxamount 100
	ammo.backpackamount 0
	ammo.backpackmaxamount 100
	states {
	Spawn:
		TNT1 A 0
		stop
	}
}

actor WarningChecker : Inventory {}

ACTOR OverheatSmokeSpawner {
	PROJECTILE
	+CLIENTSIDEONLY
	speed 25
	States {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("PulseBallSmokePuff",0,0,-2,0,0,0.1*Random(0,10))
		Stop
	}
}