diff options
| author | joschiwald <joschiwald@online.de> | 2013-08-31 16:48:37 +0200 |
|---|---|---|
| committer | joschiwald <joschiwald@online.de> | 2013-08-31 16:48:37 +0200 |
| commit | ae36ddefec4f5ab6eea615ddd7a45cbdcb580b5a (patch) | |
| tree | a5b4b525a4c6db0ef781b3ad464dc0ee7625aaed /src/server/scripts/EasternKingdoms | |
| parent | a2ee732a38ff8c0c366a57d5942368982443d8b7 (diff) | |
Core/Scripts: add creature_text to pet mojo
Scripts/Karazhan/Moroes: cleanup a bit (should fixes mem leak)
Diffstat (limited to 'src/server/scripts/EasternKingdoms')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 473fe000939..780f781f58d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -73,14 +73,12 @@ enum Spells SPELL_SHIELDWALL = 29390 }; -#define POS_Z 81.73f - -float Locations[4][3]= +Position const Locations[4] = { - {-10991.0f, -1884.33f, 0.614315f}, - {-10989.4f, -1885.88f, 0.904913f}, - {-10978.1f, -1887.07f, 2.035550f}, - {-10975.9f, -1885.81f, 2.253890f}, + {-10991.0f, -1884.33f, 81.73f, 0.614315f}, + {-10989.4f, -1885.88f, 81.73f, 0.904913f}, + {-10978.1f, -1887.07f, 81.73f, 2.035550f}, + {-10975.9f, -1885.81f, 81.73f, 2.253890f}, }; const uint32 Adds[6]= @@ -137,7 +135,7 @@ public: Enrage = false; InVanish = false; - if (me->GetHealth()) + if (me->IsAlive()) SpawnAdds(); if (instance) @@ -183,39 +181,34 @@ public: void SpawnAdds() { DeSpawnAdds(); + if (isAddlistEmpty()) { - Creature* creature = NULL; - std::vector<uint32> AddList; + std::list<uint32> AddList; for (uint8 i = 0; i < 6; ++i) AddList.push_back(Adds[i]); - while (AddList.size() > 4) - AddList.erase((AddList.begin())+(rand()%AddList.size())); + Trinity::Containers::RandomResizeList(AddList, 4); uint8 i = 0; - for (std::vector<uint32>::const_iterator itr = AddList.begin(); itr != AddList.end(); ++itr) + for (std::list<uint32>::const_iterator itr = AddList.begin(); itr != AddList.end() && i < 4; ++itr, ++i) { uint32 entry = *itr; - creature = me->SummonCreature(entry, Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if (creature) + if (Creature* creature = me->SummonCreature(entry, Locations[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000)) { AddGUID[i] = creature->GetGUID(); AddId[i] = entry; } - ++i; } - }else + } + else { for (uint8 i = 0; i < 4; ++i) { - Creature* creature = me->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if (creature) - { + if (Creature* creature = me->SummonCreature(AddId[i], Locations[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000)) AddGUID[i] = creature->GetGUID(); - } } } } @@ -235,9 +228,8 @@ public: { if (AddGUID[i]) { - Creature* temp = Creature::GetCreature((*me), AddGUID[i]); - if (temp && temp->IsAlive()) - temp->DisappearAndDie(); + if (Creature* temp = ObjectAccessor::GetCreature(*me, AddGUID[i])) + temp->DespawnOrUnsummon(); } } } |
