From da283244caa272a8fcd7ced38dcf1ac1c76a6660 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 11 Feb 2023 23:30:57 -0500 Subject: [PATCH] Core/Spawns: Allow spawn groups with MANUAL_SPAWN flag to automatically despawn if conditions are not met Port From (https://github.com/TrinityCore/TrinityCore/commit/97d413c9b4be6af296490580f7acc1d66e606ca9) --- Source/Game/Conditions/ConditionManager.cs | 4 ++-- Source/Game/Maps/Map.cs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index f3617a3aa..5c5e4e997 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -1260,9 +1260,9 @@ namespace Game Log.outError(LogFilter.Sql, $"{cond.ToString()} SourceEntry in `condition` table, does not exist in `spawn_group_template`, ignoring."); return false; } - if (spawnGroup.flags.HasAnyFlag(SpawnGroupFlags.System | SpawnGroupFlags.ManualSpawn)) + if (spawnGroup.flags.HasAnyFlag(SpawnGroupFlags.System)) { - Log.outError(LogFilter.Sql, $"{cond.ToString()} in `spawn_group_template` table cannot have SPAWNGROUP_FLAG_SYSTEM or SPAWNGROUP_FLAG_MANUAL_SPAWN flags, ignoring."); + Log.outError(LogFilter.Sql, $"{cond.ToString()} in `spawn_group_template` table cannot have SPAWNGROUP_FLAG_SYSTEM flags, ignoring."); return false; } break; diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 2141303c1..bdd55948c 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -2374,11 +2374,19 @@ namespace Game.Maps foreach (uint spawnGroupId in spawnGroups) { SpawnGroupTemplateData spawnGroupTemplate = GetSpawnGroupData(spawnGroupId); - if (spawnGroupTemplate.flags.HasFlag(SpawnGroupFlags.ManualSpawn)) - continue; bool isActive = IsSpawnGroupActive(spawnGroupId); bool shouldBeActive = Global.ConditionMgr.IsMapMeetingNotGroupedConditions(ConditionSourceType.SpawnGroup, spawnGroupId, this); + + if (spawnGroupTemplate.flags.HasFlag(SpawnGroupFlags.ManualSpawn)) + { + // Only despawn the group if it isn't meeting conditions + if (isActive && !shouldBeActive && spawnGroupTemplate.flags.HasFlag(SpawnGroupFlags.DespawnOnConditionFailure)) + SpawnGroupDespawn(spawnGroupId, true); + + continue; + } + if (isActive == shouldBeActive) continue;