/*

==BFUG==
During your long string of constant battles in hell,
the first two weapons to break down were your BFG9000
and that weird boney gun you found before you wasted
that nasty mother demon. They splattered more monsters
than you could possibly count, but you were still
pretty upset when you lost them.

Thankfully the strange guy who geared you up took
what was left of those two guns and combined them into
this monstrosity you have before you. The Beam Fusion
Unmaker Gun, or BFUG, works like both of the guns 
in sequence: First it fires out five lines of lasers 
in a rapid fire spread before charging up and firing 
out a huge energy ball that lays waste to anything 
dumb enough to still be in the room after you pulled 
the trigger!

It seems to work the same way as your bomb caster
too: Just laying the smackdown on monsters seems
to charge it. Suits you just fine, you were
planning on doing that anyway.
*/

Actor UnmakerBeam : FastProjectile
{
	+notimefreeze
	projectile
    +dontblast
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+NODAMAGETHRUST
	+thruspecies
	+DONTREFLECT
	+HITTRACER
	+Bright
	species "friendly"
	radius 6
	height 8
	speed 120
	damage (30)
    missileheight 8
	missiletype "UnmakerBeamTrail"
	Scale 0.50
	Renderstyle Add
	alpha 0.95
	
	DamageType "BFUG"
	states
	{
	Spawn:
		UNM1 AB 1
		loop
	Death:
		UNM1 CDE 2
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0 A_SetScale (0.80)
		TNT1 A 0 A_PlaySound ("DoomSlayer/zerkhit2",0)
		TNT1 A 0 A_GiveToTarget ("BombCasterCharge", Random(0,1))
		UNM2 ABCDEF 2
		stop
	}
}

actor UnmakerBeamTrail
{
	projectile
	+notimefreeze
	+nointeraction
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+DONTBLAST
	+Bright
	radius 2
	speed 50
    Scale 0.50
	renderstyle add
	alpha 0.40
	states
	{
	Spawn:
		TNT1 A 0
		UNM1 A 1
		UNM1 B 1 A_SetScale (0.40)
		UNM1 A 1 A_SetScale (0.30)
		Stop
	death:
		TNT1 A 0 
		TNT1 A 1 
		stop
	}
}

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

Actor BFUGBall
{
	Radius 13
	Height 8
	Speed 30
	Damage 100
	Projectile
	+thruspecies
	+bloodlessimpact
	species "Friendly"
	+bright
	+EXTREMEDEATH
	+HITTRACER
	Scale 0.80
    Decal BFGScorch

	DamageType "BFUG"
	States
	{
	Spawn:
		FUG1 A 2 A_SpawnItemEx ("BFUGTrail",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		FUG1 B 2 A_SpawnItemEx ("BFUGTrail",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)	
		FUG1 C 2 A_SpawnItemEx ("BFUGTrail",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)	
		FUG1 D 2 A_SpawnItemEx ("BFUGTrail",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)	
		Loop
	Death:
		TNT1 A 0
		FUG1 EFGHH 2
		FUG1 IJ 2 A_SetTranslucent (0.50,1)
		TNT1 A 0 A_PlaySound ("DoomSlayer/BFUGHit",0,1,0,0.40)
		FUG1 K 3 A_BFGSpray ("FugRay",40,15)
		FUG1 LMNOP 3
		stop
	Xdeath:
		TNT1 A 0
		TNT1 AAA 0 A_GiveInventory ("BombCasterCharge",1, AAPTR_TARGET)
		FUG1 EFGHH 2
		FUG1 IJ 2 A_SetTranslucent (0.50,1)
		TNT1 A 0 A_PlaySound ("DoomSlayer/BFUGHit",0,1,0,0.40)
		FUG1 K 3 A_BFGSpray ("FugRay",40,15)
		FUG1 LMNOP 3
		stop
		
	}
}

actor BFUGTrail
{
	Radius 4
	Height 4
	RenderStyle add
	Alpha 0.90
	+NOGRAVITY
	+NOINTERACTION
	+FORCEXYBILLBOARD
	scale 0.75
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 2
	SpawnLoop:
		TNT1 A 0
		FUG1 A 1 A_SetScale (scalex - frandom(0.06,0.08))
		FUG1 B 1 A_FadeTo (0, frandom(0.08,0.10), 1)
		FUG1 C 1 A_FadeTo (0, frandom(0.08,0.10), 1)
		FUG1 D 1 A_FadeTo (0, frandom(0.08,0.10), 1)
		loop
	}
}


actor FugRay : BFGExtra
{
	species "Friendly"
	+Noextremedeath
	+Mthruspecies
	+bright
	+PUFFGETSOWNER
	Renderstyle translucent
	alpha 0.40
	scale 0.60

	DamageType "BFUG"
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_FaceTarget
		TNT1 A 0 A_SpawnItemEx ("FugRing")
		TNT1 A 0 A_GiveInventory ("BombCasterCharge",Random(0,1), AAPTR_TARGET)
		FUG1 IJ 3
		FUG1 K 3 A_PlaySound ("DoomSlayer/BFUGHit",0,1,0,0.90)
		FUG1 LMNOP 3
		FUG1 P 1 A_FadeOut (0.90)
		wait
	}
}

actor FugRing
{
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	RenderStyle add
	Alpha 0.50
	Scale 0.50
	States
	{
	spawn:
		FUG1 Q 1
		FUG1 Q 1 A_SetScale (0.60)
		FUG1 Q 1 A_SetScale (0.90)
		FUG1 Q 1 A_SetScale (1.20)
		FUG1 Q 1 A_SetScale (1.80)
	FadingOut:
		TNT1 A 0 A_SetScale (scalex + frandom(0.03,0.06))
		FUG1 Q 1 A_FadeOut (0.04)
		loop
	Death:
		TNT1 A 1
		stop
	}
}


//Tokens
actor BFGArmed : inventory
{inventory.maxamount 1}

actor UnmakerStack : inventory
{inventory.maxamount 10}
