aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJinnaix <37972361+Jinnaix@users.noreply.github.com>2020-08-06 20:03:09 +0200
committerShauren <shauren.trinity@gmail.com>2022-01-26 18:10:57 +0100
commitadfb05055141829620487234e665754d8d957e20 (patch)
treeef81c96f0d2ca9ed4b333954fef661ed7ebaf46e /src
parent676d877296498b6c75512a61e6060831f2cd6a80 (diff)
Core/Unit: Creatures' minions now engage in combat if their controller is attacked (PR #25219)
Closes #24340 (cherry picked from commit db9072a183cd93014d708d67ae3a762fdbf5d095)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index dab5216ca9c..df7e30d014a 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -720,21 +720,18 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
// Hook for OnDamage Event
sScriptMgr->OnDamage(attacker, victim, damage);
- if (victim->GetTypeId() == TYPEID_PLAYER)
+ // Signal to pets that their owner was attacked - except when DOT.
+ if (attacker != victim && damagetype != DOT)
{
- // Signal to pets that their owner was attacked - except when DOT.
- if (attacker != victim && damagetype != DOT)
- {
- for (Unit* controlled : victim->m_Controlled)
- if (Creature* cControlled = controlled->ToCreature())
- if (CreatureAI* controlledAI = cControlled->AI())
- controlledAI->OwnerAttackedBy(attacker);
- }
-
- if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD))
- return 0;
+ for (Unit* controlled : victim->m_Controlled)
+ if (Creature* cControlled = controlled->ToCreature())
+ if (CreatureAI* controlledAI = cControlled->AI())
+ controlledAI->OwnerAttackedBy(attacker);
}
+ if (Player* player = victim->ToPlayer(); player && player->GetCommandStatus(CHEAT_GOD))
+ return 0;
+
if (damagetype != NODAMAGE)
{
// interrupting auras with SpellAuraInterruptFlags::Damage before checking !damage (absorbed damage breaks that type of auras)