Misc/Util: Add a template function for returning a random element from any container

This commit is contained in:
Shocker
2011-09-15 21:28:40 +03:00
parent 8504a0107e
commit 7afb179185
23 changed files with 44 additions and 96 deletions
@@ -104,14 +104,7 @@ class boss_sulfuron : public CreatureScript
Creature* target = NULL;
std::list<Creature*> healers = DoFindFriendlyMissingBuff(45.0f, SPELL_INSPIRE);
if (!healers.empty())
{
std::list<Creature*>::const_iterator itr = healers.begin();
std::advance(itr, urand(0, healers.size()-1));
target = *itr;
}
if (target)
DoCast(target, SPELL_INSPIRE);
DoCast(SelectRandomContainerElement(healers), SPELL_INSPIRE);
DoCast(me, SPELL_INSPIRE);
events.ScheduleEvent(EVENT_INSPIRE, urand(20000, 26000));