From 862b16cf8985f44ed8d4d5b5b0b6ece6294dc3b5 Mon Sep 17 00:00:00 2001 From: Crow Date: Fri, 19 Jun 2026 17:35:11 -0500 Subject: [PATCH] Immune targets =/= possible targets (#2486) ## Pull Request Description This is mainly to address the issue of bots continuing to attack Mages with Ice Block and Paladins with Divine Shield. I made the actual check a little broader to capture all cases of when a target is both physical and magical immune. ## Feature Evaluation - Describe the **minimum logic** required to achieve the intended behavior. - Describe the **processing cost** when this logic executes across many bots. Just added immunity checks to AttackersValue::IsPossibleTarget() ## How to Test the Changes The easiest way is to play a Mage or a Paladin and go zerg into the opposing team, then put up Ice Block/Divine Shield. ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [ ] No, not at all - - [x] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) This is a new check when determining possible targets, but it should be very cheap. - Does this change modify default bot behavior? - - [ ] No - - [x] Yes (**explain why**) Default bot behavior is idiotic as they stick to immune targets like glue. - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## AI Assistance Was AI assistance used while working on this change? - - [ ] No - - [x] Yes (**explain below**) I wanted to capture more than just Ice Block and Divine Shield (which would have been simple aura checks) so I had DeepSeek *shudder* look at the spell flags. ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers --- src/Ai/Base/Value/AttackersValue.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Ai/Base/Value/AttackersValue.cpp b/src/Ai/Base/Value/AttackersValue.cpp index 65a8edeb3..bec9edcd0 100644 --- a/src/Ai/Base/Value/AttackersValue.cpp +++ b/src/Ai/Base/Value/AttackersValue.cpp @@ -154,6 +154,11 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float /*range if (attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) || attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) return false; + // Skip targets that are immune to all damage (e.g., Ice Block, Divine Shield) + if (attacker->IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL) && + attacker->IsImmunedToDamage(SPELL_SCHOOL_MASK_MAGIC)) + return false; + // Relationship checks if (attacker->IsFriendlyTo(bot)) return false;