Model Hierarchy

Quick link to the external model hierarchy documentation: Model Hierarchy

The model hierarchy provides script with a mechanism to query and browse game objects. Model hierarchy objects that represent game entities such as factions, regions or military forces may be accessed by script, usually through event contexts. Each model hierarchy object provides an interface on which calls may be made to query that object. For example, a faction may be queried to determine its name, a settlement may be queried to determine its position, or a military force may be queried to determine its current stance.

In many cases objects may also be queried to access related objects. For example, each faction object provides a faction_leader method which can be called to return a character object representing the faction leader character of that faction. This character object can then be queried like any other character object, including being asked for other related objects such as the military force commanded by the character or the region the character is stood in.

A list of model hierarchy interfaces is given further down this page. To see the list of functions they each provide, visit the external documentation. Each interface section on this page provides a link to the relevant section of the external model hierarchy documentation.

In most circumstances the model hierarchy is read-only. Changes to the game cannot be made through model hierarchy functions - see the episodic_scripting interface for a list of code-provided functions that can effect changes the game model. Certain exceptions exist, such as the modify-ritual interfaces.

The following image illustrates many of the main objects provided by the model hierarchy and how they link together. It is by no means authoritative! See the further down this page, or external documentation, for a full list.

loaded in campaign

Loaded in Campaign Loaded in Campaign
Loaded in Battle Loaded in Battle
Loaded in Frontend Loaded in Frontend
Back to top

Accessing the Model Hierarchy

The model hierarchy is accessed mainly through event contexts. When an event is triggered by the campaign model it provides a context object to any listener scripts that gets called. This context object can provides one or more objects within the model hierarchy, each of which represent objects in the game such as a faction, a settlement, or a character. For example, the context of the FactionTurnStart event provides a faction object representing the faction that is starting its turn, whereas the CharacterLootedSettlement object provides both a character and settlement object.

A list of events and what methods the related context object provides can be found in the external model hierarchy documentation. A list of the various objects that the model hierarchy provides is also given further down this page.

As well as accessing through event contexts, the model script interface which underpins the rest of the model hierarchy may also be accessed at any time by calling cm:model on the episodic_scripting interface.

Example - Accessing the model hierarchy through the FactionTurnStart event:

core:add_listener(
    "example_faction_turn_start_listener",
    "FactionTurnStart",
    true,
    function(context)
        -- access the faction starting its turn
        local faction = context:faction();
        
        -- retrieve a character script interface representing the faction's leader
        local faction_leader = faction:faction_leader();
        
        -- output some information about the faction starting its turn and the location of the faction leader
        out("* faction " .. faction:name() .. " is starting its turn, faction leader is at [" .. faction_leader:logical_position_x() .. ", " .. faction_leader:logical_position_y() .. "]");
    end,
    true
);
faction wh3_main_ksl_the_ice_court is starting its turn, faction leader is at [418, 118]

Example - Accessing the model directly:

local model = cm:model();
out("There are currently " .. model:world():faction_list():num_items() .. " factions in the game");
There are currently 108 factions in the game
Back to top

Object Imperminence

Objects retrieved from the model hierarchy in script are imperminent should not be stored for reference later in time. The game reserves the right to delete objects from memory from time to time, so a model hierarchy object stored over time may find itself invalidated. It is safe to use an object reference taken as a local variable on the tick on which it was taken, unless something happens on that tick to invalidate it (e.g. taking a character reference and then killing it - the character reference is no longer safe to use).

If it is required to access a model hierarchy object over time, then a permanent reference by which the object may be looked up should be stored in place of the object itself. This is often the command-queue index (a unique id for each object of a certain type) but can be a string key.

Example - Bad script that tries to use a reference to an object over time:

This script may work some of the time, but is not safe and will cause intermittent failures on some machines.
-- get a faction
local faction = cm:get_faction("wh_main_emp_empire")
out("The Empire have " .. faction:num_allies() .. " allies")

randomise_alliances()

-- wait one second, and try and re-access faction (BAD)
cm:callback(
    function()
        out("After randomising alliances, The Empire have " .. faction:num_allies() .. " allies")
    end,
    1
)

Example - Good script that looks up the faction by key each time it's used over time:

-- get a faction
local faction_key = "wh_main_emp_empire"
local faction = cm:get_faction(faction_key)
out("The Empire have " .. faction:num_allies() .. " allies")

randomise_alliances()

-- wait one second, look up the faction again from its key and use the new reference (GOOD)
cm:callback(
    function()
        local faction = cm:get_faction(faction_key)
        out("After randomising alliances, The Empire have " .. faction:num_allies() .. " allies")
    end,
    1
)

Active Ritual List

A list of active_ritual script interfaces. This list is mainly accessed from the faction_rituals script interface.


Active Ritual

The active ritual interface represents a ritual, previously cast by a faction, that is currently still active.


Armory

The armory script interface is owned by the family_member script interface, and grants a way to get armory information for that family member.


Bonus Values

The bonus values script interface provides access to bonus values for a campaign object such as a character, faction or faction_province_manager.


Building List

A list of building script interfaces. This is accessible from the garrison_residence script inteface.


Building Base

A building base script interface represents the base class of buildings constructed in slot, foreign_slot or military_force_slot containers.


Building

A building script interface represents a building constructed in a slot within a settlement.


Campaign AI

The campaign AI script interface provides functionality related to AI systems. It is accessible from the model script interface.


Campaign Dilemma Builder

A campaign dilemma builder provides an interface for building campaign dilemmas in script. An object of this type may is returned when the episodic scripting function cm:create_dilemma_builder is called.


Campaign Incident Builder

A campaign incident builder provides an interface for building campaign incidents in script. An object of this type may is returned when the episodic scripting function cm:create_incident_builder is called.


Campaign Mission

A campaign mission script interface represents an active mission in campaign. Not currently used.


Campaign Payload Builder

The campaign payload builder facilitates construction of payloads in script. Payloads are rewards given for completion of missions, incidents and dilemmas. A payload builder can be created by calling cm:create_payload, and is currently used to provide payload setup to a campaign_dilemma_builder.

CAMPAIGN_PAYLOAD_BUILDER_SCRIPT_INTERFACE

Caravans System

An interface to the caravan system, provided by the world script interface.


Caravan List

A list of caravan script interfaces. Such lists are provided by the faction_caravans script interface.


Caravan Recruitment Item List

A list of caravan_recruitment_item script interfaces. Provided by the faction_caravans script interface.


Caravan Recruitment Item

A caravan recruitment item represents a caravan master that can be recruited. It is found within the caravan_recruitment_item_list provided by the faction_caravans script interface.


Caravan

An interface representing a caravan on the campaign map. These are provided by caravan-related events, and found within caravan_list list interfaces such as those provided by the faction_caravans interface.


Character Details List

A list of character_details script interfaces. Each character_details script interface is a persistent reference to a character.


Character Details

A character details interface is a persistent interface related to character. While the character interface related to an immortal character in game can be destroyed and recreated with a new command-queue-index value, the related character_details interface does not change cqi.


Character Imprisonment Rejection Reason Mask

An interface that can be queried to determine why a character imprisonment failed.


Character Initiative List

A list of initiative script interfaces. This list is mainly accessed from the initiative_set script interface which is owned by a character.


Character Initiative

A character initiative provides effects over a duration. They are closer in behaviour to skills than effect bundles, and empower the Ogre Kingdoms Big Names feature. Character initiatives are returned by related events and can be ultimately accessed through character interfaces via initiative_set and initiative_list script interfaces.


Character Initiative Set List

A list of initiative_set script interfaces, accessible from the character_details script interface.


Character Initiative Set

A character initiative set is a collection of related initiative objects. Sets can be accessed from the character_details script interface.


Character Initiative Status

A character initiative status represents a snapshot of the status of a initiative. Such objects can be returned by a initiative_set interface.


Character List

A list of character script interfaces.


Character Observation Options

Observation options govern what level of information is shown during the end-turn sequence. A character observation options interface represents a type of this information, either regarding all allies, all enemies, all neutrals or a specific faction. Interfaces of this type can be retrieved by calling certain functions on the world script interface.


Character

The character script interface represents a character in campaign. This is a key interface which is provided by many events and other interfaces in the model hierarchy.

CHARACTER_SCRIPT_INTERFACE

Cooking Dish

The cooking dish interface represents a dish within the cooking system. It is provided by the FactionCookedDish script event and from the faction_cooking_info script interface.


Cooking System

This top-level cooking system interface is accesible from the world script interface.


Custom Effect Bundle

The custom effect bundle interface allows customisation of an existing effect bundle record. The record must be defined in the effect_bundles database table.


Debug Drawing

An interface providing some functionality to draw debug lines. This object will not be available in the retail version on the game.


Effect Bundle List

A list of effect_bundle interfaces.


Effect Bundle

An effect bundle is a collection of effect modifiers, and can be applied to many types of game objects.


Effect List

A list of effect interfaces.


Effect

An effect that provides bonus values via a scope. These can be applied to game objects to produce in-game modifications, usually via an effect_bundle.


Faction Caravans

The faction caravans interface provides access to caravan objects owned by a faction. Such objects are returned by the caravans_system script interface.


Faction Character Tagging System

The faction character tagging system is a method for one faction to tag characters, to which effects are applied. This is used to empower the Gift of Slaanesh feature. This interface is accessed from the world interface.


Faction Character Tag Entry List

A list of faction_character_tag_entry interfaces.


Faction Character Tag Entry

A faction character tag entry represents a tag attached to a character. It is returned by character tagging events and by the faction_character_tagging_system interface.


Faction Cooking Info

Provides information related to a the cooking status of a faction. Such objects are retrieved from the cooking_system interface.


Faction List

A list of faction interfaces.


Faction Plague

The faction plague interface provides details of which plague components are available to a faction.


Faction Province Manager List

A list of faction_province_manager interfaces.


Faction Province Manager

A faction province manager interface provides an interface to the portion of a province that a particular faction owns.


Faction Rituals

The faction rituals interface provides access to lists of rituals associated with a faction.


Faction

The faction script interface represents an in-game faction. This is a key interface and is provided by many events and other interfaces.

FACTION_SCRIPT_INTERFACE

Family Member List

A list of family_member interfaces.


Family Member

The family member script interface represents a character within a family tree. This interface is persistent, even if the related character is destroyed and recreated.


Foreign Slot List

A list of foreign_slot interfaces.


Foreign Slot Manager List

A list of foreign_slot_manager interfaces.


Foreign Slot Manager

A foreign slot manager has ownership of all foreign_slot objects for a faction within a settlement/region. A manager is returned by the various foreign-slot-related events, and from the region script interface.


Foreign Slot

A foreign slot is a building slot owned by a faction in a foreign settlement. This underpins mechanics such as Chaos Cults and Skaven Under-Empires. A foreign slot is owned by a foreign_slot_manager.


Garrison Residence

The garrison residence script interface represents the garrison residence within a settlement. It can be queried to determine information about any military_force present within the garrison, or the siege status of the settlement. There is only one settlement/garrison residence in each region.


Horde Details

The horde details script interface represents the horde aspect of a military force that belongs to a horde faction. The horde details script interface can be queried for military_force_slot objects related to the military force/horde.


Main Unit Record

The main unit record data of a unit.


Military Force List

A list of military_force interfaces.


Military Force

A military force interface represents any army or navy on the campaign map, including garrison armies. This is a key interface.


Military Force Slot

A military force slot interface represents a building slot within a horde-type military_force.


Military Force Slot List

A list of military_force_slot interfaces.


Military Force Type

Represents a military_force type record.


Model

The model script interface is the root object of the model hierarchy. It is accessible from many other objects, and can be accessed at any time by calling cm:model.


Modify Ritual Performing Character List

A list of modify_ritual_performing_character interfaces.


Modify Ritual Performing Character

A modifiable performing character for a modifiable ritual. The character performing the ritual may be queried and replaced with this interface. A modify_ritual_performing_character_list of such character interfaces may be retrieved from a modify_ritual_setup interface.

This interface is a mutable relative of ritual_performing_character.


Modify Ritual Performing Character

A modifiable ritual interface, which may be used to customise a ritual in script. An object with this interface may be created by calling cm:create_new_ritual_setup, or the clone_as_modify_interface function on the ritual_setup script interface.

Once a ritual has been sufficiently modified, it may be passed in to cm:perform_ritual_with_setup to be performed.


Modify Ritual Target

A modifiable target for a modifiable ritual. The target of the ritual may be queried and replaced with this interface. An object with this interface may be retrieved from the modify_ritual_setup interface.


Null Script Interface

An empty interface, returned in situations where a requested interface doesn't exist.


Observation Options

Observation options represent choices made about the amount of information shown to the local player during the end-turn sequence. Observation options objects can be retrieved from the world interface, modified, and then applied with the episodic_scripting interface - see the Character Observation Options section of this documentation.


Pending Battle

The pending battle script interface represents a currently-active battle sequence. The battle may or may not have taken place yet. A pending battle object may be retrieved from various battle-related script events and from the model interface.


Plague

The plague script interface represents a plague spread between military forces and regions.


Plague component

The plague component script interface represents the components that make up a plague.


Plague component list

A list of plague_component interfaces.


Pooled Resource Factor List

A list of pooled_resource_factor interfaces.


Pooled Resource Factor

A pooled resource factor is a means by which a pooled resource may be modified. These are listed in the pooled_resource_factors database table.


Pooled Resource List

A list of pooled_resource interfaces.


Pooled Resource Manager

A pooled resource manager links pooled_resource objects to an something which they can be applied to, such as a faction, military_force or province.


Pooled Resource

A pooled resource script interface represents a pooled resource, a design-driven currency of some kind like Oathgold, Grimoires, Skulls etc. Valid pooled resources are listed in the pooled_resources database table. A pooled resource belongs to a pooled_resource_manager, which is itself linked to some game object like a faction or character to which the pooled resource is associated.


Prison System

The top-level interface for the prison system. An object of this type can be accessed from the model script interface.


Province List

A list of province interfaces.


Province

A province script interface represents a province on the campaign map, containing one or more regions represented by region script interfaces. The portion of a province that a faction controls is represented by a faction_province_manager script interface.


Region Data List

A list of region_data interfaces.


Region Data

A region data represents the base data for a region on the campaign map. This may or may not be represented by a region or sea_region.


Region List

A list of region interfaces.


Region Manager

The region manager is a top-level object which provides information about regions and settlements on the campaign map.


Region

A region interface represents a region on the campaign map. A region is the land area associated with a settlement, and there are one or more regions within each province. The region script interface is a key interface, and is provided by many different script events and other interfaces.

Each region is associated with a region_data script interface, which are also linked to sea_region interfaces.


Resource Transaction

The resource cost of a transaction. Currently associated with an active_ritual interface, indicating the cost of that ritual when performed.


Ritual Performing Character List

A list of ritual_performing_character interfaces.


Ritual Performing Character

A character performing a ritual. This is related to modify_ritual_performing_character, but this interface is immutable. A ritual_performing_character_list of such interfaces may be obtained from a ritual_setup interface.


Ritual Performing Character Status

The validity status of a ritual_performing_character performing a ritual.


Ritual Setup

An unmodifiable interface representing the setup of a ritual. See also modify_ritual_setup.


Ritual Status

An unmodifiable interface representing the status of a ritual. An object of this interface can be obtained from the faction_rituals interface.


Ritual Target Faction Status

An unmodifiable interface representing the status of a faction that's the target of a ritual. This interface is a child of the modify_ritual_target and ritual_target interfaces.


Ritual Target Military Force Status

An unmodifiable interface representing the status of a military_force that's the target of a ritual. This interface is a child of the modify_ritual_target and ritual_target interfaces.


Ritual Target Region Status

An unmodifiable interface representing the status of a region that's the target of a ritual. This interface is a child of the modify_ritual_target and ritual_target interfaces.


Ritual Target

An unmodifiable interface representing the target of a ritual. This is an immutable version of modify_ritual_target. Objects of this type may be obtained from the active_ritual and ritual_setup interfaces.


Route Network

An interface representing a network of nodes, as the Caravans network for Cathay. An object with this interface may be obtained by calling the lookup_route_network function on the world interface. A list of route networks may be found in the campaign_map_route_networks database table.


Route Node List

A list of route_node interfaces.


Route Node

An interface representing a node in a route_network.


Route Path

An interface representing the path a caravan is taking through a route_network.


Route Position

An interface representing the position of a caravan alongh a route_path. Objects with this interface are supplied by caravan-related script events and the caravan and route_node interfaces.


Route Segment List

A list of route_segment interfaces.


Route Segment

An interface representing a link between two route_node objects on a route_network.


Sea Region List

A list of sea_region interfaces.


Sea Region Manager

A central interface which can be queried for information about sea_region entities in the game. This interface can be accessed from the world script interface.


Sea Region

An interface representing a region of sea. This is linked to a region_data interface.


Settlement

A settlement interface represents a settlement on the campaign map. It is most-commonly accessed through the region interface, and is also related to the garrison_residence interface.


Shared States Manager

A central interface, accessed through the model interface, which can be used to query shared state values. Shared state values are accessible by the campaign model, UI and script, and can be used to empower functionality shared between all three. See also the Shared States section of the episodic_scripting documentation.


Slot List

A list of slot interfaces.


Slot

A slot interface represents a building slot in a settlement, within which a building may be constructed (or may already exist). It is related to the military_force_slot interface which represent a building slot within a horde-type military_force.


Teleportation Network List

A list of teleportation_network interfaces.


Teleportation Network

An interface representing a teleportation network, such as as network between the Realms of Chaos. Such an interface may be obtained from an teleportation_network_system object.


Teleportation Network System

A central interface to the teleportation network system, accessible from the world script interface.


Teleportation Node List

A list of teleportation_node interfaces.


Teleportation Node Record List

A list of teleportation_node_record interfaces.


Teleportation Node Record

A record related to a teleportation_node. Objects with this interface are returned by various teleportation-network-related script events.


Teleportation Node

An interface representing an active node on a teleportation_network.


Unique Agent Details List

A list of unique_agent_details interfaces.


Unique Agent Details

An interface representing the details of a unique agent, such as the Green Knight. A faction interface may be queried for a unique_agent_details_list of unique agents the faction contains. Furthermore, objects with this interface are returned by various unique-agent-related script events.


Unit List

A list of unit interfaces.


Unit Purchasable Effect List

A list of unit_purchasable_effect_list interfaces.


Unit Purchasable Effect

An interface that represents a unit purchasable effect. Objects with this interface are returned by the various unit-purchased-effect-related script events, and a unit_purchasable_effect_list of such interfaces is obtainable from the unit script interface.


Unit

An interface that represents a unit belonging to a military_force.


War Co-ordination

A central interface to access war co-ordination information. This interface is returned by the cm:war_coordination function on the episodic_scripting interface, which allows it to be mutable (changes to the model can be made through it).


Winds of Magic Compass

A central interface to access the compass system. This is accessible from the world script interface.


World

World is a central interface that provides access to a variety of other game objects. It is primarly accessible from the model interface.

Last updated 7/9/2024 11:45:04 AM