Skip to content
Type a keyword to search.
This page was translated with machine assistance. The Simplified Chinese version is the authoritative reference.

Story Events and Triggers

Story events are the basic units used to organize game story scripts. Triggers find and call events at the right timing. Commands inside an event enter the story event queue and run in order.

Use English half-width symbols for special script syntax, such as *, #, :, ;, |, [, ], and $. Avoid treating these symbols as ordinary text inside story text or config tables.

A story event mainly consists of an event ID, command content, and results.

PartDescription
Story Event IDThe unique identifier for a story event, used by triggers or commands such as EVENT and SUB_EVENT.
Command ContentCommand entries executed after the event is triggered. Multi-line commands enter the execution queue in order.
ResultsConditions evaluated from command return values, used to jump to another event or end the current event.

Triggers connect game timings such as interactions, map entry, quest completion, and battle results to story events. When a trigger is hit, it does not immediately interrupt every flow. Instead, it places the corresponding event into the story event queue, then the event executor processes queued events in sequence.

Interface TypeTrigger TimingObject Parameter
passivePassive trigger, commonly used by map editor triggers or direct execution through the TRIGGER command.
talkTriggered when interacting with an NPC.
first_inTriggered the first time the game is entered.
encounterTriggered when interacting with a unit on the sandbox map.Target unit control ID
before_enter_mapTriggered before entering the target map. If an event responds, the current map-entry action is interrupted.Target map ID
enter_mapTriggered when entering a map.Target map ID
before_leave_mapTriggered before leaving the current map. If an event responds, the current map-leave action is interrupted.Current map ID
leave_mapTriggered when leaving the current map.Current map ID
enter_placeTriggered when entering a place.Target place ID
reach_placeTriggered before entering a place on the world map. If an event responds, place entry is interrupted.Target place ID
leave_placeTriggered when leaving a place.Current place ID
before_leave_placeTriggered before leaving a place. If an event responds, place leaving is interrupted.Current place ID
reach_buildingTriggered before entering a facility. If an event responds, facility entry is interrupted.Target facility ID
set_lordTriggered when AI appoints or removes the player as a city lord.Trigger type and object ID
job_cmdTriggered when a work command is issued to the player.
see_warbandTriggered when encountering a battle between other teams on the world map.
curplace_inwarTriggered when the place where the player is located is attacked.
quest_doneTriggered when all quest conditions are completed but the quest has not been turned in.Quest ID
on_end_workTriggered when ending work at a place.
occupy_placeTriggered when the player successfully occupies a place.Target place ID
new_dayTriggered when a new day begins.Target day count
reward_followerTriggered when rewarding the player's followers.
reward_playerTriggered when the player receives a reward.
dip_eventTriggered when the player faction encounters a diplomacy event.Diplomacy event type and opposing faction ID
dip_ret_successTriggered when a diplomacy action requested by the player faction succeeds.Diplomacy event type and opposing faction ID
dip_ret_failTriggered when a diplomacy action requested by the player faction fails.Diplomacy event type and opposing faction ID
player_failedTriggered when the player loses an encounter battle.
reinforce_requestTriggered by reinforcement events related to the player.
is_fallTriggered when a faction collapses.Faction ID
is_to_fallTriggered when a faction loses all strongholds and is about to collapse.Faction ID
before_cash_presentTriggered before a commendation reward, and can be used to interrupt the commendation.
before_presentTriggered before giving a gift, and can be used to interrupt gift giving.
on_presentTriggered when giving a gift.
encounter_roleTriggered after encountering a role and before entering common dialogue.Target role ID
helped_campTriggered after helping one side in a battle between two encountered sides.Faction of the opposing team's leader
on_saodangTriggered after sweeping an outdoor place.
on_place_rep_upTriggered when place contribution increases. The latest contribution can be read from arg_int_val1.
on_place_rep_downTriggered when place contribution decreases. The latest contribution can be read from arg_int_val1.
team_dismissTriggered when a team disbands.Team type
team_into_placeTriggered when a team enters a place.Team type and place ID
in_gameTriggered after creating or loading a game.
bar_challengeTriggered when the player starts a tavern challenge.
tournament_startTriggered when the player joins a local fighting tournament.
be_promotedTriggered when the player's title rank rises. tagrole is the faction lord.
be_demotedTriggered when the player's title rank drops. tagrole is the faction lord.
space_moveTriggered when the player switches areas inside a city.enter or leave; area ID
on_diplomacy_strategyTriggered when pressing the diplomacy button in the intelligence screen. tagcamp is the target faction.
on_diplomacy_quitTriggered when pressing the exit button in the intelligence screen. tagcamp is the target faction.
after_generate_roleTriggered after a role is generated. tagrole is the generated role.Generation template ID
match_prepareTriggered when a tournament starts preparing.Tournament ID
match_startTriggered when a tournament officially starts.Tournament ID
match_endTriggered when a tournament ends.End type and tournament ID
match_fightTriggered when a tournament battle starts.Tournament ID
match_watch_fightTriggered when watching a tournament battle.Tournament ID
match_fast_fightTriggered for a quick tournament battle.Tournament ID
match_join_teamTriggered when joining a tournament team. arg_int_val1 is the team ID being applied to.Tournament ID
match_end_talkTriggered for tournament end dialogue.Result type and dialogue role

Preset fields can stand in for objects in the current context, making reusable shared events easier to write.

FieldDescription
CUR_ROLEThe current encounter role template ID. Commonly used in dialogue and selection boxes.
CUR_BATTLEThe battle ID corresponding to the current encounter’s world-map spawned unit.

The restriction field of a specific battle table, as well as battle parameters for commands such as BATTLE, can override the original battle settings.

param1ID:param1;param2ID:param2;...
ParameterDescription
playerOverrides player-side hero units. Format: RoleID|RoleID2, for example 主角|曲玉.
unitsOverrides player-side squads. Format: CardID,count,level|CardID2,count,level. If level is omitted, the card’s initial level is used.
add_statAdds attributes to initial deployment roles. Format: RoleIDOrCardID=StatFieldID,fieldValue|StatFieldID2,fieldValue2.
place_statAdds attribute fields to the battle place. Format: StatFieldID,fieldValue|StatFieldID2,fieldValue2.
can_captureWhether the losing side can be captured in this battle. 1 means yes, 0 means no.
can_loot_equipWhether enemy equipment can drop in this battle. 1 means yes, 0 means no.

Result scripts route events to different follow-up commands based on conditions. The game checks from the first line and executes the command for the first matching condition.

conditionExpressionGroup1:command1
conditionExpressionGroup2:command2
...
conditionExpressionGroupN:commandN
FormDescription
[%global_int:ID%]Returns the value of global integer field ID.
[$global_str:ID$]Returns the value of global string field ID.
FieldDescription
save_max_hard_levelThe highest difficulty ever unlocked. Default value: 0.
FieldDescription
system_沙盒模式Marks whether the current mode is sandbox mode.
system_探索地图点数Stores exploration map points.
system_星星Stores the star count.
system_敌方角色血量百分比Extra multiplier for the opponent’s HP when the player fights an enemy role.
system_敌方角色攻击百分比Extra multiplier for the opponent’s attack and magic attack when the player fights an enemy role.
config_ai_levelCurrent AI strength level: 0 easy, 1 normal, 2 hard.
config_roll_limitWhether combat roll limits are enabled. 0 off, 1 on.
config_hunger_penaltyWhether hunger penalties are enabled. 0 off, 1 on.
config_upgrade_cost_reduceCurrent discount percentage for unit upgrade EXP and material costs.
config_soldier_dead_scaleCurrent death chance multiplier for common soldiers, as a percentage.

Initial setting fields are usually used for character creation, starting maps, default time speed, default battle formulas, and other base configuration.

FieldDescription
init_posDefault spawn position info.
init_statuDefault attribute state info when the player spawns.
init_moneyDefault starting assets.
home_placeDefault starting place ID.
init_skillpagesSkill pages lit at the start.
init_skillsSkills initially owned by the main character.
init_equipInitial equipment table info for the main character.
init_camp_rlInitial faction relationship table. Format: FactionA,FactionB,RelationState,Favor|...
gametime_scaleScale coefficient for game time on the world map.
battletime_scaleScale coefficient for game time in battle. When 0, game time is frozen in encounters or siege battles.
custom_intval_watcherDefault custom variable watcher field, using the same format as ADD_INTVAL_WATCHER.
def_dropitem_modelDefault model and effect info for dropped items on the ground in battle.
default_role_model_male / default_role_model_femaleDefault male and female role models used when no role model is specified.
default_role_act_male / default_role_act_femaleDefault male and female action IDs used when an action cannot be mapped from weapon type.
default_weapons_speedDefault attack speed for all weapon types.
def_formula_phy_x / def_formula_mag_xFormula factors for physical defense and shamanic defense.