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
@@ -1989,7 +1989,7 @@ bool Creature::canCreatureAttack(Unit const* pVictim, bool force) const
if (!pVictim->IsInMap(this))
return false;
if (!canAttack(pVictim, force))
if (!IsValidAttackTarget(pVictim))
return false;
if (!pVictim->isInAccessiblePlaceFor(this))
@@ -199,7 +199,7 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
if (itr->first->getVictim())
continue;
if (itr->first->canAttack(target) && itr->first->AI())
if (itr->first->IsValidAttackTarget(target) && itr->first->AI())
itr->first->AI()->AttackStart(target);
}
}
+1 -1
View File
@@ -23029,7 +23029,7 @@ void Player::UpdateCharmedAI()
GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
Unit* target = getVictim();
if (!target || !charmer->canAttack(target))
if (!target || !charmer->IsValidAttackTarget(target))
{
target = charmer->SelectNearestTarget();
if (!target)
+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;