const float SPEED_SCALAR = 0.01;

actor LaserBuster : BaseMM8BDMWep
{
Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Inventory.Pickupmessage "$PU_LASERBUSTER"
Obituary "$OB_LASERBUSTER"
Tag "$TAG_LASERBUSTER"
weapon.ammotype "BusterAmmo"
inventory.icon "NULLICON"
Dropitem ""
States
{
SpawnLoop:
WEA4 K 1
stop
Ready:
BUST B 0 A_JumpIfInventory("BusterGiven",1,"TakeBusters")
Goto Ready2
TakeBusters:
TNT1 Q 0 A_GiveInventory("TakeBuster", 1)
Goto Ready2
Ready2:
BUST B 0 ACS_ExecuteAlways(998,0,0)
BUST B 0 ACS_ExecuteAlways(991,0,0)
BUST B 0 A_TakeInventory("WeaponCharge",999)
BUST B 2 A_WeaponReady
Goto Ready2+2
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
BUST B 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
BUST B 1 A_Raise
Loop
Fire:
Altfire:
BUST B 0 A_JumpIfNoAmmo("Hold")
BUST B 0 A_PlaySoundEx("weapon/mbuster","Weapon")
BUST B 0 A_FireCustomMissile("MegaShot",0,0,8,0)
BUST B 0 A_TakeInventory("WeaponCharge",999)
BUST CD 3
BUST B 1
BUST B 0 A_Refire
goto Ready2+2
Fire2:
BUST B 0 A_TakeInventory("WeaponCharge",999)
BUST C 0 A_PlaySoundEx("weapon/minchrgshot","Weapon")
BUST B 1 ACS_ExecuteAlways(991,0,0)
BUST C 0 A_FireCustomMissile("MidShot",0,0,8,0)
BUST CD 3
BUST B 0 A_Refire
goto Ready2+2
Fire3:
BUST B 0 A_TakeInventory("WeaponCharge",999)
TNT1 A 0 A_StopSoundEx("SoundSlot5")
BUST B 0 A_PlaySoundEx("weapon/lshot","Weapon")
BUST C 0 ACS_ExecuteAlways(991,0,0)
BUST C 0 A_FireCustomMissile("LaserShot",0,0,8,0)
BUST CCD 3 
BUST C 9
BUST B 0 A_Refire
goto Ready2+2
Hold:
//BUST B 0 A_JumpIfInventory("WeaponCharge",34,"Charge2Start")
BUST B 0 A_JumpIfInventory("WeaponCharge",18,"Charge")
BUST B 1 A_GiveInventory("WeaponCharge_RC",1)
BUST B 0 A_Refire
Goto Ready2+2
Charge:
//BUST B 0 A_JumpIfInventory("WeaponCharge",34,"Charge2Start")
BUST B 0 A_JumpIfInventory("WeaponCharge",19,"Charge1")
BUST B 0 A_PlaySoundEx("weapon/coilstart","Weapon")
Goto Charge1
Charge1:
BUST B 0 A_JumpIfInventory("WeaponCharge",35,"Charge2Start")
LBST H 1 ACS_ExecuteAlways(991,0,106)
CHBU H 0 A_Refire("Charge1.a")
Goto Fire2
Charge1.a:
BUST B 1 ACS_ExecuteAlways(991,0,0)
BUST B 0 A_GiveInventory("WeaponCharge_RC",1)
CHBU H 0 A_Refire("Charge")
Goto Fire2
BotFire:
BUST B 0 A_Jump(16, "Fire3")
CHBU H 0 A_Refire
Goto Fire3
Charge2Start:
BUST B 0 A_GunFlash("Sound.BusterCharge", GFF_NOEXTCHANGE)
Goto Charge2
Charge2:
LBST I 1 ACS_ExecuteAlways(991,0,107)
CHBU H 0 A_Refire("Charge2.a")
Goto Fire3
Charge2.a:
BUST B 1 ACS_ExecuteAlways(991,0,0)
BUST B 0 A_JumpIfInventory("IsBot", 1, "BotFire")
CHBU H 0 A_Refire("Charge2")
BUST B 0 A_JumpIfInventory("WeaponCharge", 35, 2)
BUST B 0 A_GiveInventory("WeaponCharge_RC",1)
BUST B 0 A_Refire
Goto Fire3
}
}

actor LaserShot
{
PROJECTILE
+DONTREFLECT
+FORCEXYBILLBOARD
+RIPPER
Speed 50
Damage (0)
radius 5
height 5
scale 2.5
ReactionTime 5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_ScaleVelocity(SPEED_SCALAR)
Spawn2:
TNT1 A 0 A_CountDown
TNT1 A 0 A_SpawnItemEx("MegaLaser",0,0,0,(momx/SPEED_SCALAR),(momy/SPEED_SCALAR),(momz/SPEED_SCALAR),0,SXF_ABSOLUTEMOMENTUM)
TNT1 A 0 A_SpawnItemEx("LaserTrail",0,0,0,(momx/SPEED_SCALAR),(momy/SPEED_SCALAR),(momz/SPEED_SCALAR),0,SXF_ABSOLUTEMOMENTUM)
TNT1 A 0 A_SpawnItemEx("LaserTrail",-(momx/SPEED_SCALAR)/3,-(momy/SPEED_SCALAR)/3,-(momz/SPEED_SCALAR)/3,(momx/SPEED_SCALAR),(momy/SPEED_SCALAR),(momz/SPEED_SCALAR),0,SXF_ABSOLUTEPOSITION|SXF_ABSOLUTEMOMENTUM)
TNT1 A 0 A_SpawnItemEx("LaserTrail",-(momx/SPEED_SCALAR)*2/3,-(momy/SPEED_SCALAR)*2/3,-(momz/SPEED_SCALAR)*2/3,(momx/SPEED_SCALAR),(momy/SPEED_SCALAR),(momz/SPEED_SCALAR),0,SXF_ABSOLUTEPOSITION|SXF_ABSOLUTEMOMENTUM)
TNT1 A 1
loop
Death:
TNT1 A 0
stop
}
}

actor MegaLaser
{
PROJECTILE
+DONTREFLECT
+FORCEXYBILLBOARD
+RIPPER
+BRIGHT
damagetype "LaserBuster"
Obituary "$OB_LASERBUSTER"
Damage (5)
radius 16
height 10
scale 2.5
renderstyle none
States
{
Spawn:
TNT1 A 0
TNT1 A 1
Spawn2:
LASH AB 1
loop
Death:
TNT1 A 0
stop
}
}

actor LaserTrail : MegaLaser
{
renderstyle normal
Damage(0)
+CLIENTSIDEONLY
}