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

Close #19980
This commit is contained in:
treeston authored and Ovahlord committed 2020-07-22 13:49:21 +02:00
1 parent 618e604141
commit 7310ce2bc0
1 file changed
+9
+9
View File
@@ -406,6 +406,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);