1211 {
1212
1213 uint32 targetsAtRange = 0;
1216
1217
1218 for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr, ++targetsAtRange)
1219 if ((*itr)->GetDistance(
GetCaster()) < 12.0f)
1220 break;
1221
1222
1223 if (targetsAtRange < minTargets)
1224 targetsAtRange = std::min<uint32>(targets.size(), minTargets);
1225
1226 if (!targetsAtRange)
1227 return;
1228
1229 std::list<WorldObject*>::iterator itrTarget = targets.begin();
1230 std::advance(itrTarget,
urand(0, targetsAtRange - 1));
1232 targets.clear();
1234 }
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:1253