diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-06-29 19:32:13 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-13 00:42:18 +0100 |
commit | 934b72262d390f4e2cb87f07a4c1512a24a3b0d0 (patch) | |
tree | ca5242b045afa73447a479bd60b8fd0913b76f70 /src | |
parent | 6a63200e40d286dd49cc90135a519b0680a6f435 (diff) |
Core/Instance: add new method
(cherry picked from commit 14788ce026b660fe14207fa8865df4604050eb2b)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Instances/InstanceScript.cpp | 29 | ||||
-rw-r--r-- | src/server/game/Instances/InstanceScript.h | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index cbfa17dbf48..5779316b6c9 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -743,6 +743,35 @@ void InstanceScript::DoCastSpellOnPlayers(uint32 spell, bool includePets /*= fal } } +void InstanceScript::DoCastSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/) +{ + if (!player) + return; + + player->CastSpell(player, spell, true); + + if (!includePets) + return; + + 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) + return; + + 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() { return sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP); diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index 20723a6e723..129894847f2 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -234,6 +234,7 @@ class TC_GAME_API InstanceScript : public ZoneScript // Cast spell on all players in instance void DoCastSpellOnPlayers(uint32 spell, bool includePets = false, bool includeControlled = false); + void DoCastSpellOnPlayer(Player* player, uint32 spell, bool includePets = false, bool includeControlled = false); // Return wether server allow two side groups or not static bool ServerAllowsTwoSideGroups(); |