From 2b6a173f8bb9bef9dc4c5d6a0667bc873c25e05d Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Wed, 17 Jul 2024 08:25:23 -0400 Subject: [PATCH] Added gFirstPersonCamera.forceYaw --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/game/first_person_cam.c | 13 ++++++++----- src/pc/lua/smlua_cobject_autogen.c | 3 ++- src/pc/network/network.c | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 050cef42..7470e2ca 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -595,6 +595,7 @@ --- @field public enabled boolean --- @field public forcePitch boolean --- @field public forceRoll boolean +--- @field public forceYaw boolean --- @field public fov number --- @field public offset Vec3f --- @field public pitch integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index d5e10146..b09ec30d 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -852,6 +852,7 @@ | enabled | `boolean` | read-only | | forcePitch | `boolean` | | | forceRoll | `boolean` | | +| forceYaw | `boolean` | | | fov | `number` | | | offset | [Vec3f](structs.md#Vec3f) | read-only | | pitch | `integer` | | diff --git a/src/game/first_person_cam.c b/src/game/first_person_cam.c index f6f20894..8f59744c 100644 --- a/src/game/first_person_cam.c +++ b/src/game/first_person_cam.c @@ -22,8 +22,9 @@ struct FirstPersonCamera gFirstPersonCamera = { .enabled = false, - .forceRoll = true, .forcePitch = false, + .forceYaw = false, + .forceRoll = true, .centerL = true, .pitch = 0, .yaw = 0, @@ -75,10 +76,12 @@ static void first_person_camera_update(void) { } // update yaw - if (m->controller->buttonPressed & L_TRIG && gFirstPersonCamera.centerL) { - gFirstPersonCamera.yaw = m->faceAngle[1] + 0x8000; - } else { - gFirstPersonCamera.yaw += sensX * (invX * m->controller->extStickX - 1.5f * mouse_x); + if (!gFirstPersonCamera.forceYaw) { + if (m->controller->buttonPressed & L_TRIG && gFirstPersonCamera.centerL) { + gFirstPersonCamera.yaw = m->faceAngle[1] + 0x8000; + } else { + gFirstPersonCamera.yaw += sensX * (invX * m->controller->extStickX - 1.5f * mouse_x); + } } } diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index d8ac4073..f384081c 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -676,13 +676,14 @@ static struct LuaObjectField sDjuiColorFields[LUA_DJUI_COLOR_FIELD_COUNT] = { { "r", LVT_U8, offsetof(struct DjuiColor, r), false, LOT_NONE }, }; -#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 9 +#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 10 static struct LuaObjectField sFirstPersonCameraFields[LUA_FIRST_PERSON_CAMERA_FIELD_COUNT] = { { "centerL", LVT_BOOL, offsetof(struct FirstPersonCamera, centerL), false, LOT_NONE }, { "crouch", LVT_F32, offsetof(struct FirstPersonCamera, crouch), false, LOT_NONE }, { "enabled", LVT_BOOL, offsetof(struct FirstPersonCamera, enabled), true, LOT_NONE }, { "forcePitch", LVT_BOOL, offsetof(struct FirstPersonCamera, forcePitch), false, LOT_NONE }, { "forceRoll", LVT_BOOL, offsetof(struct FirstPersonCamera, forceRoll), false, LOT_NONE }, + { "forceYaw", LVT_BOOL, offsetof(struct FirstPersonCamera, forceYaw), false, LOT_NONE }, { "fov", LVT_F32, offsetof(struct FirstPersonCamera, fov), false, LOT_NONE }, { "offset", LVT_COBJECT, offsetof(struct FirstPersonCamera, offset), true, LOT_VEC3F }, { "pitch", LVT_S16, offsetof(struct FirstPersonCamera, pitch), false, LOT_NONE }, diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 8749ee55..767058ac 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -722,8 +722,9 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect cnt->extStickY = 0; gFirstPersonCamera.enabled = false; - gFirstPersonCamera.forceRoll = false; gFirstPersonCamera.forcePitch = false; + gFirstPersonCamera.forceYaw = false; + gFirstPersonCamera.forceRoll = true; gFirstPersonCamera.centerL = true; gFirstPersonCamera.fov = FIRST_PERSON_DEFAULT_FOV; vec3f_set(gFirstPersonCamera.offset, 0, 0, 0);