Core/UnitAI: SelectTarget correction (#17309)

Core/UnitAI: SelectTarget correction - have current victim always be first element of target list
This commit is contained in:
ccrs
2016-07-17 01:12:57 +02:00
committed by Aokromes
parent ef8e83f99d
commit faa310252f

View File

@@ -148,15 +148,21 @@ class UnitAI
{
ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList();
if (position >= threatlist.size())
return NULL;
return nullptr;
std::list<Unit*> targetList;
Unit* currentVictim = me->getThreatManager().getCurrentVictim()->getTarget();
// Current victim always goes first
if (predicate(currentVictim))
targetList.push_back(currentVictim);
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
if (predicate((*itr)->getTarget()))
if ((*itr)->getTarget() != currentVictim && predicate((*itr)->getTarget()))
targetList.push_back((*itr)->getTarget());
if (position >= targetList.size())
return NULL;
return nullptr;
if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST)
targetList.sort(Trinity::ObjectDistanceOrderPred(me));
@@ -187,7 +193,7 @@ class UnitAI
break;
}
return NULL;
return nullptr;
}
void SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);