Core/Spawns: Allow spawn groups with MANUAL_SPAWN flag to automatically despawn if conditions are not met (#28778)

This commit is contained in:
Meji
2023-01-29 19:50:34 +01:00
committed by GitHub
parent 03918978c1
commit 97d413c9b4
2 changed files with 12 additions and 4 deletions

View File

@@ -2459,11 +2459,19 @@ void Map::UpdateSpawnGroupConditions()
for (uint32 spawnGroupId : *spawnGroups)
{
SpawnGroupTemplateData const* spawnGroupTemplate = ASSERT_NOTNULL(GetSpawnGroupData(spawnGroupId));
if (spawnGroupTemplate->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
continue;
bool isActive = IsSpawnGroupActive(spawnGroupId);
bool shouldBeActive = sConditionMgr->IsMapMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPAWN_GROUP, spawnGroupId, this);
if (spawnGroupTemplate->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
{
// Only despawn the group if it isn't meeting conditions
if (isActive && !shouldBeActive && spawnGroupTemplate->flags & SPAWNGROUP_FLAG_DESPAWN_ON_CONDITION_FAILURE)
SpawnGroupDespawn(spawnGroupId, true);
continue;
}
if (isActive == shouldBeActive)
continue;