Skip to content

feat(Core/Maps): port spawn system/dynamic spawns from TrinityCore#25206

Open
Nyeriah wants to merge 2 commits intoazerothcore:masterfrom
Nyeriah:dynspawns
Open

feat(Core/Maps): port spawn system/dynamic spawns from TrinityCore#25206
Nyeriah wants to merge 2 commits intoazerothcore:masterfrom
Nyeriah:dynspawns

Conversation

@Nyeriah
Copy link
Copy Markdown
Member

@Nyeriah Nyeriah commented Mar 24, 2026

Changes Proposed:

This PR proposes changes to:

  • Core (units, players, creatures, game systems).
  • Scripts (bosses, spell scripts, creature scripts).
  • Database (SAI, creatures, etc).

Ports TrinityCore's spawn group system to AzerothCore, enabling logical grouping of creature and gameobject spawns with per-group control over respawn behavior.

Key changes:

  • New tables: spawn_group_template (group definitions with flags) and spawn_group (creature/GO membership)
  • ProcessRespawns(): Non-compatibility mode respawn scheduler in Map::Update() — creatures are fully removed on death and recreated fresh by the scheduler when their timer expires
  • Compatibility mode: All existing spawns default to group 0 with SPAWNGROUP_FLAG_COMPATIBILITY_MODE, preserving current behavior. A Respawn.ForceCompatibilityMode worldserver config allows forcing all spawns to use legacy behavior regardless of group flags
  • GM commands: .list respawn (show pending respawns on current map), .respawn all (force-respawn everything on the map), .npc spawngroup / .go spawngroup (show spawn group info)
  • SAI integration: SMART_ACTION_SPAWN_SPAWNGROUP and SMART_ACTION_DESPAWN_SPAWNGROUP for script-driven spawn group control
  • Grid loader awareness: Skips non-compat spawns with pending respawn times during grid loading
  • Reload command: .reload spawn_group to hot-reload group data

AI-assisted Pull Requests

Important

While the use of AI tools when preparing pull requests is not prohibited, contributors must clearly disclose when such tools have been used and specify the model involved.

  • AI tools (e.g. ChatGPT, Claude, or similar) were used entirely or partially in preparing this pull request. Claude Code (Claude Opus 4.6) was used to assist with porting, adapting, and debugging the implementation.

Issues Addressed:

  • Closes N/A — this is a new feature port

SOURCE:

The changes have been validated through:

  • The changes promoted by this pull request come partially or entirely from another project (cherry-pick). Cherry-picks must be committed using the proper --author tag in order to be accepted, thus crediting the original authors, unless otherwise unable to be found

Based on TrinityCore commit 59db2eee by r00ty-tc, adapted for AzerothCore's codebase (different DB access patterns, LoadCreatureFromDB signatures, existing dynamic respawn system, config framework, etc.)

Tests Performed:

This PR has been:

  • Tested in-game by the author.
  • Tested in-game by other community members/someone else other than the author/has been live on production servers.
  • This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  • This pull request requires further testing. Provide steps to test your changes.
  1. Apply the SQL updates and rebuild the worldserver
  2. Set Respawn.ForceCompatibilityMode = 0 in worldserver.conf to enable the new system
  3. Kill a creature in the open world and observe: the corpse should decay, the creature should be fully removed, then respawn fresh after the respawn timer
  4. Use .list respawn to verify creatures appear in the pending respawn list with correct timers
  5. Use .respawn all to force immediate respawn of all pending creatures/GOs on the map
  6. Verify .npc spawngroup and .go spawngroup show correct group info for targeted spawns
  7. Set Respawn.ForceCompatibilityMode = 1 and verify legacy corpse-stays-on-map behavior is restored

Known Issues and TODO List:

  • Spawn group data tables (spawn_group_template, spawn_group) ship with only default groups — individual creature/GO assignments to custom groups need to be populated by future DB PRs
  • Instance/boss spawn group integration (e.g. toggling boss-related spawn groups on encounter state changes) is scaffolded but not yet wired to specific encounters
  • Edge cases with phasing and cross-grid respawns may need further testing

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 24, 2026 22:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports TrinityCore’s spawn group system into AzerothCore to allow grouping spawns (creatures/gameobjects) with per-group activation and respawn behavior, including a non-compatibility respawn scheduler and admin/SAI controls.

Changes:

  • Added spawn group template/member loading in ObjectMgr, plus map-level spawn/despawn toggling and a periodic Map::ProcessRespawns() scheduler.
  • Added GM/admin commands for listing pending respawns, forcing respawns, reloading spawn group tables, and spawning/despawning groups.
  • Added config toggles for forcing legacy respawn behavior and (documented) escort NPC dynamic respawn behavior, plus initial SQL tables.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/server/scripts/Commands/cs_reload.cpp Adds .reload spawn_group command to hot-reload spawn group data
src/server/scripts/Commands/cs_npc.cpp Adds .npc spawngroup / .npc despawngroup commands
src/server/scripts/Commands/cs_misc.cpp Extends respawn-all logic to also clear non-compat pending respawns
src/server/scripts/Commands/cs_list.cpp Adds .list respawns to show pending creature/GO respawn timers
src/server/scripts/Commands/cs_gobject.cpp Adds .go spawngroup / .go despawngroup commands
src/server/game/World/WorldConfig.h Adds new config keys for spawn/respawn behavior
src/server/game/World/WorldConfig.cpp Registers new config values
src/server/game/World/World.cpp Loads spawn group templates and members during server startup
src/server/game/Maps/SpawnData.h Adds compatibility flag, per-spawn spawnId, and mapId changes for group templates
src/server/game/Maps/Map.h Adds spawn group APIs, respawn processing, and respawn-time accessors
src/server/game/Maps/Map.cpp Implements group activation, spawn/despawn, and periodic respawn processing
src/server/game/Grids/GridObjectLoader.cpp Skips loading spawns whose spawn group is inactive
src/server/game/Globals/ObjectMgr.h Adds spawn group load APIs and group-to-spawn lookup storage
src/server/game/Globals/ObjectMgr.cpp Implements spawn group template/member DB loading and bookkeeping
src/server/game/Entities/GameObject/GameObject.h Tracks per-GO compatibility mode flag
src/server/game/Entities/GameObject/GameObject.cpp Sets GO compatibility mode from spawn group flags/config
src/server/game/Entities/Creature/Creature.h Tracks per-creature compatibility mode flag
src/server/game/Entities/Creature/Creature.cpp Changes corpse removal/respawn behavior for non-compat mode and sets compatibility mode on load
src/server/game/AI/SmartScripts/SmartScriptMgr.h Adds params struct for spawn group SAI actions
src/server/game/AI/SmartScripts/SmartScriptMgr.cpp Enables SAI validation/param sizing for spawn group actions
src/server/game/AI/SmartScripts/SmartScript.cpp Implements SAI actions to spawn/despawn spawn groups
src/server/game/AI/ScriptedAI/ScriptedEscortAI.h Marks escort AI as escort NPC via new virtual
src/server/game/AI/CreatureAI.h Adds virtual IsEscortNPC() hook
src/server/database/Database/Implementation/WorldDatabase.h Adds prepared statement id for deleting spawn group members
src/server/database/Database/Implementation/WorldDatabase.cpp Prepares DELETE FROM spawn_group ... statement
src/server/apps/worldserver/worldserver.conf.dist Documents/configures new respawn toggles
data/sql/updates/pending_db_world/rev_spawn_group_tables.sql Adds initial spawn_group_template and spawn_group tables with defaults
Comments suppressed due to low confidence (1)

src/server/scripts/Commands/cs_misc.cpp:1

  • PR description says .respawn all 'force-respawn everything on the map', but this implementation only clears respawn times for the player's current grid ID (and the phase-1 visit is limited to activation range). If the intended behavior is truly 'entire map', remove the grid filter and iterate all respawn times / loaded grids accordingly; otherwise, clarify the command behavior in the PR description/help text.
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TheSCREWEDSoftware
Copy link
Copy Markdown
Contributor

Would close this #23824 ? or TC implementation is not the same as cmangos?

Currently this issue would be by this implemantion (not the pr itself) if the above is the same for TC and Cmangos

#22095 (comment)

@Nyeriah Nyeriah changed the title feat(Core/Maps): port spawn group system from TrinityCore feat(Core/Maps): port object life cycle system/dynamic spawns from TrinityCore Mar 24, 2026
@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Mar 24, 2026

Would close this #23824 ? or TC implementation is not the same as cmangos?

Currently this issue would be by this implemantion (not the pr itself) if the above is the same for TC and Cmangos

#22095 (comment)

No, completely different stuff

@github-actions github-actions bot added DB related to the SQL database CORE Related to the core Script Refers to C++ Scripts for the Core file-cpp Used to trigger the matrix build labels Mar 24, 2026
@Rorschach91 Rorschach91 added the Requires WIKI Update Wiki sources will need to be updated after merging this PR. label Mar 26, 2026
@killerwife
Copy link
Copy Markdown
Contributor

Just gonna put a dump here, since you are porting the (now known to be wrong) TC spawn group system:

wowedit_1024

This is leaked wowedit picture of spawn groups. (the name means a very specific thing on B end)

Spawning or not spawning is governed by these:

https://wowdev.wiki/DB/WorldStateExpression

https://gist.github.com/killerwife/20a822b785944dcb10cffc4018b5f48d here is a list of "leaked" ones couple years back

Relevant to the topic from https://wowdev.wiki/EnumeratedString:

JoinSummonersSpawnGroup = 9,

enum Unknown_867 => linkage is meant to be fully replaced by spawn group behaviour

An event for spawn group exists for scripting:

OnSpawnGroupDeath or something similar, essentially when last member dies it triggers (used all over vanilla and tbc for example)

Use this information as you wish, not saying my implementation is strictly correct from official standpoint, but unlike TC one it does incorporate these leaks.

@Nyeriah
Copy link
Copy Markdown
Member Author

Nyeriah commented Mar 29, 2026

Thanks for sharing! I don't plan to stray too far from the TC implementation but hopefully someone else can pick it up later

@Nyeriah Nyeriah changed the title feat(Core/Maps): port object life cycle system/dynamic spawns from TrinityCore feat(Core/Maps): port spawn system/dynamic spawns from TrinityCore Mar 29, 2026
-- Insert default spawn groups
DELETE FROM `spawn_group_template` WHERE `groupId` IN (0, 1);
INSERT INTO `spawn_group_template` (`groupId`, `groupName`, `groupFlags`) VALUES
(0, 'Default Group', 0x01), -- SYSTEM (dynamic respawn by default)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be numeric values 1 and 3 even if it's a flag?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its in hex

…ty queue

Port TrinityCore's spawn group system to AzerothCore, enabling dynamic
respawn management for creatures and gameobjects. Adds pool-aware
ProcessRespawns() that delegates pooled spawns to PoolMgr, a time-ordered
priority queue (based on TC commit 59db2eee by r00ty-tc) for O(1) idle
cost, .pool info/.pool lookup debug commands, spawn/despawn group
commands, and .list respawns. Prevents .respawn all from creating
duplicate pool spawns. Includes full localization for all 8 supported
locales and SQL migrations.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE Related to the core DB related to the SQL database file-cpp Used to trigger the matrix build Ready to be Reviewed Requires WIKI Update Wiki sources will need to be updated after merging this PR. Script Refers to C++ Scripts for the Core Waiting to be Tested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants