give mods more control over animations (#369)

* give mods more control over animations

- added HOOK_ON_OBJECT_ANIM_UPDATE
- make some animation values mutable

* add to docs
This commit is contained in:
Isaac0-dev 2023-04-29 09:56:18 +10:00 committed by GitHub
parent adba0f6de8
commit 08d31b8255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 7 deletions

View file

@ -70,6 +70,10 @@ override_field_mutable = {
"overridePalette",
"overridePaletteIndex",
],
"Animation": [
"values",
"index",
],
}
override_field_invisible = {

View file

@ -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

View file

@ -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:](#)

View file

@ -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

View file

@ -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:](#)

View file

@ -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);
}

View file

@ -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

View file

@ -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"

View file

@ -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"
};