From d2b6e83ef5ac615b7254f50c08d9d15d6e7e91cd Mon Sep 17 00:00:00 2001 From: James Huston Date: Mon, 8 Dec 2025 21:21:51 -0500 Subject: [PATCH] feat(mcp): Add 'npc reload ' command Despawns and respawns all creatures of given entry within 500 yards. Useful for picking up database changes without full server restart. --- src/araxiaonline/mcp/ServerTools.cpp | 51 +++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/araxiaonline/mcp/ServerTools.cpp b/src/araxiaonline/mcp/ServerTools.cpp index 1c3fa106ce..78ba64fbff 100644 --- a/src/araxiaonline/mcp/ServerTools.cpp +++ b/src/araxiaonline/mcp/ServerTools.cpp @@ -447,12 +447,61 @@ void RegisterServerTools() } } + // Handle: npc reload - Force respawn all creatures of entry to pick up DB changes + else if (cmd == "npc") + { + std::string subcmd; + iss >> subcmd; + + if (subcmd == "reload") + { + uint32 entry = 0; + iss >> entry; + + if (entry > 0) + { + // Reload specific creature entry - despawn and respawn all with this entry + Map* map = player->GetMap(); + if (!map) + return {{"success", false}, {"error", "Player not on valid map"}}; + + uint32 count = 0; + + // Find all creatures with this entry on the map and force respawn + std::list creatures; + Trinity::AllCreaturesOfEntryInRange check(player, entry, 500.0f); + Trinity::CreatureListSearcher searcher(player, creatures, check); + Cell::VisitAllObjects(player, searcher, 500.0f); + + for (Creature* creature : creatures) + { + creature->DespawnOrUnsummon(0ms, 1s); + count++; + } + + return { + {"success", true}, + {"command", "npc reload"}, + {"entry", entry}, + {"despawned", count}, + {"message", "Creatures will respawn in 1 second with updated DB settings"} + }; + } + else + { + return {{"success", false}, {"error", "Usage: npc reload "}}; + } + } + + return {{"success", false}, {"error", "Usage: npc reload "}}; + } + // Unknown command return { {"success", false}, {"error", "Unknown or unimplemented command"}, {"command", cmd}, - {"supported", {"go xyz", "tele", "gps", "additem", "die", "revive", "aura", "unaura", "learn", "unlearn", "respawn"}} + {"supported", {"go xyz", "tele", "gps", "additem", "die", "revive", "aura", "unaura", "learn", "unlearn", "respawn", "npc reload"}} }; } );