diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d33c1c040..7440da104 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2324,6 +2324,14 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr else LOG_DEBUG("entities.unit", "AttackerStateUpdate: (NPC) %s attacked %s for %u dmg, absorbed %u, blocked %u, resisted %u.", GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + + // Let the pet know we've started attacking someting. Handles melee attacks only + // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode + if (GetTypeId() == TYPEID_PLAYER && !m_Controlled.empty()) + for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) + if (Unit* pet = *itr) + if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) + pet->ToCreature()->AI()->OwnerAttacked(victim); } } @@ -9715,7 +9723,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) // set position before any AI calls/assistance //if (GetTypeId() == TYPEID_UNIT) // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - if (creature && !IsControlledByPlayer()) + if (creature && !(IsControllableGuardian() && IsControlledByPlayer())) { // should not let player enter combat by right clicking target - doesn't helps SetInCombatWith(victim); @@ -9737,14 +9745,6 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) if (meleeAttack) SendMeleeAttackStart(victim); - // Let the pet know we've started attacking someting. Handles melee attacks only - // Spells such as auto-shot and others handled in WorldSession::HandleCastSpellOpcode - if (GetTypeId() == TYPEID_PLAYER && !m_Controlled.empty()) - for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) - if (Unit* pet = *itr) - if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) - pet->ToCreature()->AI()->OwnerAttacked(victim); - return true; }