ACTOR "Plasma Handgun" : Weapon
{
  Scale 0.85
  Weapon.PreferredSkin "Handgun-Marine"
  Weapon.SlotNumber 2
  Weapon.SelectionOrder 5000
  Weapon.KickBack 60
  Inventory.PickupSound "weapons/pickuptp"
  Inventory.Pickupmessage "Plasma Handgun"
  Weapon.AmmoGive 1
  Weapon.AmmoUse 4
  Weapon.AmmoType "PlasmaHGCell"
  Tag "Plasma Handgun"
  Obituary "%o caught one right between their CF deathmatch eyes." 
  +WEAPON.NOAUTOAIM
  +NOAUTOFIRE
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOALERT
  +INVENTORY.UNDROPPABLE
  States 
  {
  Select:
	TNT1 A 0 A_Raise
	Wait
  Ready:
	TNT1 A 0 A_PlayWeaponSound("PlasmaPistol/Draw")
	PLP8 ABCD 1
	TNT1 A 0 A_TakeInventory("PlasmaPistolDontRegenToken",1)
	TNT1 A 0 A_JumpIfInventory("PlasmaHGCell",5,2)
	TNT1 A 0 A_TakeInventory("PlasmaCharge",100)
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	PLP0 A 3 A_WeaponReady
	//TNT1 A 0 A_GiveInventory("PlasmaHGCell",2)
	Goto Ready+5
  Deselect:
	TNT1 A 0 A_TakeInventory("PlasmaCharge",100)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0 A_TakeInventory("RailgunAction",1)
	TNT1 A 0 A_TakeInventory("PlasmaPistolDontRegenToken",1)
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	TNT1 A 0 A_Lower
	PLP0 A 1 A_Lower
	Goto Deselect+6
  Fire:
	TNT1 A 0 A_JumpIfInventory("PlasmaHGCell",4,1)
	Goto Ready+5
	TNT1 A 0 A_StopSound(7)
	TNT1 A 0 A_PlaySound("weapons/PHGFire",1)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 Radius_Quake(1,2,0,1,0)
	TNT1 A 0 A_GiveInventory("PlasmaPistolDontRegenToken",1)
	TNT1 A 0 A_FireCustomMissile("PHGProjectile",Random(-8,8)*0.1,5,0,8,0,Random(-4,4)*0.1)
  FireReady:
	TNT1 A 0 A_GunFlash
	PLP0 B 2 Bright
	TNT1 A 0 A_Light0
	PLP0 C 2 Bright
	PLP0 DEFG 2 A_WeaponReady
	PLP0 H 1 A_TakeInventory("PlasmaPistolDontRegenToken",1)
	Goto Ready+5
  AltFire:
	TNT1 A 0 A_JumpIfInventory("PlasmaHGCell",40,"AltHold")
	Goto Ready+5
  AltHold:
	TNT1 A 0 A_GiveInventory("PlasmaPistolDontRegenToken",1)
	TNT1 A 0 A_JumpIfInventory("PlasmaCharge",1,7)
	TNT1 A 0 A_PlaySound("weapons/PHGCharge",7)
	PLP9 ABCDE 2
	TNT1 A 0 A_JumpIfInventory("PlasmaCharge",100,6)
	PLP9 F 1 A_GiveInventory("PlasmaCharge",3)
	TNT1 A 0 A_ReFire
	TNT1 A 0 A_StopSound(CHAN_WEAPON)
	TNT1 A 0 A_TakeInventory("PlasmaCharge",100)
	TNT1 A 0 A_TakeInventory("PlasmaHGCell",4)
	Goto Fire
	TNT1 A 0 A_PlaySound("weapons/PHGIdle",1,1.0,1)
	PLP9 FGHI 1 Bright
	TNT1 A 0 A_ReFire
	TNT1 A 0 A_StopSound(CHAN_WEAPON)
	TNT1 A 0 A_TakeInventory("PlasmaCharge",100)
	TNT1 A 0 A_TakeInventory("PlasmaHGCell",40)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 Radius_Quake(1,2,0,1,0)
	TNT1 A 0 Bright A_FireCustomMissile("PlasmaFireBall",Random(-8,8)*0.1,1,0,8,0,Random(-4,4)*0.1)
  FireReady2:
	TNT1 A 0 A_PlaySound("PlasmaPistol/Chargeshot",1)
	PLP9 JJKK 1 Bright
	PLP9 LMNOP 2
	PLP0 A 1 A_TakeInventory("PlasmaPistolDontRegenToken",1)
	Goto Ready+5
  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto Ready+5
  GrenadeToss:
	TNT1 A 0 A_GunFlash
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	PLP8 DCBA 1
	TNT1 A 0 A_Light0
	TNT1 A 4
	HGRN ABC 1
	HGRN D 2
	HGRN EFG 1
	HGRN HI 2
	TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN J 1
	HGRN KLM 2
	HGRN NO 1
	TNT1 A 6
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0
	Goto Ready+1
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto Ready+5
  MineToss:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	PLP8 DCBA 1
	TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1
	TNT1 A 0 A_TakeInventory("MineAmmo",1)
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	MINE HI 1
	MINE JK 2
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Land Mine",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0
	TNT1 A 5
	Goto Ready+1
  Spawn:
	PLSP A -1
	Stop
	}
}
ACTOR PlasmaHGCell : Ammo 
{
  Inventory.Amount 100
  Inventory.MaxAmount 100
  Ammo.BackpackAmount 100
  Ammo.BackpackMaxAmount 100
  Inventory.Icon "PLSPA0"
  +IGNORESKILL
}
ACTOR PlasmaFireBall 
{
  Radius 12
  Height 12
  Speed 100
  Damage (random(9,12)*10)
  Scale 0.6
  Projectile
  Renderstyle Add
  Species "Player"
  DamageType "PlasmaClass"
  +THRUSPECIES
  +DONTHURTSPECIES
  SeeSound "monsters/newfireshoot"
  DeathSound "monsters/newfireexplode"
  Decal DoomImpScorch
  States 
  {
  Spawn:
	PLST AABB 1 Bright A_SpawnItemEx("PlasmaFireBallTrail",0,0,0,0,0,0,0,128,0)
	Loop
  Death:
	TNT1 A 0 A_Explode((random(7,10)*15),64)
	TNT1 A 0 A_JumpIf(CallAcs("LCAEffectCheck"),"Toaster")
	TNT1 A 0 A_SpawnItemEx("BlueParticleSpawner",0,0,0,0,0,0,0,128)
	TNT1 AAA 0 A_CustomMissile("Kaboom6",0,0,random(0,360),2,random(0,360))
	TNT1 A 0 A_SpawnItem("PlasmaEx")
	TNT1 AAA 0 A_CustomMissile("SmokeFX4",0,0,random(0,360),2,random(0,360))
	PLST CDE 3 Bright
	Stop
  Toaster:
	TNT1 A 1 A_SpawnItem("PlasmaEx")
	Stop
	}
}

ACTOR PlasmaFireBallTrail : BFG9500Trail 
{
  Scale 0.5
  States 
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallAcs("LCAEffectCheck"),"Toaster")
	PLST AABB 1 A_FadeOut(0.12)
	Goto Spawn+2
	}
}
Actor PlasmaCharge : Inventory { Inventory.MaxAmount 100 }
Actor PHGProjectile : FastProjectile 
{
  Scale 0.1
  Height 1
  Radius 1
  Speed 200
  DamageType "Plasma"
  Species "Player"
  Renderstyle ADD
  Damage (random(9,12)*2)
  +FORCEXYBILLBOARD
  +DONTSPLASH
  +BloodSplatter
  +THRUSPECIES
  Decal DoomImpScorch
  States 
  {
  Spawn:
	TRA4 A 1 BRIGHT 
	Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("BlueParticleSpawner",0,0,0,0,0,0,0,128)
	TNT1 AAA 0 A_CustomMissile("Kaboom6", 0, 0, random(0,360), 2, random(0,360))
	TNT1 A 1 A_SpawnItem("PlasmaEx")
	Stop
  XDeath:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("BlueParticleSpawner",0,0,0,0,0,0,0,128)
	TNT1 AAA 0 A_CustomMissile("Kaboom6", 0, 0, random(0,360), 2, random(0,360))
	TNT1 A 1 A_SpawnItem("PlasmaEx")
	Stop
	}
}
Actor PlasmaPistolDontRegenToken : Inventory { Inventory.MaxAmount 1 }