Core/Units: Fixed SelectNearbyTarget to ignore totems, critters and spirit healers
This commit is contained in:
@@ -14454,14 +14454,10 @@ Unit* Unit::SelectNearbyTarget(float dist) const
|
||||
targets.remove(getVictim());
|
||||
|
||||
// remove not LoS targets
|
||||
for (std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
|
||||
for (std::list<Unit*>::iterator tIter = targets.begin(); tIter != targets.end();)
|
||||
{
|
||||
if (!IsWithinLOSInMap(*tIter))
|
||||
{
|
||||
std::list<Unit *>::iterator tIter2 = tIter;
|
||||
++tIter;
|
||||
targets.erase(tIter2);
|
||||
}
|
||||
if (!IsWithinLOSInMap(*tIter) || (*tIter)->isTotem() || (*tIter)->isSpiritService() || (*tIter)->GetCreatureType() == CREATURE_TYPE_CRITTER)
|
||||
targets.erase(tIter++);
|
||||
else
|
||||
++tIter;
|
||||
}
|
||||
@@ -14471,11 +14467,8 @@ Unit* Unit::SelectNearbyTarget(float dist) const
|
||||
return NULL;
|
||||
|
||||
// select random
|
||||
uint32 rIdx = urand(0,targets.size()-1);
|
||||
std::list<Unit *>::const_iterator tcIter = targets.begin();
|
||||
for (uint32 i = 0; i < rIdx; ++i)
|
||||
++tcIter;
|
||||
|
||||
std::list<Unit*>::const_iterator tcIter = targets.begin();
|
||||
std::advance(tcIter, urand(0, targets.size()-1));
|
||||
return *tcIter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user