diff options
| author | Traesh <Traesh@users.noreply.github.com> | 2022-02-16 23:54:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-16 23:54:26 +0100 |
| commit | 543a7b79c3e5259ed3da413a6d91f00dfd85977e (patch) | |
| tree | da6ab6007675f5213ea3d12f7c9c9a9a624f9813 /src/server/scripts/Outland | |
| parent | 64e8e11377c9b0bf92e81afb38e0668ba3fdf3f4 (diff) | |
Core/Maps: Add Map::DoOnPlayers helper function (#25233)
Diffstat (limited to 'src/server/scripts/Outland')
3 files changed, 26 insertions, 25 deletions
diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp index 2d05d172819..f8adc261570 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ObjectAccessor.h" #include "Player.h" #include "ScriptedCreature.h" +#include "InstanceScript.h" enum Spells { @@ -110,21 +111,22 @@ public: //Inhibitmagic_Timer if (Inhibitmagic_Timer <= diff) { - float dist; - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* i_pl = i->GetSource()) - if (i_pl->IsAlive() && (dist = i_pl->GetDistance(me)) < 45) - { - i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC); - me->AddAura(SPELL_INHIBITMAGIC, i_pl); - if (dist < 35) - me->AddAura(SPELL_INHIBITMAGIC, i_pl); - if (dist < 25) - me->AddAura(SPELL_INHIBITMAGIC, i_pl); - if (dist < 15) - me->AddAura(SPELL_INHIBITMAGIC, i_pl); - } + me->GetMap()->DoOnPlayers([this](Player* player) + { + float dist = player->GetDistance(me); + + if (player->IsAlive() && dist < 45.f) + { + player->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC); + me->AddAura(SPELL_INHIBITMAGIC, player); + if (dist < 35) + me->AddAura(SPELL_INHIBITMAGIC, player); + if (dist < 25) + me->AddAura(SPELL_INHIBITMAGIC, player); + if (dist < 15) + me->AddAura(SPELL_INHIBITMAGIC, player); + } + }); Inhibitmagic_Timer = 3000 + (rand32() % 1000); } else Inhibitmagic_Timer -= diff; diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index 707c3c07338..37ec05b8028 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -186,11 +186,11 @@ class boss_grandmaster_vorpil : public CreatureScript break; case EVENT_DRAW_SHADOWS: { - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* i_pl = i->GetSource()) - if (i_pl->IsAlive() && !i_pl->HasAura(SPELL_BANISH)) - i_pl->TeleportTo(me->GetMapId(), VorpilPosition.GetPositionX(), VorpilPosition.GetPositionY(), VorpilPosition.GetPositionZ(), VorpilPosition.GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT); + instance->instance->DoOnPlayers([this](Player* player) + { + if (player->IsAlive() && !player->HasAura(SPELL_BANISH)) + player->TeleportTo(me->GetMapId(), VorpilPosition.GetPositionX(), VorpilPosition.GetPositionY(), VorpilPosition.GetPositionZ(), VorpilPosition.GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT); + }); me->UpdatePosition(VorpilPosition); DoCast(me, SPELL_DRAW_SHADOWS, true); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index c20dee859a2..92e00e915c2 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -285,12 +285,11 @@ public: if (RotTimer) { - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + instance->instance->DoOnPlayers([this, diff](Player* player) { - if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater()) - DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water - } + if (player->IsAlive() && me->HasInArc(diff / 20000.f * float(M_PI) * 2.f, player) && me->IsWithinDist(player, SPOUT_DIST) && !player->IsInWater()) + DoCast(player, SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water + }); if (SpoutAnimTimer <= diff) { |
