From fcefd43915ccbc660814ef2eb7565cdd6761e96c Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:13:19 +1000 Subject: [PATCH] Blood: Add joystick option to center view on landing --- source/blood/src/config.cpp | 2 ++ source/blood/src/config.h | 1 + source/blood/src/controls.cpp | 5 +++++ source/blood/src/menu.cpp | 13 +++++++++++-- source/blood/src/osdcmd.cpp | 1 + source/blood/src/player.cpp | 2 ++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 2368a520dc..196642ac91 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -77,6 +77,7 @@ char CommbatMacro[MAXRIDECULE][MAXRIDECULELENGTH]; char szPlayerName[MAXPLAYERNAME]; int32_t gTurnSpeed; int32_t gTurnAcceleration; +int32_t gCenterViewOnDrop; int32_t gDetail; int32_t gMouseAim; int32_t gAutoAim; @@ -387,6 +388,7 @@ void CONFIG_SetDefaults(void) gViewSize = 2; gTurnSpeed = 92; gTurnAcceleration = 1; + gCenterViewOnDrop = 0; gDetail = 4; gAutoRun = 0; gViewInterpolate = 1; diff --git a/source/blood/src/config.h b/source/blood/src/config.h index 1124484f21..db4cf237a3 100644 --- a/source/blood/src/config.h +++ b/source/blood/src/config.h @@ -58,6 +58,7 @@ extern char CommbatMacro[MAXRIDECULE][MAXRIDECULELENGTH]; extern char szPlayerName[MAXPLAYERNAME]; extern int32_t gTurnSpeed; extern int32_t gTurnAcceleration; +extern int32_t gCenterViewOnDrop; extern int32_t gDetail; extern int32_t gAutoAim; extern int32_t gWeaponSwitch; diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 9cca0f055d..02c5c9daf2 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -520,6 +520,11 @@ void ctrlGetInput(void) } if (input.q16turn == 0) input.q16turn = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.dyaw>>4), F16(32))); + if (gCenterViewOnDrop == 2) + { + gInput.keyFlags.lookCenter = 1; + gCenterViewOnDrop = 1; + } } if (!gMouseAimingFlipped) input.q16mlook = -input.q16mlook; diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index f245a6e331..09fceee7e2 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -68,6 +68,7 @@ void SetMouseSensitivity(CGameMenuItemSliderFloat *); void SetMouseAimFlipped(CGameMenuItemZBool *); void SetTurnSpeed(CGameMenuItemSlider *); void SetTurnAcceleration(CGameMenuItemZCycle *); +void SetCenterView(CGameMenuItemZBool *); void SetJoystickRumble(CGameMenuItemZBool *pItem); void ResetKeys(CGameMenuItemChain *); void ResetKeysClassic(CGameMenuItemChain *); @@ -847,7 +848,8 @@ CGameMenuItemSlider *pItemOptionsControlJoystickAxisDeadzone[MAXJOYAXES]; CGameMenuItemSlider *pItemOptionsControlJoystickAxisSaturate[MAXJOYAXES]; CGameMenuItemTitle itemOptionsControlJoystickMiscTitle("JOYSTICK MISC", 1, 160, 20, 2038); -CGameMenuItemZBool itemOptionsControlJoystickMiscRumble("RUMBLE CONTROLLER:", 1, 18, 70, 280, 0, SetJoystickRumble, NULL, NULL); +CGameMenuItemZBool itemOptionsControlJoystickMiscCenterView("CENTER VIEW ON DROP:", 1, 18, 80, 280, gCenterViewOnDrop, SetCenterView, NULL, NULL); +CGameMenuItemZBool itemOptionsControlJoystickMiscRumble("RUMBLE CONTROLLER:", 1, 18, 100, 280, 0, SetJoystickRumble, NULL, NULL); void SetupLoadingScreen(void) { @@ -1487,9 +1489,11 @@ void SetupJoystickMenu(void) } menuOptionsControlJoystickMisc.Add(&itemOptionsControlJoystickMiscTitle, false); - menuOptionsControlJoystickMisc.Add(&itemOptionsControlJoystickMiscRumble, true); + menuOptionsControlJoystickMisc.Add(&itemOptionsControlJoystickMiscCenterView, true); + menuOptionsControlJoystickMisc.Add(&itemOptionsControlJoystickMiscRumble, false); menuOptionsControlJoystickMisc.Add(&itemBloodQAV, false); + itemOptionsControlJoystickMiscCenterView.at20 = gCenterViewOnDrop; itemOptionsControlJoystickMiscRumble.at20 = gSetup.joystickrumble; int i = 0, y = 0; @@ -1821,6 +1825,11 @@ void SetTurnAcceleration(CGameMenuItemZCycle *pItem) gTurnAcceleration = pItem->m_nFocus; } +void SetCenterView(CGameMenuItemZBool *pItem) +{ + gCenterViewOnDrop = pItem->at20; +} + void SetJoystickRumble(CGameMenuItemZBool *pItem) { gSetup.joystickrumble = pItem->at20; diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 52ecc9df22..e3ae0cdacf 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -1023,6 +1023,7 @@ int32_t registerosdcommands(void) { "fov", "change the field of view", (void *)&gFov, CVAR_INT|CVAR_FUNCPTR, 75, 140 }, { "in_aimmode", "0: toggle, 1: hold to aim", (void *)&gMouseAiming, CVAR_BOOL, 0, 1 }, + { "in_centerviewondrop", "enable/disable recenter view when dropping down onto ground", (void *)&gCenterViewOnDrop, CVAR_BOOL, 0, 1 }, { "in_mousebias", "emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time", (void *)&MouseBias, CVAR_INT, 0, 32 diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index eff0d08ade..2b1223f010 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -2436,6 +2436,8 @@ void playerLandingSound(PLAYER *pPlayer) SPRITEHIT *pHit = &gSpriteHit[pSprite->extra]; if (pHit->florhit) { + if ((pPlayer == gMe) && gCenterViewOnDrop) + gCenterViewOnDrop = 2; if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, &sprite[pHit->florhit & 0x3fff])) return; char nSurf = tileGetSurfType(pHit->florhit);