actor MegaBusterBoss : BaseMM8BDMWep_CBM
{
tag "$TAGC_0B"
dropitem "MegaArmUpgrade2GiverDropped"

Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Inventory.Pickupmessage "You got the Mega Buster!"
Obituary "$OB_MEGABUSTER"
States
{
Spawn:
C_00 B 1
loop
Ready:
BUST B 0 A_JumpIfInventory("Once",1,"Ready2")
BUST B 0 ACS_ExecuteAlways(981,0,0)
BUST B 0 A_GiveInventory("Once",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:
BUST B 0 A_TakeInventory("SlideVivifyFlag",9)
BUST BBBBBBBBBBBBBBBBBBBBBB 0 A_Lower
BUST B 1 A_Lower
Loop
Select:
BUST BBBBBBBBBBBBBBBBBBBBBB 0 A_Raise
BUST B 1 A_Raise
Loop

Fire:
//BUST B 0 A_JumpIfNoAmmo("Hold")
BUST B 0 A_PlaySoundEx("weapon/mbuster","Weapon")
BUST B 0 A_GiveInventory("MegamanMain_CI",1)
BUST B 0 A_TakeInventory("WeaponCharge",999)
BUST CD 3
BUST B 0 A_Refire
goto Ready2+2

Fire2:
BUST C 0 A_TakeInventory("WeaponCharge",999)
BUST C 0 A_PlaySoundEx("weapon/minchrgshot","Weapon")
BUST C 0 ACS_ExecuteAlways(991,0,0)
BUST C 0 A_GiveInventory("MegamanMain2_CI",1)
BUST CD 3
BUST B 0 A_Refire
goto Ready2+2

Fire3:
BUST C 0 A_TakeInventory("WeaponCharge",999)
BUST C 0 A_PlaySoundEx("weapon/cfire2","Weapon")
BUST C 0 ACS_ExecuteAlways(991,0,0)
BUST C 3 A_GiveInventory("MegamanMain3_CI",1)
BUST D 8
BUST C 4
BUST B 3
BUST B 0 A_Refire
goto Ready2+2

Hold:
BUST B 0 A_JumpIfInventory("WeaponCharge",34,"Charge2")
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,"Charge2")
BUST B 0 A_PlaySoundEx("weapon/coilstart","Weapon")
Goto Charge1

Charge1:
LBST H 0 A_JumpIfInventory("WeaponCharge",34,"Charge2")
LBST H 1 ACS_ExecuteAlways(998,0,106,5)
BUST B 0 A_Refire("Charge1.a")
Goto Fire2
Charge1.a:
BUST B 1 ACS_ExecuteAlways(998,0,DYE_MEGAMANC,1)
BUST B 0 A_GiveInventory("WeaponCharge_RC",1)
LBST H 0 A_Refire("Charge1")
Goto Fire2

Charge2:
BUST B 0 A_JumpIfInventory("WeaponCharge",40,"ChargeLoop")
BUST B 1 ACS_ExecuteAlways(998,0,93,6)
BUST B 0 A_Refire("Charge2.a")
Goto Fire2
Charge2.a:
CHBU I 1 ACS_ExecuteAlways(998,0,94,7)
BUST B 0 A_Refire("Charge2.b")
Goto Fire2
Charge2.b:
CHBU J 1 ACS_ExecuteAlways(998,0,DYE_MEGAMANC,5)
BUST B 0 A_Refire("Charge2.c")
Goto Fire2
Charge2.c:
BUST B 0 A_GiveInventory("WeaponCharge",6)
BUST B 0 A_GunFlash("Flash", GFF_NOEXTCHANGE)
BUST B 0 A_Refire("ChargeLoop")
Goto Fire3

Flash:
TNT1 A 5 A_PlaySoundEx("weapon/coilcharge", "Weapon")
TNT1 A 0 A_JumpIfInventory("IsDead",1,"NoFlash")
TNT1 A 0 A_JumpIfInventory("WeaponCharge",1,"Flash")
stop

ChargeLoop:
BUST B 1 ACS_ExecuteAlways(998,0,93,6)
BUST B 0 A_Refire("ChargeLoop.a")
Goto Fire3
ChargeLoop.a:
CHBU I 1 ACS_ExecuteAlways(998,0,94,7)
BUST B 0 A_Refire("ChargeLoop.b")
Goto Fire3
ChargeLoop.b:
CHBU J 1 ACS_ExecuteAlways(998,0,DYE_MEGAMANC,5)
BUST B 0 A_JumpIfInventory("IsBot",1,"BotFire")
BUST B 0 A_Refire("ChargeLoop")
Goto Fire3

BotFire:
BUST B 0 A_Jump(16,"Fire3")
BUST B 0 A_Refire("ChargeLoop")
Goto Fire3

User1Fire:
BUST B 0 A_JumpIfNoAmmo("Hold")
BUST B 0 A_PlaySoundEx("weapon/mbuster","Weapon")
BUST B 0 A_GiveInventory("MegamanMain_CI",1)
BUST B 0 A_TakeInventory("WeaponCharge",999)
BUST CD 3
BUST B 2
goto Ready2+3

Altfire:
MKIC C 0 A_JumpIf(ACS_NamedExecuteWithResult("cbm_user1_check")==1, "User1Fire")
MKIC C 0 A_JumpIf(z-floorz==0,"SlideSlide") //A_JumpIf(momz==0, "SlideSlide")
Goto Ready2+2
SlideSlide:
MKIC C 0 A_GiveInventory("SlideVivifyFlag",1)
MKIC C 0 A_Refire(1)
MKIC C 0 A_PlaySoundEx("weapon/chargekick","Weapon")
MKIC C 0 SetPlayerProperty(0,1,0)
MKIC C 0 ACS_ExecuteAlways(CORE_ACS_191,0,APROP_JumpZ,0,1)
MKIC C 2 A_GiveInventory("CopySlideThrust_P",1)
MKIC A 8 //A_GiveInventory("StayDown",1) //SetPlayerProperty(0,0,0)
MKIC B 5 SetPlayerProperty(0,0,0)
MKIC C 5 ACS_ExecuteAlways(CORE_ACS_191,0,APROP_JumpZ,10,1)
MKIC A 0 A_TakeInventory("SlideVivifyFlag",9)
MKIC C 0 A_Refire
Goto Ready2+2
}
}

actor MegaShotC
{
Translation "204:204=215:215"
PROJECTILE
damagetype "MegaM_Shot"
Obituary "$OB_MEGABUSTER"
+BRIGHT
Damage (100)
radius 5
height 5
Speed 27
scale 2.5
States
{
Spawn:
TNT1 A 2
W_0B B 1
wait
Death:
W_0B B 1
stop
}
}
actor MegaShotCB : MegaShotC{translation "204:204=205:205"}
actor MegaShotCR : MegaShotC{translation "204:204=171:171"}
actor MegaShotCO : MegaShotC{translation "204:204=104:104"}
actor MegaShotCP : MegaShotC{translation "204:204=229:229"}

actor MidShotC
{
Translation "204:204=215:215"
PROJECTILE
damagetype "MegaM_Shot2"
Obituary "$OB_MEGABUSTER"
+BRIGHT
Damage (250)
radius 20
height 20
Speed 26
scale 2.5
States
{
Spawn:
TNT1 A 2
MBU2 DE 2
Goto Spawn+1
}
}
actor MidShotCB : MidShotC{translation "204:204=205:205"}
actor MidShotCR : MidShotC{translation "204:204=171:171"}
actor MidShotCO : MidShotC{translation "204:204=104:104"}
actor MidShotCP : MidShotC{translation "204:204=229:229"}

actor MegaShot3
{
Translation "198:198=198:198","202:202=193:193","204:204=215:215"
PROJECTILE
damagetype "MegaM_Shot3"
Obituary "$OB_MEGABUSTER"
+BRIGHT
Damage (400)
radius 25
height 25
Speed 26
scale 2.5
States
{
Spawn:
MBU2 ABCE 2
loop
}
}

actor MegaShot3B : MegaShot3{translation"202:202=205:205","204:204=205:205","198:198=74:74"}
actor MegaShot3R : MegaShot3{translation"202:202=171:171","204:204=171:171","198:198=41:41"}
actor MegaShot3O : MegaShot3{translation"202:202=104:104","204:204=104:104","198:198=128:128"}
actor MegaShot3P : MegaShot3{translation"202:202=229:229","204:204=229:229","198:198=232:232"}


actor MegamanMain_CI : TeamColor_CI
{
states
{
FireX:
TNT1 A 0 A_FireCustomMissile("MegaShotC",0,0,8,0)
goto Done
FireB:
TNT1 A 0 A_FireCustomMissile("MegaShotCB",0,0,8,0)
goto Done
FireR:
TNT1 A 0 A_FireCustomMissile("MegaShotCR",0,0,8,0)
goto Done
FireO:
TNT1 A 0 A_FireCustomMissile("MegaShotCO",0,0,8,0)
goto Done
FireP:
TNT1 A 0 A_FireCustomMissile("MegaShotCP",0,0,8,0)
goto Done
}
}

actor MegamanMain2_CI : TeamColor_CI
{
states
{
FireX:
TNT1 A 0 A_FireCustomMissile("MidShotC",0,0,8,0)
goto Done
FireB:
TNT1 A 0 A_FireCustomMissile("MidShotCB",0,0,8,0)
goto Done
FireR:
TNT1 A 0 A_FireCustomMissile("MidShotCR",0,0,8,0)
goto Done
FireO:
TNT1 A 0 A_FireCustomMissile("MidShotCO",0,0,8,0)
goto Done
FireP:
TNT1 A 0 A_FireCustomMissile("MidShotCP",0,0,8,0)
goto Done
}
}

actor MegamanMain3_CI : TeamColor_CI
{
states
{
FireX:
TNT1 A 0 A_FireCustomMissile("MegaShot3",0,0,8,0)
goto Done
FireB:
TNT1 A 0 A_FireCustomMissile("MegaShot3B",0,0,8,0)
goto Done
FireR:
TNT1 A 0 A_FireCustomMissile("MegaShot3R",0,0,8,0)
goto Done
FireO:
TNT1 A 0 A_FireCustomMissile("MegaShot3O",0,0,8,0)
goto Done
FireP:
TNT1 A 0 A_FireCustomMissile("MegaShot3P",0,0,8,0)
goto Done
}
}