From 2a2860ef10b456200e1d6af4a76b582e0839716f Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 3 Mar 2022 13:22:09 -0500 Subject: [PATCH] Core/Unit: Creatures' minions now engage in combat if their controller is attacked Port From (https://github.com/TrinityCore/TrinityCore/commit/adfb05055141829620487234e665754d8d957e20) --- Source/Game/Entities/Unit/Unit.cs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 7695bcf40..7b75cfa26 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -2353,26 +2353,24 @@ namespace Game.Entities // Hook for OnDamage Event Global.ScriptMgr.OnDamage(attacker, victim, ref damage); - if (victim.IsTypeId(TypeId.Player)) + // Signal to pets that their owner was attacked - except when DOT. + if (attacker != victim && damagetype != DamageEffectType.DOT) { - // Signal to pets that their owner was attacked - except when DOT. - if (attacker != victim && damagetype != DamageEffectType.DOT) + foreach (Unit controlled in victim.m_Controlled) { - foreach (Unit controlled in victim.m_Controlled) + Creature cControlled = controlled.ToCreature(); + if (cControlled != null) { - Creature cControlled = controlled.ToCreature(); - if (cControlled != null) - { - CreatureAI controlledAI = cControlled.GetAI(); - if (controlledAI != null) - controlledAI.OwnerAttackedBy(attacker); - } + CreatureAI controlledAI = cControlled.GetAI(); + if (controlledAI != null) + controlledAI.OwnerAttackedBy(attacker); } } - - if (victim.ToPlayer().GetCommandStatus(PlayerCommandStates.God)) - return 0; } + + Player player = victim.ToPlayer(); + if (player != null && player.GetCommandStatus(PlayerCommandStates.God)) + return 0; if (damagetype != DamageEffectType.NoDamage) {