From 752595dccf98f0fc63cdbdd269542859f4506549 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sat, 1 May 2021 19:18:29 +0200 Subject: [PATCH] fix(Core/TotemAI): Totems should not attack neutral unless owner is in combat (#5434) --- src/server/game/AI/CoreAI/TotemAI.cpp | 6 ++++++ src/server/game/Grids/Notifiers/GridNotifiers.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index 2fd904464..a6e81dd92 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -76,6 +76,12 @@ void TotemAI::UpdateAI(uint32 /*diff*/) me->VisitNearbyObject(max_range, checker); } + + if (!victim && me->GetCharmerOrOwnerOrSelf()->IsInCombat()) + { + victim = me->GetCharmerOrOwnerOrSelf()->GetVictim(); + } + // If have target if (victim) { diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 84f4b2761..1b97b7fe0 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -931,7 +931,7 @@ namespace acore bool operator()(Unit* u) { if (u->isTargetableForAttack(true, i_funit) && 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;