From 5981bcc2a61712189a1ba4b2c936f23c6c218408 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 30 Aug 2026 01:40:44 -0600 Subject: [PATCH] Separate ping from attack3 --- game/neo/scripts/kb_act.lst | 2 +- game/neo/scripts/kb_def.lst | 2 +- src/game/client/c_baseplayer.cpp | 2 +- src/game/client/cdll_client_int.cpp | 25 +++++++++++++++++ src/game/client/in_main.cpp | 9 +++++++ src/game/client/in_steamcontroller.cpp | 3 +++ .../server/NextBot/Player/NextBotPlayer.h | 27 +++++++++++++++++++ .../neo/bot/behavior/neo_bot_behavior.cpp | 2 +- src/game/server/neo/bot/neo_bot.cpp | 2 ++ src/game/server/player.cpp | 2 +- src/game/server/vscript_server.cpp | 4 +++ src/game/shared/in_buttons.h | 4 +++ src/game/shared/neo/neo_player_shared.cpp | 2 +- 13 files changed, 80 insertions(+), 6 deletions(-) diff --git a/game/neo/scripts/kb_act.lst b/game/neo/scripts/kb_act.lst index 966a3d43e2..4b5d01b635 100644 --- a/game/neo/scripts/kb_act.lst +++ b/game/neo/scripts/kb_act.lst @@ -47,7 +47,7 @@ "+voicerecord" "#Valve_Use_Voice_Communication" "messagemode" "#Valve_Chat_Message" "messagemode2" "#Valve_Team_Message" -"+attack3" "Ping Location" +"+ping" "Ping Location" "joinstar 0" "Join Alpha Star" "joinstar 1" "Join Bravo Star" "joinstar 2" "Join Charlie Star" diff --git a/game/neo/scripts/kb_def.lst b/game/neo/scripts/kb_def.lst index 710d383105..78affd1642 100644 --- a/game/neo/scripts/kb_def.lst +++ b/game/neo/scripts/kb_def.lst @@ -51,6 +51,6 @@ "MWHEELUP" "invnext" "MOUSE1" "+attack" "MOUSE2" "+toggle_aim" -"MOUSE3" "+attack3" +"MOUSE3" "+ping" "PAUSE" "pause" "`" "neo_toggleconsole" diff --git a/src/game/client/c_baseplayer.cpp b/src/game/client/c_baseplayer.cpp index 21e5f5170f..c25f2f653a 100644 --- a/src/game/client/c_baseplayer.cpp +++ b/src/game/client/c_baseplayer.cpp @@ -2600,7 +2600,7 @@ void C_BasePlayer::PhysicsSimulate( void ) ctx->cmd.sidemove = 0; ctx->cmd.upmove = 0; ctx->cmd.impulse = 0; - ctx->cmd.buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_ATTACK3 | IN_JUMP | IN_ALT1 | IN_ALT2 | IN_ZOOM); + ctx->cmd.buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_ATTACK3 | IN_PING | IN_JUMP | IN_ALT1 | IN_ALT2 | IN_ZOOM); } else if (static_cast(this)->GetNeoFlags() & NEO_FL_FREEZETIME) { diff --git a/src/game/client/cdll_client_int.cpp b/src/game/client/cdll_client_int.cpp index fbc1f34ac0..223052c420 100644 --- a/src/game/client/cdll_client_int.cpp +++ b/src/game/client/cdll_client_int.cpp @@ -1530,6 +1530,31 @@ void CHLClient::PostInit() } } + if (iCfgVerMajor < 34) + { + // Player pings moved off of +attack3 onto their own +ping bind, + // so move whichever key the player had bound to +attack3 over to it. + const ButtonCode_t bcPing = gameuifuncs->GetButtonCodeForBind("+attack3"); + if (bcPing > BUTTON_CODE_NONE) + { + const char *bindBtnName = g_pInputSystem->ButtonCodeToString(bcPing); + if (bindBtnName && bindBtnName[0]) + { + char szCmd[128]; + + V_sprintf_safe(szCmd, "unbind \"%s\"\n", bindBtnName); + engine->ClientCmd_Unrestricted(szCmd); + + V_sprintf_safe(szCmd, "bind \"%s\" \"+ping\"\n", bindBtnName); + engine->ClientCmd_Unrestricted(szCmd); + } + } + else + { + SetupBindIfNotSet("+ping", MOUSE_MIDDLE); // Ping location + } + } + cvr_cl_neo_cfg_version_major.SetValue(NEO_VERSION_MAJOR); cvr_cl_neo_cfg_version_minor.SetValue(NEO_VERSION_MINOR); } diff --git a/src/game/client/in_main.cpp b/src/game/client/in_main.cpp index a414ab7b87..a5e84c0f1b 100644 --- a/src/game/client/in_main.cpp +++ b/src/game/client/in_main.cpp @@ -153,6 +153,7 @@ static kbutton_t in_attack3; kbutton_t in_ducktoggle; #ifdef NEO +static kbutton_t in_ping; static kbutton_t in_drop; static kbutton_t in_aim; static kbutton_t in_lean_left; @@ -649,6 +650,9 @@ void IN_Attack3Down( const CCommand &args ) { KeyDown(&in_attack3, args[1] );} void IN_Attack3Up( const CCommand &args ) { KeyUp(&in_attack3, args[1] );} #ifdef NEO +void IN_PingDown( const CCommand &args ) { KeyDown(&in_ping, args[1] );} +void IN_PingUp( const CCommand &args ) { KeyUp(&in_ping, args[1] );} + void IN_DropUp( const CCommand &args ) { KeyUp( &in_drop, args[1] ); } void IN_DropDown( const CCommand &args ) { KeyDown( &in_drop, args[1] ); } @@ -1726,6 +1730,7 @@ int CInput::GetButtonBits( int bResetState ) CalcButtonBits( bits, IN_ATTACK3, s_ClearInputState, &in_attack3, bResetState ); #ifdef NEO + CalcButtonBits( bits, IN_PING, s_ClearInputState, &in_ping, bResetState ); CalcButtonBits( bits, IN_DROP, s_ClearInputState, &in_drop, bResetState ); CalcButtonBits( bits, IN_AIM, s_ClearInputState, &in_aim, bResetState ); CalcButtonBits( bits, IN_LEAN_LEFT, s_ClearInputState, &in_lean_left, bResetState ); @@ -1900,6 +1905,10 @@ static ConCommand endgrenade2( "-grenade2", IN_Grenade2Up ); static ConCommand startgrenade2( "+grenade2", IN_Grenade2Down ); static ConCommand startattack3("+attack3", IN_Attack3Down); static ConCommand endattack3("-attack3", IN_Attack3Up); +#ifdef NEO +static ConCommand startping("+ping", IN_PingDown); +static ConCommand endping("-ping", IN_PingUp); +#endif #ifdef TF_CLIENT_DLL static ConCommand toggle_duck( "toggle_duck", IN_DuckToggle ); diff --git a/src/game/client/in_steamcontroller.cpp b/src/game/client/in_steamcontroller.cpp index 62527970a0..96f9e0f918 100644 --- a/src/game/client/in_steamcontroller.cpp +++ b/src/game/client/in_steamcontroller.cpp @@ -137,6 +137,9 @@ static ControllerDigitalActionToCommand g_ControllerDigitalGameActions[] = { "attack", "+attack", CONTROLLER_ACTION_FLAGS_NONE }, { "attack2", "+attack2", CONTROLLER_ACTION_FLAGS_NONE }, { "attack3", "+attack3", CONTROLLER_ACTION_FLAGS_NONE }, +#ifdef NEO + { "ping", "+ping", CONTROLLER_ACTION_FLAGS_NONE }, +#endif { "jump", "+jump", CONTROLLER_ACTION_FLAGS_STOPS_TAUNT }, { "use_action_slot_item", "+use_action_slot_item", CONTROLLER_ACTION_FLAGS_NONE }, { "invprev", "invprev", CONTROLLER_ACTION_FLAGS_STOPS_TAUNT|CONTROLLER_ACTION_FLAGS_NEEDS_DEBOUNCE }, diff --git a/src/game/server/NextBot/Player/NextBotPlayer.h b/src/game/server/NextBot/Player/NextBotPlayer.h index 2a90a830ec..b1890f5707 100644 --- a/src/game/server/NextBot/Player/NextBotPlayer.h +++ b/src/game/server/NextBot/Player/NextBotPlayer.h @@ -122,6 +122,9 @@ class INextBotPlayerInput virtual void ReleaseJumpButton( void ) = 0; #ifdef NEO + virtual void PressPingButton( float duration = -1.0f ) = 0; + virtual void ReleasePingButton( void ) = 0; + virtual void PressDropButton( float duration = -1.0f ) = 0; virtual void ReleaseDropButton( void ) = 0; @@ -216,6 +219,9 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI virtual void ReleaseSpecialFireButton( void ); #ifdef NEO + virtual void PressPingButton( float duration = -1.0f ); + virtual void ReleasePingButton( void ); + virtual void PressDropButton( float duration = -1.0f ); virtual void ReleaseDropButton( void ); @@ -313,6 +319,7 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI CountdownTimer m_walkButtonTimer; CountdownTimer m_buttonScaleTimer; #ifdef NEO + CountdownTimer m_pingButtonTimer; CountdownTimer m_moveUpButtonTimer; CountdownTimer m_moveDownButtonTimer; CountdownTimer m_dropButtonTimer; @@ -433,6 +440,22 @@ inline void NextBotPlayer< PlayerType >::ReleaseSpecialFireButton( void ) m_specialFireButtonTimer.Invalidate(); } +#ifdef NEO +template < typename PlayerType > +inline void NextBotPlayer< PlayerType >::PressPingButton( float duration ) +{ + m_inputButtons |= IN_PING; + m_pingButtonTimer.Start( duration ); +} + +template < typename PlayerType > +inline void NextBotPlayer< PlayerType >::ReleasePingButton( void ) +{ + m_inputButtons &= ~IN_PING; + m_pingButtonTimer.Invalidate(); +} +#endif // NEO + template < typename PlayerType > inline void NextBotPlayer< PlayerType >::PressUseButton( float duration ) { @@ -731,6 +754,7 @@ inline void NextBotPlayer< PlayerType >::Spawn( void ) m_forwardScale = m_rightScale = 0.04; m_burningTimer.Invalidate(); #ifdef NEO + m_pingButtonTimer.Invalidate(); m_moveUpButtonTimer.Invalidate(); m_moveDownButtonTimer.Invalidate(); m_dropButtonTimer.Invalidate(); @@ -873,6 +897,9 @@ inline void NextBotPlayer< PlayerType >::PhysicsSimulate( void ) m_inputButtons |= IN_SPEED; #ifdef NEO + if ( !m_pingButtonTimer.IsElapsed() ) + m_inputButtons |= IN_PING; + if ( !m_sneakButtonTimer.IsElapsed() ) m_inputButtons |= IN_WALK; diff --git a/src/game/server/neo/bot/behavior/neo_bot_behavior.cpp b/src/game/server/neo/bot/behavior/neo_bot_behavior.cpp index 32723f42c8..c959f41753 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_behavior.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_behavior.cpp @@ -872,7 +872,7 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me ) { if (NEORules()->IsTeamplay()) { - me->PressSpecialFireButton(); // place a player ping to alert friends + me->PressPingButton(); // place a player ping to alert friends } if (bThreatIsGhoster) diff --git a/src/game/server/neo/bot/neo_bot.cpp b/src/game/server/neo/bot/neo_bot.cpp index 175eb07c2f..e7f8319a05 100644 --- a/src/game/server/neo/bot/neo_bot.cpp +++ b/src/game/server/neo/bot/neo_bot.cpp @@ -443,6 +443,8 @@ DEFINE_SCRIPTFUNC_WRAPPED( GetSpawnArea, "Return the nav area of where we spawne DEFINE_SCRIPTFUNC( PressFireButton, "" ) DEFINE_SCRIPTFUNC( PressAltFireButton, "" ) DEFINE_SCRIPTFUNC( PressSpecialFireButton, "" ) +DEFINE_SCRIPTFUNC( PressPingButton, "" ) +DEFINE_SCRIPTFUNC( ReleasePingButton, "" ) DEFINE_SCRIPTFUNC( GetBotId, "Get this bot's id" ) DEFINE_SCRIPTFUNC( FlagForUpdate, "Flag this bot for update" ) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 596f300be2..6df4749cac 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -4049,7 +4049,7 @@ void CBasePlayer::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper) ucmd->sidemove = 0; ucmd->upmove = 0; ucmd->impulse = 0; - ucmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_ATTACK3 | IN_JUMP | IN_ALT1 | IN_ALT2 | IN_ZOOM); + ucmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_ATTACK3 | IN_PING | IN_JUMP | IN_ALT1 | IN_ALT2 | IN_ZOOM); } #endif diff --git a/src/game/server/vscript_server.cpp b/src/game/server/vscript_server.cpp index db411f25b3..6fadfee5f9 100644 --- a/src/game/server/vscript_server.cpp +++ b/src/game/server/vscript_server.cpp @@ -2933,7 +2933,11 @@ DECLARE_SCRIPT_CONST( FButtons, IN_WALK ) DECLARE_SCRIPT_CONST( FButtons, IN_ZOOM ) DECLARE_SCRIPT_CONST( FButtons, IN_WEAPON1 ) DECLARE_SCRIPT_CONST( FButtons, IN_WEAPON2 ) +#ifdef NEO +DECLARE_SCRIPT_CONST( FButtons, IN_PING ) +#else DECLARE_SCRIPT_CONST( FButtons, IN_BULLRUSH ) +#endif DECLARE_SCRIPT_CONST( FButtons, IN_GRENADE1 ) DECLARE_SCRIPT_CONST( FButtons, IN_GRENADE2 ) DECLARE_SCRIPT_CONST( FButtons, IN_ATTACK3 ) diff --git a/src/game/shared/in_buttons.h b/src/game/shared/in_buttons.h index 1897d07993..28c9aeafbc 100644 --- a/src/game/shared/in_buttons.h +++ b/src/game/shared/in_buttons.h @@ -33,7 +33,11 @@ #define IN_ZOOM (1 << 19) // Zoom key for HUD zoom #define IN_WEAPON1 (1 << 20) // weapon defines these bits #define IN_WEAPON2 (1 << 21) // weapon defines these bits +#ifdef NEO +#define IN_PING (1 << 22) // player ping +#else #define IN_BULLRUSH (1 << 22) +#endif #define IN_GRENADE1 (1 << 23) // grenade 1 #define IN_GRENADE2 (1 << 24) // grenade 2 #define IN_ATTACK3 (1 << 25) diff --git a/src/game/shared/neo/neo_player_shared.cpp b/src/game/shared/neo/neo_player_shared.cpp index 2f1b1a5f7e..e2d4df9a55 100644 --- a/src/game/shared/neo/neo_player_shared.cpp +++ b/src/game/shared/neo/neo_player_shared.cpp @@ -133,7 +133,7 @@ extern ConVar cl_neo_player_pings; #endif // CLIENT_DLL void CheckPingButton(CNEO_Player* player) { - if (!player->IsAlive() || !(player->m_afButtonPressed & IN_ATTACK3) || player->m_flNextPingTime > gpGlobals->curtime) + if (!player->IsAlive() || !(player->m_afButtonPressed & IN_PING) || player->m_flNextPingTime > gpGlobals->curtime) { return; }