bot: always remove bomb entities from ignore item list

This commit is contained in:
jeefo 2024-07-03 22:00:58 +03:00
commit 78d9e88caf
No known key found for this signature in database
GPG key ID: D696786B81B667C8
2 changed files with 12 additions and 2 deletions

View file

@ -263,7 +263,7 @@ public:
return "";
}
// simple accessor to c4 model name
// simple accessors to c4 model name
StringRef getBombModelName () {
return fetchCustom ("C4ModelName");
}

View file

@ -202,6 +202,11 @@ int Bot::findBestGoalWhenBombAction () {
result = graph.getNearest (game.getEntityOrigin (ent));
if (graph.exists (result)) {
// if bomb entity is bot's ignore list, clear ignore list
if (isIgnoredItem (ent)) {
m_ignoredItems.clear ();
}
return EntitySearchResult::Break;
}
}
@ -3158,11 +3163,16 @@ int Bot::getNearestToPlantedBomb () {
auto result = kInvalidNodeIndex;
// search the bomb on the map
game.searchEntities ("classname", "grenade", [&result, &bombModel] (edict_t *ent) {
game.searchEntities ("classname", "grenade", [&] (edict_t *ent) {
if (util.isModel (ent, bombModel)) {
result = graph.getNearest (game.getEntityOrigin (ent));
if (graph.exists (result)) {
// if bomb entity is bot's ignore list, clear ignore list
if (isIgnoredItem (ent)) {
m_ignoredItems.clear ();
}
return EntitySearchResult::Break;
}
}