aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-06-29 19:32:13 +0200
committerccrs <ccrs@users.noreply.github.com>2019-06-29 19:32:13 +0200
commit14788ce026b660fe14207fa8865df4604050eb2b (patch)
tree2cb0099a890b31cc1b4e7ec36a0954ded98d88d7
parent953b05459a517fb83f18047ab82ac09021bc9440 (diff)
Core/Instance: add new method
-rw-r--r--src/server/game/Instances/InstanceScript.cpp28
-rw-r--r--src/server/game/Instances/InstanceScript.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index b451fd6f1f1..dd01f46f38a 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -708,6 +708,34 @@ 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)
+ {
+ if (ObjectGuid summonGUID = player->m_SummonSlot[itr2])
+ 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 ba69495d68c..72519797ed5 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -232,6 +232,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();