Core/Instance: add new hook & method
Port From (https://github.com/TrinityCore/TrinityCore/commit/6a63200e40d286dd49cc90135a519b0680a6f435)
This commit is contained in:
@@ -669,6 +669,40 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DoRemoveAurasDueToSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false)
|
||||||
|
{
|
||||||
|
if (!player)
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.RemoveAurasDueToSpell(spell);
|
||||||
|
|
||||||
|
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.RemoveAurasDueToSpell(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.RemoveAurasDueToSpell(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cast spell on all players in instance
|
// Cast spell on all players in instance
|
||||||
public void DoCastSpellOnPlayers(uint spell, bool includePets = false, bool includeControlled = false)
|
public void DoCastSpellOnPlayers(uint spell, bool includePets = false, bool includeControlled = false)
|
||||||
{
|
{
|
||||||
@@ -900,9 +934,15 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Initialize() { }
|
public virtual void Initialize() { }
|
||||||
|
|
||||||
public virtual void Update(uint diff) { }
|
public virtual void Update(uint diff) { }
|
||||||
|
|
||||||
|
// Called when a player successfully enters the instance.
|
||||||
public virtual void OnPlayerEnter(Player player) { }
|
public virtual void OnPlayerEnter(Player player) { }
|
||||||
|
|
||||||
|
// Called when a player successfully leaves the instance.
|
||||||
|
public virtual void OnPlayerLeave(Player player) { }
|
||||||
|
|
||||||
// Return wether server allow two side groups or not
|
// Return wether server allow two side groups or not
|
||||||
public bool ServerAllowsTwoSideGroups() { return WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGroup); }
|
public bool ServerAllowsTwoSideGroups() { return WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGroup); }
|
||||||
|
|
||||||
|
|||||||
@@ -5256,10 +5256,12 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public override void RemovePlayerFromMap(Player player, bool remove)
|
public override void RemovePlayerFromMap(Player player, bool remove)
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.Maps,
|
Log.outInfo(LogFilter.Maps, "MAP: Removing player '{0}' from instance '{1}' of map '{2}' before relocating to another map", player.GetName(), GetInstanceId(), GetMapName());
|
||||||
"MAP: Removing player '{0}' from instance '{1}' of map '{2}' before relocating to another map",
|
|
||||||
player.GetName(), GetInstanceId(), GetMapName());
|
if (i_data != null)
|
||||||
//if last player set unload timer
|
i_data.OnPlayerLeave(player);
|
||||||
|
|
||||||
|
// if last player set unload timer
|
||||||
if (m_unloadTimer == 0 && GetPlayers().Count == 1)
|
if (m_unloadTimer == 0 && GetPlayers().Count == 1)
|
||||||
m_unloadTimer = m_unloadWhenEmpty ? 1 : (uint)Math.Max(WorldConfig.GetIntValue(WorldCfg.InstanceUnloadDelay), 1);
|
m_unloadTimer = m_unloadWhenEmpty ? 1 : (uint)Math.Max(WorldConfig.GetIntValue(WorldCfg.InstanceUnloadDelay), 1);
|
||||||
|
|
||||||
@@ -5267,6 +5269,7 @@ namespace Game.Maps
|
|||||||
i_scenario.OnPlayerExit(player);
|
i_scenario.OnPlayerExit(player);
|
||||||
|
|
||||||
base.RemovePlayerFromMap(player, remove);
|
base.RemovePlayerFromMap(player, remove);
|
||||||
|
|
||||||
// for normal instances schedule the reset after all players have left
|
// for normal instances schedule the reset after all players have left
|
||||||
SetResetSchedule(true);
|
SetResetSchedule(true);
|
||||||
Global.InstanceSaveMgr.UnloadInstanceSave(GetInstanceId());
|
Global.InstanceSaveMgr.UnloadInstanceSave(GetInstanceId());
|
||||||
|
|||||||
Reference in New Issue
Block a user