diff --git a/Source/Framework/Constants/UnitConst.cs b/Source/Framework/Constants/UnitConst.cs index 196b6f6c3..6b79d1add 100644 --- a/Source/Framework/Constants/UnitConst.cs +++ b/Source/Framework/Constants/UnitConst.cs @@ -607,13 +607,19 @@ namespace Framework.Constants public enum UnitDynFlags { - None = 0x00, - HideModel = 0x02, // Object model is not shown with this flag - Lootable = 0x04, - TrackUnit = 0x08, - Tapped = 0x10, // Lua_UnitIsTapped - SpecialInfo = 0x20, - CanSkin = 0x40, // previously UNIT_DYNFLAG_DEAD - ReferAFriend = 0x80 + None = 0x00, + HideModel = 0x02, // Object model is not shown with this flag + Lootable = 0x04, + TrackUnit = 0x08, + Tapped = 0x10, // Lua_UnitIsTapped + SpecialInfo = 0x20, + CanSkin = 0x40, // previously UNIT_DYNFLAG_DEAD + ReferAFriend = 0x80 + } + + public enum AreaTriggerRemoveReason + { + Default, + UnitDespawn } } diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 4ae12e526..452b1431b 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -866,10 +866,15 @@ namespace Game.Entities } } - public void RemoveAllAreaTriggers() + public void RemoveAllAreaTriggers(AreaTriggerRemoveReason reason = AreaTriggerRemoveReason.Default) { - while (!m_areaTrigger.Empty()) - m_areaTrigger.Last()?.Remove(); + foreach (AreaTrigger at in m_areaTrigger) + { + if (reason == AreaTriggerRemoveReason.UnitDespawn && at.GetTemplate().ActionSetFlags.HasFlag(AreaTriggerActionSetFlag.DontDespawnWithCreator)) + continue; + + at.Remove(); + } } public NPCFlags GetNpcFlags() { return (NPCFlags)m_unitData.NpcFlags.GetValue(); }