On this page you learn how to write event MODs by building the sample MODs step by step. Read it from top to bottom. The other pages are under "Event Creation" in the top menu.
To look up fields and values → the "Reference" page
For detailed rules, or when something does not work → the "Rules & Troubleshooting" page
Finished examples of common events → the "Recipes" page
The examples on this page are published as samples on Steam Workshop. If you subscribe, you can try the finished files in the game and compare their contents. (The Workshop titles and the samples' dialogue are in Japanese. The examples on this page use English text.)
Event MOD Sample 1: Your First Line (イベントMODサンプル1:はじめての一言): a line appears when you enter a territory (Chapter 1)
Event MOD Sample 2: The Traveler in the Tavern (イベントMODサンプル2:酒場の旅人): choices, money, conditions, state and recruiting (Chapters 2–7, finished version)
Event MOD Sample 3: Meeting the Monarch's Child (イベントMODサンプル3:君主の子との出会い): naming characters, roles, checking Regard (Chapter 8)
Event MOD Sample 4: Before and After Battle (イベントMODサンプル4:戦いの前と後): dialogue before and after battle, branching on the result, checking for a sworn enemy (Chapter 9)
Event MOD Sample 5: A Town Visited for the First Time (イベントMODサンプル5:はじめて訪れた街): detecting a first visit, inserting text, counting with state (Recipes)
Try the samples one at a time. If several are enabled at once, another sample's dialogue may appear first in the same scene.
An event MOD starts dialogue you wrote yourself at a certain moment in the game. One event is made of the following five parts.
Trigger (trigger): when to start (e.g. when you talk to a character, when you enter a territory, before or after battle). Required
Condition (when): an extra condition for whether it may start (e.g. when you have more Funds than the other person). Optional
Dialogue: the text and choices to show (e.g. "Lend 100", "Refuse"). Required
Actions (actions): change the game during the dialogue (e.g. hand over money, recruit someone). Optional
State (state): remember what happened (e.g. "I lent money to this person"). Optional
The dialogue goes in a "dialogue file" and everything else in an "event file". One event works as a pair of these two files.
Important: MOD dialogue appears "instead of" normal dialogue.
When the trigger and conditions are met, the MOD's dialogue appears instead of the dialogue or quest the game would normally show in that scene. It is not added to the normal dialogue. If your conditions are too broad, main quests and normal dialogue will stop appearing. This page explains how to narrow conditions in Chapters 5 and 7.
What you will make: When you enter a territory, one line appears: "The event MOD is working." It happens only once per save.
Create a local MOD from the game's MOD screen by following "Create the MOD folder" on the home page.
Inside the new MOD folder, create two folders: events and dialogues. Use lowercase names.
Create the following files in them.
<MOD folder>/
mod.json ← created by the game. Do not delete it
events/
first_line.json ← event file
dialogues/
first_line.json ← dialogue file
events/first_line.json (event file)
{
"schemaVersion": 1,
"events": [
{
"id": "first_line",
"trigger": { "type": "enter_spot" },
"repeat": { "mode": "once_per_save" },
"dialogue": {
"id": "first_line",
"file": "dialogues/first_line.json",
"startRow": "Start"
}
}
]
}
dialogues/first_line.json (dialogue file)
{
"schemaVersion": 1,
"id": "first_line",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "The event MOD is working.",
"jumpTo": "END"
}
]
}
dialogue in the event file specifies which dialogue file to use and which row to start from. Always make these three match.
dialogue.file in the event file ↔ the location of the dialogue file: write the path as seen from the MOD folder, separated by /
dialogue.id in the event file ↔ id in the dialogue file: use the same name
dialogue.startRow in the event file ↔ a row's name in the dialogue file: the dialogue starts from the row with that name
schemaVersion: The format version. Always set it to 1 for now.
id: The event's name. Use half-width letters and digits starting with a letter (_ and - are also allowed). Make it unique within the MOD.
trigger.type: The trigger. enter_spot means "when you enter a territory".
repeat.mode: How many times it happens. once_per_save means "only once per save".
rows: The rows of the dialogue. They are shown from top to bottom.
speaker: Who speaks. narrator is narration (no speaker).
jumpTo: Where to go after this row. END means "end the dialogue normally".
Enable the MOD on the MOD screen and restart the game.
Start a new game or load a save.
Enter any territory and the text appears.
If it does not appear when you enter again, it worked (because of once_per_save).
If you want to try it many times, set repeat.mode to always (every time) only while developing. After rewriting a file, you need to restart the game.
Notes on writing JSON
Save files in UTF-8. Comments are not allowed. Do not put a comma after the last item. Use the half-width quotation mark ".
What to remember from this chapter
An event works with two files: an event file and a dialogue file
Match dialogue.id with the dialogue file's id, and startRow with a row's name
End the dialogue with "jumpTo": "END"
From here to Chapter 7, you grow one MOD, "The Traveler in the Tavern", little by little. Create a new local MOD to begin. The finished version is Sample 2.
What you will make: When you talk to a character in a tavern, the MOD's dialogue appears.
events/traveler.json
{
"schemaVersion": 1,
"events": [
{
"id": "traveler",
"priority": 100,
"trigger": { "type": "talk_unit", "placeIds": ["tavern"] },
"repeat": { "mode": "always" },
"dialogue": { "id": "traveler", "file": "dialogues/traveler.json", "startRow": "Start" }
}
]
}
dialogues/traveler.json
{
"schemaVersion": 1,
"id": "traveler",
"rows": [
{
"name": "Start",
"speaker": "target",
"text": "Hello. You often see travelers in this tavern.",
"jumpTo": "END"
}
]
}
talk_unit for trigger.type: when you talk to a character. The person you talked to can be referred to as target.
trigger.placeIds: narrows down the place. tavern is the tavern. For other place names, see "Place IDs" in the Reference.
priority: when several events match the same scene, the one with the larger number is checked first. If omitted, it is 0.
target for speaker: the person you talked to speaks. To make the player speak, use player.
always for repeat.mode: happens every time the trigger occurs.
Talk to someone in a tavern. If this line appears with that person's name and face, it worked.
At this stage, this dialogue appears no matter whom you talk to in the tavern (normal dialogue no longer appears). In Chapter 5 you add a condition to narrow down the person.
What to remember from this chapter
talk_unit fires when you talk to someone, and that person is target
placeIds narrows down the place
What you will make: The traveler asks to borrow money, and you can choose "Lend 100" or "Refuse". (No money moves yet.)
The event file stays as in Chapter 2. Rewrite the dialogue file as follows.
dialogues/traveler.json
{
"schemaVersion": 1,
"id": "traveler",
"rows": [
{ "name": "Start", "speaker": "narrator", "text": "A traveler in the corner of the tavern notices you." },
{
"name": "Ask",
"speaker": "target",
"text": "To tell the truth, I've run out of money for the road... Could you lend me about 100?",
"branches": [
{ "id": "lend", "text": "Lend 100", "jumpTo": "Thanks" },
{ "id": "refuse", "text": "Refuse", "jumpTo": "Refused" }
]
},
{
"name": "Thanks",
"speaker": "target",
"text": "Thank you! I won't forget this kindness.",
"jumpTo": "END"
},
{
"name": "Refused",
"speaker": "target",
"text": "...I see. I asked too much of you.",
"jumpTo": "END"
}
]
}
List the choices in branches. Up to 16 can be placed in one row.
Give each choice an id that is unique within that row.
The choice's text is shown on the button.
In the choice's jumpTo, write the name of the row to go to after it is chosen.
A row without jumpTo, like the Start row, goes on to the row right below it. Always write jumpTo in the last row.
"jumpTo": "END": end the dialogue normally (when to use: usually this one)
"jumpTo": "ABORT": treat the dialogue as stopped partway (when to use: when you want a "one-time" event to count as not done yet)
One-time events such as once_per_save are recorded as "done" only when they end with END. If they end with ABORT, they happen again at the next opportunity.
What to remember from this chapter
Choices go in branches; write the target row's name in jumpTo
END ends normally; ABORT counts as stopped partway
What you will make: Choosing "Lend 100" reduces your Funds by 100 and raises the other person's Regard for you. If you do not have enough money, a different line appears.
events/traveler.json
{
"schemaVersion": 1,
"events": [
{
"id": "traveler",
"priority": 100,
"trigger": { "type": "talk_unit", "placeIds": ["tavern"] },
"repeat": { "mode": "always" },
"dialogue": { "id": "traveler", "file": "dialogues/traveler.json", "startRow": "Start" },
"actions": {
"lend": {
"onFailure": { "goto": "NoMoney" },
"steps": [
{ "type": "money.take", "target": "player", "amount": 100 },
{
"type": "impression.change",
"from": "target",
"to": "player",
"delta": 10
}
]
}
}
}
]
}
dialogues/traveler.json
{
"schemaVersion": 1,
"id": "traveler",
"rows": [
{ "name": "Start", "speaker": "narrator", "text": "A traveler in the corner of the tavern notices you." },
{
"name": "Ask",
"speaker": "target",
"text": "To tell the truth, I've run out of money for the road... Could you lend me about 100?",
"branches": [
{ "id": "lend", "text": "Lend 100", "event": "MOD/lend", "jumpTo": "Thanks" },
{ "id": "refuse", "text": "Refuse", "jumpTo": "Refused" }
]
},
{
"name": "Thanks",
"speaker": "target",
"text": "Thank you! I won't forget this kindness.",
"jumpTo": "END"
},
{
"name": "Refused",
"speaker": "target",
"text": "...I see. I asked too much of you.",
"jumpTo": "END"
},
{
"name": "NoMoney",
"speaker": "target",
"text": "Oh, it seems you don't have enough on you. Please don't worry about it.",
"jumpTo": "END"
}
]
}
Processing that changes the game is written as "action groups" in actions in the event file. Here we created a group named lend.
List the actions in steps. They run from top to bottom.
money.take: reduces the Funds of the character in target by amount. It fails if there is not enough.
impression.change: changes the Regard of the from character toward the to character by delta. To lower it, write something like -10.
For the list of available actions, see "List of actions" in the Reference.
From the dialogue file, call it by writing "MOD/lend" in the choice's event. When the choice is selected, the action group runs first, and if it succeeds, the dialogue goes to the jumpTo row.
In onFailure.goto, write the row to go to when an action fails. Here, when there is not enough money, it goes to the NoMoney row.
Actions are not undone. If an action partway fails, the actions that succeeded before it stay in effect and the actions after it do not run.
So put actions that may fail (such as taking money) first.
Rules for referring to names
When the dialogue file refers to parts written in the event file, add the kind in front.
Action group: "event": "MOD/group name"
Branch (Chapter 6): "jumpTo": "JumpCondition/branch name"
When writing names inside the event file (onStart, onComplete, etc.), write only the name without the kind.
What to remember from this chapter
Write processing that changes the game as action groups in actions, and call them from the dialogue with MOD/name
The destination on failure is onFailure.goto
Actions are not undone, so put actions that may fail first
What you will make: Only people with less Funds than you approach you as the traveler. Everyone else gets the normal dialogue.
Add when to the event file. The dialogue file stays as in Chapter 4.
events/traveler.json
{
"schemaVersion": 1,
"events": [
{
"id": "traveler",
"priority": 100,
"trigger": { "type": "talk_unit", "placeIds": ["tavern"] },
"repeat": { "mode": "always" },
"when": { "var": "player.money", "op": ">", "valueRef": "target.money" },
"dialogue": { "id": "traveler", "file": "dialogues/traveler.json", "startRow": "Start" },
"actions": {
"lend": {
"onFailure": { "goto": "NoMoney" },
"steps": [
{ "type": "money.take", "target": "player", "amount": 100 },
{
"type": "impression.change",
"from": "target",
"to": "player",
"delta": 10
}
]
}
}
}
]
}
The event starts only when the condition written in when is met. When it is not met, the MOD's dialogue does not appear and the normal dialogue appears.
One condition is written with three parts: "what", "how to compare" and "against what".
{ "var": "player.money", "op": ">", "valueRef": "target.money" }
var: the value to check. player.money is the player's Funds. The list of readable values is in the Reference.
op: how to compare. There are == (equal), != (not equal), >, >=, <, <= and others.
Write what to compare against using exactly one of the following.
To compare with a fixed number or text: value. For example, "value": 100 means "compare with 100".
To compare with another value: valueRef. For example, "valueRef": "target.money" means "compare with the other person's Funds".
The condition above means "the player's Funds are greater than the other person's Funds".
Write numbers without quotation marks, like 100. If you write "100", it is treated as text and cannot be compared.
{ "all": [condition, condition] }: all are met
{ "any": [condition, condition] }: at least one is met
{ "not": condition }: not met
Chapters 6 and 7 use any and all.
What to remember from this chapter
If when is not met, the MOD's dialogue does not appear and the normal dialogue is shown
Compare against a fixed value with value, and against another value with valueRef
What you will make: The person you lent money to thanks you the next time you talk to them.
events/traveler.json
{
"schemaVersion": 1,
"state": { "flags": { "lent": { "scope": "unit", "default": false } } },
"events": [
{
"id": "traveler",
"priority": 100,
"trigger": { "type": "talk_unit", "placeIds": ["tavern"] },
"repeat": { "mode": "always" },
"when": {
"any": [
{ "var": "flags.lent", "owner": "target", "op": "==", "value": true },
{ "var": "player.money", "op": ">", "valueRef": "target.money" }
]
},
"dialogue": { "id": "traveler", "file": "dialogues/traveler.json", "startRow": "Start" },
"jumpConditions": {
"first_or_again": {
"cases": [
{
"when": { "var": "flags.lent", "owner": "target", "op": "==", "value": true },
"goto": "Again"
}
],
"else": "Ask"
}
},
"actions": {
"lend": {
"onFailure": { "goto": "NoMoney" },
"steps": [
{ "type": "money.take", "target": "player", "amount": 100 },
{ "type": "flag.set", "key": "lent", "owner": "target", "value": true },
{
"type": "impression.change",
"from": "target",
"to": "player",
"delta": 10
}
]
}
}
}
]
}
dialogues/traveler.json
{
"schemaVersion": 1,
"id": "traveler",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "A traveler in the corner of the tavern notices you.",
"jumpTo": "JumpCondition/first_or_again"
},
{
"name": "Ask",
"speaker": "target",
"text": "To tell the truth, I've run out of money for the road... Could you lend me about 100?",
"branches": [
{ "id": "lend", "text": "Lend 100", "event": "MOD/lend", "jumpTo": "Thanks" },
{ "id": "refuse", "text": "Refuse", "jumpTo": "Refused" }
]
},
{
"name": "Thanks",
"speaker": "target",
"text": "Thank you! I won't forget this kindness.",
"jumpTo": "END"
},
{
"name": "Refused",
"speaker": "target",
"text": "...I see. I asked too much of you.",
"jumpTo": "END"
},
{
"name": "NoMoney",
"speaker": "target",
"text": "Oh, it seems you don't have enough on you. Please don't worry about it.",
"jumpTo": "END"
},
{
"name": "Again",
"speaker": "target",
"text": "You really saved me that time. Thanks to you, I've been able to keep traveling.",
"jumpTo": "END"
}
]
}
Declare the records you use in state at the top of the file. Here a record called lent is declared as a flags record (a yes/no record).
scope is the unit that holds the record. unit means per character. There are also save (one for the whole save) and spot (per territory).
default is the value before anything has been recorded.
Record it with flag.set in an action group. The second action of lend sets lent to true after the money has been taken.
Read it by writing flags.lent in a condition's var.
For records whose scope is unit or spot, specify "whose record" with owner. "owner": "target" is the record of the person you talked to. Note that this role differs from target in money.take (whose money).
There are also vars for recording numbers and texts for recording text. See the Recipes and the Reference for how to use them.
To change where the dialogue goes partway through depending on conditions, use a "branch".
Write it with a name in jumpConditions in the event file. Here it is first_or_again.
cases are checked from the top, and the dialogue goes to the goto row of the first one whose condition is met.
If none is met, it goes to the else row. else is always required.
From the dialogue file, call it with "jumpTo": "JumpCondition/first_or_again".
After the Start row, the dialogue goes to the Again row if this is the person you lent money to, and to the Ask row otherwise.
When it is checked … start condition: before the dialogue starts / branch: partway through the dialogue
When not met … start condition: the MOD's dialogue does not appear and the normal dialogue is shown / branch: goes to the else row
In this chapter, the start condition uses any (at least one). It starts when the person is "someone you lent money to" or "someone with less Funds than you". Otherwise, once the person you lent money to has more Funds, the thank-you dialogue would no longer appear.
repeat can be written both for a whole event and for an action group. The meanings differ, so be careful.
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
Lend money in a tavern.
Talk to the same person again and check that you get the thank-you dialogue.
Save on the game's save screen, load, and talk to them again. The record should still be there.
Records are stored in the save data. If you quit the game without saving, the records are not kept.
What to remember from this chapter
Declare records in state, record with flag.set, read with flags.name
For per-character records, specify "whose record" with owner
Branching partway through a dialogue uses branches (jumpConditions); else is required
What you will make: You can invite the traveler who comes to thank you to join you. Once they have joined, this dialogue no longer appears for them.
With this, the files are the same as Sample 2, "The Traveler in the Tavern".
events/traveler.json
{
"schemaVersion": 1,
"state": {
"flags": {
"lent": { "scope": "unit", "default": false },
"joined": { "scope": "unit", "default": false }
}
},
"events": [
{
"id": "traveler",
"priority": 100,
"trigger": { "type": "talk_unit", "placeIds": ["tavern"] },
"repeat": { "mode": "always" },
"when": {
"all": [
{ "var": "flags.joined", "owner": "target", "op": "==", "value": false },
{
"any": [
{ "var": "flags.lent", "owner": "target", "op": "==", "value": true },
{ "var": "player.money", "op": ">", "valueRef": "target.money" }
]
}
]
},
"dialogue": { "id": "traveler", "file": "dialogues/traveler.json", "startRow": "Start" },
"jumpConditions": {
"first_or_again": {
"cases": [
{
"when": { "var": "flags.lent", "owner": "target", "op": "==", "value": true },
"goto": "Again"
}
],
"else": "Ask"
}
},
"actions": {
"lend": {
"onFailure": { "goto": "NoMoney" },
"steps": [
{ "type": "money.take", "target": "player", "amount": 100 },
{ "type": "flag.set", "key": "lent", "owner": "target", "value": true },
{
"type": "impression.change",
"from": "target",
"to": "player",
"delta": 10
}
]
},
"recruit": {
"onFailure": { "goto": "Declined" },
"steps": [
{
"type": "unit.join",
"target": "target",
"leader": "player",
"mode": "unit_to_power"
},
{
"type": "flag.set",
"key": "joined",
"owner": "target",
"value": true
}
]
}
}
}
]
}
dialogues/traveler.json
{
"schemaVersion": 1,
"id": "traveler",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "A traveler in the corner of the tavern notices you.",
"jumpTo": "JumpCondition/first_or_again"
},
{
"name": "Ask",
"speaker": "target",
"text": "To tell the truth, I've run out of money for the road... Could you lend me about 100?",
"branches": [
{ "id": "lend", "text": "Lend 100", "event": "MOD/lend", "jumpTo": "Thanks" },
{ "id": "refuse", "text": "Refuse", "jumpTo": "Refused" }
]
},
{
"name": "Thanks",
"speaker": "target",
"text": "Thank you! I won't forget this kindness.",
"jumpTo": "END"
},
{
"name": "Refused",
"speaker": "target",
"text": "...I see. I asked too much of you.",
"jumpTo": "END"
},
{
"name": "NoMoney",
"speaker": "target",
"text": "Oh, it seems you don't have enough on you. Please don't worry about it.",
"jumpTo": "END"
},
{
"name": "Again",
"speaker": "target",
"text": "You really saved me that time. Thanks to you, I've been able to keep traveling.",
"branches": [
{
"id": "recruit",
"text": "Why not come with me?",
"event": "MOD/recruit",
"jumpTo": "Joined"
},
{ "id": "bye", "text": "Take care.", "jumpTo": "END" }
]
},
{ "name": "Joined", "speaker": "target", "text": "I'd be glad to go with you!", "jumpTo": "END" },
{
"name": "Declined",
"speaker": "target",
"text": "That's a kind offer, but I can't accept right now.",
"jumpTo": "END"
}
]
}
Added joined (has joined) to state.
Added the action group recruit. unit.join adds the person to your faction, and if it succeeds, joined is recorded.
"mode": "unit_to_power" means "add a character to a faction". There is also power_to_country (add a faction to a country).
Whether they can join follows the game's normal checks. If they cannot join, the action fails and the dialogue goes to the Declined row.
Added choices to the Again row.
Wrapped the start condition in all and added "has not joined yet". People who have joined get the normal dialogue back.
What to remember from this chapter
unit.join recruits someone. If they cannot join, it is treated as a failure
Exclude people whose story is over with a condition so they return to normal dialogue
What you will make: When you talk to a child of the monarch of your country, they tell you what the monarch thinks of you. Once per person.
events/ruler_child.json
{
"schemaVersion": 1,
"events": [
{
"id": "ruler_child",
"priority": 200,
"trigger": {
"type": "talk_unit",
"units": {
"ref": "player.country.ruler.children",
"where": { "var": "candidate.isDead", "op": "==", "value": false }
}
},
"roles": {
"ruler": {
"select": { "ref": "player.country.ruler" },
"pick": "unique",
"required": true
}
},
"when": {
"query": "entity.same",
"args": { "left": { "ref": "player" }, "right": { "ref": "roles.ruler" } },
"op": "==",
"value": false
},
"repeat": { "mode": "once_per_target" },
"dialogue": {
"id": "ruler_child",
"file": "dialogues/ruler_child.json",
"startRow": "Start"
},
"onComplete": "greet",
"jumpConditions": {
"ruler_opinion": {
"cases": [
{
"when": {
"query": "unit.impression",
"args": { "from": { "ref": "roles.ruler" }, "to": { "ref": "player" } },
"op": ">=",
"value": 50
},
"goto": "Praised"
}
],
"else": "NotYet"
}
},
"actions": {
"greet": {
"steps": [
{
"type": "impression.change",
"from": "target",
"to": "player",
"delta": 5
}
]
}
}
}
]
}
dialogues/ruler_child.json
{
"schemaVersion": 1,
"id": "ruler_child",
"rows": [
{
"name": "Start",
"speaker": "target",
"text": "My father has told me about you.",
"jumpTo": "JumpCondition/ruler_opinion"
},
{
"name": "Praised",
"speaker": "target",
"text": "My father seems to think highly of you. Please keep lending us your strength.",
"jumpTo": "END"
},
{
"name": "NotYet",
"speaker": "target",
"text": "My father doesn't seem to know you well yet. I'm sure you'll have a chance to talk someday.",
"jumpTo": "END"
}
]
}
You can specify characters by their relationship to the player without knowing their IDs.
The event starts only when you talk to a character listed in trigger.units.
"ref": "player.country.ruler.children" means "the children of the monarch of the player's country". Join relationships with . to follow them.
where narrows down the candidates. candidate refers to each candidate in turn. Here only children who are "not dead" are included.
You can also search by name (find) or specify by ID (id/ids). For the full list, see "Specifying characters and territories" in the Reference.
Characters who do not appear in the dialogue can also be used in conditions and actions if you name them in roles. Here the monarch is given the role name ruler and referred to as roles.ruler.
unique for pick starts the event only when there is exactly one candidate.
If required is true, the event does not start when the role's character cannot be found.
Relationships between characters are checked with query instead of var.
entity.same: whether two are the same character. Here it checks that "the player is not the monarch".
unit.impression: the Regard value from from toward to. The line changes depending on whether the monarch's Regard for the player is 50 or more.
Write query arguments like { "ref": "player" }. You cannot write just "player".
"repeat": { "mode": "once_per_target" }: only once for the same child. Talking to a different child triggers it again.
onComplete: the action group that runs when the dialogue ends with END. Here it slightly raises the other person's Regard.
priority is 200. When used together with Sample 2, this one is checked first when you talk to the monarch's child in a tavern.
What to remember from this chapter
Characters can be specified by relationship (ref) and narrowed with where
Characters who do not appear in the dialogue can be given role names with roles
Relationships between characters are checked with query
What you will make: When the opponent regards the player as a sworn enemy, the opponent says a line before the battle. After the battle, the line changes depending on whether you won or lost.
events/battle.json
{
"schemaVersion": 1,
"events": [
{
"id": "revenge_before",
"priority": 100,
"trigger": { "type": "before_battle" },
"repeat": { "mode": "always" },
"when": {
"query": "unit.hasRevengeTarget",
"args": { "from": { "ref": "target" }, "to": { "ref": "player" } },
"op": "==",
"value": true
},
"dialogue": {
"id": "revenge_before",
"file": "dialogues/revenge_before.json",
"startRow": "Start"
}
},
{
"id": "after_battle",
"priority": 100,
"trigger": { "type": "after_battle" },
"repeat": { "mode": "always" },
"dialogue": {
"id": "after_battle",
"file": "dialogues/after_battle.json",
"startRow": "Start"
},
"jumpConditions": {
"by_result": {
"cases": [
{
"when": { "var": "context.battleResult", "op": "==", "value": "win" },
"goto": "Victory"
},
{
"when": { "var": "context.battleResult", "op": "==", "value": "lose" },
"goto": "Defeat"
}
],
"else": "UnknownResult"
}
}
}
]
}
dialogues/revenge_before.json
{
"schemaVersion": 1,
"id": "revenge_before",
"rows": [
{
"name": "Start",
"speaker": "target",
"text": "So we finally meet. Here I'll settle the grudge from that day!",
"jumpTo": "END"
}
]
}
dialogues/after_battle.json
{
"schemaVersion": 1,
"id": "after_battle",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "The battle is over.",
"jumpTo": "JumpCondition/by_result"
},
{
"name": "Victory",
"speaker": "player",
"text": "Victory! Let's build on this win.",
"jumpTo": "END"
},
{
"name": "Defeat",
"speaker": "player",
"text": "Defeated... We'll regroup and win next time.",
"jumpTo": "END"
},
{
"name": "UnknownResult",
"speaker": "narrator",
"text": "The battle ended with no clear outcome.",
"jumpTo": "END"
}
]
}
You can list any number of events in events (up to 256 per file). Here the before-battle and after-battle events are in one file. Dialogue files are separate for each event.
before_battle appears instead of the dialogue before a real-time battle.
target is the one person chosen to represent the opposing side.
unit.hasRevengeTarget checks whether the from character regards the to character as a sworn enemy. Reversing the direction means something different.
after_battle appears instead of the dialogue after a real-time battle.
context.battleResult gives the result for the player's side.
win: the player's side won
lose: the player's side lost (including when a retreat or surrender is judged a defeat)
unknown: the result could not be obtained, or the player did not take part
Write the defeat condition as "op": "==", "value": "lose". If you write != "win", unknown is included too. Use the else row for text for when the result is unknown.
You can also split the events themselves for victory and defeat. See the Recipes.
What to remember from this chapter
Before and after battle are before_battle/after_battle; target represents the opposing side
The result is context.battleResult; write defeat as == "lose"
Before publishing on the Workshop, check the following. For how to publish, see the home page.
Are you blocking normal dialogue? If conditions are too broad, main quests and normal dialogue stop appearing. However, an existing dialogue that was blocked once by a MOD event tries to start again later if there is a chance where it is not blocked.
Did you also test the cases where things go wrong? For example, when there is no one to talk to, when there is not enough money, or when someone cannot join.
Did you test one-time events with a new save?
Do records remain after saving and loading?
Do not change the MOD folder name or event id after publishing. Records are managed by these two. If you change them, players' records will not carry over.
Detailed rules and how to investigate when things do not work are collected on the "Rules & Troubleshooting" page.