diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 72a0dc12b8..c87b646d89 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2078,7 +2078,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim)) return; - AttackedTarget(victim, true); + AtTargetAttacked(victim, true); RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MELEE_ATTACK); if (attType != BASE_ATTACK && attType != OFF_ATTACK) @@ -8406,24 +8406,6 @@ void Unit::EngageWithTarget(Unit* enemy) SetInCombatWith(enemy); } -void Unit::AttackedTarget(Unit* target, bool canInitialAggro) -{ - if (!target->IsEngaged() && !canInitialAggro) - return; - target->EngageWithTarget(this); - if (Unit* targetOwner = target->GetCharmerOrOwner()) - targetOwner->EngageWithTarget(this); - - Player* myPlayerOwner = GetCharmerOrOwnerPlayerOrPlayerItself(); - Player* targetPlayerOwner = target->GetCharmerOrOwnerPlayerOrPlayerItself(); - if (myPlayerOwner && targetPlayerOwner && !(myPlayerOwner->duel && myPlayerOwner->duel->opponent == targetPlayerOwner)) - { - myPlayerOwner->UpdatePvP(true); - myPlayerOwner->SetContestedPvP(targetPlayerOwner); - myPlayerOwner->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); - } -} - void Unit::SetImmuneToAll(bool apply, bool keepCombat) { if (apply) @@ -9264,6 +9246,29 @@ void Unit::AtExitCombat() RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LEAVE_COMBAT); } +void Unit::AtTargetAttacked(Unit* target, bool canInitialAggro) +{ + if (!target->IsEngaged() && !canInitialAggro) + return; + target->EngageWithTarget(this); + if (Unit* targetOwner = target->GetCharmerOrOwner()) + targetOwner->EngageWithTarget(this); + + //Patch 3.0.8: All player spells which cause a creature to become aggressive to you will now also immediately cause the creature to be tapped. + if (Creature* creature = target->ToCreature()) + if (!creature->hasLootRecipient() && GetTypeId() == TYPEID_PLAYER) + creature->SetLootRecipient(this); + + Player* myPlayerOwner = GetCharmerOrOwnerPlayerOrPlayerItself(); + Player* targetPlayerOwner = target->GetCharmerOrOwnerPlayerOrPlayerItself(); + if (myPlayerOwner && targetPlayerOwner && !(myPlayerOwner->duel && myPlayerOwner->duel->Opponent == targetPlayerOwner)) + { + myPlayerOwner->UpdatePvP(true); + myPlayerOwner->SetContestedPvP(targetPlayerOwner); + myPlayerOwner->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); + } +} + void Unit::UpdatePetCombatState() { ASSERT(!IsPet()); // player pets do not use UNIT_FLAG_PET_IN_COMBAT for this purpose - but player pets should also never have minions of their own to call this diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 828ded2795..33c72610a5 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1241,7 +1241,7 @@ class TC_GAME_API Unit : public WorldObject // Combat handling CombatManager& GetCombatManager() { return m_combatManager; } CombatManager const& GetCombatManager() const { return m_combatManager; } - void AttackedTarget(Unit* target, bool canInitialAggro); + void AtTargetAttacked(Unit* target, bool canInitialAggro); bool IsImmuneToAll() const { return IsImmuneToPC() && IsImmuneToNPC(); } void SetImmuneToAll(bool apply, bool keepCombat); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 6bb7cd51a7..e271451a55 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2700,7 +2700,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // spellHitTarget can be null if spell is missed in DoSpellHitOnUnit if (missInfo != SPELL_MISS_EVADE && spellHitTarget && !m_caster->IsFriendlyTo(unit) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL))) { - m_caster->AttackedTarget(unit, m_spellInfo->HasInitialAggro()); + if (Unit* unitCaster = spell->m_caster->ToUnit()) + unitCaster->AtTargetAttacked(unit, spell->m_spellInfo->HasInitialAggro()); if (!unit->IsStandState()) unit->SetStandState(UNIT_STAND_STATE_STAND);