//This is a copy from v6b but edited so the buster lights are different color

actor MegaArm_ScriptBar : ScriptBar {}

actor MegaArm : BaseMM8BDMWep
{
Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Inventory.Pickupmessage "$PU_MEGAARM"
Obituary "$OB_MEGAARM"
Tag "$TAG_MEGAARM"
weapon.ammotype "BusterAmmo"
inventory.icon "NULLICON"
Dropitem ""
States
{
SpawnLoop:
MARM A 1
stop
Ready:
MARM Q 0 A_JumpIfInventory("BusterGiven",1,"TakeBusters")
Goto Ready2
TakeBusters:
MARM Q 0 A_GiveInventory("TakeBuster", 1)
Goto Ready2
Ready2:
MARM Q 0 ACS_NamedExecuteWithResult("core_weaponcolor",CLR_MEGABUSTER)
MARM Q 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
MARM Q 0 A_TakeInventory("WeaponCharge",999)
MARM Q 2 A_WeaponReady
Goto Ready2+2
Deselect:
MARM Q 0
goto DeselectSwap
Select:
MARM Q 0
goto SelectSwap
Fire:
Altfire:
MARM Q 0 A_JumpIfNoAmmo("Hold")
MARM Q 0 A_PlaySoundEx("weapons/busters/megaarmfire","Weapon")
MARM Q 0 A_TakeInventory("WeaponCharge",999)
MARM Q 0 A_FireCustomMissile("MegaShot",0,0,8,0)
MARM R 1 
MARM Q 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
MARM R 2
		MARM S 3
MARM Q 2
MARM Q 0 A_Refire
goto Ready2+2
MiniFire:
TNT1 A 0 A_TakeInventory("WeaponCharge",999)
TNT1 A 0 A_StopSoundEx("SoundSlot5")
TNT1 A 0 A_PlaySoundEx("weapons/busters/megaarmfire2","Weapon")
TNT1 A 0 A_FireCustomMissile("MegaArmHand",0,0,8,0)
TNT1 A 1
TNT1 A 0 A_GiveInventory("MegaArmWait", 1)
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
goto ChargeFireWait
ChargeFire:
TNT1 A 0 A_TakeInventory("WeaponCharge",999)
TNT1 A 0 A_StopSoundEx("SoundSlot5")
TNT1 A 0 A_PlaySoundEx("weapons/busters/megaarmfire3","Weapon")
TNT1 A 0 A_FireCustomMissile("MegaArmFist",0,0,8,0)
TNT1 A 1
TNT1 A 0 A_GiveInventory("MegaArmWait", 1)
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
ChargeFireWait:
TNT1 A 1 A_RailWait
TNT1 A 0 A_JumpIfInventory("MegaArmWait", 1, "ChargeFireWait")
TNT1 A 0 A_JumpIf(true, "ChargeFireEnd")
loop
ChargeFireEnd:
MARM Q 0 A_PlaySoundEx("weapons/busters/megaarmreturn","Weapon")
MARM Q 10
MARM Q 0 A_Refire
goto Ready2+2
Hold:
//MARM Q 0 A_JumpIfInventory("WeaponCharge",34,"Charge2Start")
MARM Q 0 A_JumpIfInventory("WeaponCharge",18,"Charge")
MARM Q 1 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM Q 0 A_Refire
Goto Ready2+2
Charge:
//MARM H 0 A_JumpIfInventory("WeaponCharge",34,"Charge2Start")
MARM T 0 A_PlaySoundEx("weapons/busters/megaarmcharge","Weapon")
MARM T 0 A_JumpIfInventory("WeaponCharge",19,"Charge1")
Goto Charge1
BotFire:
MARM T 0 A_Jump(128, "ChargeFire")
MARM T 0 A_Refire
Goto ChargeFire
Charge1:
MARM T 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE1,TCLR_MEGAARM_CHARGE1)
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.a")
Goto MiniFire
Charge1.a:
MARM T 1 A_RailWait
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.b")
Goto MiniFire
Charge1.b:
MARM Q 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.c")
Goto MiniFire
Charge1.c:
MARM Q 1 A_RailWait
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.d")
Goto MiniFire
Charge1.d:
MARM U 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE2,TCLR_MEGAARM_CHARGE2)
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.e")
Goto MiniFire
Charge1.e:
MARM U 1 A_RailWait
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.f")
Goto MiniFire
Charge1.f:
MARM V 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE3,TCLR_MEGAARM_CHARGE3)
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.g")
Goto MiniFire
Charge1.g:
MARM V 1 A_RailWait
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.h")
Goto MiniFire
Charge1.h:
MARM T 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE1,TCLR_MEGAARM_CHARGE1)
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1.i")
Goto MiniFire
Charge1.i:
MARM T 1 A_RailWait
MARM T 0 A_GiveInventory("WeaponCharge", 1 + CallACS("core_checkrune", RUNE_RAGE))
MARM T 0 A_JumpIfInventory("WeaponCharge", 56, "Charge2Start")
MARM T 0 A_Refire("Charge1")
Goto MiniFire
Charge2Start:
MARM T 0 A_GunFlash("Sound.BusterCharge", GFF_NOEXTCHANGE)
Goto Charge2
Charge2:
MARM K 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE4,TCLR_MEGAARM_CHARGE4)
MARM K 0 A_Refire("Charge2.a")
Goto ChargeFire
Charge2.a:
MARM L 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE5,TCLR_MEGAARM_CHARGE5)
MARM L 0 A_Refire("Charge2.b")
Goto ChargeFire
Charge2.b:
MARM M 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGAARMCHARGE6,TCLR_MEGAARM_CHARGE6)
MARM M 0 A_Refire("Charge2.c")
Goto ChargeFire
Charge2.c:
HSPR C 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
HSPR C 0 A_JumpIfInventory("IsBot", 1, "BotFire")
HSPR C 0 A_Refire("Charge2")
Goto ChargeFire
}
}

actor MegaArmFist : BasicProjectile
{
+HITTRACER
+SKYEXPLODE
+DONTREFLECT
Damage (20)
Speed 50
height 10
radius 10
reactiontime 5
Obituary "$OB_MEGAARM"
Damagetype "MegaArm"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1", 0, 0, 0, 0, 0, 0, 0, SXF_WEPFXCOLOR)
MARM BC 2
MARM B 0 A_SpawnItemEx("ThunderClawPegHelper")
MARM B 0 A_Countdown
goto Spawn+2
GripCheck:
MARM D 0 A_JumpIfInventory("CanBeMegaArmed", 1, "Grip", AAPTR_TRACER)
MARM D 1 A_JumpIf(true, "GripFail")
loop
Grip:
MARM D 0 A_SpawnItemEx("MegaArmGrip", 0, 0, 0, 0, 0, 0, 0, SXF_TRANSFERPOINTERS)
stop
XDeath:
MARM D 0 A_CheckFlag("SHOOTABLE", "GripCheck", AAPTR_TRACER)
MARM D 1 A_JumpIf(true, "Death")
loop
GripFail:
MARM C 0
Death:
MARM C 0 A_SpawnItemEx("ThunderClawPegHelper")
MARM C 0 A_CustomMissile("MegaArmReturn", 0, 0, 0, 0)
stop
}
}

actor MegaArmGrip : BasicProjectile
{
+NOINTERACTION
Damage (0)
Speed 50
height 10
radius 10
reactiontime 5
Obituary "$OB_MEGAARM"
Damagetype "MegaArm"
	reactiontime 1
States
{
Spawn:
MARM D 0
MARM D 0 A_GiveInventory("CutterFlag", 12)
		MARM D 0 A_GiveInventory("TracerAndTargetTeamsMatchCheck",1)
		MARM D 0 A_JumpIfInventory("TracerAndTargetTeamsMatchFlag", 1, "Death")
		MARM D 0 A_GiveInventory("GripSight",1)
		MARM D 0 A_GiveInventory("TightenInterval",1)
goto Grip
Grip:
MARM D 1 A_Warp(AAPTR_TRACER, -12, frandom(-2, 2), 32, 180, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
MARM D 0 A_GiveInventory("MegaArmGripFunc",1)
loop
Death:
MARM C 0 A_SpawnItemEx("MegaArmReturn", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
stop
}
}

actor GripSight : Powerup
{
Powerup.Duration 16
}

actor TightenInterval : Powerup
{
Powerup.Duration 8
}

actor MegaArmGripFunc : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_JumpIfInventory("CutterFlag", 1, "Pickup2")
KillThis:
TNT1 A 0 A_CountDown
stop
Pickup2:
TNT1 A 0 A_JumpIfInventory("IsDead", 1, "KillThis", AAPTR_TRACER)
TNT1 A 0 A_JumpIfInTargetInventory("IsDead", 1, "KillThis")
TNT1 A 0 A_GiveInventory("GripSightFunc",1)
TNT1 A 0 A_JumpIfInventory("GripSight", 1, "Pickup3")
goto KillThis
Pickup3:
TNT1 A 0 A_GiveInventory("MegaArmTightenFunc",1)
stop
}
}

actor GripSightFunc : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_JumpIfCloser(1200, "GripCheckLOS")
stop
GripCheckLOS:
TNT1 A 0 A_JumpIfTargetInLOS("GripCheckTime", 0)
stop
GripCheckTime:
TNT1 A 0 A_GiveInventory("GripSight",1)
stop
}
}

actor MegaArmTightenFunc : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_GiveToTarget("MegaArmWait", 1)
TNT1 A 0 A_JumpIfInventory("TightenInterval",1,"PickupNo")
TNT1 A 0 A_GiveInventory("TightenInterval",1)
TNT1 A 0 A_SpawnItemEx("MegaArmDamage", 16)
TNT1 A 0 A_TakeInventory("CutterFlag", 1)
stop
PickupNo:
TNT1 A 0
stop
}
}

actor MegaArmDamage
{
PROJECTILE
+DONTREFLECT
Damage (5)
Speed 0
Height 5
Radius 5
Obituary "$OB_MEGAARM"
Damagetype "MegaArm"
+EXPLODEONDEATH
States
{
Spawn:
TNT1 A 0
TNT1 A 1
stop
}
}

actor MegaArmWait : Powerup
{
powerup.duration 70
}

actor MegaArmHand : MegaArmFist
{
Damage (30)
	reactiontime 2
Damagetype "MegaArmHand"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1", 0, 0, 0, 0, 0, 0, 0, SXF_WEPFXCOLOR)
MARM BC 2
MARM B 0 A_SpawnItemEx("ThunderClawPegHelper")
MARM B 0 A_Countdown
goto Spawn+2
XDeath:
MARM D 0
goto Death
}
}

actor MegaArmReturn : BasicProjectile
{
+NOINTERACTION
+NOCLIP
+SEEKERMISSILE
reactiontime 70
speed 30
Damage (0)
height 10
radius 10
States 
{
Spawn:
TNT1 A 0
TNT1 A 0 A_RearrangePointers(AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
SpawnLoop:
MARM ZZZZ 0 A_SeekerMissile(90, 90, SMF_PRECISE)
MARM Z 1 A_GiveToTarget("MegaArmWait", 1)
MARM Z 0 A_Countdown
MARM Z 0 A_JumpIfCloser(64, "Death")
loop
Death:
MARM Z 0 A_TakeFromTarget("MegaArmWait", 1)
stop
}
}
