From 5ba1f34108ff13f05d6e369ef69e01dace9987c8 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 26 Dec 2021 19:27:28 -0500 Subject: [PATCH] Core/Instance: add new method Port From (https://github.com/TrinityCore/TrinityCore/commit/934b72262d390f4e2cb87f07a4c1512a24a3b0d0) --- Source/Game/Maps/Instances/InstanceScript.cs | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Source/Game/Maps/Instances/InstanceScript.cs b/Source/Game/Maps/Instances/InstanceScript.cs index c58c2ad62..d5f0532d4 100644 --- a/Source/Game/Maps/Instances/InstanceScript.cs +++ b/Source/Game/Maps/Instances/InstanceScript.cs @@ -669,8 +669,7 @@ namespace Game.Maps } } - - void DoRemoveAurasDueToSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false) + public void DoRemoveAurasDueToSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false) { if (!player) return; @@ -738,6 +737,39 @@ namespace Game.Maps } } + public void DoCastSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false) + { + if (!player) + return; + + player.CastSpell(player, spell, true); + + if (!includePets) + return; + + for (var i = 0; i < SharedConst.MaxSummonSlot; ++i) + { + ObjectGuid summonGUID = player.m_SummonSlot[i]; + if (!summonGUID.IsEmpty()) + { + Creature summon = instance.GetCreature(summonGUID); + if (summon != null) + summon.CastSpell(player, spell, true); + } + } + + if (!includeControlled) + return; + + for (var i = 0; i < player.m_Controlled.Count; ++i) + { + Unit controlled = player.m_Controlled[i]; + if (controlled != null) + if (controlled.IsInWorld && controlled.IsCreature()) + controlled.CastSpell(player, spell, true); + } + } + public virtual bool CheckAchievementCriteriaMeet(uint criteria_id, Player source, Unit target = null, uint miscvalue1 = 0) { Log.outError(LogFilter.Server, "Achievement system call CheckAchievementCriteriaMeet but instance script for map {0} not have implementation for achievement criteria {1}",