// The name of the character!
// The value MUST match the name value of your character
// Make sure the name is between quotes (like "this")
local super_name = "sonic"
// How many Rings we need to be Super?
// SRB2's default is 50
local super_rings = 50
// What button will we use to go Super?
// SRB2's default is BT_SPIN
// See available options here -> https://wiki.srb2.org/wiki/Constants#Button_flags_(BT_*)
local super_button = BT_CUSTOM2
// PlayerThink runs every frame for every player available
addHook("PlayerThink", function(player)
if skins[player.skin].name == super_name // Must be using the specified skin
and player.mo // Make sure we have an assigned object in the level...
and player.mo.valid // ...and make sure said object exists
and player.mo.health // To transform, u must be alive. Duh.
and skins[super_name].flags & SF_SUPER // Make sure the character's defs allow them to have a Super form
and not player.powers[pw_super] // If you're ALREADY Super, don't run the code
and not (player.pflags & PF_THOKKED) // Avoids players from transforming right after using an ability
and All7Emeralds(emeralds) // Check for the Chaos Emeralds (Singleplayer/Co-op)
// Deleting the Super flag allows us to avoid the player from using Spin to transform!
player.charflags = $&~SF_SUPER
if player.pflags & PF_JUMPED // You want to transform during a jump, right?
and not P_IsObjectOnGround(player.mo) // Just in case, check if we're actually mid-air
and player.rings >= super_rings // Do we have the required amount of rings?
and player.cmd.buttons & super_button // Are you pressing the assigned input?
player.charflags = $|SF_SUPER // u can be supah :>
P_DoSuperTransformation(player) // Now you do the thing!! >:3
end
end
end) // ~ FIN ~