From 87e0b1a60366719a5188d81f09ef9e23c047e811 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 20 Sep 2017 00:28:17 -0400 Subject: [PATCH] Changed NearestAttackableUnitInObjectRangeCheck to only consider neutral units as targets if they are already in combat with target searching unit --- Game/AI/CoreAI/TotemAI.cs | 2 +- Game/Maps/GridNotifiers.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Game/AI/CoreAI/TotemAI.cs b/Game/AI/CoreAI/TotemAI.cs index e7124e5ac..af531df67 100644 --- a/Game/AI/CoreAI/TotemAI.cs +++ b/Game/AI/CoreAI/TotemAI.cs @@ -58,7 +58,7 @@ namespace Game.AI me.IsFriendlyTo(victim) || !me.CanSeeOrDetect(victim)) { victim = null; - var u_check = new NearestAttackableUnitInObjectRangeCheck(me, me, max_range); + var u_check = new NearestAttackableUnitInObjectRangeCheck(me, me.GetCharmerOrOwnerOrSelf(), max_range); var checker = new UnitLastSearcher(me, u_check); Cell.VisitAllObjects(me, checker, max_range); victim = checker.GetTarget(); diff --git a/Game/Maps/GridNotifiers.cs b/Game/Maps/GridNotifiers.cs index fa9d596fa..b158dd1cd 100644 --- a/Game/Maps/GridNotifiers.cs +++ b/Game/Maps/GridNotifiers.cs @@ -1582,7 +1582,7 @@ namespace Game.Maps public bool Invoke(Unit u) { if (u.isTargetableForAttack() && i_obj.IsWithinDistInMap(u, i_range) && - !i_funit.IsFriendlyTo(u) && i_funit.CanSeeOrDetect(u)) + (i_funit.IsInCombatWith(u) || i_funit.IsHostileTo(u)) && i_obj.CanSeeOrDetect(u)) { i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check return true; @@ -1606,7 +1606,11 @@ namespace Game.Maps i_range = range; if (_spellInfo == null) - _spellInfo = i_obj.ToDynamicObject().GetSpellInfo(); + { + DynamicObject dynObj = i_obj.ToDynamicObject(); + if (dynObj) + _spellInfo = dynObj.GetSpellInfo(); + } } public bool Invoke(Unit u)