fix: bot is marked as stale when not needed

bot: port enemy noticeable function from regamedll
This commit is contained in:
jeefo 2023-05-07 01:04:09 +03:00
commit 2b2b82ee13
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
6 changed files with 122 additions and 28 deletions

View file

@ -1510,7 +1510,7 @@ void Bot::updateEmotions () {
if (m_nextEmotionUpdate > game.time ()) {
return;
}
if (m_agressionLevel > m_baseAgressionLevel) {
m_agressionLevel -= 0.05f;
}
@ -2105,21 +2105,26 @@ bool Bot::reactOnEnemy () {
}
if (m_enemyReachableTimer < game.time ()) {
int ownIndex = m_currentNodeIndex;
if (ownIndex == kInvalidNodeIndex) {
ownIndex = findNearestNode ();
}
int enemyIndex = graph.getNearest (m_enemy->v.origin);
auto lineDist = m_enemy->v.origin.distance (pev->origin);
auto pathDist = planner.preciseDistance (ownIndex, enemyIndex);
if (pathDist - lineDist > 112.0f || isOnLadder ()) {
m_isEnemyReachable = false;
if (isEnemyNoticeable (lineDist)) {
m_isEnemyReachable = true;
}
else {
m_isEnemyReachable = true;
int ownIndex = m_currentNodeIndex;
if (ownIndex == kInvalidNodeIndex) {
ownIndex = findNearestNode ();
}
auto enemyIndex = graph.getNearest (m_enemy->v.origin);
auto pathDist = planner.preciseDistance (ownIndex, enemyIndex);
if (pathDist - lineDist > 112.0f || isOnLadder ()) {
m_isEnemyReachable = false;
}
else {
m_isEnemyReachable = true;
}
}
m_enemyReachableTimer = game.time () + 1.0f;
}