Finished examples of common events. Each one works if you put the event file and dialogue file into a MOD as they are. Copy them and rewrite the text and conditions to use them.
The basics of writing events are explained on the "How Event Creation Works" page (tutorial). For the meaning of each field, see the "Reference" page.
1. A town visited for the first time (Sample 5): detecting a first visit, inserting text, counting with state, onStart, if
2. Getting pocket money from your father in a tavern of your own country, based on Renown: specifying by relationship, narrowing territories, if
3. A word when you enter the guild with high Renown: entering a place (enter_place), one-time
4. Specifying a character by name: name search (find)
5. Changing lines by the number of times you talked: per-character number records, branches
6. Separate events for victory and defeat: battle result after battle, priority, onComplete
Workshop: Event MOD Sample 5: A Town Visited for the First Time (イベントMODサンプル5:はじめて訪れた街)
What it does: When you enter a territory for the first time, text based on its population appears. When you visit your fifth new territory, your Renown rises by 10 (only once per save).
events/first_visit.json
{
"schemaVersion": 1,
"state": {
"vars": { "towns": { "scope": "save", "default": 0 } },
"flags": { "seasoned": { "scope": "save", "default": false } }
},
"events": [
{
"id": "first_visit",
"priority": 100,
"trigger": { "type": "enter_spot" },
"repeat": { "mode": "always" },
"when": { "var": "context.isFirstSpotVisit", "op": "==", "value": true },
"dialogue": {
"id": "first_visit",
"file": "dialogues/first_visit.json",
"startRow": "Start"
},
"onStart": "count",
"jumpConditions": {
"milestone": {
"cases": [
{
"when": {
"all": [
{ "var": "vars.towns", "op": ">=", "value": 5 },
{ "var": "flags.seasoned", "op": "==", "value": false }
]
},
"goto": "Seasoned"
}
],
"else": "Done"
}
},
"actions": {
"count": { "steps": [{ "type": "number.add", "key": "towns", "value": 1 }] },
"describe": {
"steps": [
{
"type": "if",
"when": { "var": "spot.population", "op": ">=", "value": 5000 },
"then": [
{
"type": "dialogue.var.set",
"key": "impression",
"value": "A big town. Voices can be heard from every direction."
}
],
"else": [
{
"type": "dialogue.var.set",
"key": "impression",
"value": "A quiet land. You can clearly hear the wind."
}
]
}
]
},
"reward": {
"steps": [
{ "type": "renown.change", "target": "player", "delta": 10 },
{ "type": "flag.set", "key": "seasoned", "value": true }
]
}
}
}
]
}
dialogues/first_visit.json
{
"schemaVersion": 1,
"id": "first_visit",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"event": "MOD/describe",
"text": "A land you are visiting for the first time. {{impression}}",
"jumpTo": "JumpCondition/milestone"
},
{
"name": "Seasoned",
"speaker": "narrator",
"event": "MOD/reward",
"text": "This is your fifth land. You are getting used to traveling. (Renown +10)",
"jumpTo": "END"
},
{
"name": "Done",
"speaker": "narrator",
"text": "You breathe in the air of the new land.",
"jumpTo": "END"
}
]
}
Points
context.isFirstSpotVisit tells whether this entry is the first visit to that territory. Use it when you want something to happen only on the first visit.
onStart is the action group that runs when the dialogue starts. Here it adds 1 to the number of territories visited (vars.towns). Its scope is save, so it is one number for the whole save.
If you write event in a dialogue row, the action group runs before that row's text is shown. The describe group chooses the text depending on whether the population is 5000 or more, and puts it into impression with dialogue.var.set. {{impression}} in the text is replaced with that text.
Only text decided by an action group can go into {{…}}. You cannot show numbers such as the population directly in the text.
The if action runs then if when is met, and else otherwise.
What it does: When you talk to your father in a tavern in a territory of your own country, you get 200 if your Renown is 50 or more, and 50 otherwise. Once per father.
events/father_allowance.json
{
"schemaVersion": 1,
"events": [
{
"id": "father_allowance",
"priority": 100,
"trigger": {
"type": "talk_unit",
"units": { "ref": "player.father" },
"spots": { "ref": "player.country.spots" },
"placeIds": ["tavern"]
},
"repeat": { "mode": "once_per_target" },
"dialogue": {
"id": "father_allowance",
"file": "dialogues/father_allowance.json",
"startRow": "Start"
},
"actions": {
"allowance": {
"steps": [
{
"type": "if",
"when": { "var": "player.renown", "op": ">=", "value": 50 },
"then": [{ "type": "money.give", "target": "player", "amount": 200 }],
"else": [{ "type": "money.give", "target": "player", "amount": 50 }]
}
]
}
}
}
]
}
dialogues/father_allowance.json
{
"schemaVersion": 1,
"id": "father_allowance",
"rows": [
{
"name": "Start",
"speaker": "target",
"text": "Oh, fancy meeting you here. It isn't much, but use it for your travels.",
"event": "MOD/allowance",
"jumpTo": "END"
}
]
}
Points
units, spots and placeIds in trigger start the event only when all are met. Here the three are "the person is your father", "a territory of your own country" and "a tavern".
If there is no father (dead, unknown, etc.), the event does not start.
once_per_target is once per person talked to. It can only be used with talk_unit.
What it does: When your Renown is 100 or more and you enter the guild of any territory, text appears. Only once per save.
events/guild_invite.json
{
"schemaVersion": 1,
"events": [
{
"id": "guild_invite",
"priority": 100,
"trigger": { "type": "enter_place", "placeIds": ["guild"] },
"repeat": { "mode": "once_per_save" },
"when": { "var": "player.renown", "op": ">=", "value": 100 },
"dialogue": {
"id": "guild_invite",
"file": "dialogues/guild_invite.json",
"startRow": "Start"
}
}
]
}
dialogues/guild_invite.json
{
"schemaVersion": 1,
"id": "guild_invite",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "As you enter the guild, the receptionist notices you and bows. Your name seems to be known here too.",
"jumpTo": "END"
}
]
}
Points
enter_place fires when you enter a place inside a territory. Use it together with placeIds.
If you write several entries in placeIds, the event starts when you enter any one of them. Example: ["guild", "tavern"].
It does not start while your Renown is below 100. It appears only once, the first time you enter after reaching 100 or more.
What it does: When you talk to a living character named "John Smith", the dialogue appears. Once per person.
events/by_name.json
{
"schemaVersion": 1,
"events": [
{
"id": "by_name",
"priority": 100,
"trigger": {
"type": "talk_unit",
"units": {
"find": "unit",
"name": { "first": "John", "family": "Smith", "language": "en" },
"where": { "var": "candidate.isDead", "op": "==", "value": false }
}
},
"repeat": { "mode": "once_per_target" },
"dialogue": { "id": "by_name", "file": "dialogues/by_name.json", "startRow": "Start" }
}
]
}
dialogues/by_name.json
{
"schemaVersion": 1,
"id": "by_name",
"rows": [
{
"name": "Start",
"speaker": "target",
"text": "You know my name? Have we met somewhere?",
"jumpTo": "END"
}
]
}
Points
The name in the example is only for explaining the format. Rewrite it to match a character in the actual game.
The name must exactly match the name displayed in the game. It is searched in the spelling of the language written in language. It is not automatically translated into another language for the search.
If several characters have the same name, all of them are targets. To narrow it to one person, add a condition with where, or specify by relationship (ref).
What it does: When you talk to your spouse in the palace, the line differs the first, second and third time. From the fourth time on, the normal dialogue returns.
events/spouse_talk.json
{
"schemaVersion": 1,
"state": { "vars": { "talks": { "scope": "unit", "default": 0 } } },
"events": [
{
"id": "spouse_talk",
"priority": 100,
"trigger": {
"type": "talk_unit",
"units": { "ref": "player.spouse" },
"placeIds": ["palace"]
},
"repeat": { "mode": "always" },
"when": { "var": "vars.talks", "owner": "target", "op": "<", "value": 3 },
"dialogue": {
"id": "spouse_talk",
"file": "dialogues/spouse_talk.json",
"startRow": "Start"
},
"onStart": "count",
"jumpConditions": {
"by_count": {
"cases": [
{
"when": { "var": "vars.talks", "owner": "target", "op": "==", "value": 1 },
"goto": "First"
},
{
"when": { "var": "vars.talks", "owner": "target", "op": "==", "value": 2 },
"goto": "Second"
}
],
"else": "Third"
}
},
"actions": {
"count": {
"steps": [{ "type": "number.add", "key": "talks", "owner": "target", "value": 1 }]
}
}
}
]
}
dialogues/spouse_talk.json
{
"schemaVersion": 1,
"id": "spouse_talk",
"rows": [
{
"name": "Start",
"speaker": "narrator",
"text": "Your spouse was waiting in the palace corridor.",
"jumpTo": "JumpCondition/by_count"
},
{
"name": "First",
"speaker": "target",
"text": "You seem busy lately. Please don't overdo it.",
"jumpTo": "END"
},
{
"name": "Second",
"speaker": "target",
"text": "We meet again. How was your day today?",
"jumpTo": "END"
},
{
"name": "Third",
"speaker": "target",
"text": "Talking with you somehow puts my heart at ease.",
"jumpTo": "END"
}
]
}
Points
The count is kept in a per-character number record (vars with scope unit). Both reading and writing need "owner": "target".
The start condition (when) is checked before the dialogue starts. Then onStart adds 1 to the count, and the branch is chosen using the value after the increase.
After three talks, the start condition is no longer met and the normal dialogue returns.
What it does: After a battle, a dialogue that raises your Renown by 5 appears if you win, and a different dialogue if you lose. When the result is unknown, the normal post-battle dialogue is shown.
events/battle_result.json
{
"schemaVersion": 1,
"events": [
{
"id": "after_win",
"priority": 110,
"trigger": { "type": "after_battle" },
"repeat": { "mode": "always" },
"when": { "var": "context.battleResult", "op": "==", "value": "win" },
"dialogue": { "id": "after_win", "file": "dialogues/after_win.json", "startRow": "Start" },
"onComplete": "win_reward",
"actions": {
"win_reward": { "steps": [{ "type": "renown.change", "target": "player", "delta": 5 }] }
}
},
{
"id": "after_lose",
"priority": 100,
"trigger": { "type": "after_battle" },
"repeat": { "mode": "always" },
"when": { "var": "context.battleResult", "op": "==", "value": "lose" },
"dialogue": {
"id": "after_lose",
"file": "dialogues/after_lose.json",
"startRow": "Start"
}
}
]
}
dialogues/after_win.json
{
"schemaVersion": 1,
"id": "after_win",
"rows": [
{
"name": "Start",
"speaker": "player",
"text": "Victory! This win will be talked about for years. (Renown +5)",
"jumpTo": "END"
}
]
}
dialogues/after_lose.json
{
"schemaVersion": 1,
"id": "after_lose",
"rows": [
{
"name": "Start",
"speaker": "player",
"text": "Defeated... We'll regroup and win next time.",
"jumpTo": "END"
}
]
}
Points
Only one MOD event starts per scene. If you also put an after_battle event that does not distinguish the result in the same MOD, give it a priority lower than 100. Otherwise it may start before the result-specific events.
Write the defeat condition as == "lose". With != "win", the case where the result is unknown (unknown) is included too.
onComplete runs when the dialogue ends with END.
To change only the lines depending on the result within one event, see Chapter 9 of the tutorial (Sample 4).