diff options
author | ccrs <ccrs@users.noreply.github.com> | 2016-07-17 01:12:57 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-02-05 21:07:31 +0100 |
commit | afbdb99d90a1c8c3046a07edd35e582b7289ebd5 (patch) | |
tree | 7a275ee858d9c05df00bd7eb0ba2b0eac8ee56d3 /src | |
parent | f2c5c6995f438b1b631376e51514b8a2273f0054 (diff) |
Core/UnitAI: SelectTarget correction (#17309)
Core/UnitAI: SelectTarget correction - have current victim always be first element of target list
(cherry picked from commit 63e62117ea339e6d76958b13bba8ec7ed99b7616)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/CoreAI/UnitAI.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 31881cf3b7e..15fba06df1b 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -148,15 +148,21 @@ class TC_GAME_API 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 TC_GAME_API 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); |