aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2017-06-20 00:58:32 +0200
committerCarbenium <carbenium@outlook.com>2020-07-16 22:00:30 +0200
commit09027e5ccc9618e5fae45a354bcd01cd04ee0aa1 (patch)
treef92ef9640a6241470217939d1bb3c21b86f529a9
parentced48202526b32c0eb8e98cb0f713dfa0b94bf64 (diff)
Fix an overly strict check that was causing guardians to evade loop. Also make players properly enter combat when their pets are engaged by a creature.
(cherry picked from commit 052fc24315ace866ea1cf610e85df119b68100c9)
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp10
2 files changed, 9 insertions, 2 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index a1c1b72e9b0..6448389150a 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -66,7 +66,6 @@ void PetAI::_stopAttack()
{
if (!me->IsAlive())
{
- TC_LOG_DEBUG("misc", "Creature stoped attacking cuz his dead [%s]", me->GetGUID().ToString().c_str());
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveIdle();
me->CombatStop();
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 1075e81bfdc..9bdd317e0ea 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -5618,7 +5618,7 @@ void Unit::_removeAttacker(Unit* pAttacker)
Unit* Unit::getAttackerForHelper() const // If someone wants to help, who to give them
{
if (Unit* victim = GetVictim())
- if (!IsControlledByPlayer() || IsInCombatWith(victim) || victim->IsInCombatWith(this))
+ if ((!IsPet() && !GetPlayerMovingMe()) || IsInCombatWith(victim) || victim->IsInCombatWith(this))
return victim;
if (!m_attackers.empty())
@@ -5725,6 +5725,14 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
if (victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
+ if (Unit* owner = victim->GetOwner())
+ {
+ AddThreat(owner, 0.0f);
+ SetInCombatWith(owner);
+ if (owner->GetTypeId() == TYPEID_PLAYER)
+ owner->SetInCombatWith(this);
+ }
+
creature->SendAIReaction(AI_REACTION_HOSTILE);
creature->CallAssistance();