@@ -46,8 +46,7 @@ EndContentData */
4646#include " SpellMgr.h"
4747#include " TemporarySummon.h"
4848#include " WorldSession.h"
49- #include < random>
50- #include " vector"
49+ #include < list>
5150
5251/* ######
5352## go_gilded_brazier (Paladin First Trail quest (9678))
@@ -1227,9 +1226,9 @@ class go_bells : public GameObjectScript
12271226
12281227enum it_takes_guts
12291228{
1230- ANCIENT_DRAKKARI_SOOTHSAYER = 26812 ,
1231- ANCIENT_DRAKKARI_WARMONGER = 26811 ,
1232- NPC_ANCIENT_DRAKKARI_TALK = 1
1229+ ANCIENT_DRAKKARI_SOOTHSAYER = 26812 ,
1230+ ANCIENT_DRAKKARI_WARMONGER = 26811 ,
1231+ NPC_ANCIENT_DRAKKARI_TALK = 1
12331232};
12341233
12351234class go_188499_chest : public GameObjectScript
@@ -1250,30 +1249,32 @@ class go_188499_chest : public GameObjectScript
12501249 if (!player)
12511250 return ;
12521251
1253- std::vector<uint32> entries = { ANCIENT_DRAKKARI_SOOTHSAYER , ANCIENT_DRAKKARI_WARMONGER };
1254- if (entries.empty ())
1255- return ;
1252+ constexpr uint32 entries[] = { ANCIENT_DRAKKARI_SOOTHSAYER , ANCIENT_DRAKKARI_WARMONGER };
1253+ constexpr size_t entryCount = sizeof (entries) / sizeof (entries[0 ]);
12561254
1257- std::random_device rd;
1258- std::mt19937 gen (rd ());
1259- std::uniform_int_distribution<> distEntry (0 , entries.size () - 1 );
1260- uint32 chosenEntry = entries[distEntry (gen)];
1255+ std::list<Creature*> npcList;
12611256
1262- std::list<Creature*> tempList;
1263- GetCreatureListWithEntryInGrid (tempList, me, chosenEntry, 30 .0f );
1257+ for (size_t i = 0 ; i < entryCount; ++i)
1258+ {
1259+ std::list<Creature*> tempList;
1260+ GetCreatureListWithEntryInGrid (tempList, me, entries[i], 30 .0f );
12641261
1265- std::vector<ObjectGuid> npcGuids;
1266- for (Creature* c : tempList )
1267- if (c && c-> IsAlive ())
1268- npcGuids. push_back (c-> GetGUID ());
1262+ for (Creature* c : tempList)
1263+ if (c && c-> IsAlive () )
1264+ npcList. push_back (c);
1265+ }
12691266
1270- if (npcGuids .empty ())
1267+ if (npcList .empty ())
12711268 return ;
12721269
1273- std::uniform_int_distribution<> distNpc (0 , npcGuids.size () - 1 );
1274- ObjectGuid selectedGuid = npcGuids[distNpc (gen)];
1270+ size_t listSize = npcList.size ();
1271+ size_t randIndex = urand (0 , listSize - 1 );
1272+
1273+ auto it = npcList.begin ();
1274+ std::advance (it, randIndex);
12751275
1276- if (Creature* target = ObjectAccessor::GetCreature (*me, selectedGuid))
1276+ Creature* target = *it;
1277+ if (target)
12771278 {
12781279 target->SetFaction (14 );
12791280 target->AI ()->AttackStart (player);
0 commit comments