fix: hostage code (#269)

fix: hostage code
add: yb_random_knife_attacks cvar
This commit is contained in:
godhand897 2022-01-03 07:18:36 +01:00 committed by GitHub
commit f55ac6c5c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 8 deletions

View file

@ -79,9 +79,7 @@ int Bot::findBestGoal () {
return findGoalPost (tactic, defensiveNodes, offensiveNodes);
}
else if (m_team == Team::CT && hasHostage ()) {
tactic = 2;
offensiveNodes = &graph.m_rescuePoints;
tactic = 4;
return findGoalPost (tactic, defensiveNodes, offensiveNodes);
}
@ -208,6 +206,31 @@ int Bot::findGoalPost (int tactic, IntArray *defensive, IntArray *offsensive) {
postprocessGoals (graph.m_goalPoints, goalChoices);
}
}
else if (tactic == 4 && !graph.m_rescuePoints.empty ()) // rescue goal
{
// force ct with hostage(s) to select closest rescue goal
float minDist = kInfiniteDistance;
int count = 0;
for (auto &point : graph.m_rescuePoints) {
float distance = graph[point].origin.distanceSq (pev->origin);
if (distance < minDist) {
goalChoices[count] = point;
if (++count > 3) {
count = 0;
}
minDist = distance;
}
}
for (auto &choice : goalChoices) {
if (choice == kInvalidNodeIndex) {
choice = graph.m_rescuePoints.random ();
}
}
}
if (!graph.exists (m_currentNodeIndex)) {
m_currentNodeIndex = changePointIndex (findNearestNode ());