Files
ForeverCore/src/modules
Karrz1 5fb0a86de7 BWL Nefarian: the area-damage casters take the Bone Constructs
The encounter hands every second caster the Bone Constructs (a Priority
row for Who::AoeShare, value 8: they clear them with area spells while the
rest burn Nefarian). The Nefarian fight script took every DPS bot,
those casters too, and gave them all its single focus, so the row never
counted.

sweep 1111e: at 20% Nefarian raised 29-41 Bone Constructs. After the rise
the DPS started 122 attacks on Nefarian and 28 on the constructs; the
constructs walked into the healers and casters and killed 20-25 raiders
in 40-55 s, and both runs wiped with Nefarian at 3% and 9%.

A bot that a Who::AoeShare row matches is left to the generic rules while
an enemy of that row is up, so the row's target and the area spells win
over the script's focus. Only the Bone Construct row uses Who::AoeShare.

(cherry picked from commit c0df04512c190218e8194b2b8e9b0d76004e50c7)
2026-11-11 23:38:05 +00:00
..
…

Optional modules

A module is a folder in src/modules/ with its own CMakeLists.txt. It is built into the worldserver without changing core files: the core only offers ScriptMgr hooks, and the module registers scripts for the ones it needs. With no module folder (or every module switched off), AddModuleScripts() is empty and the server is the same as without this system.

Layout

src/modules/MyModule/
    CMakeLists.txt
    MyModuleScripts.cpp     # AddSC_my_module(): registers the module's scripts
    conf/my_module.conf.dist

CMakeLists.txt

option(BUILD_MY_MODULE "Build the MyModule module" 0)
if(NOT BUILD_MY_MODULE)
  return()
endif()

CollectSourceFiles(${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES)
add_library(my-module STATIC ${PRIVATE_SOURCES})
target_link_libraries(my-module
  PRIVATE
    trinity-core-interface
  PUBLIC
    game-interface)

trinity_add_module(my-module AddSC_my_module
  CONFIGS
    ${CMAKE_CURRENT_SOURCE_DIR}/conf/my_module.conf.dist)

trinity_add_module(<library> <loader> [CONFIGS <files>]) links the library into the worldserver, calls the loader function from AddModuleScripts() (after the core scripts) and copies the config files to worldserver.conf.d/. Like worldserver.conf.dist, a copied .conf.dist is only read after it is renamed to .conf; the file must start with a section header such as [my_module].

Scripts

The loader registers scripts the same way as an AddSC_ function in src/server/scripts:

class my_module_world : public WorldScript
{
public:
    my_module_world() : WorldScript("my_module_world") { }
    void OnWorldInitialized() override { /* load data, before the realm is online */ }
    void OnBeforeMapsUpdate(uint32 diff) override { /* every world tick, before the maps update */ }
};

void AddSC_my_module()
{
    new my_module_world();
}

Hooks marked "map thread" in ScriptMgr.h can run on several map update threads at once; a module that keeps shared state in them has to lock it.

Database

Modules apply their own SQL (for example a migration step in OnWorldInitialized, or files the server owner applies by hand); the core database updater only handles sql/updates and sql/custom.