Core/AreaTrigger: Implement AreaTriggerActionSetFlag::DontDespawnWithCreator (#30832)

This commit is contained in:
ModoX
2025-05-10 18:49:25 +02:00
committed by GitHub
parent 3b91724203
commit c40b6e0b3f
3 changed files with 18 additions and 6 deletions

View File

@@ -191,7 +191,7 @@ enum class AreaTriggerActionSetFlag : uint32
CreatorsPartyOnly = 0x0100,
DontRunOnLeaveWhenExpiring = 0x0200, /*NYI*/
CanAffectUninteractible = 0x0400,
DontDespawnWithCreator = 0x0800, /*NYI*/
DontDespawnWithCreator = 0x0800,
CanAffectBeastmaster = 0x1000, // Can affect GMs
RequiresLineOfSight = 0x2000 /*NYI*/
};

View File

@@ -5453,10 +5453,15 @@ void Unit::RemoveAreaTrigger(AuraEffect const* aurEff)
}
}
void Unit::RemoveAllAreaTriggers()
void Unit::RemoveAllAreaTriggers(AreaTriggerRemoveReason reason /*= AreaTriggerRemoveReason::Default*/)
{
while (!m_areaTrigger.empty())
m_areaTrigger.back()->Remove();
for (AreaTrigger* at : AreaTriggerList(std::move(m_areaTrigger)))
{
if (reason == AreaTriggerRemoveReason::UnitDespawn && at->GetTemplate()->ActionSetFlags.HasFlag(AreaTriggerActionSetFlag::DontDespawnWithCreator))
continue;
at->Remove();
}
}
void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log)
@@ -10034,7 +10039,7 @@ void Unit::RemoveFromWorld()
RemoveAllGameObjects();
RemoveAllDynObjects();
RemoveAllAreaTriggers();
RemoveAllAreaTriggers(AreaTriggerRemoveReason::UnitDespawn);
ExitVehicle(); // Remove applied auras with SPELL_AURA_CONTROL_VEHICLE
UnsummonAllTotems();

View File

@@ -1626,9 +1626,16 @@ class TC_GAME_API Unit : public WorldObject
void _UnregisterAreaTrigger(AreaTrigger* areaTrigger);
AreaTrigger* GetAreaTrigger(uint32 spellId) const;
std::vector<AreaTrigger*> GetAreaTriggers(uint32 spellId) const;
enum class AreaTriggerRemoveReason : uint8
{
Default,
UnitDespawn
};
void RemoveAreaTrigger(uint32 spellId);
void RemoveAreaTrigger(AuraEffect const* aurEff);
void RemoveAllAreaTriggers();
void RemoveAllAreaTriggers(AreaTriggerRemoveReason reason = AreaTriggerRemoveReason::Default);
void ModifyAuraState(AuraStateType flag, bool apply);
uint32 BuildAuraStateUpdateForTarget(Unit const* target) const;