PWADLCharacter 6 Status = 0 SkinName = metalsonic DisplayName = Metal#Sonic PlayerText = ^4Metal Sonic^0 can keep up with Sonic in speed, but also has the same difficulty getting around hazards. ^4Ability:^0 Boost Mode Keep moving at high speeds to increase his stats, letting him charge through spikes and sprint over water. ^4Ability:^0 Boost Drive Change directions on a dime, and convert your extra speed into a great leap. #-- Credits -- CosmicSRB2: figuring out how to overwrite a character's base ability and trigger a different one. -- skeletondome & luigibudd: debugging. -- Skydusk: teaching me Lua to begin with. -- Script for Metal Sonic's Boost Drive ability. -- Handles everything that should happen during a PlayerThink step; holdingjump provided by skeletondome. addHook("PlayerThink", function(player) if player == "nil" then return end if not player.mo.skin == "metalsonic" then return end if not player.holdingjump and player.cmd.buttons & BT_JUMP ~= 0 then player.holdingjump = true elseif player.cmd.buttons & BT_JUMP == 0 then player.holdingjump = false end -- MSConv variable only allows this to happen once per ability: if jump is released before landing, upward vertical momentum is halved. if (player.pflags & PF_JUMPED) and (player.pflags & PF_THOKKED) if (player.msconv == 1) then if (player.holdingjump == false) then player.msconv = 0 -- Don't halve vmom if going down. if (player.mo.momz > 0) then player.mo.momz = $/2 end end end end -- Reinitialise Boost Drive variables on floor impact. if player.mo.eflags & MFE_JUSTHITFLOOR then player.msconv = -1 player.eeghosts = 0 player.dashhalve = 0 end -- Do ghosts while ascending from a full Boost Drive and vertical momentum is facing up. if (player.pflags & PF_JUMPED) and (player.pflags & PF_THOKKED) if player.msconv == 1 and player.eeghosts == 1 and player.mo.momz > 0 then if player.mtlghosttimer > 0 then player.mtlghosttimer = $ - 1 end if player.mtlghosttimer == 0 then P_SpawnGhostMobj(player.mo) player.mtlghosttimer = 2 end end -- 2/3 Dashmode gain while in air from Boost Drive. if player.dashhalve == 1 then player.dashhalvetimer = $ - 1 if player.dashhalvetimer < 1 then if player.dashmode > 0 then player.dashmode = $ - 1 end player.dashhalvetimer = 3 end end if player.mo.momz < 0 and player.mo.state == S_PLAY_SPRING then player.mo.state = S_PLAY_FALL end end end) -- The ability. addHook("AbilitySpecial", function(player) --Only do this if you're Metal Sonic! if player == "nil" then return end if not player.mo.skin == "metalsonic" then return end player.charability = CA_NONE -- Check to see that using this is legal. if (player.pflags & PF_JUMPED) and not (player.pflags & PF_THOKKED) then -- Store dashmode early and reset your dashmode stat to make sure that stuff actually works. player.dashcharge = player.dashmode player.dashmode = 0 -- Removes Metal's tank powers until he lands. player.powers[pw_strong] = $ &~ STR_METAL -- Also reset your values, because that has to be done manually. if player.jumpfactor > 1*FRACUNIT then player.jumpfactor = 1*FRACUNIT end if player.normalspeed > 36*FRACUNIT then player.normalspeed = 36*FRACUNIT end -- More checks to make sure you can't hit anything until you land (hardcode resets these on landing). Also halve your Dashmode gain until you land, but don't cut it entirely. player.pflags = $|PF_THOKKED|PF_JUMPED|PF_NOJUMPDAMAGE player.dashhalve = 1 player.dashhalvetimer = 2 -- Play the Death Egg rocket launch sound and put you in falling state. S_StartSound(player.mo, sfx_s3k82) -- Set MSConv to 1, allowing release of double jump for upwards momentum halving. player.msconv = 1 -- Activate Boost Drive when you have dashmode: kills your dashmode, converts excess dashmode to jump height, plays extra lightning SFX. if player.dashcharge > 104 then player.mo.state = S_PLAY_SPRING P_SetObjectMomZ(player.mo, (player.dashcharge*2/11)*FRACUNIT, false) S_StartSound(player.mo, sfx_s3k85) player.eeghosts = 1 player.mtlghosttimer = 1 player.mtlghostcount = 6 -- Else do a tiny baby hop. else player.mo.state = S_PLAY_FALL P_SetObjectMomZ(player.mo, (player.dashcharge*2/11)*FRACUNIT, false) end if player.mo.momx and player.mo.momy then -- Use trigonometry to redirect momentum. P_InstaThrust(player.mo, player.mo.angle, min(2359296,FixedHypot(player.mo.momx, player.mo.momy))) end end end) µSOC_PLAYÁ‹LUA_BOOS