Core/Combat: Fixed issues with creatures sometimes entering combat with friendly targets

Close #19980

(cherry picked from commit 07593f6c34)
This commit is contained in:
treeston
2017-07-03 19:40:04 -03:00
committed by Shauren
parent daf9c703c4
commit 67ffe7bcf0

View File

@@ -407,6 +407,15 @@ void ThreatManager::AddThreat(Unit* victim, float amount, SpellInfo const* spell
(void)ignoreModifiers; (void)ignoreRedirection;
if (!iOwner->CanHaveThreatList() || iOwner->HasUnitState(UNIT_STATE_EVADE))
return;
if (iOwner->IsControlledByPlayer() || victim->IsControlledByPlayer())
{
if (iOwner->IsFriendlyTo(victim) || victim->IsFriendlyTo(iOwner))
return;
}
else if (!iOwner->IsHostileTo(victim) && !victim->IsHostileTo(iOwner))
return;
iOwner->SetInCombatWith(victim);
victim->SetInCombatWith(iOwner);
addThreat(victim, amount, spell ? spell->GetSchoolMask() : victim->GetMeleeDamageSchoolMask(), spell);