User:MIDIMan/Ringslinger Revolution/Hooks
Ringslinger Revolution has four hooks for overriding pickup behavior.
All four hooks are "TouchSpecial" hooks. For every hook, special
is the Object being touched, and toucher
is the Object representing the player touching it. If the function returns true, the default touching behavior is overridden; Otherwise, if will be performed after executing the function. The default behavior for most items is to play its DeathSound
, call RSR.SetItemFuse
so it can respawn in "Waves" or multiplayer modes, and use P_KillMobj
to go to the item's DeathState
, but this depends on the item.
These hooks work similar to the Lua hooks provided by SRB2, but instead of using addHook
to bind a function, hookLib.AddHook
is used instead:
-- A local function hooked
local function MyWeaponTouchSpecialHandler()
end
hookLib.AddHook("RSR_WeaponTouchSpecial", MyWeaponTouchSpecialHandler)
-- An inline function hooked
hookLib.AddHook("RSR_WeaponTouchSpecial", function()
-- do things
end)
There are also only two arguments instead of three, since hookLib doesn't support a third argument for Object types.
List of hooks
RSR_WeaponTouchSpecial
Hook format: hookLib.AddHook(“RSR_WeaponTouchSpecial”, functionname)
Function format: function(mobj_t special, mobj_t toucher, int weapon)
Function return value: Boolean (override default behavior?)
Determines what happens when a player touches a weapon ring Object. Default behavior is to give the player the weapon
, give a specific amount of ammo for it depending on if it’s a panel or not, call RSR.BonusFade
and RSR.SetItemFuse
, and kill the Object.
RSR_PowerupTouchSpecial
Hook format: hookLib.AddHook(“RSR_PowerupTouchSpecial”, functionname)
Function format: function(mobj_t special, mobj_t toucher, int powerup)
Function return value: Boolean (override default behavior?)
Determines what happens when a player touches a powerup Object. Default behavior is to give the player the powerup
, call RSR.BonusFade
and RSR.SetItemFuse
, and kill the Object.
RSR_HealthTouchSpecial
Hook format: hookLib.AddHook(“RSR_HealthTouchSpecial”, functionname)
Function format: function(mobj_t special, mobj_t toucher, int health)
Function return value: Boolean (override default behavior?)
Determines what happens when a player touches a health Object. Default behavior is to give the player the specified amount of health
, call RSR.BonusFade
and RSR.SetItemFuse
, and kill the Object.
RSR_ArmorTouchSpecial
Hook format: hookLib.AddHook(“RSR_ArmorTouchSpecial”, functionname)
Function format: function(mobj_t special, mobj_t toucher, int armor)
Function return value: Boolean (override default behavior?)
Determines what happens when a player touches a health Object. Default behavior is to give the player the specified amount of armor
, call RSR.BonusFade and RSR.SetItemFuse
, and kill the Object.