Add `ModelExtendedId param to HOOK_OBJECT_SET_MODEL` (#834)
Some checks are pending
Build coop / build-linux (push) Waiting to run
Build coop / build-steamos (push) Waiting to run
Build coop / build-windows-opengl (push) Waiting to run
Build coop / build-windows-directx (push) Waiting to run
Build coop / build-macos-arm (push) Waiting to run
Build coop / build-macos-intel (push) Waiting to run

This commit is contained in:
Beckowl 2025-06-03 05:12:56 -03:00 committed by GitHub
parent 73e72e1b77
commit 566e2ba934
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 6 deletions

View file

@ -121,7 +121,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
| HOOK_ON_SCREEN_TRANSITION | Called when the game is about to play a transition, return `false` to prevent the transition from playing | `integer` type |
| HOOK_ALLOW_HAZARD_SURFACE | Called once per player per frame. Return `false` to prevent the player from being affected by lava, quicksand, or wind | [MarioState](../structs.md#MarioState) mario, `integer` hazardType |
| HOOK_ON_CHAT_MESSAGE | Called when a chat message gets sent. Return `false` to prevent the message from being sent | [MarioState](../structs.md#MarioState) messageSender, `string` messageSent |
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns | [Object](../structs.md#Object) obj, `integer` modelID |
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns | [Object](../structs.md#Object) obj, `integer` modelID, `integer` modelExtendedId|
| HOOK_CHARACTER_SOUND | Called when mario retrieves a character sound to play, return a character sound or `0` to override it | [MarioState](../structs.md#MarioState) mario, [enum CharacterSound](../constants.md#enum-CharacterSound) characterSound |
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes Return an action to change the incoming action or `1` to cancel the action change | [MarioState](../structs.md#MarioState) mario, `integer` incomingAction, `integer` actionArg |
| HOOK_JOINED_GAME | Called when the local player finishes the join process (if the player isn't the host) | None |

View file

@ -30,6 +30,7 @@
#include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h"
#include "pc/lua/utils/smlua_camera_utils.h"
#include "pc/lua/utils/smlua_model_utils.h"
#include "first_person_cam.h"
u8 (*gContinueDialogFunction)(void) = NULL;
@ -696,7 +697,7 @@ struct Object *spawn_object_at_origin(struct Object *parent, UNUSED s32 unusedAr
obj->globalPlayerIndex = 0;
geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, dynos_model_get_geo(model), gVec3fZero, gVec3sZero);
smlua_call_event_hooks_object_model_param(HOOK_OBJECT_SET_MODEL, obj, model);
smlua_call_event_hooks_object_set_model(HOOK_OBJECT_SET_MODEL, obj, model, smlua_model_util_id_to_ext_id(model));
return obj;
}
@ -1453,7 +1454,7 @@ void cur_obj_set_model(s32 modelID) {
void obj_set_model(struct Object* obj, s32 modelID) {
obj->header.gfx.sharedChild = dynos_model_get_geo(modelID);
dynos_actor_override(obj, (void*)&obj->header.gfx.sharedChild);
smlua_call_event_hooks_object_model_param(HOOK_OBJECT_SET_MODEL, obj, modelID);
smlua_call_event_hooks_object_set_model(HOOK_OBJECT_SET_MODEL, obj, modelID, smlua_model_util_id_to_ext_id(modelID));
}
void mario_set_flag(s32 flag) {

View file

@ -5,6 +5,7 @@
#include "macros.h"
#include "types.h"
#include "pc/lua/utils/smlua_model_utils.h"
// used for chain chomp and wiggler
struct ChainSegment

View file

@ -19,6 +19,7 @@
#include "pc/djui/djui_panel.h"
#include "pc/configfile.h"
#include "pc/utils/misc.h"
#include "pc/lua/utils/smlua_model_utils.h"
#include "../mods/mods.h"
#include "game/print.h"
@ -445,7 +446,7 @@ void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struc
}
}
void smlua_call_event_hooks_object_model_param(enum LuaHookedEventType hookType, struct Object* obj, s32 modelID) {
void smlua_call_event_hooks_object_set_model(enum LuaHookedEventType hookType, struct Object* obj, s32 modelID, enum ModelExtendedId modelExtendedId) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
@ -456,9 +457,10 @@ void smlua_call_event_hooks_object_model_param(enum LuaHookedEventType hookType,
// push params
smlua_push_object(L, LOT_OBJECT, obj, NULL);
lua_pushinteger(L, modelID);
lua_pushinteger(L, modelExtendedId);
// call the callback
if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i])) {
if (0 != smlua_call_hook(L, 3, 0, 0, hook->mod[i])) {
LOG_LUA("Failed to call the callback: %u", hookType);
continue;
}

View file

@ -6,6 +6,7 @@
#include "smlua.h"
#include "pc/mods/mod.h"
#include "pc/lua/utils/smlua_model_utils.h"
// forward declare
struct Camera;
@ -189,7 +190,7 @@ void smlua_call_event_hooks_interact_params(enum LuaHookedEventType hookType, st
void smlua_call_event_hooks_interact_params_ret_bool(enum LuaHookedEventType hookType, struct MarioState* m, struct Object* obj, u32 interactType, bool* returnValue);
void smlua_call_event_hooks_interact_params_no_ret(enum LuaHookedEventType hookType, struct MarioState* m, struct Object* obj, u32 interactType);
void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struct Object* obj);
void smlua_call_event_hooks_object_model_param(enum LuaHookedEventType hookType, struct Object* obj, s32 modelID);
void smlua_call_event_hooks_object_set_model(enum LuaHookedEventType hookType, struct Object* obj, s32 modelID, enum ModelExtendedId modelExtendedId);
bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* returnValue);
void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue);
void smlua_call_event_hooks_int_params_ret_bool(enum LuaHookedEventType hookType, s16 param, bool* returnValue);