This page explains how VMaNGOS decides which AI controls a creature, and how the
ai_name and script_name columns of creature_template interact with the built-in AI classes.
The selection logic is implemented in FactorySelector::selectAI
(src/game/AI/CreatureAISelector.cpp) and runs once when a creature spawns.
Registered in AIRegistry::Initialize() (src/game/AI/CreatureAIRegistry.cpp):
ai_name value |
Class | Purpose |
|---|---|---|
| (empty) | see selection order below | Let the core decide automatically |
EventAI |
CreatureEventAI |
Table-driven AI using creature_ai_events / creature_ai_scripts. The most common choice for custom content. |
BasicAI |
BasicAI |
Generic combat AI without scripted behaviour. |
CritterAI |
CritterAI |
Passive critters (rats, birds); flees when attacked. |
GuardAI |
GuardAI |
City guards: attack players with negative reputation/flagged status. |
PetAI |
PetAI |
Controlled pets (hunter/warlock pets). |
TotemAI |
TotemAI |
Totems: cast a single spell on spawn. |
NullAI |
NullCreatureAI |
Does nothing at all (also used for mind-controlled creatures). |
PetEventAI |
PetEventAI |
EventAI variant for pets/guardians - same tables, pet-safe actions. |
GuardEventAI |
GuardEventAI |
EventAI variant for guards - same tables, guard behaviour. |
Note:
ScriptedAI, escort/follower AI and instance scripts are C++ scripts, notai_namevalues. They are selected through thescript_namecolumn instead.
When a creature spawns, the first matching rule wins:
- Player-possessed creature (mind control) →
NullCreatureAI. The player drives the body; no AI interference. script_namematch - For normal creatures (not controlled pets, not charmed), ifcreature_template.script_name matches a C++ script registered by the script library, that AI is used. This overrides everything below.- Controlled pet or charmed creature →
PetAI. - Totem →
TotemAI. ai_name = "EventAI"on a pet →PetEventAI; on a guard →GuardEventAI. (Prevents table-driven AI from breaking pet/guard behaviour.)ai_namelookup - any other non-emptyai_nameis looked up in the registry above.- Guard flag →
GuardAI. - Creature type = critter →
CritterAI. - Permit-based pick - remaining AIs are asked how well they suit the creature (
Permissible): generic AIs answerPERMIT_BASE_NORMAL(100), special-purpose onesPERMIT_BASE_SPECIAL(200), unsuitable onesPERMIT_BASE_NO(-1). Highest score wins. - Fallback →
NullCreatureAI.
- Custom scripted NPCs: prefer
EventAI+creature_ai_events. Usescript_nameonly for behaviour that exists as a C++ script insrc/scripts. - Pets with EventAI events: set
ai_name = "EventAI"and let rule 5 upgrade it toPetEventAI; setting it explicitly toPetEventAIalso works. - Completely static NPCs (decorations, props): leave
ai_nameempty or useNullAIto save CPU. An emptyai_nameresolves toBasicAIvia permit scoring.
- creature_ai_events - event triggers for EventAI
- creature_ai_scripts - actions executed by EventAI events
- DB Script Tables - the command set available to EventAI actions
- creature_template -
ai_name/script_namecolumns