Add option to disable first person centering with L

This commit is contained in:
Agent X 2023-12-15 17:21:06 -05:00
parent b04dc23aa5
commit fff0c83866
5 changed files with 8 additions and 2 deletions

View file

@ -591,6 +591,7 @@
--- @field public r integer
--- @class FirstPersonCamera
--- @field public centerL boolean
--- @field public crouch number
--- @field public enabled boolean
--- @field public forceRoll boolean

View file

@ -846,6 +846,7 @@
| Field | Type | Access |
| ----- | ---- | ------ |
| centerL | `boolean` | |
| crouch | `number` | |
| enabled | `boolean` | read-only |
| forceRoll | `boolean` | |

View file

@ -23,6 +23,7 @@
struct FirstPersonCamera gFirstPersonCamera = {
.enabled = false,
.forceRoll = true,
.centerL = true,
.pitch = 0,
.yaw = 0,
.crouch = 0,
@ -71,7 +72,7 @@ void first_person_camera_update(void) {
gFirstPersonCamera.pitch = CLAMP(gFirstPersonCamera.pitch, -0x3F00, 0x3F00);
// update yaw
if (m->controller->buttonPressed & L_TRIG) {
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);
@ -187,6 +188,7 @@ void first_person_update(void) {
void first_person_reset(void) {
gFirstPersonCamera.forceRoll = false;
gFirstPersonCamera.centerL = true;
gFirstPersonCamera.pitch = 0;
gFirstPersonCamera.yaw = 0;
gFirstPersonCamera.crouch = 0;

View file

@ -11,6 +11,7 @@
struct FirstPersonCamera {
bool enabled;
bool forceRoll;
bool centerL;
s16 pitch;
s16 yaw;
f32 crouch;

View file

@ -674,8 +674,9 @@ 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 7
#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 8
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 },
{ "forceRoll", LVT_BOOL, offsetof(struct FirstPersonCamera, forceRoll), false, LOT_NONE },