mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-06-19 16:00:27 -04:00
fix: free look releases the door peek camera (#6756)
* fix(camera): let free look release the door peek camera After walking through a door, the door camera (CAM_SET_DOORC) held the view and only handed control back once the player moved or pressed a button, so the right stick did nothing until then. With free look the camera appeared frozen after every door. Treat right-stick movement as a release condition too, using the same stick threshold as free-look activation. * refactor(camera): move door-cam free-look release to a VB_SHOULD hook Reimplements the door peek camera free-look release as a vanilla-behavior hook instead of inline logic in z_camera.c, keeping the decomp file close to upstream. - Add VB_RELEASE_DOORC_CAMERA wrapping the existing Camera_Special9 release condition; the vanilla button/xzSpeed expression is left untouched. - Move the right-stick / free-look threshold logic into a new enhancement, FreeLookDoorCamRelease.cpp, registered with COND_VB_SHOULD and gated on FreeLook.Enabled so the hook only exists while Free Look is on. Behavior is unchanged from the previous fix; this only relocates the logic. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
#include "soh/Enhancements/controls/Mouse.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern "C" {
|
||||
#include "global.h"
|
||||
}
|
||||
|
||||
void RegisterFreeLookDoorCamRelease() {
|
||||
COND_VB_SHOULD(VB_RELEASE_DOORC_CAMERA, CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0), {
|
||||
Camera* camera = va_arg(args, Camera*);
|
||||
|
||||
// Also release the door peek camera when free look moves it, reusing SetCameraManual's threshold.
|
||||
f32 freeLookX = -camera->play->state.input[0].cur.right_stick_x * 10.0f;
|
||||
f32 freeLookY = camera->play->state.input[0].cur.right_stick_y * 10.0f;
|
||||
Mouse_HandleThirdPerson(&freeLookX, &freeLookY);
|
||||
|
||||
if (fabsf(freeLookX) >= 15.0f || fabsf(freeLookY) >= 15.0f) {
|
||||
*should = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc(RegisterFreeLookDoorCamRelease, { CVAR_SETTING("FreeLook.Enabled") });
|
||||
@@ -2083,6 +2083,13 @@ typedef enum {
|
||||
VB_RED_ICE_MELTED_FLAG,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// camera->xzSpeed > 0.001f || <any release button pressed> || params->interfaceFlags & 0x8
|
||||
// ```
|
||||
// #### `args`
|
||||
// - `Camera*` (`camera`)
|
||||
VB_RELEASE_DOORC_CAMERA,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
|
||||
+13
-8
@@ -6921,14 +6921,19 @@ s32 Camera_Special9(Camera* camera) {
|
||||
camera->unk_14C |= (0x400 | 0x10);
|
||||
sCameraInterfaceFlags = 0;
|
||||
|
||||
if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z) || params->interfaceFlags & 0x8) {
|
||||
// SOH [Enhancement] VB_RELEASE_DOORC_CAMERA lets free look hand the door peek camera
|
||||
// back on right-stick input (see soh/Enhancements/camera/FreeLookDoorCamRelease.cpp).
|
||||
if (GameInteractor_Should(
|
||||
VB_RELEASE_DOORC_CAMERA,
|
||||
camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
|
||||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z) || params->interfaceFlags & 0x8,
|
||||
camera)) {
|
||||
|
||||
Camera_ChangeSettingFlags(camera, camera->prevSetting, 2);
|
||||
camera->unk_14C |= (0x4 | 0x2);
|
||||
|
||||
Reference in New Issue
Block a user