diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-06-29 18:36:11 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-13 00:42:18 +0100 |
commit | 70fd6e7398040dc197c3470c6db8aa82f4e42ab1 (patch) | |
tree | df41e2f2f5307eacb1921b7de200608c736e628d /src/server/game/Instances/InstanceScript.cpp | |
parent | cadbf42ea4489933f28caf356f8c8d09ca243083 (diff) |
Core/Instances: improve DoRemoveAurasDueToSpellOnPlayers & DoCastSpellOnPlayers handling
(cherry picked from commit 22b3b21ae3e60c1f38b8e3bf1d7cd50ee5efca21)
Diffstat (limited to 'src/server/game/Instances/InstanceScript.cpp')
-rw-r--r-- | src/server/game/Instances/InstanceScript.cpp | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 00f8387e0ac..0d8b75ddbf9 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -648,33 +648,70 @@ void InstanceScript::DoStopCriteriaTimer(CriteriaStartEvent startEvent, uint32 e player->RemoveCriteriaTimer(startEvent, entry); } -// Remove Auras due to Spell on all players in instance -void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell) +void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/) { - Map::PlayerList const& PlayerList = instance->GetPlayers(); - if (!PlayerList.isEmpty()) + Map::PlayerList const& playerList = instance->GetPlayers(); + for (auto itr = playerList.begin(); itr != playerList.end(); ++itr) { - for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + if (Player* player = itr->GetSource()) { - if (Player* player = itr->GetSource()) + player->RemoveAurasDueToSpell(spell); + + if (!includePets) + continue; + + for (uint8 itr2 = 0; itr2 < MAX_SUMMON_SLOT; ++itr2) { - player->RemoveAurasDueToSpell(spell); - if (Pet* pet = player->GetPet()) - pet->RemoveAurasDueToSpell(spell); + ObjectGuid summonGUID = player->m_SummonSlot[itr2]; + if (!summonGUID.IsEmpty()) + if (Creature* summon = instance->GetCreature(summonGUID)) + summon->RemoveAurasDueToSpell(spell); + } + + if (!includeControlled) + continue; + + for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2) + { + if (Unit* controlled = *itr2) + if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT) + controlled->RemoveAurasDueToSpell(spell); } } } } -// Cast spell on all players in instance -void InstanceScript::DoCastSpellOnPlayers(uint32 spell) +void InstanceScript::DoCastSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/) { - Map::PlayerList const& PlayerList = instance->GetPlayers(); + Map::PlayerList const& playerList = instance->GetPlayers(); + for (auto itr = playerList.begin(); itr != playerList.end(); ++itr) + { + if (Player* player = itr->GetSource()) + { + player->CastSpell(player, spell, true); - if (!PlayerList.isEmpty()) - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* player = i->GetSource()) - player->CastSpell(player, spell, true); + if (!includePets) + continue; + + for (uint8 itr2 = 0; itr2 < MAX_SUMMON_SLOT; ++itr2) + { + ObjectGuid summonGUID = player->m_SummonSlot[itr2]; + if (!summonGUID.IsEmpty()) + if (Creature* summon = instance->GetCreature(summonGUID)) + summon->CastSpell(player, spell, true); + } + + if (!includeControlled) + continue; + + for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2) + { + if (Unit* controlled = *itr2) + if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT) + controlled->CastSpell(player, spell, true); + } + } + } } bool InstanceScript::ServerAllowsTwoSideGroups() |