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

Close #19980

(cherry picked from commit 07593f6c3488666423093c2c32514a0a378da942)
This commit is contained in:
treeston
2020-08-18 18:53:13 +02:00
committed by Shauren
parent daf9c703c4
commit 67ffe7bcf0
+9
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);