Core/Instances: improve DoRemoveAurasDueToSpellOnPlayers & DoCastSpellOnPlayers handling
Port From (https://github.com/TrinityCore/TrinityCore/commit/70fd6e7398040dc197c3470c6db8aa82f4e42ab1)
This commit is contained in:
@@ -635,29 +635,73 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove Auras due to Spell on all players in instance
|
// Remove Auras due to Spell on all players in instance
|
||||||
public void DoRemoveAurasDueToSpellOnPlayers(uint spell)
|
public void DoRemoveAurasDueToSpellOnPlayers(uint spell, bool includePets = false, bool includeControlled = false)
|
||||||
{
|
{
|
||||||
var PlayerList = instance.GetPlayers();
|
var playerList = instance.GetPlayers();
|
||||||
if (!PlayerList.Empty())
|
foreach (var player in playerList)
|
||||||
{
|
{
|
||||||
foreach (var player in PlayerList)
|
player.RemoveAurasDueToSpell(spell);
|
||||||
|
|
||||||
|
if (!includePets)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (byte i = 0; i < SharedConst.MaxSummonSlot; ++i)
|
||||||
{
|
{
|
||||||
player.RemoveAurasDueToSpell(spell);
|
ObjectGuid summonGUID = player.m_SummonSlot[i];
|
||||||
Pet pet = player.GetPet();
|
if (!summonGUID.IsEmpty())
|
||||||
if (pet != null)
|
{
|
||||||
pet.RemoveAurasDueToSpell(spell);
|
Creature summon = instance.GetCreature(summonGUID);
|
||||||
|
if (summon != null)
|
||||||
|
summon.RemoveAurasDueToSpell(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!includeControlled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
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.RemoveAurasDueToSpell(spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast spell on all players in instance
|
// Cast spell on all players in instance
|
||||||
public void DoCastSpellOnPlayers(uint spell)
|
public void DoCastSpellOnPlayers(uint spell, bool includePets = false, bool includeControlled = false)
|
||||||
{
|
{
|
||||||
var PlayerList = instance.GetPlayers();
|
var playerList = instance.GetPlayers();
|
||||||
|
foreach (var player in playerList)
|
||||||
|
{
|
||||||
|
player.CastSpell(player, spell, true);
|
||||||
|
|
||||||
if (!PlayerList.Empty())
|
if (!includePets)
|
||||||
foreach (var player in PlayerList)
|
continue;
|
||||||
player.CastSpell(player, spell, true);
|
|
||||||
|
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)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
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)
|
public virtual bool CheckAchievementCriteriaMeet(uint criteria_id, Player source, Unit target = null, uint miscvalue1 = 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user