Add mp_hostage_fear cvar to control improved hostage AI fear reactions#1167
Open
belomaxorka wants to merge 1 commit into
Open
Add mp_hostage_fear cvar to control improved hostage AI fear reactions#1167belomaxorka wants to merge 1 commit into
mp_hostage_fear cvar to control improved hostage AI fear reactions#1167belomaxorka wants to merge 1 commit into
Conversation
When improved hostage AI (hostage_ai_enable 1) is used in CS 1.6, hostages panic and scatter in response to gunfire, explosions and nearby deaths. Setting mp_hostage_fear 0 keeps them calm, restoring 1.6-like hostage behavior while retaining the rest of the improved AI. Related to rehlds#1125 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mp_hostage_fear cvar to control improved hostage AI fear reactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the hostage panic/scatter part of #1125.
What
New cvar
mp_hostage_fear(default1- vanilla behavior) that controls whether hostages driven by the improved AI (hostage_ai_enable 1) get scared of gunfire, explosions and nearby deaths. Withmp_hostage_fear 0hostages stay calm: they don't panic, don't scatter and don't refuse to follow after nearby shooting - CS 1.6-like hostage temperament while keeping the rest of the improved AI (navigation, chatter, animations).Why
With
hostage_ai_enable 1on CS 1.6 hostage maps, any nearby enemy gunfire frightens the hostages (CHostageImprov::OnGameEvent->Frighten(SCARED/TERRIFIED)). Scared hostages scatter, crouch and refuse to follow the rescuer, which #1125 reports as disruptive on 1.6 servers, where the original hostages ignore gunfire completely. Server operators currently have no way to keep the improved AI but disable the fear reactions.How it works
All fear-driven behavior (fleeing in
HostageIdleState, refusing to follow, scared/afraid animations) is gated byCHostageImprov::IsScared(), which is true only whilem_scaredTimeris running - and that timer is started exclusively inCHostageImprov::Frighten(). So a single early return inFrighten()whenmp_hostage_fearis0keeps hostages calm everywhere. The cvar is evaluated on every call, so it can be flipped at runtime without a map change or server restart.Edge cases
OnInjury->m_mustFleein the idle state). That path is deliberately not gated: fleeing from an actual injury is self-preservation, distinct from panicking at noise.hostage_ai_enable 0) is unaffected - it has no fear logic at all.1keeps vanilla behavior; vanilla builds are unaffected (the check is under#ifdef REGAMEDLL_ADD).Tested
Windows build (MSVC), verified on a ReHLDS server with
hostage_ai_enable 1:mp_hostage_fear 1(default): hostages panic, scatter and refuse to follow when a Terrorist fires nearby - unchanged behavior.mp_hostage_fear 0(set at runtime, no restart): hostages stay calm under fire and keep following normally.