From 5c17eb01322aa5f60df9774e218c0e06491ee4aa Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sat, 31 Aug 2019 10:40:13 +0200 Subject: [PATCH] Fix monsters being unable to see the player if he generates noise. When searching for the player FinTarget() always goes after sound targets and aborts as soon as it finds one. So if the player is constantly generating sounds - for example firing the machine gun - there's a high chance that monsters will only hear but never see him. Work around this by adding a small timeout to player noises, make sure that at least 3 frames passed since the last noise. This gives monsters 2 frames to see the player. This bug was present in the original code, this is a small gameplay change. The problem was analysed by @BjossiAlfreds in #436. He also suggested the fix. --- src/game/player/weapon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/game/player/weapon.c b/src/game/player/weapon.c index 305a74ba..9dba6c14 100644 --- a/src/game/player/weapon.c +++ b/src/game/player/weapon.c @@ -123,12 +123,22 @@ PlayerNoise(edict_t *who, vec3_t where, int type) if ((type == PNOISE_SELF) || (type == PNOISE_WEAPON)) { + if (level.framenum <= (level.sound_entity_framenum + 3)) + { + return; + } + noise = who->mynoise; level.sound_entity = noise; level.sound_entity_framenum = level.framenum; } else { + if (level.framenum <= (level.sound2_entity_framenum + 3)) + { + return; + } + noise = who->mynoise2; level.sound2_entity = noise; level.sound2_entity_framenum = level.framenum;