Skip to content

Commit 6512451

Browse files
committed
redo
1 parent 8d90078 commit 6512451

1 file changed

Lines changed: 13 additions & 28 deletions

File tree

src/server/scripts/Northrend/zone_zuldrak.cpp

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include "ScriptMgr.h"
19+
#include "Containers.h"
1920
#include "GameObject.h"
2021
#include "GameObjectAI.h"
2122
#include "MotionMaster.h"
@@ -1345,36 +1346,20 @@ struct go_drakkari_canopic_jar_chest : public GameObjectAI
13451346
if (!player)
13461347
return;
13471348

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);
13501357

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))
13741359
{
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);
13781363
}
13791364
}
13801365
};

0 commit comments

Comments
 (0)