Skip to content

Commit c2a54bc

Browse files
authored
Bots notice cloaked players easier in center view (#1838)
1 parent 9ef8b22 commit c2a54bc

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

src/game/server/neo/neo_player.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ ConCommand bot_changeclass("bot_changeclass", BotChangeClassFn, "Force all bots
170170
// Bot Cloak Detection Thresholds
171171
// Base detection chance ratio (0.0 - 1.0) for bots to notice a cloaked target based on difficulty
172172
// e.g. 0 implies the bot is oblivious to anything, while 1.0 implies a bot that can roll very high on detection checks
173-
ConVar sv_neo_bot_cloak_detection_threshold_ratio_easy("sv_neo_bot_cloak_detection_threshold_ratio_easy", "0.65", FCVAR_NONE, "Bot cloak detection threshold for easy difficulty observers", true, 0.0f, true, 1.0f);
174-
ConVar sv_neo_bot_cloak_detection_threshold_ratio_normal("sv_neo_bot_cloak_detection_threshold_ratio_normal", "0.70", FCVAR_NONE, "Bot cloak detection threshold for normal difficulty observers", true, 0.0f, true, 1.0f);
175-
ConVar sv_neo_bot_cloak_detection_threshold_ratio_hard("sv_neo_bot_cloak_detection_threshold_ratio_hard", "0.75", FCVAR_NONE, "Bot cloak detection threshold for hard difficulty observers", true, 0.0f, true, 1.0f);
176-
ConVar sv_neo_bot_cloak_detection_threshold_ratio_expert("sv_neo_bot_cloak_detection_threshold_ratio_expert", "0.80", FCVAR_NONE, "Bot cloak detection threshold for expert difficulty observers", true, 0.0f, true, 1.0f);
173+
ConVar sv_neo_bot_cloak_detection_threshold_ratio_easy("sv_neo_bot_cloak_detection_threshold_ratio_easy", "0.35", FCVAR_NONE, "Bot cloak detection threshold for easy difficulty observers", true, 0.0f, true, 1.0f);
174+
ConVar sv_neo_bot_cloak_detection_threshold_ratio_normal("sv_neo_bot_cloak_detection_threshold_ratio_normal", "0.40", FCVAR_NONE, "Bot cloak detection threshold for normal difficulty observers", true, 0.0f, true, 1.0f);
175+
ConVar sv_neo_bot_cloak_detection_threshold_ratio_hard("sv_neo_bot_cloak_detection_threshold_ratio_hard", "0.45", FCVAR_NONE, "Bot cloak detection threshold for hard difficulty observers", true, 0.0f, true, 1.0f);
176+
ConVar sv_neo_bot_cloak_detection_threshold_ratio_expert("sv_neo_bot_cloak_detection_threshold_ratio_expert", "0.50", FCVAR_NONE, "Bot cloak detection threshold for expert difficulty observers", true, 0.0f, true, 1.0f);
177177

178178
// Bot Cloak Detection Bonus Factors
179179
// Used in CNEO_Player::GetFogObscuredRatio to determine if the bot (me) can detect a cloaked target given circumstances
@@ -194,6 +194,10 @@ ConVar sv_neo_bot_cloak_detection_bonus_assault_motion_vision("sv_neo_bot_cloak_
194194
ConVar sv_neo_bot_cloak_detection_bonus_non_support("sv_neo_bot_cloak_detection_bonus_non_support", "1", FCVAR_NONE,
195195
"Bot cloak detection bonus for non-support classes", true, 0, true, 100);
196196

197+
// 0.7 dot product is about a 45 degree half hangle for a 90 degree cone
198+
ConVar sv_neo_bot_cloak_detection_aim_bonus_dot_threshold("sv_neo_bot_cloak_detection_aim_bonus_dot_threshold", "0.3", FCVAR_NONE,
199+
"Bot cloak detection bonus minimum dot product threshold for aim bonus", true, 0.01, true, 0.7);
200+
197201
ConVar sv_neo_bot_cloak_detection_bonus_observer_stationary("sv_neo_bot_cloak_detection_bonus_observer_stationary", "2", FCVAR_NONE,
198202
"Bot cloak detection bonus for observer being stationary", true, 0, true, 100);
199203

@@ -1547,9 +1551,22 @@ float CNEO_Player::GetCloakObscuredRatio(CNEO_Player* target) const
15471551
}
15481552
}
15491553

1554+
// The closer a target is to the bot's center aim, the more noticeable they are
1555+
Vector vEyeForward;
1556+
AngleVectors(pl.v_angle, &vEyeForward);
1557+
Vector vToTarget = target->WorldSpaceCenter() - (GetAbsOrigin() + GetViewOffset());
1558+
vToTarget.NormalizeInPlace();
1559+
float flDot = vEyeForward.Dot(vToTarget);
1560+
float flFovBonusRatio = RemapValClamped(flDot, sv_neo_bot_cloak_detection_aim_bonus_dot_threshold.GetFloat(), 1.0f, 0.0f, 1.0f);
1561+
// Make bonus more pronounced closer to the center and less so at edges
1562+
flFovBonusRatio *= flFovBonusRatio;
1563+
15501564
float obscuredDenominator = 100.0f; // scale from 0-100 percent likelyhood to detect every 200ms
1551-
1552-
float obscuredRatio = Max(0.0f, obscuredDenominator - flDetectionBonus) / obscuredDenominator;
1565+
1566+
float obscuredNumerator = Max(0.0f, obscuredDenominator - flDetectionBonus);
1567+
obscuredNumerator *= (1.0f - flFovBonusRatio);
1568+
1569+
float obscuredRatio = obscuredNumerator / obscuredDenominator;
15531570
obscuredRatio = Clamp(obscuredRatio, 0.0f, 1.0f);
15541571
return obscuredRatio;
15551572
}

0 commit comments

Comments
 (0)