From 78d9e88caf45d4f935d8e26f80f71ca409e03520 Mon Sep 17 00:00:00 2001 From: jeefo Date: Wed, 3 Jul 2024 22:00:58 +0300 Subject: [PATCH] bot: always remove bomb entities from ignore item list --- inc/config.h | 2 +- src/navigate.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/inc/config.h b/inc/config.h index 26dc9e0..e9847bd 100644 --- a/inc/config.h +++ b/inc/config.h @@ -263,7 +263,7 @@ public: return ""; } - // simple accessor to c4 model name + // simple accessors to c4 model name StringRef getBombModelName () { return fetchCustom ("C4ModelName"); } diff --git a/src/navigate.cpp b/src/navigate.cpp index e629a10..350dff1 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -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; } }