diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index 391c8f404..a7ae26d47 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -70,6 +70,10 @@ override_field_mutable = { "overridePalette", "overridePaletteIndex", ], + "Animation": [ + "values", + "index", + ], } override_field_invisible = { diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 16200c552..c5acb0d0b 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -8254,7 +8254,10 @@ HOOK_BEFORE_SET_MARIO_ACTION = 30 HOOK_JOINED_GAME = 31 --- @type LuaHookedEventType -HOOK_MAX = 32 +HOOK_ON_OBJECT_ANIM_UPDATE = 32 + +--- @type LuaHookedEventType +HOOK_MAX = 33 --- @class HudDisplayFlags diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 4d402e1c1..62138cb18 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -2949,7 +2949,8 @@ | HOOK_CHARACTER_SOUND | 29 | | HOOK_BEFORE_SET_MARIO_ACTION | 30 | | HOOK_JOINED_GAME | 31 | -| HOOK_MAX | 32 | +| HOOK_ON_OBJECT_ANIM_UPDATE | 32 | +| HOOK_MAX | 33 | [:arrow_up_small:](#) diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index 8a3d7c536..af584645a 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -119,6 +119,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | 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_JOINED_GAME | Called when the local player finishes the join process (if the player isn't the host) | None | | 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 | +| HOOK_ON_OBJECT_ANIM_UPDATE | Called when an object's animation is updated. | [Object](structs.md#Object) objNode | ### Parameters diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 56b3858c6..49b447ede 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -106,13 +106,13 @@ | ----- | ---- | ------ | | animYTransDivisor | `integer` | | | flags | `integer` | | -| index | `Pointer` <`integer`> | read-only | +| index | `Pointer` <`integer`> | | | length | `integer` | | | loopEnd | `integer` | | | loopStart | `integer` | | | startFrame | `integer` | | | unusedBoneCount | `integer` | | -| values | `Pointer` <`integer`> | read-only | +| values | `Pointer` <`integer`> | | [:arrow_up_small:](#) diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 9c05cf0b8..ca3a45aa5 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1312,6 +1312,7 @@ static void geo_process_object(struct Object *node) { if (node->header.gfx.animInfo.curAnim != NULL) { dynos_gfx_swap_animations(node); geo_set_animation_globals(&node->header.gfx.animInfo, hasAnimation); + smlua_call_event_hooks_object_param(HOOK_ON_OBJECT_ANIM_UPDATE, node); dynos_gfx_swap_animations(node); } if (obj_is_in_view(&node->header.gfx, gMatStack[gMatStackIndex])) { @@ -1434,6 +1435,7 @@ void geo_process_held_object(struct GraphNodeHeldObject *node) { if (node->objNode->header.gfx.animInfo.curAnim != NULL) { dynos_gfx_swap_animations(node->objNode); geo_set_animation_globals(&node->objNode->header.gfx.animInfo, hasAnimation); + smlua_call_event_hooks_object_param(HOOK_ON_OBJECT_ANIM_UPDATE, node->objNode); dynos_gfx_swap_animations(node->objNode); } diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 96793386e..64964d4e4 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -42,13 +42,13 @@ static struct LuaObjectField sAnimInfoFields[LUA_ANIM_INFO_FIELD_COUNT] = { static struct LuaObjectField sAnimationFields[LUA_ANIMATION_FIELD_COUNT] = { { "animYTransDivisor", LVT_S16, offsetof(struct Animation, animYTransDivisor), false, LOT_NONE }, { "flags", LVT_S16, offsetof(struct Animation, flags), false, LOT_NONE }, - { "index", LVT_U16_P, offsetof(struct Animation, index), true, LOT_POINTER }, + { "index", LVT_U16_P, offsetof(struct Animation, index), false, LOT_POINTER }, { "length", LVT_U32, offsetof(struct Animation, length), false, LOT_NONE }, { "loopEnd", LVT_S16, offsetof(struct Animation, loopEnd), false, LOT_NONE }, { "loopStart", LVT_S16, offsetof(struct Animation, loopStart), false, LOT_NONE }, { "startFrame", LVT_S16, offsetof(struct Animation, startFrame), false, LOT_NONE }, { "unusedBoneCount", LVT_S16, offsetof(struct Animation, unusedBoneCount), false, LOT_NONE }, - { "values", LVT_S16_P, offsetof(struct Animation, values), true, LOT_POINTER }, + { "values", LVT_S16_P, offsetof(struct Animation, values), false, LOT_POINTER }, }; #define LUA_AREA_FIELD_COUNT 18 diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 8c529f6ab..1508aa8fd 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -2927,7 +2927,8 @@ char gSmluaConstants[] = "" "HOOK_CHARACTER_SOUND = 29\n" "HOOK_BEFORE_SET_MARIO_ACTION = 30\n" "HOOK_JOINED_GAME = 31\n" -"HOOK_MAX = 32\n" +"HOOK_ON_OBJECT_ANIM_UPDATE = 32\n" +"HOOK_MAX = 33\n" "ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_MAX = 2\n" diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index e0b844792..a0696a682 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -43,6 +43,7 @@ enum LuaHookedEventType { HOOK_CHARACTER_SOUND, HOOK_BEFORE_SET_MARIO_ACTION, HOOK_JOINED_GAME, + HOOK_ON_OBJECT_ANIM_UPDATE, HOOK_MAX, }; @@ -79,6 +80,7 @@ static const char* LuaHookedEventTypeName[] = { "HOOK_CHARACTER_SOUND", "HOOK_BEFORE_SET_MARIO_ACTION", "HOOK_JOINED_GAME", + "HOOK_ON_OBJECT_ANIM_UPDATE", "HOOK_MAX" };