/*

===PARTICLE LANCE===

Plasma repeater with a two stage trigger
system. A light squeeze discharges a ten
shot burst of plasma bolts. A longer pull
of the trigger charges the capacitor and
activates the plasmatic lance, short range
but is capable of cutting through nearly 
anything.

Be aware of cell consumption when firing.

*/


actor DeriverPlasma : Buran 
{
	Weapon.SlotNumber 3
	Weapon.SelectionOrder 100
	Weapon.AmmoType "Cell"
	Weapon.AmmoUse1 1
	Weapon.AmmoGive 40
	Weapon.BobStyle smooth
	Weapon.BobRangeX 0.3
	Weapon.BobRangeY 0.4
	Weapon.BobSpeed 1
	Inventory.PickupMessage "Particle Lance."
	Inventory.PickupSound "DVPlasma/Pickup"
	Obituary "%o was blitzed by %k."
	Tag "Particle Lance"
	States
	{
	Ready:
		DVP1 AB 1 A_WeaponReady
		TNT1 A 0 A_PlaySound ("DVPlasma/Equip",0,0.80)
		TNT1 A 0 A_TakeInventory ("PlasmaStack",9999)
		DVP1 CDEE 2 A_WeaponReady
		TNT1 A 0 A_PlaySound ("DVPlasma/Deploy",0)
		DVP1 FGH 2 A_WeaponReady
		Goto RealReady
	Deselect:
		TNT1 A 0
		TNT1 A 0 A_StopSound (6)
		TNT1 A 0 A_TakeInventory ("PlasmaStack",9999)
		TNT1 A 0 A_JumpIfHealthLower (1, "DeadLower")
		TNT1 A 0 A_StopSound (6)
		TNT1 A 0 A_PlaySound ("DVPlasma/Retract",0)
		TNT1 A 0 A_TakeInventory ("PlasmaStack",9999)
		DVP6 AB 1
		TNT1 A 0 A_PlaySound ("DVPlasma/Holster",0,0.80)
		DVP6 CD 1
		Goto Holster
	RealReady:
		DVP2 A 1 A_WeaponReady
		Wait
	DryFire:
		TNT1 A 0 A_PlaySound ("DShotgun/DryFire",0)
		DVP5 AB 2 A_WeaponReady (WRF_NOPRIMARY)
		DVP2 A 20 A_WeaponReady (WRF_NOPRIMARY)
		Goto RealReady
	Fire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfNoAmmo ("DryFire")
		DVP5 A 2 A_PlaySound ("DVPlasma/Trigger",0)
	ChargeLoop:
		DVP2 A 1
		TNT1 A 0 A_GiveInventory ("PlasmaStack",1)
		TNT1 A 0 A_JumpIfInventory ("PlasmaStack", 15, "BeamWindUp")
		TNT1 A 0 A_GunFlash ("ChargeSoundOverlay",GFF_NOEXTCHANGE)
		TNT1 A 0 A_Refire ("ChargeLoop")
		TNT1 A 0 A_StopSound (5)
		DVP7 FED 1 A_TakeInventory ("PlasmaStack",9999)
		DVP2 B 1 Bright
	BoltBurst:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory ("UsingDeriverGun",1)
		DVP2 C 1 Bright
		TNT1 A 0 A_PlaySound ("DVPlasma/Fire",6)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Quake(1, 5, 0, 32)
		DVP2 D 1 Bright A_FireCustomMissile ("DeriverPlasmaBolt",0,1)
		TNT1 A 0 A_GiveInventory ("PlasmaStack",1)
		TNT1 A 0 A_JumpIfInventory ("PlasmaStack", 10, "ShootFinish")
		TNT1 A 0 A_JumpIfNoAmmo ("ShootFinish")
		Loop
	



	//----------------------------------------------------------------------
	//Lance beam
	//----------------------------------------------------------------------
	ChargeSoundOverlay:
		TNT1 A 0
		TNT1 A 1 A_JumpIfInventory ("PlasmaStack",4, "PlaySound")
		Stop
	PlaySound:
		TNT1 A 0
		TNT1 A 1 A_PlaySound ("DVPlasma/ChargeUp",5)
		Stop
	
	BeamWindUp:
		DVP7 ABCD 2 A_WeaponReady (WRF_NOPRIMARY)
		DVP7 ABCD 1 A_WeaponReady (WRF_NOPRIMARY)
		TNT1 A 0 A_PlaySound ("DVPlasma/BeamStart",5,0.80)
		DVP7 G 1 Bright A_FireCustomMissile ("DeriverRingBlast",0,0,0,7)
		TNT1 A 0 A_PlaySound ("DVPlasma/BeamLoop",6,0.30,1)
	BeamLoop:
		TNT1 A 0
		TNT1 A 0 A_RailAttack (0, -8, 0, "None", "Orange", RGF_SILENT | RGF_FULLBRIGHT, 20, "DVHarmlessPuff",3,2, 328+random(0,84), 5, 0.2, 0.0, "OrangeLightning", 0)
		TNT1 A 0 A_RailAttack (0, 8, 0, "None", "Orange", RGF_SILENT | RGF_FULLBRIGHT, 20, "DVHarmlessPuff", 3,2, 328+random(0,84), 5, 0.2, 0.0, "OrangeLightning", 0)
		TNT1 A 0 A_RailAttack (0, 0, 0, "None", "Orange", RGF_SILENT | RGF_FULLBRIGHT, 20, "DVHarmlessPuff", 3,2, 328+random(0,84), 5, 0.2, 0.0, "OrangeLightning", 0)
		TNT1 A 0 A_FireCustomMissile ("SideLanceBeam",0,0,-8)
		TNT1 A 0 A_FireCustomMissile ("SideLanceBeam",0,0,8)
		TNT1 A 0 A_Quake(2, 3, 0, 32)
		DVP7 HI 1 Bright A_FireCustomMissile ("LanceBeam",0,1)
		TNT1 A 0 A_JumpIfNoAmmo ("BeamFinish")
		TNT1 A 0 A_Refire ("BeamLoop")
		Goto BeamFinish
	BeamFinish:
		DVP7 I 2 A_PlaySound ("DVPlasma/BeamFinish",6)
		DVP7 JKLM 3
		Goto ShootFinish+3
	SteamVent:
		TNT1 A 0 A_PlaySound ("DVPlasma/Vent",0,0.60)
		DVP4 ABCD 2 
		stop
		
	//Used for both attack types
	ShootFinish:
		TNT1 A 0 A_TakeInventory ("PlasmaStack",9999)
		DVP2 EFGG 2 A_Weaponready (WRF_NOPRIMARY)
		TNT1 A 0 A_TakeInventory ("PlasmaStack",9999)
		DVP2 A 3 A_Weaponready 
		DVP3 A 2 A_Weaponready 
		TNT1 A 0 A_GunFlash ("SteamVent",GFF_NOEXTCHANGE)
		TNT1 A 0 A_PlaySound ("DVPlasma/Retract",0)
		DVP3 B 2 A_Weaponready
		DVP3 C 5 A_Weaponready
		DVP3 D 3 A_Weaponready
		TNT1 A 0 A_PlaySound ("DVPlasma/Deploy",0)
		DVP3 E 2 A_Weaponready
		DVP3 F 3 A_Weaponready
		DVP2 A 2 A_Weaponready
		Goto RealReady
	
	
	Altfire:
		TNT1 A 0
		TNT1 A 2 A_StopSound (6)
		TNT1 A 0 A_Jump (256, "ParryStance")
		Goto AltfireEnd
	AltFireEnd:
		TNT1 A 0
		TNT1 A 2 A_WeaponReady
		Goto SilentReady
	SwordSheathe:
		TNT1 A 3 A_WeaponReady
		MGS6 AB 1 A_WeaponReady
		MGS6 CDEF 2 A_WeaponReady
		MGS6 G 1 A_WeaponReady
		TNT1 A 0 A_PlaySound ("MagSword/Sheathe1",0)
		MGS6 HI 1 A_WeaponReady
		TNT1 A 0 A_PlaySound ("MagSword/Sheathe2",0)
		MGS6 JJ 1 A_WeaponReady
		MGS6 KLKL 1 A_WeaponReady
		MGS6 L 3 A_WeaponReady
		MGS6 MRST 1 A_WeaponReady
		TNT1 A 1 A_WeaponReady
		Goto SilentReady
	SilentReady:
		DVP1 AB 1 A_WeaponReady
		DVP1 CDEE 2 A_WeaponReady
		//TNT1 A 0 A_PlaySound ("DVPlasma/Deploy",0)
		DVP1 FGH 2 A_WeaponReady
		Goto RealReady
	}
}


actor DeriverPlasmaBolt : Fastprojectile
{
	Radius 13
	Height 8
	Speed 90
	//Damage 5
	Damage (25)
	Projectile
	species "Player"
	+thruspecies
	+RANDOMIZE
	+bright
	RenderStyle add
	Alpha 0.80
	//SeeSound "weapons/plasmaf"
	//DeathSound "BMPlasgun/BlueHit"
	Decal DeriverBoltScorch
	ProjectileKickBack 10
	scale 0.80
	States
	{
	spawn:
		DPL4 A 6
	Flight:
		DPL1 ABCD 1
		loop
	death:
		DPL3 ABCD 2
		stop
	}
}



actor LanceBeam : FastProjectile
{
	+FORCEXYBILLBOARD
	+thruspecies
	+dontblast
	+bright
	Projectile
	damage (32)
	species "Friendly"
	speed 200
	height 12
	radius 12
	RenderStyle add
	Alpha 0.80
	Scale 0.80
	-BLOODSPLATTER
	+NOEXTREMEDEATH
	+HITTRACER
	//Decal ArtiDecal
	DamageType "CABladeBeam"
	Decal SaberDecal

    missileheight 8
	missiletype "LanceBeamTrail"
	ProjectileKickback 80
	states
	{
	Spawn:
		TNT1 AA 1
		Stop
	Crash:
	Death:
		TNT1 A 0
		TNT1 A 1
		DPL6 ABC 3
		TNT1 A 0 A_SetScale (2.50, 0.50)
		DPL6 D 3
		DPL6 E 2
		stop
	XDeath:
		TNT1 A 0
		TNT1 A 1
		//TNT1 A 0 A_JumpIfInventory ("HitTimer",1,"NoSound",AAPTR_TRACER)
		TNT1 A 0 A_PlaySound ("DVPlasma/BeamHit",6,0.40)
		DPL6 ABC 3
		TNT1 A 0 A_SetScale (2.50, 0.50)
		DPL6 D 3
		TNT1 A 0 A_SetScale (4, 0.25)
		DPL6 E 2
		stop
	NoSound:
		TNT1 A 0
		DPL3 BCD 2
		stop
	}
}

Actor SideLanceBeam : LanceBeam
{
	+PAINLESS
	ProjectileKickback 1
	states
	{
	XDeath:
		TNT1 A 0
		TNT1 A 1
		//TNT1 A 0 A_JumpIfInventory ("HitTimer",1,"NoSound",AAPTR_TRACER)
		DPL6 ABC 3
		TNT1 A 0 A_SetScale (2.50, 0.50)
		DPL6 D 3
		TNT1 A 0 A_SetScale (4, 0.25)
		DPL6 E 2
		stop
	}
}


actor LanceBeamTrail
{
	projectile
	+nointeraction
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+DONTBLAST
	+Bright
	radius 2
	speed 50
    XScale 1.60
    YScale 0.80
	renderstyle Add
	alpha 0.70
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 A_CheckRange (50,"Emit")
		TNT1 A 1
		stop
	Emit:
		TNT1 A 0
		DPL4 A 3
		DPL4 A 1 A_SetScale (0.80,0.40)
		DPL4 A 1 A_SetScale (0.40,0.20)
		DPL4 A 1 A_SetScale (0.20,0.10)
		stop
	death:
		TNT1 A 0 
		TNT1 A 1 
		stop
	}
}



Actor DeriverRingBlast
{
	RenderStyle add
	Alpha 0.99
	Scale 0.10
	Speed 4
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	ReactionTime 2
	States
	{
	spawn:
		TNT1 A 0
		TNT1 A 1
	Flight:
		DPL5 A 1 A_SetScale (ScaleX * 1.20, ScaleY * 1.20)
		TNT1 A 0 
		TNT1 A 0 A_Countdown
		loop
	Death:
		DPL5 A 1
		TNT1 A 0 A_ScaleVelocity (0.80)
		TNT1 A 0 A_FadeOut (0.40)
 		TNT1 A 0 A_SetScale (ScaleX * 1.20, ScaleY * 1.20)
		loop
	}
}

Actor OrangeLightning
{
	RenderStyle add
	Alpha 0.99
	Scale 0.60
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	States
	{
	spawn:
		TNT1 A 0 
		TNT1 A 0 A_CheckRange (50,"Flight")
		TNT1 A 2
		goto death
	Flight:
		DPL4 A 3
		TNT1 A 1 A_SetScale (0.60)
		TNT1 A 0 A_Jump (80,2)
		TNT1 A 0 A_SetScale (ScaleX * -1, ScaleY)
		TNT1 A 0 A_SetScale (ScaleX * 1.50, ScaleY * 1.50)
		TNT1 A 0 A_Jump (80,2)
		TNT1 A 0 A_SetScale (ScaleX * -1, ScaleY * -1)
		TNT1 A 0 A_SetScale (ScaleX * 0.40, ScaleY * 0.40)
		TNT1 A 0 A_Jump (80,2)
		TNT1 A 0 A_SetScale (ScaleX, ScaleY * -1)
		TNT1 A 0 A_SetScale (ScaleX * 1.10, ScaleY * 1.10)
		TNT1 A 0 A_Jump (90,"LingeringZap2")
		Goto LingeringZap
	LingeringZap:
		TNT1 A random (3,7)
		TNT1 A 0 A_CheckRange (50,2)
		TNT1 A 0 A_Jump (256,"Death")
		DVZ1 FGF 1
		Goto Death
	LingeringZap2:
		TNT1 A random (1,3)
		TNT1 A 0 A_CheckRange (50,2)
		TNT1 A 0 A_Jump (256,"Death")
		DVZ1 GFG 1
		Goto Death
	Death:
		TNT1 A 0
		TNT1 A 1
		stop
	}
}




Actor DVHarmlessPuff : BulletPuff // used for cosmetic lightning
{ 
	+THRUACTORS
	+NODAMAGETHRUST
	+BLOODLESSIMPACT
	+PAINLESS
	+NOTELEPORT
	Decal "None"
	States
	{
	Melee:
	Spawn:
		TNT1 A 5
		Stop
	}
}



actor PlasmaStack : inventory
{
	Inventory.RestrictedTo "Deriver"
	inventory.maxamount 15
}


