Noob Srb2 Modding Help.

DolphinCube

Cubin' Around SRB2
Hiya! I am creating a character wad and I was wondering how to make a animation where if I activate my characters ability (It is the double jump). My character does an animation (a flip) then the sprites stop at the final frame. Can someone help me with this?
 
I'm not truly sure, but replace Amy with your skin name and then try
Code:
//In this example, p is the player

addHook("PlayerThink", function(p)
    if (p.mo) and (p.mo.skin == "Amy") //Or something else
        if (p.cmd.buttons & BT_CUSTOM1) and (p.pressc1 == true) then //If pressing C1
            if not (p.pflags & PF_THOKKED)
                p.pressc1 = false //We probably want this to run only once per C1 press
                p.pflags = p.pflags + PF_THOKKED
                if (p.charability == CA_TWINSPIN) then 
                    p.charability = CA_DOUBLEJUMP
                else
                    p.charability = CA_TWINSPIN
                end
            end
        end
        if not (p.cmd.buttons & BT_CUSTOM1) then //If NOT pressing C1
            p.pressc1 = true //You can now press it again
        end
    end
end)
 
Last edited by a moderator:
You need to create a custom state for your character. You can mostly follow the documentation on the wiki here: https://wiki.srb2.org/wiki/State. It is a little out of date though, so I recommend also opening up another mod with custom states, such as this one https://mb.srb2.org/showthread.php?t=48758 and examine its lua files to help you with the discrepancies between SRB2 2.1 and SRB2 2.2.

---------- Post added at 01:32 AM ---------- Previous post was at 01:18 AM ----------

Once you have a custom state to hold your sprites, you need to call an addHook function for the AbilitySpecial hook as described here: https://wiki.srb2.org/wiki/Lua/Hooks#AbilitySpecial.

The function that you write for it needs to contain the following:
- It should start by checking if the player performing the ability is currently playing as your custom character. If that player is not, the function should end, returning false or nil. This way only your character will have this ability.

- If your character should be able to double jump right then, then it needs it's mobj's state set to your custom state. This will cause it to begin its animation.

- Once your custom character is in your custom state, give the character the proper thrust for its ability. this can be done using the A_ZThrust action, or by directly modifying the character's mobj's momz.

--Here's the documentation for A_ZThrust: https://wiki.srb2.org/wiki/A_ZThrust.

--Modifying the momz directly would look something like this: player.mobj.momz = yourThrustAmount * P_MobjFlip(player.mobj)

--It should also take into account the difference between normal, space, and water gravity as well eventually. For now though just focus on getting it to work with normal gravity.

- Lastly, after thrusting your custom character into the air, the function in the AbilitySpecial hook needs to return true. This will override the default ability so that it doesn't interfere with yours.
 
Last edited:

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

Back
Top