aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Combat/CombatManager.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2019-07-21 01:49:58 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-17 00:23:33 +0100
commitc13d83796f7b2111c5dcf8546bdd84eccd232ae3 (patch)
tree03c4220a955113e46b3aa2f9cc270574ba3a79c4 /src/server/game/Combat/CombatManager.cpp
parentf9fe00bf8c4c913bcfedd8df7d8e1001129962a0 (diff)
Core/AI: Finally move the "is creature engaged" flag to be a property of the creature AI, where it honestly always belonged. Fixes #17981 and #23602 for real this time.
(cherry picked from commit 0e7c66cb4c7ff7d44e232d0b50703a48605ffd24)
Diffstat (limited to 'src/server/game/Combat/CombatManager.cpp')
-rw-r--r--src/server/game/Combat/CombatManager.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/server/game/Combat/CombatManager.cpp b/src/server/game/Combat/CombatManager.cpp
index d6f7a55665b..a43bb72eca4 100644
--- a/src/server/game/Combat/CombatManager.cpp
+++ b/src/server/game/Combat/CombatManager.cpp
@@ -293,13 +293,8 @@ void CombatManager::EndAllPvPCombat()
/*static*/ void CombatManager::NotifyAICombat(Unit* me, Unit* other)
{
- if (!me->IsAIEnabled())
- return;
- me->GetAI()->JustEnteredCombat(other);
-
- if (Creature* cMe = me->ToCreature())
- if (!cMe->CanHaveThreatList())
- cMe->AI()->JustEngagedWith(other);
+ if (UnitAI* ai = me->GetAI())
+ ai->JustEnteredCombat(other);
}
void CombatManager::PutReference(ObjectGuid const& guid, CombatReference* ref)
@@ -336,14 +331,14 @@ bool CombatManager::UpdateOwnerCombatState() const
{
_owner->AddUnitFlag(UNIT_FLAG_IN_COMBAT);
_owner->AtEnterCombat();
- if (!_owner->CanHaveThreatList() && !_owner->IsEngaged())
+ if (_owner->GetTypeId() == TYPEID_UNIT)
_owner->AtEngage(GetAnyTarget());
}
else
{
_owner->RemoveUnitFlag(UNIT_FLAG_IN_COMBAT);
_owner->AtExitCombat();
- if (_owner->IsEngaged() && !(_owner->ToCreature() && _owner->CanHaveThreatList() && _owner->ToCreature()->IsAIEnabled()))
+ if (_owner->GetTypeId() != TYPEID_UNIT)
_owner->AtDisengage();
}