mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
fix HOOK_BEFORE_WARP (#753)
* fix HOOK_BEFORE_WARP * actual fix and correct hooks.md * reset arg, make WARP_ARG_EXIT_COURSE -1
This commit is contained in:
parent
5c3ef3d419
commit
a0f557bf68
7 changed files with 15 additions and 10 deletions
|
|
@ -3354,6 +3354,9 @@ WARP_TYPE_CHANGE_AREA = 2
|
|||
--- @type integer
|
||||
WARP_TYPE_SAME_AREA = 3
|
||||
|
||||
--- @type integer
|
||||
WARP_ARG_EXIT_COURSE = -1
|
||||
|
||||
--- @type integer
|
||||
PRESS_START_DEMO_TIMER = 800
|
||||
|
||||
|
|
|
|||
|
|
@ -1592,6 +1592,7 @@
|
|||
- WARP_TYPE_CHANGE_LEVEL
|
||||
- WARP_TYPE_CHANGE_AREA
|
||||
- WARP_TYPE_SAME_AREA
|
||||
- WARP_ARG_EXIT_COURSE
|
||||
- PRESS_START_DEMO_TIMER
|
||||
- PAINTING_WARP_INDEX_START
|
||||
- PAINTING_WARP_INDEX_FA
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS | Called before running Mario's geometry input logic, return `false` to not run it. | [MarioState](../structs.md) m |
|
||||
| HOOK_ON_INTERACTIONS | Called when the Mario interactions are processed | [MarioState](../structs.md#MarioState) mario |
|
||||
| HOOK_ALLOW_FORCE_WATER_ACTION | Called when executing a non-water action while under the water's surface, or vice versa. Return `false` to prevent the player from being forced out of the action at the water's surface | [MarioState](../structs.md#MarioState) mario, `boolean` isInWaterAction |
|
||||
| HOOK_BEFORE_WARP | Called before the local player warps. Return a table with `destLevel`, `destArea`, `destAreaWarpNode`, and `arg` to override the warp | `integer` destLevel, `integer` destArea, `integer` destAreaWarpNode, `integer` arg |
|
||||
| HOOK_BEFORE_WARP | Called before the local player warps. Return a table with `destLevel`, `destArea`, `destWarpNode`, to override the warp | `integer` destLevel, `integer` destArea, `integer` destWarpNode, `integer` arg |
|
||||
| HOOK_ON_INSTANT_WARP | Called when the local player goes through an instant warp.| `integer` area, `integer` id, `Vec3s` displacement|
|
||||
|
||||
### Parameters
|
||||
|
|
|
|||
|
|
@ -747,12 +747,15 @@ s16 music_changed_through_warp(s16 arg) {
|
|||
/**
|
||||
* Set the current warp type and destination level/area/node.
|
||||
*/
|
||||
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg) {//
|
||||
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg) {
|
||||
|
||||
smlua_call_event_hooks_before_warp(HOOK_BEFORE_WARP, &destLevel, &destArea, &destWarpNode, &arg);
|
||||
|
||||
if (destWarpNode >= WARP_NODE_CREDITS_MIN) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
} else if (arg == WARP_ARG_EXIT_COURSE) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
arg = 0;
|
||||
} else if (destLevel != gCurrLevelNum) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
} else if (destArea != gCurrentArea->index) {
|
||||
|
|
@ -919,6 +922,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
|||
case WARP_OP_EXIT:
|
||||
sSourceWarpNodeId = WARP_NODE_DEATH;
|
||||
sDelayedWarpTimer = 20;
|
||||
sDelayedWarpArg = WARP_ARG_EXIT_COURSE;
|
||||
play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00);
|
||||
break;
|
||||
|
||||
|
|
@ -1352,7 +1356,7 @@ s32 play_mode_paused(void) {
|
|||
if (gDebugLevelSelect) {
|
||||
fade_into_special_warp(-9, 1);
|
||||
} else {
|
||||
initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0);
|
||||
initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, WARP_ARG_EXIT_COURSE);
|
||||
fade_into_special_warp(0, 0);
|
||||
gSavedCourseNum = COURSE_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ enum MarioSpawnType {
|
|||
#define WARP_TYPE_CHANGE_AREA 2
|
||||
#define WARP_TYPE_SAME_AREA 3
|
||||
|
||||
#define WARP_ARG_EXIT_COURSE -1
|
||||
|
||||
#define PRESS_START_DEMO_TIMER 800
|
||||
|
||||
// From Surface 0xD3 to 0xFC
|
||||
|
|
|
|||
|
|
@ -1586,6 +1586,7 @@ char gSmluaConstants[] = ""
|
|||
"WARP_TYPE_CHANGE_LEVEL=1\n"
|
||||
"WARP_TYPE_CHANGE_AREA=2\n"
|
||||
"WARP_TYPE_SAME_AREA=3\n"
|
||||
"WARP_ARG_EXIT_COURSE=-1\n"
|
||||
"PRESS_START_DEMO_TIMER=800\n"
|
||||
"PAINTING_WARP_INDEX_START=0x00\n"
|
||||
"PAINTING_WARP_INDEX_FA=0x2A\n"
|
||||
|
|
|
|||
|
|
@ -814,6 +814,7 @@ void smlua_call_event_hooks_before_warp(enum LuaHookedEventType hookType, s16 *d
|
|||
|
||||
// if the hook returns a table, use it to override the warp parameters
|
||||
if (lua_istable(L, -1)) {
|
||||
|
||||
lua_getfield(L, -1, "destLevel");
|
||||
if (lua_isnumber(L, -1)) {
|
||||
*destLevel = (s16)lua_tointeger(L, -1);
|
||||
|
|
@ -832,12 +833,6 @@ void smlua_call_event_hooks_before_warp(enum LuaHookedEventType hookType, s16 *d
|
|||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, -1, "arg");
|
||||
if (lua_isnumber(L, -1)) {
|
||||
*arg = (s32)lua_tointeger(L, -1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_settop(L, prevTop);
|
||||
return;
|
||||
}
|
||||
|
|
@ -845,7 +840,6 @@ void smlua_call_event_hooks_before_warp(enum LuaHookedEventType hookType, s16 *d
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void smlua_call_event_hooks_on_seq_load(enum LuaHookedEventType hookType, u32 player, u32 seqId, s32 loadAsync, s16* returnValue) {
|
||||
lua_State* L = gLuaState;
|
||||
if (L == NULL) { return; }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue