Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions game/neo/scripts/kb_act.lst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"+moveright" "#Valve_Move_Right"
"+leanl" "Lean left"
"+leanr" "Lean right"
"toggle_leanl" "Lean left (toggle)"
"toggle_leanr" "Lean right (toggle)"
"+sprint" "#Valve_Sprint"
"+walk" "Walk"
"toggle_walk" "Walk (toggle)"
Expand Down
23 changes: 23 additions & 0 deletions src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,22 @@ static void SetupBindIfNotSet(const char *pszBindName, const ButtonCode_t bc)
}
}

static void UnbindIfExists(const char *pszBindName)
{
const ButtonCode_t btnCode = gameuifuncs->GetButtonCodeForBind(pszBindName);
if (btnCode)
{
const char* bindBtnName = g_pInputSystem->ButtonCodeToString(btnCode);
if (bindBtnName && bindBtnName[0])
{
char szCmd[128];

V_sprintf_safe(szCmd, "unbind \"%s\"\n", bindBtnName);
engine->ClientCmd_Unrestricted(szCmd);
}
}
}

#endif // NEO

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1445,6 +1461,13 @@ void CHLClient::PostInit()
engine->ClientCmd_Unrestricted(szCmd);
}
}

// neo_lean_hold added and toggle binds removed
// Set lean keys to default value and unblind toggle lean
UnbindIfExists("toggle_leanl");
UnbindIfExists("toggle_leanr");
SetupBindIfNotSet("+leanl", KEY_Q);
SetupBindIfNotSet("+leanr", KEY_E);
}

cvr_cl_neo_cfg_version_major.SetValue(NEO_VERSION_MAJOR);
Expand Down
84 changes: 50 additions & 34 deletions src/game/client/in_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ConVar thirdperson_screenspace( "thirdperson_screenspace", "0", 0, "Movement wil
ConVar sv_noclipduringpause( "sv_noclipduringpause", "0", FCVAR_REPLICATED | FCVAR_CHEAT, "If cheats are enabled, then you can noclip with the game paused (for doing screenshots, etc.)." );

extern ConVar cl_mouselook;
extern ConVar cl_neo_lean_hold;

#define UsingMouselook() cl_mouselook.GetBool()

Expand Down Expand Up @@ -527,17 +528,61 @@ void IN_DropDown( const CCommand &args ) { KeyDown( &in_drop, args[1] ); }
void IN_AimUp( const CCommand &args ) { KeyUp( &in_aim, args[1] ); }
void IN_AimDown( const CCommand &args ) { KeyDown( &in_aim, args[1] ); }

void IN_LeanLeftUp( const CCommand &args ) { KeyUp( &in_lean_left, args[1] ); }
void IN_LeanLeftDown( const CCommand &args ) { KeyDown( &in_lean_left, args[1] ); }
void IN_LeanLeftUp( const CCommand &args ) {
if(cl_neo_lean_hold.GetBool())
{
KeyUp(&in_lean_left, args[1]);
}
}
void IN_LeanLeftDown( const CCommand &args ) {
if (cl_neo_lean_hold.GetBool())
{
KeyDown(&in_lean_left, args[1]);
}
else
{
if (::input->KeyState(&in_lean_left))
{
KeyUp(&in_lean_left, nullptr);
}
else
{
KeyDown(&in_lean_left, args[1]);
KeyUp(&in_lean_right, nullptr);
}
}
}

void IN_LeanLeft() { KeyUp(&in_lean_right, nullptr); KeyDown(&in_lean_left, nullptr); }
void IN_LeanLeft() { KeyUp(&in_lean_right, nullptr);KeyDown(&in_lean_left, nullptr); }
void IN_LeanRight() { KeyUp(&in_lean_left, nullptr); KeyDown(&in_lean_right, nullptr); }
void IN_LeanReset() { KeyUp(&in_lean_left, nullptr); KeyUp(&in_lean_right, nullptr); }

void IN_SpeedReset() { KeyUp(&in_speed, nullptr); }

void IN_LeanRightUp( const CCommand &args ) { KeyUp( &in_lean_right, args[1] ); }
void IN_LeanRightDown( const CCommand &args ) { KeyDown( &in_lean_right, args[1] ); }
void IN_LeanRightUp( const CCommand &args ) {
if (cl_neo_lean_hold.GetBool()) {
KeyUp(&in_lean_right, args[1]);
}
}
void IN_LeanRightDown( const CCommand &args )
{
if (cl_neo_lean_hold.GetBool())
{
KeyDown(&in_lean_right, args[1]);
}
else
{
if (::input->KeyState(&in_lean_right))
{
KeyUp(&in_lean_right, nullptr);
}
else
{
KeyDown(&in_lean_right, args[1]);
KeyUp(&in_lean_left, nullptr);
}
}
}

void IN_ThermOpticUp(const CCommand &args) { KeyUp(&in_thermoptic, args[1]); }
void IN_ThermOpticDown(const CCommand &args) { KeyDown(&in_thermoptic, args[1]); }
Expand All @@ -563,32 +608,6 @@ void IN_AimToggle(const CCommand& args)
}
}

void IN_LeanLeftToggle(const CCommand& args)
{
if (::input->KeyState(&in_lean_left))
{
KeyUp(&in_lean_left, args[1]);
}
else
{
KeyDown(&in_lean_left, args[1]);
KeyUp(&in_lean_right, args[1]);
}
}

void IN_LeanRightToggle(const CCommand& args)
{
if (::input->KeyState(&in_lean_right))
{
KeyUp(&in_lean_right, args[1]);
}
else
{
KeyDown(&in_lean_right, args[1]);
KeyUp(&in_lean_left, args[1]);
}
}

void IN_WalkToggle(const CCommand& args)
{
if (::input->KeyState(&in_walk))
Expand Down Expand Up @@ -1787,9 +1806,6 @@ static ConCommand endthermoptic("-thermoptic", IN_ThermOpticUp);
static ConCommand startvision("+vision", IN_VisionDown);
static ConCommand endvision("-vision", IN_VisionUp);

static ConCommand toggle_leanleft("toggle_leanl", IN_LeanLeftToggle);
static ConCommand toggle_leanright("toggle_leanr", IN_LeanRightToggle);

static ConCommand toggle_walk("toggle_walk", IN_WalkToggle);

static ConCommand startspecnextplayer("+specnextplayer", IN_SpecNextDown);
Expand Down
24 changes: 20 additions & 4 deletions src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,22 +534,39 @@ void C_NEO_Player::CheckVisionButtons()
}
}

ConVar cl_neo_lean_hold("cl_neo_lean_hold", "0", FCVAR_ARCHIVE, "Hold leaning instead of toggle");

void C_NEO_Player::CheckLeanButtons()
{
if (!IsAlive())
{
return;
}

m_bInLean = NEO_LEAN_NONE;
if ((m_nButtons & IN_LEAN_LEFT) && !(m_nButtons & IN_LEAN_RIGHT || IsSprinting()))
if (IsSprinting() || IsAirborne()) {
m_bInLean = NEO_LEAN_NONE;

if (!cl_neo_lean_hold.GetBool()) {
IN_LeanReset();
}

return;
}

bool leanLeft = m_nButtons & IN_LEAN_LEFT;
bool leanRight = m_nButtons & IN_LEAN_RIGHT;

if (leanLeft && !leanRight)
{
m_bInLean = NEO_LEAN_LEFT;
}
else if ((m_nButtons & IN_LEAN_RIGHT) && !(m_nButtons & IN_LEAN_LEFT || IsSprinting()))
else if (leanRight && !leanLeft)
{
m_bInLean = NEO_LEAN_RIGHT;
}
else {
m_bInLean = NEO_LEAN_NONE;
}
}

int C_NEO_Player::GetAttackersScores(const int attackerIdx) const
Expand Down Expand Up @@ -1616,7 +1633,6 @@ void C_NEO_Player::StartSprinting(void)
void C_NEO_Player::StopSprinting(void)
{
m_fIsSprinting = false;
IN_SpeedReset();
}

bool C_NEO_Player::CanSprint(void)
Expand Down
4 changes: 3 additions & 1 deletion src/game/client/neo/ui/neo_root_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey
pGeneral->bViewmodelRighthand = cvr->cl_righthand.GetBool();
pGeneral->bLeanViewmodelOnly = cvr->cl_neo_lean_viewmodel_only.GetBool();
pGeneral->iLeanAutomatic = cvr->cl_neo_lean_automatic.GetInt();
pGeneral->bLeanHold = cvr->cl_neo_lean_hold.GetBool();
pGeneral->bHipFireCrosshair = cvr->cl_neo_crosshair_hip_fire.GetBool();
pGeneral->bShowSquadList = cvr->cl_neo_squad_hud_original.GetBool();
pGeneral->iHealthMode = cvr->cl_neo_hud_health_mode.GetInt();
Expand Down Expand Up @@ -690,6 +691,7 @@ void NeoSettingsSave(const NeoSettings *ns)
cvr->cl_righthand.SetValue(pGeneral->bViewmodelRighthand);
cvr->cl_neo_lean_viewmodel_only.SetValue(pGeneral->bLeanViewmodelOnly);
cvr->cl_neo_lean_automatic.SetValue(pGeneral->iLeanAutomatic);
cvr->cl_neo_lean_hold.SetValue(pGeneral->bLeanHold);
cvr->cl_neo_crosshair_hip_fire.SetValue(pGeneral->bHipFireCrosshair);
cvr->cl_neo_squad_hud_original.SetValue(pGeneral->bShowSquadList);
cvr->cl_neo_hud_health_mode.SetValue(pGeneral->iHealthMode);
Expand Down Expand Up @@ -946,7 +948,7 @@ void NeoSettings_General(NeoSettings *ns)
NeoUI::RingBoxBool(L"Right hand viewmodel", &pGeneral->bViewmodelRighthand);
NeoUI::RingBoxBool(L"Lean viewmodel only", &pGeneral->bLeanViewmodelOnly);
NeoUI::RingBox(L"Automatic leaning", AUTOMATIC_LEAN_LABELS, ARRAYSIZE(AUTOMATIC_LEAN_LABELS), &pGeneral->iLeanAutomatic);

NeoUI::RingBoxBool(L"Lean hold", &pGeneral->bLeanHold);

NeoUI::HeadingLabel(L"HUD");
NeoUI::RingBoxBool(L"Classic squad list", &pGeneral->bShowSquadList);
Expand Down
2 changes: 2 additions & 0 deletions src/game/client/neo/ui/neo_root_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct NeoSettings
bool bLeanViewmodelOnly;
bool bHipFireCrosshair;
int iLeanAutomatic;
bool bLeanHold;
bool bShowSquadList;
bool bShowPlayerSprays;
int iHealthMode;
Expand Down Expand Up @@ -212,6 +213,7 @@ struct NeoSettings
CONVARREF_DEF(cl_righthand);
CONVARREF_DEF(cl_neo_lean_viewmodel_only);
CONVARREF_DEF(cl_neo_lean_automatic);
CONVARREF_DEF(cl_neo_lean_hold);
CONVARREF_DEF(cl_neo_squad_hud_original);
CONVARREF_DEF(cl_neo_hud_health_mode);
CONVARREF_DEF(cl_neo_hud_iff_verbosity);
Expand Down
18 changes: 14 additions & 4 deletions src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,16 +705,26 @@ void CNEO_Player::CheckLeanButtons()
{
return;
}

m_bInLean = NEO_LEAN_NONE;
if ((m_nButtons & IN_LEAN_LEFT) && !(m_nButtons & IN_LEAN_RIGHT || IsSprinting()))

if (IsSprinting() || IsAirborne()) {
m_bInLean = NEO_LEAN_NONE;
return;
}

auto leanLeft = m_nButtons & IN_LEAN_LEFT;
auto leanRight = m_nButtons & IN_LEAN_RIGHT;

if (leanLeft && !leanRight)
{
m_bInLean = NEO_LEAN_LEFT;
}
else if ((m_nButtons & IN_LEAN_RIGHT) && !(m_nButtons & IN_LEAN_LEFT || IsSprinting()))
else if (leanRight && !leanLeft)
{
m_bInLean = NEO_LEAN_RIGHT;
}
else {
m_bInLean = NEO_LEAN_NONE;
}
}

void CNEO_Player::CalculateSpeed(void)
Expand Down