diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 8c143a771..b6579534b 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -8111,9 +8111,8 @@ HOOK_MARIO_OVERRIDE_FLOOR_CLASS = 56 --- @type LuaHookedEventType HOOK_ON_ADD_SURFACE = 57 --- @type LuaHookedEventType HOOK_ON_CLEAR_AREAS = 58 --- @type LuaHookedEventType HOOK_ON_PACKET_BYTESTRING_RECEIVE = 59 --- @type LuaHookedEventType -HOOK_BEFORE_OBJECT_UPDATE = 60 --- @type LuaHookedEventType -HOOK_OBJECT_UPDATE = 61 --- @type LuaHookedEventType -HOOK_MAX = 62 --- @type LuaHookedEventType +HOOK_OBJECT_UPDATE = 60 --- @type LuaHookedEventType +HOOK_MAX = 61 --- @type LuaHookedEventType --- @alias LuaHookedEventType --- | `HOOK_UPDATE` @@ -8176,7 +8175,6 @@ HOOK_MAX = 62 --- @type LuaHookedEventType --- | `HOOK_ON_ADD_SURFACE` --- | `HOOK_ON_CLEAR_AREAS` --- | `HOOK_ON_PACKET_BYTESTRING_RECEIVE` ---- | `HOOK_BEFORE_OBJECT_UPDATE` --- | `HOOK_OBJECT_UPDATE` --- | `HOOK_MAX` diff --git a/docs/lua/constants.md b/docs/lua/constants.md index eed2abe62..681d47479 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -3519,9 +3519,8 @@ | HOOK_ON_ADD_SURFACE | 57 | | HOOK_ON_CLEAR_AREAS | 58 | | HOOK_ON_PACKET_BYTESTRING_RECEIVE | 59 | -| HOOK_BEFORE_OBJECT_UPDATE | 60 | -| HOOK_OBJECT_UPDATE | 61 | -| HOOK_MAX | 62 | +| HOOK_OBJECT_UPDATE | 60 | +| HOOK_MAX | 61 | [:arrow_up_small:](#) diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index af1226bae..db9382f46 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -151,7 +151,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | HOOK_MARIO_OVERRIDE_FLOOR_CLASS | Called when Mario's floor class logic updates, return a `SURFACE_CLASS_*` constant to override the type. | [MarioState](../structs.md#MarioState) mario, `integer` surfaceClass | | HOOK_ON_ADD_SURFACE | Called when collision surfaces are added. | [Surface](../structs.md#Surface) surface, `boolean` dynamic | | HOOK_ON_CLEAR_AREAS | Called when a level's areas are unloaded. | None | - +| HOOK_OBJECT_UPDATE | Called once per object per frame | [Object](../structs.md#Object) obj | ### Parameters | Field | Type | diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 8ea5a3a4f..fa395afab 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -1293,7 +1293,6 @@ static BhvCommandProc BehaviorCmdTable[BEHAVIOR_CMD_TABLE_MAX] = { void cur_obj_update(void) { if (!gCurrentObject) { return; } // Don't update if dormant - if (gCurrentObject->activeFlags & ACTIVE_FLAG_DORMANT) { gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; gCurrentObject->oInteractStatus = INT_STATUS_INTERACTED; @@ -1381,9 +1380,7 @@ cur_obj_update_begin:; smlua_call_behavior_hook(&gCurBhvCommand, gCurrentObject, false); gCurrentObject->curBhvCommand = gCurBhvCommand; - - smlua_call_event_hooks(HOOK_BEFORE_OBJECT_UPDATE, gCurrentObject); - + // Increment the object's timer. if (gCurrentObject->oTimer < 0x3FFFFFFF) { gCurrentObject->oTimer++; diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index fcc7bc391..3cf7a50b8 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -3483,9 +3483,8 @@ char gSmluaConstants[] = "" "HOOK_ON_ADD_SURFACE=57\n" "HOOK_ON_CLEAR_AREAS=58\n" "HOOK_ON_PACKET_BYTESTRING_RECEIVE=59\n" -"HOOK_BEFORE_OBJECT_UPDATE=60\n" -"HOOK_OBJECT_UPDATE=61\n" -"HOOK_MAX=62\n" +"HOOK_OBJECT_UPDATE=60\n" +"HOOK_MAX=61\n" "HUD_DISPLAY_LIVES=0\n" "HUD_DISPLAY_COINS=1\n" "HUD_DISPLAY_STARS=2\n" diff --git a/src/pc/lua/smlua_hook_events.inl b/src/pc/lua/smlua_hook_events.inl index efb6953d4..facb885e0 100644 --- a/src/pc/lua/smlua_hook_events.inl +++ b/src/pc/lua/smlua_hook_events.inl @@ -58,5 +58,4 @@ SMLUA_EVENT_HOOK(HOOK_MARIO_OVERRIDE_FLOOR_CLASS, HOOK_RETURN_ON_OUTPUT_SET, str SMLUA_EVENT_HOOK(HOOK_ON_ADD_SURFACE, HOOK_RETURN_NEVER, struct Surface *surface, bool dynamic) SMLUA_EVENT_HOOK(HOOK_ON_CLEAR_AREAS, HOOK_RETURN_NEVER) SMLUA_EVENT_HOOK(HOOK_ON_PACKET_BYTESTRING_RECEIVE, HOOK_RETURN_NEVER, s32 modIndex, s32 valueIndex) -SMLUA_EVENT_HOOK(HOOK_BEFORE_OBJECT_UPDATE, HOOK_RETURN_NEVER, struct Object *obj) SMLUA_EVENT_HOOK(HOOK_OBJECT_UPDATE, HOOK_RETURN_NEVER, struct Object *obj) diff --git a/src/pc/lua/smlua_hook_events_autogen.inl b/src/pc/lua/smlua_hook_events_autogen.inl index 088a7622e..7b291cc57 100644 --- a/src/pc/lua/smlua_hook_events_autogen.inl +++ b/src/pc/lua/smlua_hook_events_autogen.inl @@ -1864,33 +1864,6 @@ bool smlua_call_event_hooks_HOOK_ON_PACKET_BYTESTRING_RECEIVE(s32 modIndex, s32 return hookResult; } -bool smlua_call_event_hooks_HOOK_BEFORE_OBJECT_UPDATE(struct Object *obj) { - lua_State *L = gLuaState; - if (L == NULL) { return false; } - bool hookResult = false; - - struct LuaHookedEvent *hook = &sHookedEvents[HOOK_BEFORE_OBJECT_UPDATE]; - for (int i = 0; i < hook->count; i++) { - s32 prevTop = lua_gettop(L); - - // push the callback onto the stack - lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); - - // push obj - smlua_push_object(L, LOT_OBJECT, obj, NULL); - - // call the callback - if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_OBJECT_UPDATE]); - continue; - } - hookResult = true; - - lua_settop(L, prevTop); - } - return hookResult; -} - bool smlua_call_event_hooks_HOOK_OBJECT_UPDATE(struct Object *obj) { lua_State *L = gLuaState; if (L == NULL) { return false; } diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index 1ce10dded..7230177e7 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -74,7 +74,6 @@ enum LuaHookedEventType { HOOK_ON_ADD_SURFACE, HOOK_ON_CLEAR_AREAS, HOOK_ON_PACKET_BYTESTRING_RECEIVE, - HOOK_BEFORE_OBJECT_UPDATE, HOOK_OBJECT_UPDATE, HOOK_MAX, };