Skip to content

Add SuperReady and PlayerSuper Lua hooks

Lach requested to merge super-hooked into next

Adds two new Lua hooks to more easily control the player's eligibility to turn and remain super, and exposes a new function P_RevertSuperForm to allow scripters to deactivate a super form with all the bells and whistles.

SuperReady
Hook format: addHook("SuperReady", functionname)
Function format: function(player_t player)
Function return value: Boolean (can the player turn super? nil = use default behavior)
Executes whenever a player attempts to turn super (i.e. whenever P_SuperReady is called). If the function returns true, the player will be considered ready to turn super, and if the function returns false, the player will not be considered ready to turn super, regardless of the number of chaos emeralds or rings collected or whether they have the SF_SUPER flag. Otherwise (return, return nil or simply no return value), SRB2's default checks are used to determine whether the player can turn super.

(I am aware that !1641 (closed) implements a feature similar this hook—I wrote this hook before that MR was put up, but I can remove the hook if that implementation is preferred.)

PlayerSuper
Hook format: addHook("PlayerSuper", functionname)
Function format: function(player_t player)
Function return value: Boolean (can the player remain super? nil = use default behavior)
Executes every tic while a player is super. If the function returns true, the player will be forced to stay super, and if the function returns false, the player will revert from their super form, regardless of the number of chaos emeralds or rings they have or whether they have the SF_SUPER flag. Otherwise (return, return nil or simply no return value), SRB2's default checks are used to determine whether the player can remain super.

Example script: fang69.lua
This lets Fang turn super when he has exactly 69 rings (nice) and doesn't care about how many emeralds he has or that he doesn't have the SF_SUPER flag. However, if he fires a cork, he will revert from his super form immediately.
srb20177

Merge request reports

Loading