From 8cd7718b3881e7e2d7d3487aade08c0c1fea4488 Mon Sep 17 00:00:00 2001 From: thecozies <79979276+thecozies@users.noreply.github.com> Date: Tue, 28 May 2024 09:26:30 -0500 Subject: [PATCH] #279 Adjusted autocam/analog cam behavior while inside of a deku flower --- patches/camera_patches.c | 8 ++++++++ patches/input.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/patches/camera_patches.c b/patches/camera_patches.c index a1d0075..316109a 100644 --- a/patches/camera_patches.c +++ b/patches/camera_patches.c @@ -1873,3 +1873,11 @@ void analog_cam_post_play_update(PlayState* play) { active_cam->inputDir.y = analog_camera_pos.yaw + DEG_TO_BINANG(180); } } + +bool get_analog_cam_active() { + return analog_cam_active; +} + +void set_analog_cam_active(bool is_active) { + analog_cam_active = is_active; +} diff --git a/patches/input.c b/patches/input.c index ec28383..6b19d55 100644 --- a/patches/input.c +++ b/patches/input.c @@ -2297,3 +2297,32 @@ void draw_dpad_icons(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } + +extern s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYawTarget, f32 speedMode, + PlayState* play); +extern bool get_analog_cam_active(); +extern void set_analog_cam_active(bool is_active); + +// @recomp Updates yaw while inside of deku flower. +void func_80855F9C(PlayState* play, Player* this) { + f32 speedTarget; + s16 yawTarget; + + this->stateFlags2 |= PLAYER_STATE2_20; + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, 0.018f, play); + + // @recomp If analog cam is active and left stick inputs are occurring, reset auto cam. + if ( + get_analog_cam_active() && + (play->state.input[0].rel.stick_y != 0 || play->state.input[0].rel.stick_x != 0) + ) { + set_analog_cam_active(false); + } + + if (get_analog_cam_active()) { + // @recomp set current yaw to active camera's yaw. + this->currentYaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); + } else { + Math_ScaledStepToS(&this->currentYaw, yawTarget, 0x258); + } +}