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)