*Use some more standard functions in _IsTargetAcceptable. Should also fix the perma-unattackable boss issue.
--HG-- branch : trunk
This commit is contained in:
+4
-10
@@ -2187,28 +2187,22 @@ bool Creature::_IsTargetAcceptable(const Unit *target) const
|
|||||||
{
|
{
|
||||||
assert(target);
|
assert(target);
|
||||||
|
|
||||||
// if the target or myself are unattackable, the target is not acceptable
|
|
||||||
if (!isAttackableByAOE() || !target->isAttackableByAOE())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const Unit *myVictim = getAttackerForHelper();
|
const Unit *myVictim = getAttackerForHelper();
|
||||||
|
const Unit *targetVictim = target->getAttackerForHelper();
|
||||||
|
|
||||||
// if I'm already fighting target, the target is acceptable
|
// if I'm already fighting target, the target is acceptable
|
||||||
if (myVictim == target || target->getVictim() == this)
|
if (myVictim == target || targetVictim == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// if I'm hostile towards the target, the target is acceptable
|
// if I'm hostile towards the target, the target is acceptable
|
||||||
if (IsHostileTo(target))
|
if (!canAttack(target, false))
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
const Unit *targetVictim = target->getAttackerForHelper();
|
|
||||||
|
|
||||||
// if the target does not have a victim, the target is not acceptable
|
// if the target does not have a victim, the target is not acceptable
|
||||||
if (!targetVictim)
|
if (!targetVictim)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if the target's victim is friendly, and the target is neutral, the target is acceptable
|
// if the target's victim is friendly, and the target is neutral, the target is acceptable
|
||||||
// NOTE: !IsHostileTo(target) is true at this point
|
|
||||||
if (IsFriendlyTo(targetVictim) && !IsFriendlyTo(target))
|
if (IsFriendlyTo(targetVictim) && !IsFriendlyTo(target))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user