From 7ceac49098ec0150388e41d3896bd7912225c206 Mon Sep 17 00:00:00 2001 From: thecozies <79979276+thecozies@users.noreply.github.com> Date: Thu, 30 May 2024 08:43:10 -0500 Subject: [PATCH] Init auto cam when spike rolling --- patches/camera_patches.c | 4 ++++ patches/input.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/patches/camera_patches.c b/patches/camera_patches.c index 842b238..c13ab82 100644 --- a/patches/camera_patches.c +++ b/patches/camera_patches.c @@ -1884,6 +1884,10 @@ bool get_analog_cam_active() { return analog_cam_active; } +void set_analog_cam_active(bool isActive) { + analog_cam_active = isActive; +} + // Calling this will avoid analog cam taking over for the following game loop. // E.g. using left stick inputs while in a deku flower taking priority over right stick. void skip_analog_cam_once() { diff --git a/patches/input.c b/patches/input.c index e35b18e..be2e770 100644 --- a/patches/input.c +++ b/patches/input.c @@ -2323,3 +2323,39 @@ void func_80855F9C(PlayState* play, Player* this) { Math_ScaledStepToS(&this->currentYaw, yawTarget, 0x258); } } + +extern void set_analog_cam_active(bool isActive); +extern void Player_Action_4(Player* this, PlayState* play); +extern s32 Player_SetAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 arg3); +extern LinkAnimationHeader gPlayerAnim_pg_maru_change; + +s32 func_80857950(PlayState* play, Player* this) { + // @recomp track if newly going from non-spike roll to spike roll (spike rolling when this->unk_B86[1] == 1) + static bool wasOff = true; + bool isOff = this->unk_B86[1] == 0; + if (wasOff && !isOff) { + // @recomp set analog cam to be active now that rolling has started + set_analog_cam_active(false); + } + wasOff = isOff; + + // @recomp Manual relocation, TODO remove when automated. + Input* player_control_input = *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput); + + if (((this->unk_B86[1] == 0) && !CHECK_BTN_ALL(player_control_input->cur.button, BTN_A)) || + ((this->av1.actionVar1 == 3) && (this->actor.velocity.y < 0.0f))) { + + // @recomp Manual relocation, TODO remove when automated. + PlayerActionFunc Player_Action_4_reloc = KaleidoManager_GetRamAddr(Player_Action_4); + Player_SetAction(play, this, Player_Action_4_reloc, 1); + + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pg_maru_change, -2.0f / 3.0f, 7.0f, 0.0f, + ANIMMODE_ONCE, 0.0f); + Player_PlaySfx(this, NA_SE_PL_BALL_TO_GORON); + wasOff = true; + return true; + } + + return false; +}