actor BusterRifle : Weapon Replaces PlasmaRifle
{
	Weapon.SelectionOrder 30
	Weapon.AmmoUse 0
	Weapon.Ammouse2 0
	Weapon.AmmoGive 50
	Weapon.AmmoType "Cell"
	Weapon.AmmoType2 "Cell"
	Weapon.SlotNumber 6
	+weapon.noautofire
	+WEAPON.ALT_AMMO_OPTIONAL
	+noalert
	Inventory.PickupMessage "You got the Buster Rifle!"
	Tag "Buster Rifle"
	States
	{
	Spawn:
		PLZM E -1
		Stop
	Ready:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("rocketmode", 1, "rocketready")
		TNT1 A 0 a_jumpifinventory ("railgunmode", 1, "railgunready")
		BRIF A 1 A_WeaponReady
		Loop
	railgunready:
		BRRG A 1 a_weaponready
		loop
	rocketready:
		BRRL A 1 a_weaponready
		loop
	Deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_playsound ("buster/holster",0)
	holster:
		TNT1 A 0
		BRIF A 1 A_Lower
		TNT1 AA 0 A_Lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		Loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait
	Select:
		TNT1 A 0
		TNT1 A 0 a_playsound ("buster/draw", 0)
	draw:
		TNT1 A 0
		BRIF AAAA 0 A_Raise
		BRIF A 1 A_Raise
		Loop
	Fire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("rocketmode", 1, "plasmarocketshot")
		TNT1 A 0 a_jumpifinventory ("railgunmode", 1, "railgunshot")
		TNT1 A 0 a_jumpifinventory ("cell", 1, "realfire")
		BRIF A 1 offset (0,35)
		BRIF A 1 offset (0,40) a_playsound ("buster/dryfire",0) 
		BRIF A 1 offset (0,35)
		goto ready
	realfire:
		TNT1 A 0
		BRIF A 0 Bright A_GunFlash
		TNT1 A 0 a_alertmonsters
		PLZM A 0 Bright A_TakeInventory("Cell", 1)
		PLZM A 0 A_FireCustomMissile("FuzzyPlasma",0,0,0,0)
		BRFI A 1 Bright
		BRIF A 0 A_PlaySound("fuzzy/plasma",1)
		BRFI B 1 Bright
		BRFI C 1 Bright
		TNT1 A 0 a_refire		
		BRFI A 1 Bright a_weaponready
		Goto ready
	Railgunshot: 
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("cell", 5, "realrailshot")
		BRRG A 1 offset (0,35)
		BRRG A 1 offset (0,40) a_playsound ("buster/dryfire",0) 
		BRRG A 1 offset (0,35)
		goto ready
	Realrailshot:
		TNT1 A 0
		TNT1 A 0 a_alertmonsters
		TNT1 A 0 A_GunFlash
		PLZM A 0 Bright A_TakeInventory("Cell", 5)
		TNT1 A 0 a_playsound ("buster/railshot",0)
		BRIF A 0 bright a_firecustommissile ("railshot")
		BRHA A 1 Bright A_Quake(1, 5, 0, 32)
		BRHA BC 2 bright
		BRHA C 8
		BRHA D 2
		TNT1 A 0 a_playsound ("buster/pin",0)
		TNT1 A 0 a_playsound ("buster/pinback",0)
		BRCD AB 2
		BRFI C 5
		TNT1 A 0 a_playsound ("buster/pin",0)
		TNT1 A 0 a_playsound ("buster/pinforward",0)
		BRCD BA 2
		BRRG A 1
		goto ready
	PlasmaRocketShot:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("cell", 15, "realrocketshot")
		BRRL A 1 offset (0,35)
		BRRL A 1 offset (0,40) a_playsound ("buster/dryfire",0) 
		BRRL A 1 offset (0,35)
		goto ready
	realrocketshot:
		TNT1 A 0
		TNT1 A 0 a_alertmonsters
		PLZM A 0 Bright A_TakeInventory("Cell", 15)
		PLZM A 0 Bright A_FireCustomMissile ("plasmamissile")
		PLZM A 0 Bright a_playsound ("buster/rocket",0)
		TNT1 A 0 a_recoil (5)
		TNT1 A 0 radius_quake (2,10,0,5,0)
		BRMA A 3 Bright 
		BRMA B 8 Bright 
		BRMA CD 6 Bright
		BRMA E 4 bright
		TNT1 A 0 a_playsound ("buster/pin",0)
		TNT1 A 0 a_playsound ("buster/pinback",0)
		BRCD CD 3 
		BRFI C 8
		TNT1 A 0 a_playsound ("buster/pin",0)
		TNT1 A 0 a_playsound ("buster/pinforward",0)
		BRCD DC 2
		BRRL A 1
		Goto Ready
	Flash:
		TNT1 A 2 Bright A_Light(3)
		TNT1 A 2 Bright A_Light2
		TNT1 A 2 Bright A_Light1
		Goto LightDone
	altfire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("rocketmode", 1, "backtoplasma")
		TNT1 A 0 a_jumpifinventory ("railgunmode", 1, "rocketswitch")
		TNT1 A 0 a_playsound ("buster/pin",0)
		BRIF B 1 a_weaponready (WRF_NOFIRE)
		BRIF C 1 a_weaponready (WRF_NOFIRE)
		TNT1 A 0 a_giveinventory ("railgunmode", 1)
		BRRG A 1 a_weaponready (WRF_NOFIRE)
		goto ready
	rocketswitch:
		TNT1 A 0
		TNT1 A 0 a_playsound ("buster/pin",0)		
		TNT1 A 0 a_takeinventory ("railgunmode", 99)
		BRRG B 1 a_weaponready (WRF_NOFIRE)
		BRRG C 1 a_weaponready (WRF_NOFIRE)
		TNT1 A 0 a_giveinventory ("rocketmode", 1)
		BRRL A 1 a_weaponready (WRF_NOFIRE)
		goto ready
	backtoplasma:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("rocketmode", 99)
		BRRL A 1 a_weaponready (WRF_NOFIRE)
		TNT1 A 0 a_playsound ("buster/pin",0)		
		BRRG CBA 1 a_weaponready (WRF_NOFIRE)
		TNT1 A 0 a_playsound ("buster/pin",0)		
		BRIF CBA 1 a_weaponready (WRF_NOFIRE)
		BRIF A 1 a_weaponready (WRF_NOFIRE)
		goto ready
	}
}


actor FuzzyPlasma // edited from Doom's standard plasmaball actor
{
  Radius 13
  Height 8
  Speed 40
  Damage 4
  Decal DoomImpScorch
  Projectile
  species "Player"
  +thruspecies
  +RANDOMIZE
  RenderStyle Add
  Alpha 0.65
  SeeSound ""
  DeathSound "fuzzy/pdeath"
  Obituary "%o was left decayed by %k's Plasmatic Rifle"
  States
  {
	Spawn:
		AMB1 A 0
		AMB1 A 0 A_SpawnItemEx("FuzzyPlasmaTrail")
		AMB1 A 1 bright
		AMB1 A 0 A_SpawnItemEx("FuzzyPlasmaTrail")
		AMB1 B 1 bright
		AMB1 A 0 A_SpawnItemEx("FuzzyPlasmaTrail")
		AMB1 C 1 bright
		loop
	Death:
		PLZM H 0
		PLZM HIJKL 3 bright
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0 a_jumpifintargetinventory ("daibatana", 1, "givecharge")
		PLZM HIJKL 3 bright
		stop
	givecharge:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_jump (60, "nothing")
		TNT1 A 0 a_giveinventory ("batcharge", 2, AAPTR_TARGET)
		PLZM HIJKL 3 bright
		stop
	nothing:
		TNT1 A 0
		PLZM HIJKL 3 bright
		Stop
	}
}

ACTOR FuzzyPlasmaTrail
{
	RenderStyle Translucent
	Alpha 0.80
	Scale 0.5
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
		AMB1 A 0
		AMB1 A 1 A_SetTranslucent(0.70, 1)
		AMB1 B 1 A_SetTranslucent(0.65, 1)
		AMB1 C 1 A_SetTranslucent(0.60, 1)
		AMB1 A 1 A_SetTranslucent(0.55, 1)
		AMB1 B 1 A_SetTranslucent(0.50, 1)
		AMB1 C 1 A_SetTranslucent(0.45, 1)
		Stop
	}
}

actor railshot : fastprojectile
{
	+notimefreeze
	+ripper
	projectile
    +FORCEXYBILLBOARD	
	RenderStyle Add
	species "player"
	missiletype "railshottrail"
    missileheight 12
	Decal DoomImpScorch
	+thruspecies
	+RANDOMIZE
	height 12
	radius 14
	speed 300
	damage (40)
    Scale 1
	alpha 0.95
	states
	{
	spawn:
		AMB1 A 0
		AMB1 A 0 A_SpawnItemEx("railshottrail")
		AMB1 A 1 bright
		AMB1 A 0 A_SpawnItemEx("railshottrail")
		AMB1 B 1 bright
		AMB1 A 0 A_SpawnItemEx("railshottrail")
		AMB1 C 1 bright
		loop
	Death:
		PLZM H 0
		PLZM HIJKL 3 bright
		stop
	}
}

actor railshottrail
{
	RenderStyle add
	Alpha 0.95
	Scale 0.7
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
		AMB1 A 0
		AMB1 A 2 A_SetTranslucent(0.70, 1)
		AMB1 B 2 A_SetTranslucent(0.65, 1)
		AMB1 C 2 A_SetTranslucent(0.60, 1)
		AMB1 A 2 A_SetTranslucent(0.55, 1)
		AMB1 B 2 A_SetTranslucent(0.50, 1)
		AMB1 C 2 A_SetTranslucent(0.45, 1)
		AMB1 A 2 A_SetTranslucent(0.40, 1)
		AMB1 B 2 A_SetTranslucent(0.35, 1)
		AMB1 C 2 A_SetTranslucent(0.20, 1)
		AMB1 A 2 A_SetTranslucent(0.15, 1)
		AMB1 B 2 A_SetTranslucent(0.10, 1)
		AMB1 C 2 A_SetTranslucent(0.05, 1)
		Stop
	}
}	
			
actor plasmamissile 
{
	+notimefreeze
	projectile
    +FORCEXYBILLBOARD	
	alpha 0.50
	RenderStyle Add
	species "player"
    decal scorch
	+thruspecies
	+RANDOMIZE
	radius 14
	speed 45
	damage 50
    Scale 1
	alpha 0.95
	deathsound "buster/explosion"
	states
	{
	spawn:
		PMSL A 1 a_spawnitem ("fuzzyplasmatrail")
		loop
	Death:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAAAA 0 a_spawnitemex ("POWbreakage",random(-8,8),random(-8,8),random(-8,8),random(-80,80)/20.0,random(-80,80)/20.0,random(-80,80)/20.0,0,160)
		TNT1 A 0 a_spawnitemex ("plasmaring")
		PMSL B 5 Bright A_Explode (180, 258, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAA 0 a_spawnitemex ("POWbreakage",random(-8,8),random(-8,8),random(-8,8),random(-80,80)/20.0,random(-80,80)/20.0,random(-80,80)/20.0,0,160)
		TNT1 A 0 a_spawnitemex ("plasmabang")
		PMSL C 3 Bright
		PMSL D 2 Bright
		Stop
	}
}		

actor plasmaring
{
	RenderStyle add
	Alpha 0.50
	Scale 3
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:
		PSMH ABC 4
		stop
	death:
		TNT1 A 2
		stop
	}
}

actor plasmabang
{
	RenderStyle add
	Alpha 0.60
	Scale 1
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:
		PSMH DEFGH 2
		stop
	death:
		TNT1 A 2
		stop
	}
}


		
actor railgunmode : inventory
{inventory.maxamount 1}

actor rocketmode : inventory
{inventory.maxamount 1}