From 5b72836c158a421c3d86f81f4a1fb8e421b036e1 Mon Sep 17 00:00:00 2001 From: SharenTheCat <113565806+SharenTheCat@users.noreply.github.com> Date: Thu, 16 Nov 2023 23:01:18 -0300 Subject: [PATCH] Modify Mario's head and torso rotation outside of specific cases Adds "m.marioBodyState.allowPartRotation", which when set to 1, will make "m.marioBodyState.headAngle" and "m.marioBodyStates.torsoAngle" actually change where Mario's head and torso face outside of very specific cases (like running, or being underwater). --- autogen/lua_definitions/structs.lua | 2 ++ docs/lua/structs.md | 2 ++ include/types.h | 1 + src/game/mario.c | 2 ++ src/game/mario_misc.c | 5 +++-- src/pc/lua/smlua_cobject_autogen.c | 6 ++++-- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 1e6177d6..79bbe6e3 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -942,6 +942,7 @@ --- @class MarioBodyState --- @field public action integer +--- @field public allowPartRotation integer --- @field public capState integer --- @field public eyeState integer --- @field public grabPos integer @@ -1990,6 +1991,7 @@ --- @field public surface Surface --- @class ServerSettings +--- @field public bouncyLevelBounds BouncyLevelBounds --- @field public bubbleDeath integer --- @field public enableCheats integer --- @field public enablePlayerList integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index b3b111bb..7a85801e 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1314,6 +1314,7 @@ | Field | Type | Access | | ----- | ---- | ------ | | action | `integer` | | +| allowPartRotation | `integer` | | | capState | `integer` | | | eyeState | `integer` | | | grabPos | `integer` | | @@ -2510,6 +2511,7 @@ | Field | Type | Access | | ----- | ---- | ------ | +| bouncyLevelBounds | [enum BouncyLevelBounds](constants.md#enum-BouncyLevelBounds) | | | bubbleDeath | `integer` | | | enablePlayerList | `integer` | | | enablePlayersInLevelDisplay | `integer` | | diff --git a/include/types.h b/include/types.h index deeb9f3c..66b5451a 100644 --- a/include/types.h +++ b/include/types.h @@ -316,6 +316,7 @@ struct MarioBodyState /*????*/ f32 lightingDirX; /*????*/ f32 lightingDirY; /*????*/ f32 lightingDirZ; + /*????*/ u8 allowPartRotation; // u8 padding[4]; }; diff --git a/src/game/mario.c b/src/game/mario.c index 76b859a7..1eb35f71 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -2323,6 +2323,8 @@ void init_single_mario(struct MarioState* m) { m->marioBodyState->lightingDirY = 0; m->marioBodyState->lightingDirZ = 0; + m->marioBodyState->allowPartRotation = FALSE; + m->marioObj->oPosX = m->pos[0]; m->marioObj->oPosY = m->pos[1]; m->marioObj->oPosZ = m->pos[2]; diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index f17d0ebe..9671282c 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -430,7 +430,8 @@ Gfx* geo_mario_tilt_torso(s32 callContext, struct GraphNode* node, Mat4* mtx) { if (callContext == GEO_CONTEXT_RENDER) { struct GraphNodeRotation* rotNode = (struct GraphNodeRotation*) node->next; - if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING && action != ACT_RIDING_SHELL_GROUND) { + if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING && action != ACT_RIDING_SHELL_GROUND + && !bodyState->allowPartRotation) { vec3s_copy(bodyState->torsoAngle, gVec3sZero); } rotNode->rotation[0] = bodyState->torsoAngle[1] * character->torsoRotMult; @@ -468,7 +469,7 @@ Gfx* geo_mario_head_rotation(s32 callContext, struct GraphNode* node, Mat4* c) { rotNode->rotation[0] = gPlayerCameraState[plrIdx].headRotation[1]; rotNode->rotation[2] = gPlayerCameraState[plrIdx].headRotation[0]; } - else if (action & ACT_FLAG_WATER_OR_TEXT) { + else if (action & ACT_FLAG_WATER_OR_TEXT || bodyState->allowPartRotation) { rotNode->rotation[0] = bodyState->headAngle[1]; rotNode->rotation[1] = bodyState->headAngle[2]; rotNode->rotation[2] = bodyState->headAngle[0]; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 9dcca2e1..774cb8e3 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1059,9 +1059,10 @@ static struct LuaObjectField sMarioAnimationFields[LUA_MARIO_ANIMATION_FIELD_COU { "targetAnim", LVT_COBJECT_P, offsetof(struct MarioAnimation, targetAnim), false, LOT_ANIMATION }, }; -#define LUA_MARIO_BODY_STATE_FIELD_COUNT 23 +#define LUA_MARIO_BODY_STATE_FIELD_COUNT 24 static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_COUNT] = { { "action", LVT_U32, offsetof(struct MarioBodyState, action), false, LOT_NONE }, + { "allowPartRotation", LVT_U8, offsetof(struct MarioBodyState, allowPartRotation), false, LOT_NONE }, { "capState", LVT_S8, offsetof(struct MarioBodyState, capState), false, LOT_NONE }, { "eyeState", LVT_S8, offsetof(struct MarioBodyState, eyeState), false, LOT_NONE }, { "grabPos", LVT_S8, offsetof(struct MarioBodyState, grabPos), false, LOT_NONE }, @@ -2179,8 +2180,9 @@ static struct LuaObjectField sRayIntersectionInfoFields[LUA_RAY_INTERSECTION_INF { "surface", LVT_COBJECT_P, offsetof(struct RayIntersectionInfo, surface), false, LOT_SURFACE }, }; -#define LUA_SERVER_SETTINGS_FIELD_COUNT 11 +#define LUA_SERVER_SETTINGS_FIELD_COUNT 12 static struct LuaObjectField sServerSettingsFields[LUA_SERVER_SETTINGS_FIELD_COUNT] = { + { "bouncyLevelBounds", LVT_S32, offsetof(struct ServerSettings, bouncyLevelBounds), false, LOT_NONE }, { "bubbleDeath", LVT_U8, offsetof(struct ServerSettings, bubbleDeath), false, LOT_NONE }, { "enableCheats", LVT_U8, offsetof(struct ServerSettings, enableCheats), false, LOT_NONE }, { "enablePlayerList", LVT_U8, offsetof(struct ServerSettings, enablePlayerList), false, LOT_NONE },