mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Core/UnitAI: SelectTarget correction (#17309)
Core/UnitAI: SelectTarget correction - have current victim always be first element of target list
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user