Skip to main content

Mob script structure

Mob scripts live in the mobs/ subdirectory of a zone folder. A mob script file returns a local entity table with handler functions and configuration tables.

Mob handler reference

Placeholder (PH) and lottery NM system

The PH system uses entity.phList and xi.mob.phOnDespawn to spawn lottery NMs when a placeholder mob dies.

phList format

Hooking phOnDespawn

In the placeholder mob’s own script or in Zone.lua, call xi.mob.phOnDespawn from the placeholder’s onDespawn:

NM spawn point randomization

When entity.spawnPoints is defined, the framework calls xi.mob.updateNMSpawnPoint automatically on the NM’s pop to choose a random position from the table. You can also call it manually or supply an override table:

Global mob death hook

scripts/globals/mobs.lua defines xi.mob.onMobDeathEx, which is called by the core for every mob death:

Mob entity API

The mob object is a CBaseEntity (same as players and NPCs) with additional mob-specific methods:

Mob skills

Mob skill scripts live in scripts/actions/mobskills/. They are linked to mobs through the SQL mob_skill_lists table rather than in the Lua file itself.

SQL relationship

Mob behavior is driven by two key SQL tables: The Lua entity table in mobs/ supplements and overrides these SQL values for named mobs and NMs.
For placeholder NMs, the NM’s mob ID is always the last entry in the phList value (not a key). Placeholder IDs are the keys.