diff options
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() |