A list of the fields, values and actions you can use in event MODs. For the overall flow, see the "How Event Creation Works" page (tutorial); for detailed behavior, see the "Rules & Troubleshooting" page.
<MOD folder>/
mod.json
events.json ← optional. Read as an event file
events/
*.json ← event files
dialogues/
*.json ← dialogue files (any folder name; specified in dialogue.file)
Event files are read from the .json files directly under events/ and from events.json directly under the MOD folder. Subfolders inside events/ are not read.
Keep the number of files in events/ to 64 or fewer.
Write dialogue.file as the path seen from the MOD folder, separated by /. A leading /, .., drive names and \ cannot be used.
Save files in UTF-8. Comments, a comma after the last item, and full-width quotation marks cannot be used.
Whole file:
schemaVersion (required): 1
state (optional): declarations of records (Section 13)
events (required): array of events (up to 256 per file)
One event:
id (required): the event's name. Make it unique within the MOD
enabled (optional, default true): set to false to not use it
priority (optional, default 0): larger numbers are checked first. An integer from -1000000 to 1000000
trigger (required): the trigger (Section 3)
roles (optional): roles (Section 6)
repeat (optional, default always): repeat rules (Section 14). Write it as { "mode": "…" }
when (optional, default no restriction): start condition (Section 7)
dialogue (required): id, file, startRow (default Start)
onStart (optional): name of the action group to run when the dialogue starts
onComplete (optional): name of the action group to run when the dialogue ends with END
jumpConditions (optional): branches (Section 10)
actions (optional): action groups (Section 12)
talk_unit: when you talk to a character (target: the person you talked to, spot: the current territory)
enter_spot: when you enter a territory (spot: the territory entered)
enter_place: when you enter a place inside a territory. Combine with placeIds (spot: the current territory)
before_battle: the dialogue before a real-time battle (target: the representative of the opposing side)
after_battle: the dialogue after a real-time battle (target: the representative of the opposing side)
Narrowing fields (all optional):
units: only when the person is this character (or one of this group) (format in Section 5)
spots: only when you are in this territory (or one of this group) (format in Section 5)
placeIds: only when you are in this place. Matching any one entry in the array is enough
If you write several of units, spots, placeIds and when, the event starts only when all are met.
Events cannot start battles, and cannot replace duel dialogue.
field: outside a territory
none: no place
plaza: plaza
tavern: tavern
trade_shop: Trading Post
item_shop: Shop
guild: guild
palace: lord's manor
obelisk: Obelisk research facility
training_ground: training ground
farm: farm
security: restoring public order
wall: castle walls
wait: standby
leaving: leaving
This is how to specify characters and territories in units, spots, select in roles, query arguments and so on. There are four ways.
ref: specify by relationship to the player or the other person (e.g. { "ref": "player.father" })
ref + where: narrow a group reached by relationship with a condition (see the example below)
find: search by name (e.g. { "find": "unit", "name": { … } })
id/ids: when you know the in-game IDs (e.g. { "entity": "unit", "ids": ["…", "…"] })
player: the player
target: the other person this time (the person you talked to, the representative of the opposing side in battle)
spot: the territory this time
roles.role name: a character named in roles
XX.father/XX.mother/XX.spouse: father/mother/spouse (e.g. player.father, target.spouse)
XX.children: children (a group)
XX.country.ruler: the monarch of their country
XX.power.leader: the leader of their faction (countries and factions are different things)
XX.country.spots: the territories of their country (a group)
spot.lord: the lord of the territory this time
Put groups such as children and spots at the end.
Specifying a group does not decide a single speaker. To use someone as a speaker, use roles.
{
"ref": "player.country.ruler.children",
"where": { "var": "candidate.isDead", "op": "==", "value": false }
}
candidate is each candidate in turn. It can only be used inside where.
The format is the same as for conditions (Section 7).
children includes dead characters. To include only living ones, narrow it as above.
{ "find": "unit", "name": { "first": "John", "family": "Smith", "language": "en" } }
{ "find": "spot", "name": { "text": "Territory display name", "language": "en" } }
The name must match exactly. It is searched in the spelling of the language written in language, and is not translated automatically.
All characters with the same name are targets.
{ "entity": "unit", "ids": ["known_unit_id_1", "known_unit_id_2"] }
Use "id": "…" for one and "ids": […] for several. Separate fields such as trigger.unitIds cannot be used. Write them inside units/spots.
"roles": {
"client": { "select": { "ref": "target" }, "pick": "unique", "required": true }
}
select: specify a character in the format of Section 5
pick (default unique): unique: valid only when there is exactly one candidate. random_once: pick one candidate and keep them fixed during that dialogue
required (default true): true: do not start the event if not found. false: start even if not found (check that they exist before using them)
Only characters can be roles. Countries, factions and territories cannot.
A role's name is used as roles.role name in speakers, conditions and actions.
Roles cannot refer to each other.
Up to 32 roles per event.
One condition:
{ "var": "player.money", "op": ">=", "value": 100 }
var: the value to check (Section 9)
query + args: instead of var, check a relationship (Section 8)
owner: when reading a per-character or per-territory record, whose record it is
op: how to compare
value: compare with a fixed value
valueRef: compare with another value (cannot be written together with value)
Comparisons:
==/!=: equal / not equal
>/>=/</<=: greater / greater or equal / less / less or equal (numbers only)
in/not_in: matches any in an array / matches none (write an array of values of the same type in value)
Combinations:
{ "all": [ … ] }: all are met
{ "any": [ … ] }: at least one is met
{ "not": condition }: not met
Match the types (number, yes/no, text). Do not put numbers in quotation marks, like "100".
Empty all/any cannot be written.
Formulas, regular expressions and automatic conversion from text to numbers are not available.
Nesting up to 8 levels, and up to 256 conditions in one expression.
{
"query": "unit.impression",
"args": { "from": { "ref": "target" }, "to": { "ref": "player" } },
"op": ">=",
"value": 60
}
unit.hasTrait: arguments unit: character, traitId: trait ID → yes/no
unit.impression: arguments from, to: characters → number (Regard from from toward to)
unit.hasRevengeTarget: arguments from, to: one character each → yes/no (whether from regards to as a sworn enemy)
entity.exists: argument selector → yes/no (whether it exists)
entity.same: arguments left, right → yes/no (whether they are the same)
entity.in: arguments entity, collection → yes/no (whether it is in the group)
entity.count: argument selector → number (how many there are)
Write arguments in the form { "ref": "target" }. You cannot write just "target".
Do not pass a group to an argument that expects one character.
unit.hasRevengeTarget has a direction. Swapping from and to is a different check. Dead characters are not excluded automatically, so add an isDead condition if needed.
Read a character's values by adding the field name after the character, like player.money, target.isDead or roles.client.rank. Read territories like spot.population. Fields not in this list cannot be read.
Numbers: money (Funds), rank (internal rank number), influence (influence), renown (Renown), hp, health, sanity, birthYear, deadDate, childCount, tolerance, leadershipExp, politicsExp, intelligenceExp, battleExp, intuitionExp, charmExp, focusPoint, traitCount
Yes/no: exists, isPlayer, isRandomGenerated, isDead, isInBattle, isPregnant
Text/ID: id, cultureId, homeSpotId, fatherId, motherId, spouseId, countryId, powerId, stayingSpotId, armyId, firstNameId, familyNameId
hp and health are different values. countryId (country) and powerId (faction) are also different.
XXExp are experience points.
childCount is the number of recorded children, including dead ones.
Numbers: population, humanResource, foodSurplus, wallDefence, agricultureRaw, commerceRaw, constructionRaw, safetyRaw, loyaltyRaw, warDevastationRaw, stayingUnitCount
Yes/no: exists, isInSiege, playerVisited
Text/ID: id, cultureId, tradingAreaId, countryId, powerId
XXRaw are base values.
stayingUnitCount is the number recorded as staying, not the number excluding the dead.
context.trigger: the kind of trigger this time
context.spotId/context.targetId/context.placeId: IDs of the territory, other person and place this time
context.isFirstSpotVisit: whether this entry is the first visit to that territory
context.battleResult: the battle result (list below)
world.year/world.month/world.day/world.hour/world.mode: in-game date, time and so on
flags.name/vars.name/texts.name: records (Section 13)
context.isFirstSpotVisit tells whether it was the first visit at the moment of entering; spot.playerVisited tells whether the territory is visited now. For "only the first time you enter", use context.isFirstSpotVisit.
Values of context.battleResult:
win: after_battle. The player's side won
lose: after_battle. The player's side lost (including when a retreat or surrender is judged a defeat)
unknown: after_battle. The result could not be obtained, or the player did not take part
pending: before_battle. Not decided yet
none: triggers other than battle
The value is decided when the scene starts and does not change during the dialogue.
It does not remember the previous battle result. If you want to use it in a later event, keep it in a record (Section 13).
There is no value meaning only a draw or a retreat.
"jumpConditions": {
"can_pay": {
"cases": [
{ "when": { "var": "player.money", "op": ">=", "value": 100 }, "goto": "Offer" }
],
"else": "NotEnough"
}
}
Use it by writing "JumpCondition/can_pay" in jumpTo in the dialogue file.
cases are checked from the top, and the dialogue goes to the goto row of the first one met. If none is met, it goes to the else row. else is required.
In goto/else, write the name of a row in the same dialogue file.
If the preceding action changed money or records, the check uses the changed values.
Up to 32 cases.
Whole file: schemaVersion (1), id, rows (array of rows).
Rows:
name (required): the row's name. Make it unique within the dialogue file
speaker (optional): who speaks. narrator (narration, default), player, target, roles.role name
text (optional): the text (up to 8192 characters)
event (optional): MOD/group name. Runs before the text is shown
branches (optional): array of choices (up to 16 per row)
jumpTo (optional): where to go next. If omitted, the next row. Required in the last row
wait (optional): a number from 0 to 60
Choices:
id (required): a name unique within that row
text (required): the button text (up to 8192 characters)
event (optional): MOD/group name. Runs after the choice is selected; if it succeeds, the dialogue goes to jumpTo
jumpTo (required): destination
What you can write as a destination (jumpTo):
A row name: go to that row in the same dialogue file
JumpCondition/name: choose the destination with a branch
END: end normally (runs onComplete and marks one-time records)
ABORT: end as stopped partway (does not run onComplete and does not mark one-time records)
END/ABORT cannot be used as row names.
Up to 512 rows per dialogue file.
{{name}} in the text is replaced with the text set by dialogue.var.set (the value after running that row's event).
Text and choices are shown exactly as written. They are not translated automatically.
Images, voices, backgrounds, effects and special choice conditions of the game's built-in dialogue cannot be used.
Action group:
"actions": {
"pay": {
"repeat": "once_per_run",
"onFailure": { "goto": "PaymentFailed" },
"steps": [ … ]
}
}
steps: array of actions, run from top to bottom (up to 64)
repeat: Section 14
onFailure.goto: the row to go to on failure. If omitted, the dialogue is interrupted
Actions:
money.give/money.take (target, amount (positive number)): increase/decrease Funds. Fails if there is not enough
influence.add/influence.take (target, amount (positive number)): increase/decrease influence
renown.change (target, delta (positive or negative number)): increase or decrease Renown
impression.change (from, to, delta (positive or negative number)): increase or decrease the Regard of from toward to
unit.join (target, leader, mode): with mode unit_to_power, adds target to leader's faction; with power_to_country, adds target's faction to leader's country. Fails if joining is not allowed by the game's normal checks
flag.set (key, value (true/false), owner): set a yes/no record
number.set/number.add (key, value (number), owner): assign/add to a number record
text.set (key, value (text), owner): set a text record
dialogue.var.set (key, value (text)): decide the text that goes into {{key}} in the dialogue text (not recorded)
if (when, then (array of actions), else (optional)): split actions by condition
Write target/leader/from/to as text, like "player", "target" or "roles.client".
owner is needed for records whose scope is unit/spot.
Actions are not undone. If one fails partway, earlier successes remain and later ones do not run.
Not possible: giving or taking items, freely changing HP, sanity and so on, changing the state of existing quests, changing arbitrary values, loops, calling another group from an action group, running game functions or commands.
"state": {
"flags": { "paid": { "scope": "unit", "default": false } },
"vars": { "visits": { "scope": "save", "default": 0 } },
"texts": { "memo": { "scope": "save", "default": "" } }
}
flags: yes/no (read as flags.name)
vars: numbers (read as vars.name)
texts: text (read as texts.name)
save: one for the whole save (owner: do not write)
unit: per character (owner: required (e.g. "owner": "target"))
spot: per territory (owner: required (e.g. "owner": "spot"))
Undeclared names and values of the wrong type cannot be used.
Write state at the top of the file; it is used by the events in that file.
Records are separate for each MOD and event id. You cannot read another event's records.
Records are stored in the save data.
The event's repeat.mode
always (default): happens every time the trigger occurs
once_per_save: only once per save
once_per_target: only once per person talked to (talk_unit only)
An action group's repeat
once_per_run (default): runs only once within one dialogue
every_call: runs every time it is called
One-time records are marked when the dialogue ends with END. For details, see the "Rules & Troubleshooting" page.
Naming: Event ids, row names, choice ids, role names and record names must start with a letter, use only half-width letters, digits, _ and -, and be 64 characters or fewer.
The following names cannot be used as role names: player, target, spot, candidate, context, world, roles, flags, vars, texts.
Referring:
Calling an action group from a dialogue file (event): MOD/group name
Calling a branch from a dialogue file (jumpTo): JumpCondition/name
Calling a row from a dialogue file (jumpTo): the row name
Calling an action group from an event file (onStart/onComplete): the group name only
Calling a row from an event file (goto/else): the row name
Referring to characters from conditions, actions and speakers: player, target, roles.role name
One dialogue file: 512 rows. 16 choices per row. Text and choice text up to 8192 characters each.
Conditions: 8 levels of nesting, 256 conditions
Action group: 64 actions (actions inside if also count, so leave room)
Roles and candidates: 32 roles, 128 candidates in a group
Branches: 32 cases
Events: 256 per file. 64 files in events/
Files: loaded JSON up to 1048576 characters, paths up to 256 characters
If you exceed a limit or write a field not in the rules, that event is not loaded. Misspelled fields are never silently ignored.