Core/Creature: Get rid of a few Creature::getAttackerForHelper misuses. That's not what the function does, folks.

(cherry picked from commit 71c5569d18)
This commit is contained in:
Treeston
2018-09-09 14:47:05 +02:00
committed by Shauren
parent 5bcfe93c20
commit 26ca7b0fc2

View File

@@ -1978,11 +1978,6 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
if (!_IsTargetAcceptable(who))
return false;
if (who->IsEngaged() && IsWithinDist(who, ATTACK_DISTANCE))
if (Unit* victim = who->getAttackerForHelper())
if (IsWithinDistInMap(victim, sWorld->getFloatConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)))
force = true;
if (!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
return false;
}
@@ -2535,16 +2530,10 @@ bool Creature::_IsTargetAcceptable(Unit const* target) const
return false;
}
Unit const* targetVictim = target->getAttackerForHelper();
// if I'm already fighting target, or I'm hostile towards the target, the target is acceptable
if (IsEngagedBy(target) || IsHostileTo(target))
return true;
// if the target's victim is friendly, and the target is neutral, the target is acceptable
if (targetVictim && IsFriendlyTo(targetVictim))
return true;
// if the target's victim is not friendly, or the target is friendly, the target is not acceptable
return false;
}