Core/Combat: Fix CanAIAttack implementation

This commit is contained in:
Elron103
2012-06-16 20:55:07 +02:00
parent 1c8211e852
commit 3164ba627b
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -354,7 +354,9 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
// list sorted and and we check current target, then this is best case // list sorted and and we check current target, then this is best case
if (currentVictim == currentRef || currentRef->getThreat() <= 1.1f * currentVictim->getThreat()) if (currentVictim == currentRef || currentRef->getThreat() <= 1.1f * currentVictim->getThreat())
{ {
currentRef = currentVictim; // for second case if (currentVictim != currentRef && attacker->canCreatureAttack(currentVictim->getTarget()))
currentRef = currentVictim; // for second case, if currentvictim is attackable
found = true; found = true;
break; break;
} }
+2 -2
View File
@@ -12958,7 +12958,7 @@ Unit* Creature::SelectVictim()
else else
return NULL; return NULL;
if (target && _IsTargetAcceptable(target)) if (target && _IsTargetAcceptable(target) && canCreatureAttack(target))
{ {
SetInFront(target); SetInFront(target);
return target; return target;
@@ -12984,7 +12984,7 @@ Unit* Creature::SelectVictim()
{ {
target = SelectNearestTargetInAttackDistance(m_CombatDistance ? m_CombatDistance : ATTACK_DISTANCE); target = SelectNearestTargetInAttackDistance(m_CombatDistance ? m_CombatDistance : ATTACK_DISTANCE);
if (target && _IsTargetAcceptable(target)) if (target && _IsTargetAcceptable(target) && canCreatureAttack(target))
return target; return target;
} }