1212 {
1213
1214 uint32 targetsAtRange = 0;
1217
1218
1219 for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr, ++targetsAtRange)
1220 if ((*itr)->GetDistance(
GetCaster()) < 12.0f)
1221 break;
1222
1223
1224 if (targetsAtRange < minTargets)
1225 targetsAtRange = std::min<uint32>(targets.size(), minTargets);
1226
1227 if (!targetsAtRange)
1228 return;
1229
1230 std::list<WorldObject*>::iterator itrTarget = targets.begin();
1231 std::advance(itrTarget,
urand(0, targetsAtRange - 1));
1233 targets.clear();
1235 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
std::uint32_t uint32
Definition: Define.h:107
Unit * GetCaster()
Definition: SpellScript.cpp:401
WorldObject * _target
Definition: boss_deathbringer_saurfang.cpp:1254