Skip to content

Commit

Permalink
Blood: Add joystick option to center view on landing
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyqlfpir committed Jan 6, 2025
1 parent 007cdb1 commit fcefd43
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions source/blood/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -387,6 +388,7 @@ void CONFIG_SetDefaults(void)
gViewSize = 2;
gTurnSpeed = 92;
gTurnAcceleration = 1;
gCenterViewOnDrop = 0;
gDetail = 4;
gAutoRun = 0;
gViewInterpolate = 1;
Expand Down
1 change: 1 addition & 0 deletions source/blood/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions source/blood/src/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions source/blood/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/blood/src/osdcmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/blood/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fcefd43

Please sign in to comment.