How do I prevent the Super Transformation?

FiredReadyBlocks

I'm Fired Up!
I'd like to prevent the super transformation from activating at all until 150+ rings are collected, but I've been digging around and trying things for a few hours now, and cant figure out how to prevent the transformation. I know how to cancel it, just not prevent it. Do any of yall know how that'd be done?
 
I'd like to prevent the super transformation from activating at all until 150+ rings are collected, but I've been digging around and trying things for a few hours now, and cant figure out how to prevent the transformation. I know how to cancel it, just not prevent it. Do any of yall know how that'd be done?
Take this! Hope it helps.

dah code.:
local skin_name = "sonic" // The name of the character!
local super_rings = 150 // How many rings we need to be Super?
local super_button = BT_SPIN // What button we'll use to go Super?

addHook("PlayerThink", function(player) // PlayerThink runs every frame as long as there's at least one player in the level
    if player.mo        // Do we exist?
    and player.mo.valid //
    and player.mo.health // Are we alive?
    and player.mo.skin == skin_name // u r dah char ??
    and not player.powers[pw_super] // No Super Saiyans!
    and skins[skin_name].flags & SF_SUPER // Can go Super?
    and All7Emeralds(emeralds) // We have all the 7 funny rocks? (Singleplayer/Co-op)
    and player.rings >= super_rings // We have the required amount of rings?
        player.charflags = $ & ~SF_SUPER // Can't be Super

        if player.pflags & PF_JUMPED // We've jumped?
        and player.cmd.buttons & super_button // Pressing our new Super button?
        and not P_IsObjectOnGround(player.mo) // We r NOT on dah groun?
            player.charflags = $|SF_SUPER // u can be supah :>
            P_DoSuperTransformation(player) // SUPERRRR!!!!!!!!
        end
    end
end)
 
Take this! Hope it helps.
Unless I'm doing something really wrong, I think this code doesnt work :/
I've tried messing around with it and even making my own script based on the principles of yours, but still no luck.
I've been testing it with no other addons loaded, just vanilla and this script.

I have seen one mod do what I want to, and that's Super Redux. I've tried looking in the code to perhaps reverse engineer how they did it, but I'm unfortunately too new to SRB2 modding/lua programming to make out what I need to. The mod has other functions aside from the ring restriction, so for me, it's kinda hard to read. :/
I guess this may be something I'll need to wait to make until im more familiar with lua programming and the inner workings of SRB2. :P
 
I'm not sure what was wrong previously but now it's working. Here's the fixed code, along with some changed comments:

EDIT: In skin_name, replace "sonic" with "all" to make it affect all characters! (This wasn't tested, though.)

150 Rings Transformation:
local skin_name = "sonic" // The name of the character!
local super_rings = 150 // How many rings we need to be Super?
local super_button = BT_USE // What button we'll use to go Super? (BT_SPIN same as BT_USE)

addHook("PlayerThink", function(player) // PlayerThink runs every frame as long as there's at least one player in the level
    if player.mo        // Do we exist?
    and player.mo.valid //
    and player.mo.health // Are we alive?
    and not (player.pflags & PF_THOKKED) // We aren't using any ability?
    and not player.powers[pw_super] // No Super Saiyans!
    and skins[skin_name].flags & SF_SUPER // Can go Super?
    and All7Emeralds(emeralds) // We have all the 7 funny rocks? (Singleplayer/Co-op)

    and ((skin_name != "all" // If we setted an specific character...
    and player.mo.skin == skin_name) // ...check if we're using that character
    or skin_name == "all") // Else, if we setted "all", this will affect any character

        player.charflags = $ & ~SF_SUPER // Can't be Super :knuxsmug:

        if player.pflags & PF_JUMPED // We've jumped?
        and player.cmd.buttons & super_button // Pressing our Super button?
        and not P_IsObjectOnGround(player.mo) // We are NOT on grounded?
        and player.rings >= super_rings // We have the required amount of rings?
            player.charflags = $|SF_SUPER // u can be supah :>
            P_DoSuperTransformation(player) // SUPERRRR TRANSFORMATIONNNN!!!!!!!!
        end
    end
end)
 
Last edited:

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top