- Exhumed: Add crouch toggle mechanism.

This commit is contained in:
Mitchell Richters 2020-11-07 13:27:58 +11:00
parent 7c8efde38c
commit 032db82f82
3 changed files with 19 additions and 7 deletions

View file

@ -106,6 +106,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN; if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
} }
Player* pPlayer = &PlayerList[nLocalPlayer];
double const scaleAdjust = InputScale(); double const scaleAdjust = InputScale();
InputPacket input {}; InputPacket input {};
@ -119,10 +120,23 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
processMovement(&input, &localInput, hidInput, scaleAdjust); processMovement(&input, &localInput, hidInput, scaleAdjust);
} }
// Handle crouch toggling.
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle)
{
localInput.actions |= SB_CROUCH;
}
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
{
pPlayer->crouch_toggle = !pPlayer->crouch_toggle;
buttonMap.ClearButton(gamefunc_Toggle_Crouch);
}
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump))
{
pPlayer->crouch_toggle = false;
}
if (!cl_syncinput) if (!cl_syncinput)
{ {
Player* pPlayer = &PlayerList[nLocalPlayer];
if (!nFreeze) if (!nFreeze)
{ {
applylook(&pPlayer->angle, input.avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080); applylook(&pPlayer->angle, input.avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080);

View file

@ -75,6 +75,8 @@ struct Player
PlayerHorizon horizon; PlayerHorizon horizon;
PlayerAngle angle; PlayerAngle angle;
vec3_t opos; vec3_t opos;
bool crouch_toggle;
}; };
extern short PlayerCount; extern short PlayerCount;

View file

@ -514,11 +514,7 @@ OptionMenu "ActionControlsMenu" protected
StaticText "" StaticText ""
Control "$CNTRLMNU_JUMP" , "+jump" Control "$CNTRLMNU_JUMP" , "+jump"
Control "$CNTRLMNU_CROUCH" , "+crouch" Control "$CNTRLMNU_CROUCH" , "+crouch"
ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides, Blood) Control "$CNTRLMNU_TOGGLECROUCH" , "+toggle_crouch"
{
// Fixme: Make this work in all games
Control "$CNTRLMNU_TOGGLECROUCH" , "+toggle_crouch"
}
StaticText "" StaticText ""
Control "$CNTRLMNU_MOUSELOOK" , "+mouse_aiming" Control "$CNTRLMNU_MOUSELOOK" , "+mouse_aiming"