actor GrabBusterWep : BaseMM8BDMWep 10103
{
//$Category MM8BDM-Weapons
//$Title Grab Buster
//$Sprite GRBUA0
Weapon.AmmoUse 2
Weapon.AmmoGive 28
Weapon.SlotNumber 2
Obituary "$OB_GRABBUSTER"
Tag "$TAG_GRABBUSTER"
Inventory.Pickupmessage "$PU_GRABBUSTER"
weapon.ammotype "GrabBusterAmmo"
inventory.icon "GRABBI"
States
{
SpawnLoop:
GRBU A -1
loop
Ready:
GRBU J 0 ACS_ExecuteAlways(998,0,206)
GRBU J 1 A_WeaponReady
Goto Ready+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
GRBU J 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
GRBU J 1 A_Raise
Loop
Fire:
GRBU J 0 A_JumpIfNoAmmo("NoAmmo")
GRBU J 0 A_PlaySoundEx("weapon/grabbuster","Weapon")
GRBU J 0 A_FireCustomMissile("GrabBuster",0,1,8,0)
GRBU JKL 3
GRBU J 4
GRBU J 0 A_Refire
Goto Ready+1
NoAmmo:
GRBU J 1 ACS_Execute(979,0)
Goto Ready+1
}
}

actor GrabBusterAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL
}

actor GrabBuster
{
    PROJECTILE
    +FORCEXYBILLBOARD
    +HITTRACER
    +BRIGHT
	Obituary "$OB_GRABBUSTER"
	Damagetype "GrabBuster"
	Damage (20)
	height 10
	radius 5
	Speed 35
	Scale 2.5
	translation "117:117=110:110", "104:104=34:34"
	States
	{
	Spawn:
		GRBU B 2
    SpawnLoop:
        GRBU CDED 2 A_SpawnItemEx("GrabBusterFX", 0, frandom(-6, 6), frandom(-6, 6))
		loop
    XDeath:
        GRBU A 0 A_JumpIfInventory("CanBeGrabBustered", 1, "TeamCheck", AAPTR_TRACER)
        stop
    TeamCheck:
        GRBU A 0 A_JumpIfInventory("LightTeamFlag", 1, "LightCheck", AAPTR_TARGET)
        GRBU A 0 A_JumpIfInventory("WilyTeamFlag", 1, "WilyCheck", AAPTR_TARGET)
        GRBU A 0 A_JumpIfInventory("CossackTeamFlag", 1, "CossackCheck", AAPTR_TARGET)
        GRBU A 0 A_JumpIfInventory("KingTeamFlag", 1, "KingCheck", AAPTR_TARGET)
        goto HealReturn
    LightCheck:
        GRBU A 0 A_JumpIfInventory("LightTeamFlag", 1, "Failed", AAPTR_TRACER)
        GRBU A 1 A_JumpIf(true, "HealReturn")
        wait
    WilyCheck:
        GRBU A 0 A_JumpIfInventory("WilyTeamFlag", 1, "Failed", AAPTR_TRACER)
        GRBU A 1 A_JumpIf(true, "HealReturn")
        wait
    CossackCheck:
        GRBU A 0 A_JumpIfInventory("CossackTeamFlag", 1, "Failed", AAPTR_TRACER)
        GRBU A 1 A_JumpIf(true, "HealReturn")
        wait
    KingCheck:
        GRBU A 0 A_JumpIfInventory("KingTeamFlag", 1, "Failed", AAPTR_TRACER)
        GRBU A 1 A_JumpIf(true, "HealReturn")
        wait
    Failed:
        TNT1 A 0
        stop
    HealReturn:
        GRBU A 0 A_CustomMissile("GrabBusterHeal", 0, 0, frandom(0.0, 360.0), 0)
        stop
    }
}

actor GrabBusterHeal
{
translation "117:117=110:110", "104:104=34:34"
    PROJECTILE
    +NOINTERACTION
    +NOCLIP
    +SEEKERMISSILE
    +BRIGHT
    reactiontime 6
    speed 30
    Damage (0)
    height 10
    radius 10
    Scale 2.5
    States 
    {
    Spawn:
        TNT1 A 0
        TNT1 A 0 ThrustThingZ(0, random(0, 35), random(0, 1), 0)
        GRBU A 0 A_RearrangePointers(AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
        GRBU G 6
    SpawnLoop:
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU F 2
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU F 2
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU F 2
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU G 2
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU G 2
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        GRBU FFFF 0 A_SeekerMissile(90, 90, SMF_PRECISE)
        GRBU G 2
        GRBU Z 0 A_Countdown
        GRBU Z 0 A_JumpIfCloser(64, "Death")
        loop
    Death:
        GRBU A 0 A_GiveToTarget("GrabBusterHealPickup", 1)
        stop
    }
}

actor GrabBusterHealPickup : CustomInventory
{
translation "117:117=110:110", "104:104=34:34"
	inventory.pickupmessage "$PU_SMALLHEALTH"
	//inventory.pickupsound "item/energyup"
	reactiontime 60
	Scale 2.0
	States
	{
	Spawn:
		GRBU HI 6 A_Countdown
		loop
	Pickup:
		GRBU I 0 A_PlaySoundEx("item/energyup", "voice")
		GRBU I 0 A_GiveInventory("Health", 15)
		stop
	Death:
		GRBU I 0 A_ChangeFlag("NOINTERACTION", true)
		GRBU I 10
		GRBU I 1 A_Fadeout
		wait
	}
}

actor GrabBusterFX
{
translation "117:117=110:110", "104:104=34:34"
    +NOINTERACTION
    +NOGRAVITY
    +CLIENTSIDEONLY
    +FORCEXYBILLBOARD
    -SOLID
    +BRIGHT
    scale 2.5
    height 1
    radius 1
    States
    {
    Spawn:
        GRBU ZMON 2
        stop
    }
}
