|
16 | 16 | */ |
17 | 17 |
|
18 | 18 | #include "ScriptMgr.h" |
| 19 | +#include "Containers.h" |
19 | 20 | #include "GameObject.h" |
20 | 21 | #include "GameObjectAI.h" |
21 | 22 | #include "MotionMaster.h" |
@@ -1345,36 +1346,20 @@ struct go_drakkari_canopic_jar_chest : public GameObjectAI |
1345 | 1346 | if (!player) |
1346 | 1347 | return; |
1347 | 1348 |
|
1348 | | - constexpr uint32 entries[] = { NPC_ANCIENT_DRAKKARI_SOOTHSAYER, NPC_ANCIENT_DRAKKARI_WARMONGER }; |
1349 | | - constexpr size_t entryCount = sizeof(entries) / sizeof(entries[0]); |
| 1349 | + std::list<Creature*> creatureList; |
| 1350 | + FindCreatureOptions args; |
| 1351 | + args.IsAlive = true; |
| 1352 | + args.IsInCombat = false; |
| 1353 | + args.CreatureId = NPC_ANCIENT_DRAKKARI_SOOTHSAYER; |
| 1354 | + GetCreatureListWithOptionsInGrid(creatureList, me, 30.f, args); |
| 1355 | + args.CreatureId = NPC_ANCIENT_DRAKKARI_WARMONGER; |
| 1356 | + GetCreatureListWithOptionsInGrid(creatureList, me, 30.f, args); |
1350 | 1357 |
|
1351 | | - std::list<Creature*> npcList; |
1352 | | - |
1353 | | - for (size_t i = 0; i < entryCount; ++i) |
1354 | | - { |
1355 | | - std::list<Creature*> tempList; |
1356 | | - GetCreatureListWithEntryInGrid(tempList, me, entries[i], 30.0f); |
1357 | | - |
1358 | | - for (Creature* c : tempList) |
1359 | | - if (c && c->IsAlive()) |
1360 | | - npcList.push_back(c); |
1361 | | - } |
1362 | | - |
1363 | | - if (npcList.empty()) |
1364 | | - return; |
1365 | | - |
1366 | | - size_t listSize = npcList.size(); |
1367 | | - size_t randIndex = urand(0, listSize - 1); |
1368 | | - |
1369 | | - auto it = npcList.begin(); |
1370 | | - std::advance(it, randIndex); |
1371 | | - |
1372 | | - Creature* target = *it; |
1373 | | - if (target) |
| 1358 | + if (Creature* attacker = Trinity::Containers::SelectRandomContainerElement(creatureList)) |
1374 | 1359 | { |
1375 | | - target->SetFaction(14); |
1376 | | - target->AI()->AttackStart(player); |
1377 | | - target->AI()->Talk(SAY_ANCIENT_DRAKKARI); |
| 1360 | + attacker->SetFaction(14); |
| 1361 | + attacker->AI()->AttackStart(player); |
| 1362 | + attacker->AI()->Talk(SAY_ANCIENT_DRAKKARI); |
1378 | 1363 | } |
1379 | 1364 | } |
1380 | 1365 | }; |
|
0 commit comments