Core/Entities: Replace Unit::canAttack usage with more accurate Unit::IsValidAttackTarget

This commit is contained in:
QAston
2011-09-16 23:49:31 +02:00
parent 3a3f2d927f
commit c0b1823524
15 changed files with 23 additions and 19 deletions
+5 -1
View File
@@ -12370,6 +12370,8 @@ bool Unit::IsValidAttackTarget(Unit const* target) const
bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) const
{
ASSERT(target);
// can't attack self
if (this == target)
return false;
@@ -12506,6 +12508,8 @@ bool Unit::IsValidAssistTarget(Unit const* target) const
bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const
{
ASSERT(target);
// can assist to self
if (this == target)
return true;
@@ -13171,7 +13175,7 @@ Unit* Creature::SelectVictim()
{
--aura;
caster = (*aura)->GetCaster();
if (caster && canSeeOrDetect(caster, true) && canAttack(caster) && caster->isInAccessiblePlaceFor(ToCreature()))
if (caster && canSeeOrDetect(caster, true) && IsValidAttackTarget(caster) && caster->isInAccessiblePlaceFor(ToCreature()))
{
target = caster;
break;