From 626a6ae3a231a2a12c450ce8e95f97960afe3be9 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 25 Jul 2026 22:39:29 -0600 Subject: [PATCH] Emit player cloak/footstep sounds for bots to detect --- .../bot/behavior/neo_bot_seek_and_destroy.cpp | 2 +- src/game/server/neo/neo_player.cpp | 5 +++ src/game/server/soundent.h | 34 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index 00419171c3..0242a5fde2 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -41,7 +41,7 @@ CSound* CNEOBotSeekAndDestroy::SearchGunfireSounds(CNEOBot* me, const Vector* cu break; } - if (!(pSound->SoundType() & SOUND_COMBAT)) + if (!(pSound->SoundType() & (SOUND_COMBAT | SOUND_PLAYER))) { continue; } diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index 7e04b45bc1..5d5a8e8c5f 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -1303,6 +1303,9 @@ void CNEO_Player::PlayCloakSound(bool removeLocalPlayer) // effect lasts 0.5 seconds, but allow 200-300ms leeway with GetFogObscuredRatio cache window m_botThermOpticCamoDisruptedTimer.Start(0.2f); } + + // For bots to notice cloak sound + CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_CLOAK, 0.5, this); } void CNEO_Player::SetCloakState(bool state) @@ -3060,6 +3063,8 @@ void CNEO_Player::PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force ) { BaseClass::PlayStepSound(vecOrigin, psurface, fvol, force); + // For bots to hear footsteps + CSoundEnt::InsertSound(SOUND_PLAYER | SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_FOOTSTEP, 0.1, this); } bool CNEO_Player::IsCarryingGhost(void) const diff --git a/src/game/server/soundent.h b/src/game/server/soundent.h index 4de733f434..486abbc690 100644 --- a/src/game/server/soundent.h +++ b/src/game/server/soundent.h @@ -90,6 +90,40 @@ enum #define SOUNDENT_VOLUME_PISTOL 1500.0 #define SOUNDENT_VOLUME_EMPTY 500.0 // volume of the "CLICK" when you have no bullets +#ifdef NEO +// Used for calibrating bot detection distances for CSoundEnt::InsertSound() + +// Murata shotgun sound uses SNDLVL_150dB with volume 1.0 [weapon_murata.single in game_sounds_weapons.txt] +// Human player recipient list hearing distance calculation: +// maxAudible = (2 * SOUND_NORMAL_CLIP_DIST) / attenuation [recipientfilter.cpp] +// SOUND_NORMAL_CLIP_DIST = 10000.0f [public/const.h] +// attenuation = SNDLVL_TO_ATTN(150) = 20.0f / (150 - 50) = 0.2 [public/soundflags.h] +// maxAudible = (2 * 10000.0) / 0.2 = 100000 units +// Volume multiplier: 100000 * 1.0 = 100000 units +// SOUNDENT_VOLUME_SHOTGUN = 1500.0 +// ratio = 100000 / 1500 = 66.666...u + +// Cloak sound uses SNDLVL_75dB with volume 0.7 [NeoPlayer.ThermOpticOn/Off in game_sounds_player.txt] +// Human player recipient list hearing distance calculation: +// maxAudible = (2 * SOUND_NORMAL_CLIP_DIST) / attenuation [recipientfilter.cpp] +// SOUND_NORMAL_CLIP_DIST = 10000.0f [public/const.h] +// attenuation = SNDLVL_TO_ATTN(75) = 20.0f / (75 - 50) = 0.8 [public/soundflags.h] +// maxAudible = (2 * 10000.0) / 0.8 = 25000 units +// Volume multiplier: 25000 * 0.7 = 17500 units +// SOUNDENT_VOLUME_CLOAK = 17500 / 66.666... = 262.5 units +#define SOUNDENT_VOLUME_CLOAK 262 // round down in context of int volume param + +// Footstep sounds use SNDLVL_75dB with volume 1.0 [Lowest of StepLeft/StepRight in game_sounds_physics.txt] +// Human player recipient list hearing distance calculation: +// maxAudible = (2 * SOUND_NORMAL_CLIP_DIST) / attenuation [recipientfilter.cpp] +// SOUND_NORMAL_CLIP_DIST = 10000.0f [public/const.h] +// attenuation = SNDLVL_TO_ATTN(75) = 20.0f / (75 - 50) = 0.8 [public/soundflags.h] +// maxAudible = (2 * 10000.0) / 0.8 = 25000 units +// Volume multiplier: 25000 * 1.0 = 25000 units +// SOUNDENT_VOLUME_FOOTSTEP = 25000 / 66.666... = 375.0 units +#define SOUNDENT_VOLUME_FOOTSTEP 375 // round down in context of int volume param +#endif + enum { SOUND_PRIORITY_VERY_LOW = -2,