actor MetalMan_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_2A"
dropitem "MetalBladeWep"
Weapon.AmmoUse 0
Weapon.AmmoGive 28
Obituary "$OB_METALBLADE"
weapon.ammotype "BuzzsawAmmo"
States
{
Spawn:
C_02 A 1
loop

Deselect:
BUIN A 0
goto DeselectSwap
Select:
BUIN A 0
goto SelectSwap

Ready:
BUIN A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_METALMAN)
BUIN A 0 A_GunFlash("Flash",1)
Goto Ready1
Ready1:
BUIN A 2 A_WeaponReady
BUIN A 0 A_GiveInventory("BuzzsawAmmo",2)
loop

Hold:
Fire:
BUIN A 0 A_JumpIfInventory("IsBot",1,"BotFire")
BUIN A 0 A_GiveInventory("Metalman_Fire_P")
FireEnd:
BUIN BCDEF 2
BUIN A 0 A_GiveInventory("BuzzsawAmmo",1)
BUIN A 0 A_ReFire
Goto Ready1
Altfire:
BUIN D 0 A_JumpIfInventory("IsBot",1,"BotFire0")
BUIN D 3 A_GiveInventory("Metalman_Alt_P")
BUIN D 0 A_Refire("Altfire")
BUIN D 0 A_TakeInventory("VivifyDelay8",9)
goto Ready1

Flash:
TNT1 A 1 A_GiveInventory("MetalmanFlashGive_P")
loop

BotFire:
BUIN A 0 A_JumpIfInventory("BuzzsawAmmo",56,"BotFire1")
BUIN A 0 A_JumpIfCloser(100,"AltFire")
BUIN A 0 A_Jump(181,2)
BUIN A 0 A_GiveInventory("BotFloorJump")
BUIN A 0 A_GiveInventory("BotRetreatFlag",1)
BUIN A 0 A_GiveInventory("Metalman_Fire_P")
BUIN BCDEF 2
BUIN A 0 A_GiveInventory("BuzzsawAmmo",2)
BUIN A 0 A_TakeInventory("BotRetreatFlag",999)
BUIN A 0 A_ReFire
Goto Ready1
BotFire0:
BUIN A 0 A_JumpIfCloser(100,2)
BUIN A 0 A_Jump(8,"BotFire2")
BUIN A 0
goto Altfire+1

BotFire1:
BUIN A 0 A_Jump(196,"BotFire2")
goto BotFire+1
BotFire2:
BUIN D 0 A_PlaySound("weapon/MetalMelee",1,1.0)
BUIN A 0 A_GiveInventory("MetalmanItemBot_P",1)
BUIN D 0 A_TakeInventory("BuzzsawAmmo",56)
BUIN D 0 A_PlaySound("weapon/MetalJump",7,1.0)//SoundSlot7
BUIN A 0 A_Jump(256,1,2,3)
BUIN D 3 A_ChangeVelocity(-Cos(pitch)*36,0,sin(pitch)*18,1)
Goto Ready1
BUIN D 3 A_ChangeVelocity(-Cos(25)*36,0,sin(25)*18,1)
Goto Ready1
BUIN D 3 A_ChangeVelocity(-Cos(75)*36,0,sin(75)*26,3)
Goto Ready1
}
}

actor BuzzsawAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 56
+INVENTORY.IGNORESKILL
}

actor MetalHoverBootsAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 280
+INVENTORY.IGNORESKILL
}

actor MetalFloatFlag : OnceC {}

actor PowerMetalFloat : PowerUp
{
powerup.duration 6
}
actor MetalClimbing : PowerMetalFloat{}

actor PowerMetalFloatSpeed : PowerSpeed
{
Speed 1.65
powerup.duration 3
+POWERSPEED.NOTRAIL
}


actor Metalman_Fire_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_PlaySound("weapon/metalblade",1,1.0)
TNT1 A 0 A_GiveInventory("PowerMetalFloat",1)
TNT1 A 0 A_FireCustomMissile("MetalManBlade",0,1,8,0)
stop
}
}

actor Metalman_Alt_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_GiveInventory("MetalClimbing",1)
TNT1 A 0 A_GiveInventory("BuzzsawAmmo",1)
TNT1 A 0 A_PlaySound("weapon/MetalMelee",1,1.0)
TNT1 A 0 A_FireCustomMissile("MetalManChainBlade",0,1,0,0)
stop
}
}

actor MetalmanItemBot_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("MetalFloatFlag",1,"Use2")
TNT1 A 0 A_GiveInventory("MetalFloatFlag",1)
stop
Use2:
TNT1 A 0 A_TakeInventory("MetalFloatFlag",1)
stop
}
}

actor MetalmanFlashGive_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("MetalmanFloat_P",1)
TNT1 A 0 A_JumpIfInventory("MetalClimbing",1,2)
TNT1 A 0 A_JumpIf(z-floorz<1,2)
TNT1 A 0
stop
TNT1 A 0 A_GiveInventory("MetalHoverBootsAmmo",1+CallACS("core_checkrune",RUNE_RAGE))
stop
}
}

actor MetalmanFloat_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("MetalFloatFlag",1,"Pickup0")
TNT1 A 0 A_JumpIf(CallACS("cbm_GetPointerButtonInput",0,true) & BT_JUMP,"Pickup0")
stop
Pickup0:
TNT1 A 0 A_JumpIfInventory("PlayerPropertyGrounded",1,"No")
TNT1 A 0 A_JumpIfInventory("PowerMetalFloat",1,"Pickup1")
stop
No:
TNT1 A 0
stop
Pickup1:
TNT1 A 0 A_JumpIfInventory("MetalHoverBootsAmmo",1,"Pickup2")
stop
Pickup2:
TNT1 A 0 A_JumpIf(momz<0,"Pickup3")
stop
Pickup3:
TNT1 A 0 A_GiveInventory("PowerMetalFloatSpeed",1)
TNT1 A 0 A_TakeInventory("MetalHoverBootsAmmo",1)
//TNT1 A 0 ThrustThingZ(0,4,0,0)//A_ChangeVelocity(momx,momy,0,2)
TNT1 A 0 ThrustThingZ(0,12,1,0)
stop
}
}

actor MetalManBlade : ProjSpawnFuncActor
{
var int user_TranslateWhiteColors;
PROJECTILE
damagetype "MetalM_Blade"
Obituary "$OB_METALBLADE"
+RIPPER
+SKYEXPLODE
+EXPLODEONWATER
Damage (140)
Radius 4//3
Height 5
Speed 40
scale 2.5
States
{
Spawn:
TNT1 AA 0
SpawnL:
MEGR TU 1
loop
Death:
MEGR U 0 A_JumpIf(z-floorz<Height, "Floor")
MEGR U 0 A_JumpIf(z-ceilingz==-Height, "Ceiling")
stop
Floor:
MEGR U 0 A_SpawnItemEx("MetalManBladeF",0,0,0,30)
stop
Ceiling:
MEGR U 0 A_SpawnItemEx("MetalManBladeC")
stop
Crash:
XDeath:
MEGR U 0
stop
}
}

actor MetalManBladeF : MetalManBlade
{
-NOGRAVITY
+BOUNCEONCEILINGS
+NOEXPLODEFLOOR
+STEPMISSILE
maxstepheight 16
Damage(0+140*Args[0])
Speed 30
States
{
Spawn:
MEGR T 1
MEGR T 0 A_SetArg(0,1)
MEGR UT 1
goto Spawn+2
Death:
TNT1 A 1
stop
}
}

actor MetalManBladeC : MetalManBlade
{
-NOGRAVITY
Speed 0
}

actor MetalManChainBlade : ProjSpawnFuncActor
{
var int user_TranslateWhiteColors;
PROJECTILE
Damagetype "MetalM_Chain" 
Obituary "$OB_METALBLADE"
+RIPPER
+DONTBLAST
+DONTREFLECT
Damage (60)
Radius 3
Height 4
Speed 64
scale 2.5
States
{
Spawn:
MEGR TU 1
stop
Death:
TNT1 A 0 A_GiveToTarget("MetalManClimb_P",1)
stop
XDeath:
Crash:
TNT1 A 1
stop
}
}


actor MetalManClimb_P : CustomInventory
{
states
{
Pickup:
TNT1 A 0
TNT1 A 0 A_JumpIfInventory("PlayerPropertyGrounded",1,"No")
TNT1 A 0 A_JumpIfInventory("MetalHoverBootsAmmo",1,"Success")
TNT1 A 0 A_JumpIfInventory("VivifyDelay8",1,5)
stop
Success:
TNT1 A 0 A_JumpIf(CallACS("cbm_GetPointerButtonInput",0,true) & BT_JUMP,"SuccessChain")
TNT1 A 0 A_JumpIfInventory("VivifyDelay8",1,3)
TNT1 A 0 A_TakeInventory("MetalHoverBootsAmmo",5)
TNT1 A 0 A_GiveInventory("VivifyDelay8",1)
TNT1 A 0 A_PlaySound("weapon/MetalMelee2",4,0.35)
TNT1 A 0 ThrustThingZ(0,30+CallACS("core_checkrune",RUNE_RAGE)*24,0,0)//old 16+12=28
stop
SuccessChain:
TNT1 A 0 A_JumpIfInventory("BuzzsawAmmo",56,"SuccessChainBoost")
stop
SuccessChainBoost:
TNT1 A 0 A_TakeInventory("MetalHoverBootsAmmo",25)
TNT1 A 0 A_TakeInventory("BuzzsawAmmo",14)
TNT1 A 0 A_TakeInventory("BuzzsawAmmo",42,1)
TNT1 A 0 A_PlaySound("weapon/MetalJump",7,1.0)//SoundSlot7
TNT1 A 0 A_ChangeVelocity(-Cos(pitch)*36, 0, sin(pitch)*18,1)
stop
No:
TNT1 A 0
stop
}
}


actor MetalMan_W_NormalBar : NormalBar {Args 210,164}
actor MetalMan_W_ScriptBar : ScriptBar {}