actor Protoman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_0A"
dropitem "PowerAdaptorUpgrade"
weapon.preferredskin "Protoman-ShieldLess"

Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Inventory.Pickupmessage "$PU_PROTOBUSTER"
Obituary "$OB_PROTOBUSTER"
weapon.ammotype "JumpAndShootManAmmo"
weapon.ammotype2 "NuclearSkidAmmo"
States
{
Spawn:
C_00 A 1
loop

Deselect:
PSLI J 0 A_JumpIfInventory("StopShield",1,3)
PSLI KL 1
PSLI L 0 A_GiveInventory("StopShield",1)
PSLI L 0 A_TakeInventory("SlideVivifyFlag")
PSLI L 0 A_TakeInventory("JumpAndShootManAmmo")
goto DeselectSwap
Select:
PSLI J 0 A_TakeInventory("JumpAndShootManAmmo")
goto SelectSwap

Ready:
PSLI J 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_PROTOMANC)
Goto Ready2
Ready2:
PSLI J 0 A_TakeInventory("JumpAndShootManAmmo")
PSLI J 0 A_TakeInventory("StopShield",1)
PSLI K 0 A_GunFlash("Flash",1)
PSLI LKJ 1 A_WeaponReady
wait

Flash:
TNT1 A 0 A_GiveInventory("ProtoShieldHitbox_P",1)
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ProtoShieldFX",23,-10,8,momx,momy,momz,0,9,0)
TNT1 A 1 A_JumpIfInventory("StopShield",1,"NoFlash")
goto Flash+1

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

Fire:
PSLI D 0 A_JumpIfInventory("StopShield",1,"ChargeStart")
//PSLI D 0 A_JumpIfInventory("StopShield",1,"Fire1")
PSLI D 0 A_GiveInventory("Protoman_Fire_P1")
PSLI KLD 1
PSLI EF 3
PSLI D 2
PSLI D 0 A_Refire("ChargeStart")
FireWait:
//PSLI DDDDDD 2 A_WeaponReady
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0 A_JumpIfInventory("PlayerPropertyRage",1,3)
PSLI D 0 A_Refire("Fire1")
PSLI D 1 A_WeaponReady(WRF_NOPRIMARY)
PSLI D 0
goto Ready2
Fire1:
PSLI D 0 A_GiveInventory("Protoman_Fire_P1")
PSLI EF 3
PSLI D 2
PSLI D 0 A_Refire("ChargeStart")
goto FireWait

Fire2:
PSLI F 3 A_GiveInventory("Protoman_Fire_P2")
PSLI EDD 3
PSLI D 0 A_Refire("ChargeStart")
goto Ready2

Fire3:
PSLI F 3 A_GiveInventory("Protoman_Fire_P3")
PSLI ED 3
PSLI D 8
PSLI D 0 A_Refire("ChargeStart")
goto Ready2

Fire4:
PSLI F 6 A_GiveInventory("Protoman_Fire_P4")
PSLI ED 3
PSLI D 4
PSLI D 5
//PSLI D 0 A_Refire("ChargeStart")//Altfire reaches this state, so holding alt would cause charging
PSLI D 1 A_WeaponReady
goto Ready2

ChargeStart:
PSLI D 0 A_GiveInventory("StopShield",1)
PSLI D 0 A_GunFlash("Flash.Charge",1)
Charge0:
PSLI D 1 A_JumpIfInventory("JumpAndShootManAmmo",10,"Charge1_Snd")
PSLI D 0 A_Refire("Charge0")
Goto Fire1

Charge1_Snd:
PSLI D 0 A_PlaySound("weapon/pchargelong",1)//weapon/pcharge
ChargeX1:
PSLI H 0 A_JumpIfInventory("JumpAndShootManAmmo",0,"ChargeX2_Snd")
PSLI H 1 ACS_NamedExecuteWithResult("core_chargecolor",CLR_PROTOCHARGE1,TCLR_PROTO_CHARGE1)//5
PSLI H 0 A_Refire(1)
Goto Fire2
PSLI H 1 A_JumpIfInventory("JumpAndShootManAmmo",0,"ChargeX2_Snd")
PSLI H 0 A_Refire(1)
Goto Fire2
PSLI D 0 A_JumpIfInventory("JumpAndShootManAmmo",0,"ChargeX2_Snd")
PSLI D 1 ACS_NamedExecuteWithResult("core_chargecolor",DYE_PROTOMANC,TCLR_NONE)
PSLI D 0 A_Refire(1)
Goto Fire2
PSLI D 1 A_JumpIfInventory("JumpAndShootManAmmo",0,"ChargeX2_Snd")
PSLI D 0 A_Refire("ChargeX1")
Goto Fire2

ChargeX2_Snd:
PSLI D 0 A_GunFlash("Flash.Charge2",1)//A_GiveInventory("ProtoStrikeReady",1)
ChargeX2:
PSLI I 1 A_GiveInventory("Protoman_Charge2_P2")
PSLI I 0 A_Refire(1)
Goto Fire3
PSLI D 1 A_GiveInventory("Protoman_Charge2_P0")
PSLI D 0 A_Refire(1)
Goto Fire3
PSLI H 1 A_GiveInventory("Protoman_Charge2_P1")
PSLI H 0 A_Refire(1)
Goto Fire3
PSLI D 1 A_GiveInventory("Protoman_Charge2_P0")
PSLI D 0 A_JumpIfInventory("IsBot",1,"BotFireX2")
PSLI D 0 A_Refire("ChargeX2")
Goto Fire3

BotFireX2:
PSLI D 0 A_JumpIfCloser(256,3)
PSLI D 0 A_Jump(16,"Fire3")
PSLI D 0 A_Refire("ChargeX2")
Goto Fire3
PSLI D 0 A_Jump(48,"Fire4")
Goto BotFireX2+1

Altfire:
PSLI I 0 A_JumpIfInventory("ProtoStrikeReady",1,"Fire4")
PSLI K 0 A_JumpIf(z-floorz==0,"SlideSlide") //A_JumpIf(momz==0, "SlideSlide")
PSLI K 1 A_WeaponReady
PSLI J 0 A_JumpIfInventory("StopShield",1,2)
PSLI J 1 A_WeaponReady
wait
PSLI J 0 A_TakeInventory("StopShield")
PSLI J 0 A_GunFlash("Flash",1)
PSLI J 1 A_WeaponReady
wait


Flash.Slide:
TNT1 AAAAAAAAAAAAAAAAAAAAA 1 A_JumpIf(CallACS("cbm_GetPointerButtonInput",0,true) & BT_JUMP,"Flash.SlideJump")
//21
stop
Flash.SlideJump:
TNT1 A 0 A_GiveInventory("VivifyDelay7",1)
TNT1 A 1 A_GiveInventory("ProtoSlideJump_P",1)
stop

SlideSlide:
PSLI D 0 A_GiveInventory("SlideVivifyFlag",1)
PSLI D 0 A_Refire(1)
PSLI D 0 A_GiveInventory("ProtoSlideCheck_P")
PSLI D 0 A_GunFlash("Flash.Slide",1)
PSLI D 0 A_JumpIfInventory("StopShield",1,5)
PSLI D 0 A_GiveInventory("StopShield",1)
PSLI KB 2
PSLI B 0 A_Jump(256,3)
PSLI BA 2
PSLI A 11
PSLI B 2
PSLI B 3 A_TakeInventory("ProtomanSlideSlow")//ACS_NamedExecuteWithResult("core_stopplayer",0,0)
PSLI L 0 A_GunFlash("NoFlash",1)
PSLI L 7 A_TakeInventory("CBM_150_JumpPower")//CBM_DisableJumpPower
PSLI K 0 A_TakeInventory("SlideVivifyFlag")
PSLI K 0 A_TakeInventory("JumpAndShootManAmmo")
PSLI K 0 A_TakeInventory("StopShield",1)
PSLI K 0 A_GunFlash("Flash",1)
PSLI KKKJ 1 A_WeaponReady
wait

}
}

actor JumpAndShootManAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 40
+INVENTORY.IGNORESKILL
}
actor NuclearSkidAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 500
+INVENTORY.IGNORESKILL
}

actor ProtoStrikeReady : Inventory
{
inventory.maxamount 32
}

actor ProtomanSlideSlow : PowerSpeed
{
powerup.duration 20
Speed 0.2
+POWERSPEED.NOTRAIL
}

actor ProtoSlideJumpReduce : Powerup
{
Powerup.Duration 4
}
actor ProtoSlideDelay : Powerup
{
Powerup.Duration -2
+INVENTORY.ALWAYSPICKUP
}
actor ProtoHasSlid_F : Inventory{}

actor ProtoSlideRestore_H : BasicWatcher
{
+SERVERSIDEONLY
States
{
Spawn:
TNT1 A 1
TNT1 A 5
Spawn2:
TNT1 A 0 A_JumpIfInTargetInventory("ProtoSlideDelay",1,2)
TNT1 A 0 A_GiveToTarget("NuclearSkidAmmo",5+CallACS("core_checkrune",RUNE_RAGE,2)*5)
TNT1 A 5
TNT1 A 0 A_JumpIfInTargetInventory("NuclearSkidAmmo",0,"Death")
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIfInTargetInventory("ProtoHasSlid_F",1,"Spawn2")
goto Death
Death:
TNT1 A 1 A_TakeFromTarget("ProtoHasSlid_F",99)
stop
}
}

actor ProtoSlideCheck_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("Protoman/Slide",1)//weapon/chargekick
TNT1 A 0 A_GiveInventory("ProtoSlideThrust_P")
TNT1 A 0 A_GiveInventory("CBM_150_JumpPowerGiver",1)//CBM_DisableJumpPowerGiver
TNT1 A 0 A_GiveInventory("ProtoSlideJumpReduce",1)
TNT1 A 0 A_GiveInventory("ProtomanSlideSlow",1)//ACS_NamedExecuteWithResult("core_stopplayer",0,1)
TNT1 A 0 A_GiveInventory("ProtoSlideDelay",1)
TNT1 A 0 A_JumpIfInventory("ProtoHasSlid_F",1,3)
TNT1 A 0 A_GiveInventory("ProtoHasSlid_F",1)
TNT1 A 0 A_SpawnItemEx("ProtoSlideRestore_H",0,0,24)
TNT1 A 0 A_JumpIfInventory("NuclearSkidAmmo",100,1)
stop
TNT1 A 0 A_TakeInventory("NuclearSkidAmmo",100,1)
stop
}
}

actor ProtoSlideThrust_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("BasicSlideDashFX_P")
TNT1 A 0 A_JumpIfInventory("NuclearSkidAmmo",100,"Thrust")
TNT1 A 0 ThrustThingZ(0,0,1,0)
TNT1 AA 0 A_Recoil(-15)
stop
Thrust:
TNT1 A 0 ThrustThingZ(0,0,1,0)
TNT1 AA 0 A_Recoil(-26)
stop
}
}


actor ProtoSlideJump_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySound("Protoman/SlideJump",4)
TNT1 A 0 A_GiveInventory("JumpCancler",1)
TNT1 A 0 A_TakeInventory("CBM_150_JumpPower")
TNT1 A 0 A_JumpIfInventory("ProtoSlideJumpReduce",1,2)
TNT1 A 0 A_ChangeVelocity(momx*0.775,momy*0.775,CallACS("core_getactorproperty",0,APROP_JumpZ,DATATYPE_INT)*(CallACS("core_checkrune",RUNE_HIGHJUMP,0)+1),CVF_REPLACE)
stop
TNT1 A 0 A_ChangeVelocity(momx*0.500,momy*0.500,CallACS("core_getactorproperty",0,APROP_JumpZ,DATATYPE_INT)*(CallACS("core_checkrune",RUNE_HIGHJUMP,0)+1),CVF_REPLACE)
stop
}
}

actor Protoman_Charge2_P0 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_PROTOMANC,TCLR_NONE)//7
TNT1 A 0 A_JumpIfInventory("ProtoStrikeReady",0,"Strike")
stop
Strike:
TNT1 A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOPRIMARY)//2+4
stop
}
}
actor Protoman_Charge2_P1 : Protoman_Charge2_P0
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_PROTOCHARGE1,TCLR_PROTO_CHARGE1)//5
TNT1 A 0 A_JumpIfInventory("ProtoStrikeReady",0,"Strike")
stop
}
}
actor Protoman_Charge2_P2 : Protoman_Charge2_P0
{
States
{
Pickup:
//Old colors 160,148,166 [] Core colors 138,229,230
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",CLR_PROTOCHARGE2,TCLR_PROTO_CHARGE2)//6
TNT1 A 0 A_JumpIfInventory("ProtoStrikeReady",0,"Strike")
stop
}
}

actor Protoman_Fire_P1 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("StopShield",1)
TNT1 A 0 A_TakeInventory("JumpAndShootManAmmo")
TNT1 A 0 A_PlaySound("Protoman/BusterFire",1)//weapon/mbuster
TNT1 A 0 A_FireCustomMissile("ProtoShotC",0,0,8,0)
stop
}
}

actor Protoman_Fire_P2 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_FireCustomMissile("ProtoShot2C",0,0,8,0)
End:
TNT1 A 0 A_PlaySound("weapon/pshot",1)
TNT1 A 0 ACS_NamedExecuteWithResult("core_chargecolor",DYE_PROTOMANC,TCLR_NONE)
TNT1 A 0 A_TakeInventory("JumpAndShootManAmmo")
TNT1 A 0 A_TakeInventory("ProtoStrikeReady")
TNT1 A 0 A_GiveInventory("StopShield",1)
stop
}
}

actor Protoman_Fire_P3 : Protoman_Fire_P2
{
States
{
Pickup:
TNT1 A 0 A_FireCustomMissile("ProtoShot3C",0,0,8,0)
goto End
}
}

actor Protoman_Fire_P4 : Protoman_Fire_P2
{
States
{
Pickup:
TNT1 A 0 A_FireCustomMissile("ProtoStrikeShot",0,0,8,0)
TNT1 A 0 A_PlaySound("Protoman/ProtoStrike",1)
goto End+1
}
}


actor ProtoShotC : ProjSpawnFuncActor
{
PROJECTILE
damagetype "ProtoM_Shot"
Obituary "$OB_PROTOBUSTER"
+THRUGHOST
+BRIGHT
Damage (100)
radius 10
height 5
Speed 35
scale 2.5
States
{
Spawn:
TNT1 A 2
Q_0B B 2
Q_0B B 0 A_ChangeFlag("THRUGHOST",0)
Q_0B B 1
wait
Death:
TNT1 A 1
stop
}
}

actor ProtoShot2C : ProjSpawnFuncActor
{
PROJECTILE
+THRUGHOST
+BRIGHT
damagetype "ProtoM_Shot2"
Obituary "$OB_PROTOBUSTER"
Damage (200)
radius 14
height 14
Speed 35
scale 2.5
States
{
Spawn:
TNT1 A 2
NMFX C 2
NMFX C 0 A_ChangeFlag("THRUGHOST",0)
NMFX C 1
wait
}
}

actor ProtoShot3C : ProjSpawnFuncActor
{
PROJECTILE
damagetype "ProtoM_Shot3"
Obituary "$OB_PROTOBUSTER"
+THRUGHOST
+BRIGHT
Damage (350)
radius 18
height 18
Speed 60
scale 2.5
States
{
Spawn:
PCOI X 2
PCOI Y 2 A_ChangeFlag("THRUGHOST",0)
PCOI Z 2
PCOI XYZ 2
Goto Spawn+3
}
}


actor ProtoM_StrikeProtect : PowerProtection
{
Powerup.Duration 2
DamageFactor "ProtoM_Strike", 0.0
}

actor ProtoStrikeShot : BasicExplosion
{
Damagetype "ProtoM_Strike"
Obituary "$OB_PROTOSTRIKE"
Speed 20
Args 12
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItemEx("ProtoStrikeShotFX_H",-momx,-momy,-momz,momx,momy,momz,0,1+2+8+SXF_TRANSFERSPECIAL)//32768
Spawn2:
TNT1 A 0
TNT1 A 0 A_Explode((350+(Args[0]<=3)*100-Args[0]*10*(Args[0]>3))*(CallACS("core_checkrune",RUNE_SPREAD,2)+1),28,0,0,28)
TNT1 A 0 A_CountDownArg(0)
TNT1 A 0 A_SpawnItemEx("ProtoStrikeShot2",0,0,0,momx,momy,momz,0,1+8+32768)
//TNT1 A 0 A_SpawnItemEx("ProtoStrikeShotFX",0,-40,0,0,0,0,0,1+32768)//Does not sync online, so _H version mimics
TNT1 A 4
stop
Death:
TNT1 A 0
stop
}
}
actor ProtoStrikeShot2 : ProtoStrikeShot{States{Spawn:goto Spawn2}}

actor ProtoStrikeShotFX_H : BasicGraphicEffect
{
RenderStyle None
Args 12
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_CountDownArg(0)
TNT1 A 0 A_SpawnItemEx("ProtoStrikeShotFX_H",0,0,0,momx,momy,momz,0,1+8+32768)
TNT1 A 0 A_SpawnItemEx("ProtoStrikeShotFX",0,0,0,0,0,0,0,1+32768)
TNT1 A 4
stop
Death:
TNT1 A 0
stop
}
}

actor ProtoStrikeShotFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
+BRIGHT
Alpha 1.15
Speed 60
scale 2.5
States
{
SpawnFrame:
TNT1 A 0
TNT1 A 0 A_JumpIf(Args[0]<=0,"SpawnFrame2")
TNT1 A 0 A_SetScale(ScaleX-Args[0]*0.175)
TNT1 A 0 A_Jump(256,2,4,6)
SpawnL:
PCOI U 0 A_SetScale(ScaleX+0.25,ScaleY+0.1)
PCOI U 2 A_FadeOut(0.125)
PCOI V 0 A_SetScale(ScaleX+0.25,ScaleY+0.1)
PCOI V 2 A_FadeOut(0.125)
PCOI W 0 A_SetScale(ScaleX+0.25,ScaleY+0.1)
PCOI W 2 A_FadeOut(0.125)
loop

SpawnFrame2:
PCOI Q 0 A_Jump(256,2,4,6,8)
SpawnL2:
PCOI Q 0 A_SetScale(ScaleX+0.15,ScaleY+0.15)
PCOI Q 2 A_FadeOut(0.125)
PCOI R 0 A_SetScale(ScaleX+0.15,ScaleY+0.15)
PCOI R 2 A_FadeOut(0.125)
PCOI S 0 A_SetScale(ScaleX+0.15,ScaleY+0.15)
PCOI S 2 A_FadeOut(0.125)
PCOI T 0 A_SetScale(ScaleX+0.15,ScaleY+0.15)
PCOI T 2 A_FadeOut(0.125)
loop
}
}


actor ProtoShieldHitbox_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_SpawnItemEx("Protoman_ShieldHitbox1",28,-16,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("Protoman_ShieldHitbox2",28,-8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("Protoman_ShieldHitbox3",28,0,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("Protoman_ShieldHitbox4",28,8,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("Protoman_ShieldHitbox5",28,16,8,0,0,0,0,1)
stop
}
}

actor Protoman_ShieldHitbox1 : BasicShieldHitbox
{
Meleerange 28
Accuracy -16
Mass 8
}
actor Protoman_ShieldHitbox2 : Protoman_ShieldHitbox1
{
Accuracy -8
}
actor Protoman_ShieldHitbox3 : Protoman_ShieldHitbox1
{
Accuracy 0
}
actor Protoman_ShieldHitbox4 : Protoman_ShieldHitbox1
{
Accuracy 8
}
actor Protoman_ShieldHitbox5 : Protoman_ShieldHitbox1
{
Accuracy 16
}


//actor Protoman_W_NormalBar : NormalBar {Args 87,42}
actor Protoman_W_ScriptBar : ScriptBar {}