actor Megaman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_0B"
dropitem "MegaArmUpgrade"
//weapon.preferredskin "Megaman"
Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Inventory.Pickupmessage "You got the Mega Buster!"
Obituary "$OB_MEGABUSTER"
weapon.ammotype "SuperMegaBusterAmmo"
weapon.ammotype2 "NotMode9SlideAmmo"
States
{
Spawn:
C_00 B 1
loop

Deselect:
MKIC A 0 A_TakeInventory("SlideVivifyFlag")
MKIC A 0 A_TakeInventory("SuperMegaBusterAmmo")
goto DeselectSwap
Select:
MKIC A 0 A_TakeInventory("SuperMegaBusterAmmo")
goto SelectSwap

Ready:
MKIC A 0 A_TakeInventory("Megaman_W1")
MKIC A 0 A_GiveInventory("JetAdaptorUpgrade",1)
MKIC A 0 A_TakeInventory("Megaman_W2")
MKIC A 0 A_GiveInventory("PowerAdaptorUpgrade",1)
MKIC A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_MEGAMANC)
Ready2:
MKIC A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
MKIC A 0 A_TakeInventory("SuperMegaBusterAmmo")
Ready3:
MKIC A 2 A_WeaponReady
wait

Flash.Charge:
TNT1 A 1 A_GiveInventory("SuperMegaBusterAmmo",1+CallACS("core_checkrune",RUNE_RAGE,0))
TNT1 A 0 A_JumpIfInventory("SuperMegaBusterAmmo",1,"Flash.Charge")
stop

Flash.Charge1:
TNT1 A 6 A_RailWait
TNT1 A 0 A_JumpIfInventory("SuperMegaBusterAmmo",40,"Flash.Charge2")
stop
Flash.Charge2:
TNT1 A 7 A_PlaySound("weapon/MM5Charge",1)
TNT1 A 0 A_JumpIfInventory("SuperMegaBusterAmmo",40,1)
stop
TNT1 A 7 A_RailWait
TNT1 A 0 A_JumpIfInventory("SuperMegaBusterAmmo",40,"Flash.Charge2")
stop

Fire:
MKIC A 0 A_GiveInventory("Megaman_Fire1_P")
//MKIC A 1
MKIC BC 3
MKIC A 1
MKIC A 0 A_Refire("ChargeStart")
goto Ready3

Fire2:
MKIC B 0 A_GiveInventory("Megaman_Fire2_P")
MKIC BC 3
MKIC A 2
MKIC A 0 A_Refire("ChargeStart")
goto Ready3

Fire3:
MKIC B 0 A_GiveInventory("Megaman_Fire3_P")
MKIC B 2
MKIC C 9
MKIC B 4
MKIC A 3
MKIC A 0 A_Refire("ChargeStart")
goto Ready3

ChargeStart:
MKIC A 0 A_GunFlash("Flash.Charge",1)
Charge0:
MKIC A 1 A_JumpIfInventory("SuperMegaBusterAmmo",18,"Charge1_Snd")
MKIC A 0 A_Refire("Charge0")
Goto Ready2+1

Charge1_Snd:
CHBU H 0 A_PlaySound("weapon/coilstart",1)
Charge1:
CHBU H 0 A_JumpIfInventory("SuperMegaBusterAmmo",50,"Charge2_Snd")//34
CHBU H 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGACHARGE1,TCLR_CHARGE1)
CHBU H 0 A_Refire(1)
Goto Fire2
MKIC A 0 A_JumpIfInventory("SuperMegaBusterAmmo",50,"Charge2_Snd")
MKIC A 1 ACS_NamedExecuteWithResult("core_chargecolor",DYE_MEGAMANC,TCLR_NONE)
MKIC A 0 A_Refire("Charge1")
Goto Fire2

Charge2_Snd:
CHBU I 0 A_GunFlash("Flash.Charge1",1)
Charge2:
CHBU I 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGACHARGE2,TCLR_CHARGE2)
CHBU I 0 A_Refire(1)
Goto Fire3
CHBU J 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGACHARGE3,TCLR_CHARGE3)
CHBU J 0 A_Refire(1)
Goto Fire3
MKIC A 1 ACS_NamedExecuteWithResult("core_chargecolor",DYE_MEGAMANC,TCLR_NONE)
MKIC A 0 A_JumpIfInventory("IsBot",1,"BotCharge2")
MKIC A 0 A_Refire("Charge2")
Goto Fire3

BotCharge2:
MKIC A 0 A_Jump(16,"Fire3")
MKIC A 0 A_Refire("Charge2")
Goto Fire3

Altfire:
MKIC A 0 A_JumpIf(z-floorz==0,"SlideSlide") //A_JumpIf(momz==0, "SlideSlide")
Goto Ready3
SlideSlide:
MKIC J 0 A_GiveInventory("SlideVivifyFlag",1)
MKIC J 0 A_Refire(1)
MKIC J 0 A_PlaySound("Megaman/Slide",1)//weapon/chargekick
MKIC J 0 ACS_NamedExecuteWithResult("core_stopplayer",0,1)
MKIC J 2 A_GiveInventory("MegaSlideCheck_P")
MKIC K 8
MKIC J 5 ACS_NamedExecuteWithResult("core_stopplayer",0,0)
MKIC A 5 A_TakeInventory("CBM_DisableJumpPower")
MKIC A 0 A_TakeInventory("SlideVivifyFlag")
MKIC A 0 A_Refire("Altfire")
Goto Ready3
}
}

actor SuperMegaBusterAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 50
+INVENTORY.IGNORESKILL
}
actor NotMode9SlideAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 60
+INVENTORY.IGNORESKILL
}

actor MegaSlideDelay : Powerup
{
Powerup.Duration -2
+INVENTORY.ALWAYSPICKUP
}
actor MegaHasSlid_F : Inventory{}

actor MegaSlideRestore_H : BasicWatcher
{
+SERVERSIDEONLY
States
{
Spawn:
TNT1 A 1
TNT1 A 5
Spawn2:
TNT1 A 0 A_JumpIfInTargetInventory("MegaSlideDelay",1,2)
TNT1 A 0 A_GiveToTarget("NotMode9SlideAmmo",1+CallACS("core_checkrune",RUNE_RAGE,2))
TNT1 A 5
TNT1 A 0 A_JumpIfInTargetInventory("NotMode9SlideAmmo",0,"Death")
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIfInTargetInventory("MegaHasSlid_F",1,"Spawn2")
goto Death
Death:
TNT1 A 1 A_TakeFromTarget("MegaHasSlid_F",99)
stop
}
}

actor MegaSlideCheck_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("MegaSlideThrust_P")
TNT1 A 0 A_GiveInventory("CBM_DisableJumpPowerGiver",1)

TNT1 A 0 A_GiveInventory("MegaSlideDelay",1)
TNT1 A 0 A_JumpIfInventory("MegaHasSlid_F",1,3)
TNT1 A 0 A_GiveInventory("MegaHasSlid_F",1)
TNT1 A 0 A_SpawnItemEx("MegaSlideRestore_H",0,0,24)
TNT1 A 0 A_JumpIfInventory("NotMode9SlideAmmo",20,1)
stop
TNT1 A 0 A_TakeInventory("NotMode9SlideAmmo",20,1)
stop
}
}

actor MegaSlideThrust_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("BasicSlideDashFX_P")
TNT1 A 0 A_JumpIfInventory("NotMode9SlideAmmo",20,"Thrust")
TNT1 A 0 ThrustThingZ(0,0,1,0)
TNT1 A 0 A_Recoil(-24)//-21
stop
Thrust:
TNT1 A 0 ThrustThingZ(0,0,1,0)
TNT1 A 0 A_Recoil(-44)//-38
stop
}
}

actor Megaman_Fire1_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("weapon/mbuster",1)
TNT1 A 0 A_FireCustomMissile("Megaman_Shot1",0,0,8,0)
End1:
TNT1 A 0 A_TakeInventory("SuperMegaBusterAmmo")
stop
}
}
actor Megaman_Fire2_P : Megaman_Fire1_P
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("weapon/minchrgshot",1)
TNT1 A 0 A_FireCustomMissile("Megaman_Shot2",0,0,8,0)
End2:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_MEGABUSTER,TCLR_NONE)
goto End1
}
}
actor Megaman_Fire3_P : Megaman_Fire2_P
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("weapon/cfire2",1)//weapon/cfire
TNT1 A 0 A_FireCustomMissile("Megaman_Shot3",0,0,8,0)//ChargeShotC
goto End2
}
}

actor Megaman_Shot1 : ProjSpawnFuncActor
{
PROJECTILE
damagetype "MegaM_Shot"
Obituary "$OB_MEGABUSTER"
+BRIGHT
Damage (100)
radius 10
height 5
Speed 35
scale 2.5
States
{
Spawn:
TNT1 A 2
Q_0B B 1
wait
Death:
//Q_0B B 1
MMJT EFG 2
stop
}
}

actor Megaman_Shot2 : Megaman_Shot1
{
damagetype "MegaM_Shot2"
Damage (250)
radius 20
height 20
Speed 26
States
{
Spawn:
TNT1 A 2
//MBUS AB 2//core
MBU2 DE 2
Goto Spawn+1
Death:
TNT1 A 0
stop
}
}

actor Megaman_Shot3 : Megaman_Shot2
{
damagetype "MegaM_Shot3"
Damage (350)
radius 25
height 25
speed 40
States
{
Spawn:
TNT1 A 0
TNT1 A 1 
CBUS A 0 A_SpawnItemEx("Megaman_Shot3FX",-32,0,0,momx/4*3,momy/4*3,momz/4*3,0,1+8)
CBUS ABCH 2
goto Spawn+2
}
}
actor Megaman_Shot3FX : BasicGraphicEffect
{
+BRIGHT
States
{
SpawnFrame:
CBUS DEF 2
stop
}
}

actor Megaman_Shot4 : Megaman_Shot2
{
damagetype "MegaM_Shot3"
Damage (400)
radius 25
height 25
Speed 26
States
{
Spawn:
MBU2 ABCE 2
loop
}
}


actor MegaAdaptorUpgrade : BaseMM8BDMBusterUpgrade
{
Inventory.RespawnTics 350
inventory.pickupmessage "$PU_MEGAUPGRADE"
Tag "$TAG_MEGAUPGRADE"
inventory.icon "MEGUP"
Inventory.PickupSound "item/1up"
scale 2.0
+COUNTITEM
+INVBAR
states
{
SpawnLoop:
WEAP X 1
loop
Use:
TNT1 A 0 A_PlaySoundEx("item/refill","Voice")
TNT1 A 0 A_SpawnItemEx("HeroMegaman_H")
//TNT1 A 0 A_GiveInventory("Megaman_W",1)
//TNT1 A 0 A_SelectWeapon("Megaman_W")
stop
}
}

actor HeroMegaman_H : BasicWatcher
{
+SERVERSIDEONLY
+NOTIMEFREEZE
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveToTarget("HeroMegaman_P",1)
stop
}
}
actor HeroMegaman_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("Megaman_W",1)
TNT1 A 0 A_SelectWeapon("Megaman_W")
stop
}
}

actor HeroMegaman_H1 : BasicWatcher
{
+SERVERSIDEONLY
+NOTIMEFREEZE
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveToTarget("HeroMegaman_P1",1)
stop
}
}
actor HeroMegaman_P1 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("Megaman_W1",1)
TNT1 A 0 A_SelectWeapon("Megaman_W1")
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_jetadaptor",0)
stop
}
}

actor Megaman_W1 : JetAdaptorWep
{
tag "$TAGC_0B1"
//Weapon.AmmoGive 35
weapon.preferredskin "Flight-Megaman"
Inventory.Pickupmessage "You got the Rush Jet Buster!"
weapon.ammotype2 "NotMode9SlideAmmo"
-WEAPON.ALT_USES_BOTH
-THRUACTORS
Inventory.ForbiddenTo ""
States
{
Spawn:
JETB Z 1
loop

Ready:
JETB A 0 A_TakeInventory("Megaman_W")
JETB A 0 A_GiveInventory("MegaAdaptorUpgrade",1)
JETB A 0 A_TakeInventory("Megaman_W2")
JETB A 0 A_GiveInventory("PowerAdaptorUpgrade",1)
Ready1:
JETB A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_POWERFLIGHT)
JETB A 0 A_SpawnItemEx("JetAdaptorWings_M",-12,0,36)
Ready3:
JETB A 0 A_JumpIfInventory("NotMode9SlideAmmo",20,2)
JETB A 1 A_WeaponReady(WRF_NOSECONDARY)
loop
JETB A 1 A_WeaponReady
wait

Altfire:
JETB A 0 A_JumpIfNoAmmo("Ready3")
JETB A 0 A_GiveInventory("MegamanJet_Alt_P")
JETB A 0 A_Refire(1)
JETB DDDDDDDDDD 1
JETB D 0 A_TakeInventory("SlideVivifyFlag")
JETB D 1 OffSet(-10,52)
JETB D 1 OffSet(-20,72)
JETB A 2 OffSet(12,112)
JETB A 2 OffSet(9,92)
JETB A 2 OffSet(6,72)
JETB A 2 OffSet(3,52)
goto Ready3
}
}

actor MegamanJet_Alt_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_trebleboostdash")
TNT1 A 0 A_GiveInventory("SlideVivifyFlag",2)
TNT1 A 0 A_GiveInventory("JetBoostPowerFake",1)

TNT1 A 0 A_GiveInventory("MegaSlideDelay",1)
TNT1 A 0 A_JumpIfInventory("MegaHasSlid_F",1,3)
TNT1 A 0 A_GiveInventory("MegaHasSlid_F",1)
TNT1 A 0 A_SpawnItemEx("MegaSlideRestore_H",0,0,24)
TNT1 A 0 A_JumpIfInventory("NotMode9SlideAmmo",20,1)
stop
TNT1 A 0 A_TakeInventory("NotMode9SlideAmmo",15,1)
TNT1 A 0 A_TakeInventory("NotMode9SlideAmmo",5)
stop
}
}

actor JetAdaptorWings_M : JetAdaptorWings
{
States
{
Shield:
TNT1 A 0 A_JumpIfInTargetInventory("JetBoostPowerFake",1,"Shield2Fake")
TNT1 A 0 A_JumpIfInTargetInventory("JetBoostPower",1,"Shield2Start")
TNT1 A 1 A_Warp(AAPTR_TARGET,-12,0,36,0,WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION)//8+64
loop
Shield2Start:
TNT1 A 0 A_PlaySound("misc/gutsgboost")
Shield2:
TNT1 A 0 A_SpawnItemEx("BoosterFX",0,-15,-12,0,-2,-10,0)
TNT1 A 0 A_SpawnItemEx("BoosterFX",0, 15,-12,0, 2,-10,0)
TNT1 AA 1 A_Warp(2,-12,0,36,0,8+64)
TNT1 A 0 A_JumpIfInTargetInventory("JetBoostPower",1,"Shield2")
goto Shield
Shield2Fake:
TNT1 A 0 A_SpawnItemEx("BoosterFX",0,-15,-12,0,-2,-10,0)
TNT1 A 0 A_SpawnItemEx("BoosterFX",0, 15,-12,0, 2,-10,0)
TNT1 AA 1 A_Warp(2,-12,0,36,0,8+64)
TNT1 A 0 A_JumpIfInTargetInventory("JetBoostPower",1,"Shield2Start")
TNT1 A 0 A_JumpIfInTargetInventory("JetBoostPowerFake",1,"Shield2Fake")
goto Shield
}
}

actor JetBoostPowerFake : Powerup
{
Powerup.Duration 10
}



actor HeroMegaman_H2 : BasicWatcher
{
+SERVERSIDEONLY
+NOTIMEFREEZE
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveToTarget("HeroMegaman_P2",1)
stop
}
}
actor HeroMegaman_P2 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("Megaman_W2",1)
TNT1 A 0 A_SelectWeapon("Megaman_W2")
stop
}
}

actor Megaman_W2 : PowerAdaptorWep
{
tag "$TAGC_0B2"
weapon.preferredskin "Power-Megaman"
Inventory.Pickupmessage "You got the Rush Power Buster!"
weapon.ammotype2 "NotMode9SlideAmmo"
-WEAPON.ALT_USES_BOTH
-THRUACTORS
Inventory.ForbiddenTo ""
States
{
Spawn:
POWA Z 1
loop

Deselect:
POWA A 0 A_JumpIfInventory("PowerBlockFlag",1,1)
goto DeselectSwap
POWA A 4 A_GunFlash("Flash.Deselect",1)
goto DeselectSwap

Ready:
POWA A 0 A_TakeInventory("Megaman_W")
POWA A 0 A_GiveInventory("MegaAdaptorUpgrade",1)
POWA A 0 A_TakeInventory("Megaman_W1")
POWA A 0 A_GiveInventory("JetAdaptorUpgrade",1)
Ready2:
POWA A 0 A_GunFlash("Flash",1)
POWA A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_POWERFLIGHT)
Ready3:
POWA A 1 A_WeaponReady(WRF_NOSECONDARY)
wait


Flash:
TNT1 A 1 A_JumpIf(CallACS("cbm_HeroMega_PowerAltCheck",20),1)
wait
//TNT1 A 1 A_JumpIfInventory("NotMode9SlideAmmo",32,1)
//wait
//TNT1 A 1 A_JumpIf(CallACS("cbm_GetPointerButtonInput",0,true) & BT_ALTATTACK,1)
//wait
POWA P 0 A_GunFlash(1,1)
POWA PPQQ 1
POWA R 0 A_GiveInventory("PowerAdaptorBlock",1)
POWA R 0 A_GiveInventory("PowerBlockFlag",35)
POWA R 0 A_GiveInventory("MegamanPower_Alt_P")
goto Flash.Shield+2

Flash.Shield:
POWA R 0 A_GiveInventory("PowerAdaptorBlock",1)
POWA R 0 A_GiveInventory("PowerBlockFlag",35)
POWA R 1 A_GiveInventory("MegamanPower_Alt2_P")
POWA SSTTUUVVWWVVUUTTSSTTUUVVWWVVUUTTSSR 1 A_TakeInventory("PowerBlockFlag",1)
POWA R 0 A_JumpIf(CallACS("cbm_HeroMega_PowerAltCheck",20),"Flash.Shield")
goto Flash.ShieldEnd
Flash.ShieldEnd:
POWA Q 2 A_GiveInventory("MegamanPower_AltEnd_P")
POWA P 2
TNT1 A 0
goto Flash
Flash.Deselect:
POWA Q 2 A_GiveInventory("MegamanPower_AltEnd_P")
POWA P 2
TNT1 A 6
stop

Fire:
POWA B 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA B 0 A_Refire(1)
Goto Fire1
POWA B 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
POWA B 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA B 0 A_Refire(1)
Goto Fire1
POWA C 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA C 0 A_Refire(1)
Goto Fire1
POWA C 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
POWA C 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA C 0 A_Refire(1)
Goto Fire1
POWA D 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA D 0 A_Refire(1)
Goto Fire1
POWA D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
POWA D 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA D 0 A_Refire(1)
Goto Fire1
POWA E 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA E 0 A_Refire(1)
Goto Fire1
POWA E 0 A_JumpIfInventory("PlayerPropertyRage",1,"Charge0")
POWA E 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
POWA E 0 A_Refire("Charge0")
Goto Fire1

Charge0:
TNT1 A 0 A_JumpIfInventory("PowerMeter",17,"Charge1_Snd")
TNT1 A 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
TNT1 A 0 A_Refire("Charge0")
Goto Fire1

Charge1_Snd:
TNT1 A 0 A_PlaySound("weapon/coilstart",1)
Charge1:
TNT1 A 0 A_JumpIfInventory("PowerMeter",35,"Charge2_Snd")
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_POWERCHARGEAA,TCLR_POWERCHARGEAA)
TNT1 A 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
TNT1 A 0 A_Refire(1)
Goto Fire2
TNT1 A 0 A_JumpIfInventory("PowerMeter",35,"Charge2_Snd")
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_POWERCHARGEAB,TCLR_POWERCHARGEAB)
TNT1 A 1 A_GiveInventory("PowerMeter",1+CallACS("core_checkrune",RUNE_RAGE))
TNT1 A 0 A_Refire("Charge1")
Goto Fire2

Charge2_Snd:
//TNT1 A 0 A_StopSound(1)
//TNT1 A 0 A_SpawnItemEx("Megaman_PowerCharge_H")
//Due to the flash state being used, trickery of delays
TNT1 A 0 A_GiveInventory("MegaPowerChargeSnd_F",1)
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P1")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P2")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P3")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P1")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P2")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P3")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 0 A_GiveInventory("MegaPowerChargeSnd_F",1)
Charge2:
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P1")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P2")
TNT1 A 0 A_Refire(1)
Goto Fire3
TNT1 A 1 A_GiveInventory("Megaman_PowerCharge_P3")
TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotCharge2")
TNT1 A 0 A_Refire("Charge2")
Goto Fire3
BotCharge2:
TNT1 A 0 A_Jump(16,"Fire3")
TNT1 A 0 A_Refire("Charge2")
Goto Fire3

//Altfire:
Fire1:
POWA J 2 A_GiveInventory("PowerAdaptor_FireReset_P")
POWA K 0 A_PlaySound("weapon/mbuster",1)
POWA K 2 A_FireCustomMissile("PowerShot",0,0,8,0)
POWA LM 2
TNT1 A 2
POWA NO 2
goto Ready3
Fire2:
POWA J 2 A_GiveInventory("PowerAdaptor_FireReset_P")
POWA K 0 A_PlaySound("weapon/mbuster",1)
POWA K 2 A_FireCustomMissile("PowerShot2",0,0,8,0)
POWA LM 2
TNT1 A 4
POWA NO 2
goto Ready3
Fire3:
POWA J 2 A_GiveInventory("PowerAdaptor_FireReset_P")
POWA K 0 A_Quake(2,14,0,8,"none")
POWA K 0 A_PlaySound("Weapon/napalm",1)
POWA K 2 A_FireCustomMissile("PowerShot3",0,0,8,0)
POWA LM 2
TNT1 A 6
POWA NO 2
goto Ready3
}
}

actor PowerBlockFlag : Ammo
{
inventory.amount 1
inventory.maxamount 35
+INVENTORY.IGNORESKILL
}

actor PowerAdaptorBlock : BasePowerPro
{
+INVENTORY.ALWAYSPICKUP 
damagefactor "Normal", 0.75
powerup.duration 40
}

actor MegamanPower_Alt_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_nopushplayer",0,true)
TNT1 A 0 A_GiveInventory("PowerAdaptorBlock",1)
TNT1 A 0 A_GiveInventory("GuardUpFlag",1)
TNT1 A 0 A_TakeInventory("StopShield")
TNT1 A 0 A_SpawnItemEx("MegamanPowerSyncFX_H")
//TNT1 A 0 A_SpawnItemEx("PowerAdaptorShield",-32,32,52)
//TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldFX")
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldHitbox1",28,-16)
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldHitbox2",28,-8)
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldHitbox3",28,0)
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldHitbox4",28,8)
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldHitbox5",28,16)
stop
}
}

actor MegamanPowerSyncFX_H : BasicWatcher
{
+SERVERSIDEONLY
+NOTIMEFREEZE
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveToTarget("MegamanPowerSyncFX_P",1)
stop
}
}
actor MegamanPowerSyncFX_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShield",-32,32,52)
TNT1 A 0 A_SpawnItemEx("PowerAdaptorShieldFX")
stop
}
}

actor MegamanPower_Alt2_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("Megaman/BeatPowerShield",6,0.99)//weapon/birdstock
//TNT1 A 0 A_GiveInventory("PowerBlockFlag",35)

TNT1 A 0 A_GiveInventory("MegaSlideDelay",1)
TNT1 A 0 A_JumpIfInventory("MegaHasSlid_F",1,3)
TNT1 A 0 A_GiveInventory("MegaHasSlid_F",1)
TNT1 A 0 A_SpawnItemEx("MegaSlideRestore_H",0,0,24)
TNT1 A 0 A_TakeInventory("NotMode9SlideAmmo",15,1)
TNT1 A 0 A_TakeInventory("NotMode9SlideAmmo",5)
stop
}
}

actor MegamanPower_AltEnd_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_nopushplayer",0,false)
TNT1 A 0 A_TakeInventory("GuardUpFlag")
TNT1 A 0 A_TakeInventory("PowerBlockFlag")
TNT1 A 0 A_TakeInventory("PowerAdaptorBlock")
TNT1 A 0 A_GiveInventory("StopShield",1)
stop
}
}

actor MegaPowerChargeSnd_F : Powerup
{
Powerup.Duration 14
}

actor Megaman_PowerCharge_P1 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_POWERCHARGEBA,TCLR_POWERCHARGEBA)
goto Snd
Snd:
TNT1 A 0 A_JumpIfInventory("MegaPowerChargeSnd_F",1,3)
TNT1 A 0 A_GiveInventory("MegaPowerChargeSnd_F",1)
TNT1 A 0 A_PlaySound("weapon/MM5Charge",1)
TNT1 A 0
stop
}
}
actor Megaman_PowerCharge_P2 : Megaman_PowerCharge_P1
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_POWERCHARGEBB,TCLR_POWERCHARGEBB)
goto Snd
}
}
actor Megaman_PowerCharge_P3 : Megaman_PowerCharge_P1
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_POWERFLIGHT,TCLR_DEFAULT)
goto Snd
}
}

actor PowerAdaptorShieldHitbox1 : BasicShieldHitbox
{
Accuracy -16
}
actor PowerAdaptorShieldHitbox2 : BasicShieldHitbox
{
Accuracy -8
}
actor PowerAdaptorShieldHitbox3 : BasicShieldHitbox
{
Accuracy 0
}
actor PowerAdaptorShieldHitbox4 : BasicShieldHitbox
{
Accuracy 8
}
actor PowerAdaptorShieldHitbox5 : BasicShieldHitbox
{
Accuracy 16
}

actor PowerAdaptorShield : BasicGraphicEffect
{
Alpha 0.25
+DONTBLAST
States
{
SpawnFrame:
TNT1 A 0 //A_PlaySound("item/beat",0,0.75)
TNT1 A 0 A_Jump(2,1)
Goto SpawnA
TNT1 A 0 A_PlaySound("item/BirdUp",0,0.75)
Goto SpawnA
SpawnA:
BEAT AA 1 A_Warp(AAPTR_TARGET, -32, 32, 52, 0, WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION)//8+64
BEAT A 0 A_JumpIfInTargetInventory("PowerAdaptorBlock",1,"SpawnB")
BEAT A 1 A_JumpIf(true,"Death")
wait
SpawnB:
BEAT BB 1 A_Warp(2,-32,32,52,0,8+64)
BEAT B 0 A_JumpIfInTargetInventory("PowerAdaptorBlock",1,"SpawnC")
BEAT B 1 A_JumpIf(true,"Death")
wait
SpawnC:
BEAT CC 1 A_Warp(2,-32,32,52,0,8+64)
BEAT C 0 A_JumpIfInTargetInventory("PowerAdaptorBlock",1,"SpawnA")
BEAT C 1 A_JumpIf(true,"Death")
wait
Death:
TNT1 A 0
stop
}
}

actor PowerAdaptorShieldFX : BasicGraphicEffect
{
alpha 0.2
+FORCEXYBILLBOARD
+DONTBLAST
States
{
SpawnFrame:
POWW UVWXYZ 1 A_Warp(2,CallACS("cbm_ChasecamCheck_Client")*23,0,0,0,8+64)
"####" "#" 0 A_JumpIfInTargetInventory("PowerAdaptorBlock",1,"SpawnFrame")
"####" "#" 1 A_JumpIf(true,"Death")
wait
Death:
TNT1 A 0
stop
}
}

//actor MegaMan_W_NormalBar : NormalBar {Args 192,198}
actor MegaMan_W_ScriptBar : ScriptBar {}
actor MegaMan_W1_ScriptBar : ScriptBar {}
actor MegaMan_W2_ScriptBar : ScriptBar {}