Core/AreaTriggers: Implement AreaTriggerActionSetFlag::DontRunOnLeaveWhenExpiring
Port From (https://github.com/TrinityCore/TrinityCore/commit/1085b3f43321e58f151c1543a70b3558c26ed8e5)
This commit is contained in:
@@ -70,4 +70,10 @@ namespace Framework.Constants
|
|||||||
None = 2,
|
None = 2,
|
||||||
MovementScript = 3
|
MovementScript = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AreaTriggerExitReason
|
||||||
|
{
|
||||||
|
NotInside = 0, // Unit leave areatrigger
|
||||||
|
ByExpire = 1 // On areatrigger despawn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ namespace Framework.Constants
|
|||||||
SuppressConditionError = 0x40, // NYI
|
SuppressConditionError = 0x40, // NYI
|
||||||
NotTriggeredbyCaster = 0x80,
|
NotTriggeredbyCaster = 0x80,
|
||||||
CreatorsPartyOnly = 0x100,
|
CreatorsPartyOnly = 0x100,
|
||||||
DontRunOnLeaveWhenExpiring = 0x200, // NYI
|
DontRunOnLeaveWhenExpiring = 0x200,
|
||||||
CanAffectUninteractible = 0x400,
|
CanAffectUninteractible = 0x400,
|
||||||
DontDespawnWithCreator = 0x800, // NYI
|
DontDespawnWithCreator = 0x800, // NYI
|
||||||
CanAffectBeastmaster = 0x1000, // Can affect GMs
|
CanAffectBeastmaster = 0x1000, // Can affect GMs
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Framework.Constants;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ namespace Game.AI
|
|||||||
public virtual void OnUnitEnter(Unit unit) { }
|
public virtual void OnUnitEnter(Unit unit) { }
|
||||||
|
|
||||||
// Called when an unit exit the AreaTrigger, or when the AreaTrigger is removed
|
// Called when an unit exit the AreaTrigger, or when the AreaTrigger is removed
|
||||||
public virtual void OnUnitExit(Unit unit) { }
|
public virtual void OnUnitExit(Unit unit, AreaTriggerExitReason reason) { }
|
||||||
|
|
||||||
// Called when the AreaTrigger is removed
|
// Called when the AreaTrigger is removed
|
||||||
public virtual void OnRemove() { }
|
public virtual void OnRemove() { }
|
||||||
|
|||||||
@@ -1200,7 +1200,7 @@ namespace Game.AI
|
|||||||
GetScript().ProcessEventsFor(SmartEvents.AreatriggerEnter, unit);
|
GetScript().ProcessEventsFor(SmartEvents.AreatriggerEnter, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
GetScript().ProcessEventsFor(SmartEvents.AreatriggerExit, unit);
|
GetScript().ProcessEventsFor(SmartEvents.AreatriggerExit, unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Game.Entities
|
|||||||
_ai.OnRemove();
|
_ai.OnRemove();
|
||||||
|
|
||||||
// Handle removal of all units, calling OnUnitExit & deleting auras if needed
|
// Handle removal of all units, calling OnUnitExit & deleting auras if needed
|
||||||
HandleUnitEnterExit(new List<Unit>());
|
HandleUnitEnterExit(new List<Unit>(), AreaTriggerExitReason.ByExpire);
|
||||||
|
|
||||||
base.RemoveFromWorld();
|
base.RemoveFromWorld();
|
||||||
if (IsStaticSpawn())
|
if (IsStaticSpawn())
|
||||||
@@ -809,7 +809,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleUnitEnterExit(List<Unit> newTargetList)
|
void HandleUnitEnterExit(List<Unit> newTargetList, AreaTriggerExitReason exitMode = AreaTriggerExitReason.NotInside)
|
||||||
{
|
{
|
||||||
List<ObjectGuid> exitUnits = _insideUnits;
|
List<ObjectGuid> exitUnits = _insideUnits;
|
||||||
_insideUnits.Clear();
|
_insideUnits.Clear();
|
||||||
@@ -832,7 +832,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
Unit leavingUnit = Global.ObjAccessor.GetUnit(this, exitUnitGuid);
|
Unit leavingUnit = Global.ObjAccessor.GetUnit(this, exitUnitGuid);
|
||||||
if (leavingUnit != null)
|
if (leavingUnit != null)
|
||||||
HandleUnitExitInternal(leavingUnit);
|
HandleUnitExitInternal(leavingUnit, exitMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateHasPlayersFlag();
|
UpdateHasPlayersFlag();
|
||||||
@@ -861,23 +861,30 @@ namespace Game.Entities
|
|||||||
unit.EnterAreaTrigger(this);
|
unit.EnterAreaTrigger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleUnitExitInternal(Unit unit)
|
void HandleUnitExitInternal(Unit unit, AreaTriggerExitReason exitMode = AreaTriggerExitReason.NotInside)
|
||||||
{
|
{
|
||||||
|
bool canTriggerOnExit = exitMode != AreaTriggerExitReason.ByExpire || !HasActionSetFlag(AreaTriggerActionSetFlag.DontRunOnLeaveWhenExpiring);
|
||||||
|
|
||||||
Player player = unit.ToPlayer();
|
Player player = unit.ToPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if (player.IsDebugAreaTriggers)
|
if (player.IsDebugAreaTriggers)
|
||||||
player.SendSysMessage(CypherStrings.DebugAreatriggerEntityLeft, GetEntry(), IsCustom(), IsStaticSpawn(), _spawnId);
|
player.SendSysMessage(CypherStrings.DebugAreatriggerEntityLeft, GetEntry(), IsCustom(), IsStaticSpawn(), _spawnId);
|
||||||
|
|
||||||
|
if (canTriggerOnExit)
|
||||||
|
{
|
||||||
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
||||||
|
|
||||||
if (GetTemplate().ActionSetId != 0)
|
if (GetTemplate().ActionSetId != 0)
|
||||||
player.UpdateCriteria(CriteriaType.LeaveAreaTriggerWithActionSet, GetTemplate().ActionSetId);
|
player.UpdateCriteria(CriteriaType.LeaveAreaTriggerWithActionSet, GetTemplate().ActionSetId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UndoActions(unit);
|
UndoActions(unit);
|
||||||
|
|
||||||
_ai.OnUnitExit(unit);
|
if (canTriggerOnExit)
|
||||||
|
_ai.OnUnitExit(unit, exitMode);
|
||||||
|
|
||||||
unit.ExitAreaTrigger(this);
|
unit.ExitAreaTrigger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1376,7 +1376,7 @@ class at_dk_death_and_decay(AreaTrigger areaTrigger) : AreaTriggerAI(areaTrigger
|
|||||||
unit.CastSpell(unit, SpellIds.SanguineGround);
|
unit.CastSpell(unit, SpellIds.SanguineGround);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
if (unit.GetGUID() != at.GetCasterGUID())
|
if (unit.GetGUID() != at.GetCasterGUID())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -736,7 +736,7 @@ class areatrigger_dh_darkness : AreaTriggerAI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
unit.RemoveAura(SpellIds.DarknessAbsorb, at.GetCasterGUID());
|
unit.RemoveAura(SpellIds.DarknessAbsorb, at.GetCasterGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class at_hun_binding_shot(AreaTrigger areaTrigger) : AreaTriggerAI(areaTrigger)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
unit.RemoveAurasDueToSpell(SpellIds.BindingShotMarker, at.GetCasterGUID());
|
unit.RemoveAurasDueToSpell(SpellIds.BindingShotMarker, at.GetCasterGUID());
|
||||||
|
|
||||||
@@ -1322,7 +1322,7 @@ class areatrigger_hun_tar_trap(AreaTrigger areaTrigger) : AreaTriggerAI(areaTrig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
unit.RemoveAurasDueToSpell(SpellIds.TarTrapSlow, at.GetCasterGUID());
|
unit.RemoveAurasDueToSpell(SpellIds.TarTrapSlow, at.GetCasterGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1501,7 +1501,7 @@ class at_mage_meteor_burn(AreaTrigger areaTrigger) : AreaTriggerAI(areaTrigger)
|
|||||||
caster.CastSpell(unit, SpellIds.MeteorBurnDamage, TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError);
|
caster.CastSpell(unit, SpellIds.MeteorBurnDamage, TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
unit.RemoveAurasDueToSpell(SpellIds.MeteorBurnDamage, at.GetCasterGUID());
|
unit.RemoveAurasDueToSpell(SpellIds.MeteorBurnDamage, at.GetCasterGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class areatrigger_pal_ashen_hallow(AreaTrigger areaTrigger) : AreaTriggerAI(area
|
|||||||
unit.CastSpell(unit, SpellIds.AshenHallowAllowHammer, true);
|
unit.CastSpell(unit, SpellIds.AshenHallowAllowHammer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
if (unit.GetGUID() == at.GetCasterGUID())
|
if (unit.GetGUID() == at.GetCasterGUID())
|
||||||
unit.RemoveAura(SpellIds.AshenHallowAllowHammer);
|
unit.RemoveAura(SpellIds.AshenHallowAllowHammer);
|
||||||
@@ -429,7 +429,7 @@ class areatrigger_pal_consecration(AreaTrigger areaTrigger) : AreaTriggerAI(area
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
if (at.GetCasterGUID() == unit.GetGUID())
|
if (at.GetCasterGUID() == unit.GetGUID())
|
||||||
unit.RemoveAurasDueToSpell(SpellIds.ConsecrationProtectionAura, at.GetCasterGUID());
|
unit.RemoveAurasDueToSpell(SpellIds.ConsecrationProtectionAura, at.GetCasterGUID());
|
||||||
|
|||||||
@@ -1054,7 +1054,7 @@ class areatrigger_pri_divine_star(AreaTrigger areaTrigger) : AreaTriggerAI(areaT
|
|||||||
HandleUnitEnterExit(unit);
|
HandleUnitEnterExit(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
// Note: this ensures any unit receives a second hit if they happen to be inside the At when Divine Star starts its return path.
|
// Note: this ensures any unit receives a second hit if they happen to be inside the At when Divine Star starts its return path.
|
||||||
HandleUnitEnterExit(unit);
|
HandleUnitEnterExit(unit);
|
||||||
|
|||||||
@@ -3428,7 +3428,7 @@ class areatrigger_sha_arctic_snowstorm(AreaTrigger areaTrigger) : AreaTriggerAI(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUnitExit(Unit unit)
|
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||||
{
|
{
|
||||||
unit.RemoveAurasDueToSpell(SpellIds.ArcticSnowstormSlow, at.GetCasterGUID());
|
unit.RemoveAurasDueToSpell(SpellIds.ArcticSnowstormSlow, at.GetCasterGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user