事件不仅功能强大,而且易于学习。
编写事件(或事件链)时,步骤通常如下:
完成脚本编写后,通常需要:
testevent <EventID> <CharOrProvID>查看)event <EventID> <CharOrProvID>手动触发该事件,以检查是否存在设计错误并验证本地化。Events usually consist of:
namespace = <namespace>
<event_type> = {
#Basic event information
id = <namespace>.<id>
desc = EVTDESC<namespace>.<id>
#Fast event triggers
only_playable = yes
trigger = {
#Event eligibility condition block
religion_group = pagan_group
}
mean_time_to_happen = {
#Randomness of the event (not applicable for triggered-only events)
}
immediate = {
#Command block executed once the target is eligible, but before displaying the event
}
option = {
name = EVTOPTA<namespace>.<id>
trigger = {
#Option A eligibility condition block
}
ai_chance = {
#Option A modifiers
}
#Option A command block
}
option = {
name = EVTOPTB<namespace>.<id>
trigger = {
#Option B eligibility condition block
}
ai_chance = {
#Option B modifiers
}
#Option B command block
}
after = {
#Command block executed after any option is chosen. It is the counterpart of the immediate block.
}
}
There are several types of events:
| Type | ROOT scope | Description |
|---|---|---|
| character_event | Character | Basic character event. Vanilla frames: GFX_event_normal_frame_diplomacy, GFX_event_normal_frame_war, GFX_event_normal_frame_economy, GFX_event_normal_frame_intrigue, GFX_event_normal_frame_religion |
| long_character_event | Character | 角色事件弹窗更大,用于原版学习场景。 Vanilla frames: GFX_event_long_frame_diplomacy, GFX_event_long_frame_war, GFX_event_long_frame_economy, GFX_event_long_frame_intrigue, GFX_event_long_frame_religion. |
| letter_event | Character | Shows the sender in-game. Vanilla frames: GFX_event_letter_frame_diplomacy, GFX_event_letter_frame_war, GFX_event_letter_frame_war_big, GFX_event_letter_frame_economy, GFX_event_letter_frame_intrigue, GFX_event_letter_frame_religion. |
| narrative_event | Character | 与character_event类似,但首字母大而装饰,精美的框架,窗户稍大。 Vanilla frames: GFX_event_narrative_frame_diplomacy, GFX_event_narrative_frame_war, GFX_event_narrative_frame_economy, GFX_event_narrative_frame_intrigue, GFX_event_narrative_frame_religion. |
| province_event | Province | 基础省份事件。警告:火灾将归属省份所有者,但ROOT就是该省份! Vanilla frames: same as character_event. |
| diploresponse_event | Character | 用于通知外交决策,如宣战或撤销头衔。只能通过on_action事件触发。FROM是接收事件的角色,FROMFROM是发送事件的人。ROOT是空的,或者是第三方,new_character是空的,或者是第三方。 原版框架:如果与硬编码决策相关联letter_event则相同。否则窗户是隐藏的。 |
| unit_event | Unit | 用于解锁“维京袭击者”成就。只能通过on_action事件触发。警告:只有当事件通过on_entering_port触发时,ROOT才是该单位。否则就是老板的问题。 Vanilla frames: same as character_event. |
| society_quest_event | Character | Allow to define a quest_target that is determined in the immediate block of the event. For instance quest_target = event_target:infiltration_target
|
Event IDs 必须是唯一的,因为事件碰撞可能导致错误和崩溃。 为了提升兼容性 mods, and reduce the chance of identical IDs, namespaces can (and should!) be used.
命名空间可以是任何字母数字字符串(不含“.”字符),并作为前缀形式使用 <namespace>.<id>.
如果事件文件使用命名空间,必须在文件开头声明 namespace = <namespace>.每个使用命名空间的文件都必须这样做。
在加载时,命名空间被解析为一个数值。例如,事件 <namespace>.3132 可以转换为 ID 1403132(即 <namespace> 1,400,000 或 14)。 因此:
以下是命名空间“mymod”的使用示例:
namespace = mymod
character_event = {
id = mymod.0001
desc = EVTDESCmymod.0001
option = {
name = EVTOPTAmymod.0001
}
}
请注意,既不需要“EVTDESC”或“EVTOPT”前缀,也不必与你的命名空间相关,但最佳做法是根据你的模组选择一个清晰且无冲突的命名惯例。 只要存在本地化密钥,上述示例同样能成功工作:
namespace = mymod
character_event = {
id = mymod.0001
desc = mymodprefix_event_0001
option = {
name = mymodprefix_event_0001A
}
}
where mymodprefix 是你选择的一个独特前缀,用来区分你的模组。 当然,如果你选择这样做,要小心使用不会与 冲突的前缀 jargon——没有什么比为你假设的模组《Crusader Babes》选择了“cb_”这样的键,结果发现你覆盖了基础游戏中的许多casus belli键更尴尬的了。 (或许也没什么比这更尴尬的了,除了最初制作这个模组。)
描述定义事件的文本,可以是固定的 localization key 或者动态区块。 固定的定位键简单表达为 desc = key:
desc = EVTDESC450
动态块类似,但包含一系列触发条件,决定描述是否会出现
desc = {
trigger = {
#Conditions for 1st description to be chosen
}
text = EVTDESC_case1_mymod.0001
}
desc = {
trigger = {
#Conditions for 2nd description to be chosen
}
text = EVTDESC_case2_mymod.0001
}
如果能根据触发条件出现多个描述,游戏引擎将生成所有可用描述的列表,并随机选择其中一个描述。 这也可以用静态定位键实现。 例如:
character_event = {
id = mymod.733
desc = EVTDESCmymod.733.1
desc = EVTDESCmymod.733.2
desc = EVTDESCmymod.733.3
desc = EVTDESCmymod.733.4
}
当事件触发时,这会随机显示四个描述中的一个。 (此功能同样适用于选项描述。)
事件图片是出现在事件卷轴顶部的水平图像。就像描述一样,它们也可以被修正 event_pictures 或者动态区块。 固定的定位键简单表达为 picture = key, for example:
picture = GFX_evt_battle
动态块类似,但包含一系列触发条件,决定是否替换所列图片。注意,图片必须在动态描述块下定义,即使描述始终相同,只是图片有所变化,这一点也成立。
character_event = {
id = mymod.777
title = TITLE
picture = GFX_evt_battle # There needs to be a default picture, even if it won't actually show up
desc = {
trigger = { condition = yes }
text = EVTDESC_case1_mymod.777
picture = GFX_evt_battle_byzantine
}
desc = {
trigger = { condition2 = yes }
text = EVTDESC_case2_mymod.777
picture = GFX_evt_mongols_pillage_oldgods
}
}
从 3.0 版本起,你还可以在图片本身设置触发器,这样你可以定义多个图片,而无需通过事件描述。请注意,活动描述图片仍将优先。
character_event = {
id = mymod.777
desc = EVTDESCMYMOD777
picture = {
trigger = { is_female = no }
picture = GFX_evt_battle_byzantine
}
picture = {
trigger = { is_female = yes }
picture = GFX_evt_mongols_pillage_oldgods
}
}
请记住,这些触发器是在立即命令块运行后才解决的,如果你使用在同一事件中被更改的条件句,这一点需要考虑。
需要注意的是,用来叫活动图片的名称并不总是与活动图片的名称相同。在上面的例子中:GFX_evt_battle_byzantine 调用的是名为 battle_byzantine 的文件,而是调用了该文件 Battle_Cataphracts_Saracen。这是因为要调用事件图片,事件图片需要在接口文件夹中的 gfx 文件中定义,有时呼叫名称与文件名不同。如果调用名称与接口文件夹中 gfx 文件中的文本不匹配,你的事件将使用默认的事件图片。
此外,许多活动图片及其定义文件并不在主event_pictures和界面文件夹中。这些文件则存放在对应的DLC压缩包中。例如:《日落入侵》DLC的活动图片及其定义的gfx文件都位于DLC/dlc018.zip文件夹里。
你也可以自己制作活动图片。要做到这一点,可以在gfx/event_pictures文件夹里把图片做成450 x 150 .dds或.tga文件。然后在接口文件夹里的 gfx 文件里定义文件,就像这样;
spriteTypes = {
...
spriteType = {
name = "GFX_evt_custompic"
texturefile = "gfx\\event_pictures\\custompic.tga"
}
...
}
名字会调用它,纹理文件指向所需的文件。你可以随意命名,但通常为了简单起见,最好设置成和文件名一样。
Some flags can be used to configure events:
| Flag | Type | Description |
|---|---|---|
| title | Localization key | 标准事件图片上方、narrative_event描述前的简短文字。这是必须的,因为标题的首字母是装饰性的,narrative_event才能正确展示。 |
| desc | Localization key or clause | 本次活动的主文。在本地化中使用\n强制换行。 |
| window | gui | 指定使用GUI窗口的名称,意味着事件几乎可以被赋予任何外观。 |
| background | gfx | Used with window.指定事件背景,并且如果有该名称的GFX存在,也会将该GFX名称+“_option”应用到选项按钮上。
|
| picture | gfx | 显示在事件顶部的图片(450x150像素)。hide_window = 是时不需要,也不需要letter_event。引用了 interface/*.gfx 文件夹中的一条(例如:GFX_evt_council)。
这些条目可以通过定义 gfx 条目 <picture>GFX__<religion>_ 或 <picture>GFX__ 来覆盖文化和/或宗教<culture>。 |
| border | gfx | 弹出窗的框架。事件类型有不同的匹配帧。 |
| portrait | character/title/offmap | 确定在 右上角显示的字符 (long)_character_event, province_event, narrative_eventor the sole portrait in a letter_event.对于地图外的能力,将显示该地图外的统治者。如果这样,就不会显示任何东西 hide_from = yes is used.
|
| major | bool | 如果是,除了根部,其他角色也会出现。这可以通过 major_trigger block.
Warning: for events with
|
| is_friendly | bool | Always uses compliments in letter events, regardless of opinion. |
| is_hostile | bool | Always uses insults in letter events, regardless of opinion. |
| is_triggered_only | bool | 如果是,事件不能单独触发,需要从其他事件、决策或 on_action 中调用。注: trigger = { } 仍会评估该事件是否适用。
|
| offmap | string | If allow该事件既可触发地图上的统治者,也能触发地图外的统治者。 如果 only该事件不会触发地图上的统治者,只触发地图外的统治者。 如果省略该旗帜,该事件将永远不会触发地图外统治者。 |
| triggered_from_code | bool | 用于一些原版教程活动。这些内容在NLearningScenario部分有引用 defines. |
| hide_from | bool | 即使活动中FROM的头像通常可见,也不会显示。覆盖 portrait.
|
| hide_new | bool | |
| hide_window | bool | 让事件变得隐形。隐藏时事件选项仍会被评估。 |
| show_root | bool | Usually used in combination with major = yes
|
| show_from_from | bool | 覆盖右上角显示FROM作用域字符的默认行为。 |
| show_from_from_from | bool | 覆盖右上角显示FROM作用域字符的默认行为。 |
| sound | sfx | Plays the given sound. |
| notification | bool | 会添加通知消息。注意:这对province_event来说不太好,因为通知中会出现空白的角色头像。 |
Pre-triggers or fast triggers are special conditions 在事件根节点,允许引擎过滤角色可能符合条件的事件,而无需评估触发块。[1][2]
预触发次数没有限制,除了每种都只有一次(DLC检定除外)。
大多数预触发只能用于角色事件,但也有少数可以在省份事件中使用,比如 patch 2.6.
Warning: 有些预触发症状的名称与正常状态不同!
很少有预触发效果明显更好,因为它们被放在独立的事件列表中,只有当角色达到条件时才会评估。这些可以被视为“过滤”预触发,因为它们可以完全消除事件,甚至连初步评估都无法进行。
They are, in order of precedence:
| Pre-trigger | Type | Scope | Description | Equivalent trigger |
|---|---|---|---|---|
| only_playable | bool | character | 在脚本中,“可操作”并不意味着玩家真的能操作该角色。意思是:伯爵等级或以上,或者贵族阶层,不是无地的叛乱者。使用这个预触发完全消除了对不符合条件的事件评估,意味着事件会针对游戏中约1000名可玩角色进行检查,而非全部约2万名 | is_playable |
| is_part_of_plot | bool | character | 限制为支持或主导剧情的角色。它优先于一切,除了其他 only_playable,因为参与剧情的角色数量通常少于统治者的数量。
|
has_plot |
| only_rulers | bool | character | Excludes untitled characters. This is a lesser version of only_playable,因为它包括男爵、叛乱者等(即任何拥有头衔的人)。
|
is_ruler |
| religion | religion | character | 限制该宗教/religion_group成员参加活动。它与其他过滤前触发器互斥,即 only_playable and only_rulers 两者都优先,所以在某些情况下,直接使用可能更好 religion_group = SOME_RARE_GROUP and leave out only_rulers = yes.
|
religion |
| religion_group | religion_group | character | religion_group |
其他预触发点则在事件评估开始时直接检查,这比在触发器中检查要快一些。这些都是廉价的检定,所以应该尽可能多地使用(但不值得为了让它们奏效而扭曲事件逻辑)。
| Pre-trigger | Type | Scope | Description | Equivalent trigger |
|---|---|---|---|---|
| min_age | int | character | Minimum age of the character (for this event). | age |
| max_age | int | character | Maximum age of the character (for this event). | NOT age |
| only_independent | bool | character | Excludes vassals and tributaries. Implies only_playable.
|
independent |
| only_men | bool | character | is_female = no | |
| only_women | bool | character | is_female = yes | |
| only_capable | bool | character | NOT = { trait = incapable } | |
| capable_only | bool | character | If yes, only picks characters without any incapacitating = yes traits, i.e. the |
NOT = { trait = incapable } |
| lacks_dlc | string | character/province | 玩家(或者多人游戏中,主机)是否启用或禁用DLC时,永远不会被评估。每个活动可以多次应用,根据多个DLC进行筛选。 | NOT has_dlc |
| has_dlc | string | character/province | has_dlc | |
| friends | bool | character | Checks whether the character has/doesn't have friends. | num_of_friends = 0 or 1 |
| rivals | bool | character | Checks whether the character has/doesn't have rivals. | num_of_rivals = 0 or 1 |
| prisoner | bool | character | If no, can't be applied to imprisoned characters. | prisoner |
| ai | bool | character |
|
ai |
| in_command | bool | character | 示例:in_command = 否将使事件仅对非指挥部队的人触发(因为 patch 3.0). Warning: not tested, seems to be buggy right now | in_command |
| is_patrician | bool | character | 检查角色是否是商人共和国贵族家族的家主。暗示 only_playable.
|
is_patrician |
| is_female | bool | character | If yes, will only affect female characters. 警告:现在它在error.log中出现错误,请用only_men/only_women代替它。 | is_female |
| is_married | bool | character | is_married | |
| is_sick | bool | [?] | [?] | |
| has_character_flag | flag | character | 警告:触发前超过1 has_character_flag会引发error.log错误 | has_character_flag |
| has_global_flag | flag | character/province | Checks whether the global flag has been set. 警告:触发前超过1 has_global_flag会引发error.log | has_global_flag |
| war | bool | character | Checks whether the character is/isn't at war. | war |
| culture | culture | character | culture | |
| culture_group | culture_group | character | culture_group | |
| is_in_society | bool | character | Checks whether the character belongs/doesn't belong to a society. | is_in_society |
| has_quest_target | bool | character | 是的,活动会限制给有实际目标任务的人参加。不会限制活动只能给有任务但没有目标或没有任务的人。 | [?] |
| has_job_title | bool | character | has_job_title |
The trigger 事件负责确保事件在正确的时间和正确的性质上发射。有很多不同的选择 conditions 该名称可归入“触发”一词。它们的作用都是为游戏增添趣味。在某些情况下,事件可能会有这样的台词: is_triggered_only = yes这意味着该事件是由另一个事件的选项触发的,因此除非角色选择该选项,否则事件不会触发。
All events (except those with is_triggered_only = yes需要一个触发器部分。这决定了事件何时触发,也是活动模组力量的所在。在这里你几乎可以检查任何条件,唯一的限制是 scopes and conditions you have available, and your creativity.
Below is an example trigger section:
trigger = {
NOT = { wealth = -50 }
NOT = { has_character_flag = loan_taken }
OR = {
NOT = { has_character_flag = loan_refused }
had_character_flag = { flag = loan_refused days = 365 }
}
}
Mean time to happen (MTTH)是衡量随机事件平均发生所需时间的指标。例如,MTTH为90天,意味着90天后事件被触发的概率正好为50%。 使用“平均发生时间”而非概率值,使模组制作者和开发者能够明确指定他们认为事件应发生的频率,而不受事件触发机制的影响。因此,它消除了编码时计算概率的需求。
Like with the trigger, mean_time_to_happen has to be defined for any event that isn't is_triggered_only = yes.该部分决定事件发生的平均时间。这通常以月份为单位,但也可以以天或年为单位。
它可能会受到几乎任何修正值的影响 condition.
Below is an example section:
mean_time_to_happen = {
months = 1
modifier = {
factor = 2 # Decreases chances by half
some_condition = yes
}
modifier = {
factor = 0.5 # Increases chances by half
some_condition = yes
}
}
Weight multiplier is an alternative to mean-time-to-happen required by on_action events, introduced in patch 2.0. 它比使用平均发生时间非常短的事件轮询变化更高效,且速度更快。 活动 on_actions must use weight_multiplier instead of mean_time_to_happen. 虽然发动机也支持在常规赛事中使用重量倍增器代替MTTH,但它确实是 not 推荐用于延迟较低的活动,因为它们会排队后每月以大量弹窗方式触发。 The Validator will report all such uses as an error.
Weight multiplier modifiers, as used by #on_action events增加事件发生的概率,而不是增加事件所需的时间。
例如,这是游戏中的一个事件,因子增加了事件发生的概率,而不是增加事件所需的时间:
# on_failed_assassination - maimed
character_event = {
id = 158
desc = "EVTDESC158"
picture = "GFX_evt_shadow"
hide_FROM = yes
is_triggered_only = yes
trigger = {
NOT = { trait = maimed }
}
weight_multiplier = {
days = 1
modifier = {
factor = 3
trait = wounded
}
}
immediate = {
FROM = { character_event = { id = 40005 } }
}
option = {
name = "EVTOPTA158"
add_trait = maimed
}
}
Commands in the immediate = { } 块在事件显示之前执行(即在描述和标题之前 localization gets resolved).
警告:当在即时区块内无延迟触发事件时,新事件实际上使用了原始事件的范围(有点像子程序),而不是创建这些范围的副本。这在配合使用时可能带来意想不到的效果 event targets[3]
Commands in the after = { } 无论选择哪个选项,都会在选择某个选项后执行并执行。
Commands in the fail_trigger_effect = { } 如果脚本尝试触发事件但未被满足,则会执行阻塞。这对处理链条中某个角色因无关原因中途死亡的情况很有用。
最后,每个活动都需要一个或多个(最多4个符合条件) option section. Once an option is selected, the associated effects will be applied.
活动中列出的选项可以说是活动本身最重要的部分之一。它们允许玩家根据当前需求或想要的选项来决定,有时也会强制角色根据自身需求做出选择 traits and/or attributes.
选项唯一的要求是名字,但你通常需要定义效果,可能还要有一个触发条件,决定选项何时出现。下面是一个选项示例部分。
option = {
name = "EVTOPTA38000" # Go to the moneylenders - Favorable terms
trigger = {
stewardship = 8
}
wealth = 200
character_event = { id = 38001 days = 1825 tooltip = EVTTOOLTIP38001 }
set_character_flag = loan_taken
clr_character_flag = loan_refused
}
选项名称可以是固定的本地化密钥,也可以是动态的,基于满足特定条件
name= {
text = EVTOPTA_case1_mymod.0001
trigger = {
#Conditions for 1st name to be chosen
}
}
name = {
text = EVTOPTA_case2_mymod.0001
trigger = {
#Conditions for 2nd name to be chosen
}
}
为了帮助人工智能选择最理性的选项, ai_chance modifiers can be used.
每个选项都基于基础因子加权,基准因子可受修正值影响,选中的选项通过加权随机选出。
ai_chance = {
factor = 10
modifier = {
factor = 0
OR = {
trait = gregarious
trait = proud
trait = ambitious
trait = charitable
}
}
}
如果你想在选项中显示任何肖像,可以通过在选项中定义一个示波器来实现。
option = {
name = EVTOPTXXX
random_consort = {
character_event = { id = EVTXXX }
}
}
该代码会显示选项旁边的肖像,点击后会对事件接收者的随机伴侣执行事件EVTXXX。为了让肖像显示,必须定义某种后果,且必须直接在该角色的范围内定义,而非在后续范围内。 如果你没有其他想发生的事,你总可以把角色保存为一个事件目标,这个目标从未被勾选,这样头像就会显示出来。
可选地,选项可以指定边框颜色和提示,比如“此选项可用是因为......”,类似于因角色拥有特殊特质而触发的事件。
tooltip_info = <trait> : yellow bordertooltip_info = martial : red bordertooltip_info = stewardship : green bordertooltip_info = intrigue : purple bordertooltip_info = diplomacy : blue bordertooltip_info = learning : grey bordertooltip_info = combat_rating : combat icontooltip_info_custom = <loc_key>选项中新增或移除的特质图标会显示出来。要显示额外的特征图标(例如事件链后期可能添加的),请使用 show_trait effect.
Events with hide_window = yes 可以用来将特定角色纳入FROM范围(而角色头像默认是FROM字符)。
因此,通过发送一个事件 hide_window = yes 到你想在FROM范围中的角色(角色A),并让该事件的选项将另一个事件返回给原角色B(即ping事件的FROM),你可以让A进入B事件的FROM范围。现在可以在本地化和事件代码中引用 A。
这很有用:
# Initial event that fires for character A
# ROOT is character A
character_event = {
id = 1
(...)
option = {
name = OK
random_realm_character = {
# character B
character_event = { id = 2 } # this is the ping event
}
}
}
# Ping event
# ROOT is character B
# FROM is character A
character_event = {
id = 2
hide_window = yes # description and portrait don't matter if it's hidden!
immediate = {
FROM = {
character_event = { id = 3 }
}
}
option = { name = OK } # must always have an option
}
# ROOT is character A
# FROM is character B
# Note: FROMFROM is character A
character_event = {
id = 3
# FROM can be be referenced in localisation and event code
(...)
}
事件一次最多有4个选项,但第四个选项可以呼叫另一个有更多选项的事件,从而允许超过4个选项。 最后一个选项需要循环回第一个选项。
repeat_event 带有当前事件ID的命令可以用来递归触发事件,并有延迟。
它在指定的作用域内以 ROOT 身份触发,但不会向栈添加 FROM,从而大大降低递归时栈溢出的风险。
| 这是一篇小作品。你可以通过编辑或修订扩充其内容。 如果可以请尽你所能的去协助完善这篇文章。 |
Some restrictions apply when an event chain:
例如,这适用于互动决斗,即战斗,一个 dice poker mini-game, etc.
其思想是玩家A采取的任何行动结果必须通知玩家B,基于该行动B采取行动,该行动又通知A,依此类推。
有一个单一事件链在A和B之间轮流进行,直到链条达到退出条件(例如计次数变量)。 为了减少脚本重复,如果对手始终被限制在FROM范围内(你不知道ROOT是玩家A还是玩家B),事件可以设计为同时用于A和B的重复使用。
交互循环示例(未显示启动和结束事件):
# Describe the previous action from FROM (if any), and ROOT takes an action
# FROM is the opponent
character_event = {
id = event.1
is_triggered_only = yes
option = {
name = event.1.a
repeat_event = { id = event.2 } # use repeat_event to keep opponent as FROM
}
(...)
}
# Show result of own action
# FROM is the opponent
character_event = {
id = event.2
is_triggered_only = yes
option = {
name = event.2.a
FROM = {
character_event = { id = event.1 } # It's the opponent turn
}
}
(...)
}
事件可以附加到on_action触发器上,当硬编码条件满足时触发。例如: on_marriage fires when two characters marry each other.
这使得能够编写需要瞬间发生的事件脚本,否则通过普通的平均时间事件来触发这些事件是不可能或成本很高的。
这些事件本应 is_triggered_only = yes and no mean_time_to_happen block.
Note that the fast-triggers and the trigger block of these events will still be checked.
On_action事件ID通过添加新的.txt文件来引用 common\on_actions folder (vanilla uses 00_on_actions.txt). There are 3 lists:
weight_multiplier 关于事件的。在该列表中可以存在不同的命名块,包含事件。每个区块只触发一个事件(如果有的话)。在不同文件中,同名的块会合并。事件和效果会触发on_action的根源。
以下代码示例对于 ROOT:在任何事件触发前执行 effect1;火灾事件1;火灾事件2;要么发射事件3(50%概率),要么触发事件2(25%概率),要么什么都不做(25%概率);5天后,要么触发事件5(50%概率)要么什么都不做(50%几率):
<on_action_name> = {
effect = {
# Effects to happen in the scope the on-action provides. Happens before any events.
<effect1>
}
events = {
# List of events that must always fire.
<event1>
<event2>
}
random_events = {
# List of events that may fire. Weight multiplier of each event will impact the probability of the event being selected, further modified by MTTH modifiers on the event.
100 = <event3>
50 = <event4>
50 = 0 # Setting the right hand to 0 allows for the possibility of no event happening
arbitrarily_named_block = {
delay = 5 # How many days to delay the event. Useful to ensure the player doesn't get spammed with a bunch of events at the same time.
1 = <event5>
1 = 0
}
}
}
| Name | Description and scopes | Category |
|---|---|---|
| on_startup | 游戏加载时(游戏开始和从存档加载)对所有角色(不仅仅是玩家)都会触发。 BUG(版本3.2.1):新游戏开始时,历史文件中未定义的宫廷侍从不会触发。 加载存档时会触发这些角色的触发。
Note: not called for ruler designed characters.
Also see |
Control |
| on_yearly_pulse | Fires every year | Pulse |
| on_bi_yearly_pulse | Fires every 2 years | Pulse |
| on_five_year_pulse | Fires every 5 years | Pulse |
| on_decade_pulse | Fires every 10 years | Pulse |
| on_yearly_childhood_pulse | For characters 2 to 16 years old | Pulse |
| on_childhood_pulse | 6岁加6个月、8岁加6个月和10岁加6个月的火灾 | Pulse |
| on_adolescence_pulse | 12岁加6个月和14岁加6个月的火灾 | Pulse |
| on_focus_pulse | 每年一次脉冲(从on_yearly_pulse起六个月),用于焦点事件(仅触发拥有焦点的角色) | Pulse |
| on_province_major_modifier | Fires when a province modifier with major = yes is removed.
|
Province |
| on_outbreak | Fires when a new outbreak starts
|
Province |
| on_combat_pulse |
|
Pulse,War |
| on_combat_starting |
|
Pulse,War |
| on_siege_pulse | 攻城和防守的攻城指挥官大约每10天一次,先攻方。
|
Pulse,War |
| on_battle_won |
|
War |
| on_major_battle_won |
|
War |
| on_battle_won_leader |
|
War |
| on_major_battle_won_leader |
|
War |
| on_battle_won_owner |
|
War |
| on_battle_lost |
|
War |
| on_major_battle_lost |
|
War |
| on_battle_lost_leader |
|
War |
| on_major_battle_lost_leader |
|
War |
| on_battle_lost_owner |
|
War |
| on_siege_won_leader | Fires for settlements.
|
War |
| on_siege_won_leader_fort | Fires for forts.
|
War |
| on_siege_won_leader_trade_post | Fires for trade posts.
|
War |
| on_siege_lost_leader | Fires for settlements.
|
War |
| on_siege_lost_leader_fort | Fires for forts.
|
War |
| on_siege_lost_leader_trade_post | Fires for trade posts.
|
War |
| on_siege_over_winner | Fires for settlements.
|
War |
| on_siege_over_winner_fort | Fires for forts.
|
War |
| on_siege_over_winner_trade_post | Fires for trade posts.
|
War |
| on_siege_over_loc_chars | Fires for all characters presumed to be in a settlement at the time.
|
War |
| on_siege_over_loc_chars_fort | Fires for all characters presumed to be in the fort's province at the time.
|
War |
| on_siege_over_loc_chars_trade_post | Fires for all characters presumed to be in a trade post's province at the time.
|
War |
| on_failed_assassination |
|
Plot |
| on_failed_assassination_disc |
|
Plot |
| on_assassination |
|
Plot |
| on_assassination_disc |
|
Plot |
| on_birth |
Note that in case of |
Character |
| on_adulthood |
|
Character |
| on_post_birth |
Note: see also on_birth. |
Character |
| on_pregnancy | At 2 months of pregnancy.
|
Character |
| on_marriage | Sent to liege of both spouses:
|
Character |
| on_betrothal | Sent to liege of both betrothed:
|
Character |
| on_become_imprisoned_any_reason | Fires when someone gets imprisoned for any reason.
|
Character |
| on_avoided_imprison_started_war | 如果有人试图囚禁落地的人失败,就会开火。这导致自动宣战(独立)
|
War |
| on_became_imprisoned | Fires if someone becomes imprisoned by the diplo-action
|
Character |
| on_avoided_imprison_fled_country | 如果有人试图囚禁未登陆的人但失败,则会被开火。角色被流放到另一个国家
|
Character |
| on_released_from_prison | Fires if someone is released from prison
|
Character |
| on_executed | Fires if someone is executed. [Executed before on_death?]
|
Character |
| on_exiled | Fires if someone is exiled
|
Character |
| on_prepared_invasion_monthly | 每个月都会为准备入侵的角色开火。
|
War |
| on_prepared_invasion_aborts | Fires if a prepared invasion becomes invalid.
|
War |
| on_prepared_invasion_expires | Fires if a prepared invasion expires.
|
War |
| on_death | 在继承问题处理前被解雇(角色仍保留相关旗帜和头衔)
|
Succession |
| on_merc_rampage | War | |
| on_merc_leave | War | |
| on_merc_turn_coat_from | War | |
| on_merc_turn_coat_to | War | |
| on_holy_order_leave | War | |
| on_loot_settlement |
|
Holding |
| on_loot_province | Fires when someone is looting currently in a province
|
|
| on_warleader_death | Never triggered, but reserved for CB use | War |
| on_approve_law | Respond to a proposed change of de facto law
|
Realm |
| on_approve_de_jure_law | Respond to a proposed change of de jure law
|
Realm |
| on_rebel_revolt | When rebels appear.
|
War |
| on_defect_to_rebels | When province defects to rebels
|
War |
| on_defect_from_rebels | When rebels disperse
|
War |
| on_crusade_creation |
|
Religion |
| on_crusade_invalid |
|
Religion |
| on_crusade_success | When a mission succeeds
|
Religion |
| on_crusade_failure | When a mission fails
|
Religion |
| on_forced_consort | 当异教统治者强迫一名囚犯成为他的配偶时
|
Character |
| on_reform_religion | 当异教宗教被改革,旧宗教变成异端时,
|
Religion |
| on_county_religion_change | When the religion changes in a county
|
Religion |
| on_vassal_accepts_religious_conversion | 当角色接受宗教皈依(外交行动)时。为附庸及其宫廷和附庸点燃火焰。
|
Religion |
| on_heresy_takeover | 异端已成为新常态,取代了旧有的正统观念
|
Religion |
| on_become_doge | Fires for a newly elected Doge.
|
Succession |
| on_elective_gavelkind_succession |
|
Succession |
| on_entering_port | Fires when a navy moves into a port.
|
Units |
| on_rel_elector_chosen | Fires when a cardinal is elected (SoA only).
|
Religion |
| on_rel_head_chosen | Fires when a Pope is elected (SoA only)
|
Religion |
| on_settlement_looted |
|
Holding |
| on_navy_returns_with_loot |
|
Units |
| on_create_title |
|
Succession |
| on_new_holder |
|
Succession |
| on_new_holder_inheritance |
|
Succession |
| on_new_holder_usurpation |
|
Succession |
| on_create_chronicle_if_empty | 如果编年史为空,则每年年底会被点燃 | Control |
| on_chronicle_owner_change | Fires when the player changes character
|
Control |
| on_chronicle_start | 游戏开始时,玩家角色会触发(但从存档加载时不会)。查理曼DLC未激活时也能用。
注意:对于统治者设计的角色,历史角色和玩家统治者设计的角色会发射两次。 |
Control |
| on_character_convert_religion | Character converts religion, for whatever reason.
|
Character,Religion |
| on_character_convert_secret_religion | Character converts to their secret religion.
|
Character,Religion |
| on_character_convert_culture | Character converts culture, for whatever reason.
|
Character |
| on_acquire_nickname |
|
Character |
| on_over_vassal_limit_succession | 对于附庸的火灾,因为封臣超过附庸上限而可能独立 | Sucession |
| on_war_started |
|
War |
| on_war_ended_victory |
Offensive War Victory
|
War |
| on_war_ended_invalid |
|
War |
| on_war_ended_whitepeace |
Offensive War Whitepeace
|
War |
| on_war_ended_defeat |
Offensive War Defeat
|
War |
| on_divorce | 无论原因如何,角色离婚时都会触发:
|
Character |
| on_holding_building_start | Fires whenever a character build something in a holding
|
Holding |
| on_settlement_construction_start | Fires whenever the "construction" of a new settlement/holding starts
|
Holding |
| on_settlement_construction_completed | 只要新定居点/领地的“建设”完成,就会被点燃
|
Holding |
| on_trade_post_construction_start |
|
Holding |
| on_trade_post_construction_completed |
|
Holding |
| on_fort_construction_start |
|
Holding |
| on_fort_construction_completed |
|
Holding |
| on_feud_started |
|
Relations |
| on_feud_ended |
|
Relations |
| on_blood_brother_death | Relations | |
| on_ai_end_raid |
|
Relations |
| on_mercenary_hired |
|
War |
| on_mercenary_dismissed |
|
War |
| on_mercenary_captain_replacement |
|
War |
| on_enforce_peace | Conclave "enforce peace" mechanic | Realm |
| on_enforce_peace_start | Conclave "enforce peace" mechanic | Realm |
| on_enforce_peace_six_vassals | Conclave "enforce peace" mechanic | Realm |
| on_law_vote_passed | Realm | |
| on_law_vote_failed | Realm | |
| on_player_mercenary_income | Character | |
| on_artifact_inheritance | 每当角色获得神器(每个神器一个)时即被解雇
|
Character |
| on_society_bi_yearly_pulse | 每两年一次的脉冲,专为社团活动设计(仅为社团中的角色发射火) | Pulse,Society |
| on_society_created | Fires when someone joins a society with no members.
|
Society |
| on_society_destroyed | 当一个社团的最后一名成员离开且没有人替代时,解雇
|
Society |
| on_society_failed_to_find_new_leader | 当一个不可摧毁的社会未能从现有角色中找到新领导者时,会被点燃。
|
Society |
| on_society_progress_full | 当一个社会的进度被提升或设定为100时,触发点火。
|
Society |
| on_society_progress_zero | 当一个社会的进度被降低或设置为0时,会触发。
|
Society |
| on_offmap_policy_changed | 当该强权改变政策时,该大国的总裁会被触发。
|
Offmap |
| on_offmap_status_changed | 当该力量状态发生变化时,触发该地图外的总督。
|
Offmap |
| on_offmap_governor_changed | 当该国更换总督时,会触发该局的新总督。
|
Offmap |
| on_offmap_ruler_changed | 当该强权更换统治者时,会触发该地图外势力的新统治者。
|
Offmap |
| on_offmap_monthly_pulse | 每月随机某一天,会为地图外大国的总督发火。
|
Offmap |
| on_offmap_yearly_pulse | 每年在随机月度更新中为某个地图外势力的总督发火一次。
|
Offmap |
| on_eu4_conversion_start | 在EU4转换器转换游戏之前,玩家(或观察模式中的随机角色)会触发。可以用来准备游戏状态以适应EU4转换,然后恢复原始状态。
|
EU4 Converter |
| on_eu4_conversion_done | 在EU4转换器完成游戏转换后,玩家(或观察模式中的随机角色)会触发。
|
EU4 Converter |
| on_tyranny_gained | 每个角色对暴君产生“暴君”评价惩罚,而暴政是由代码造成的,而非脚本,都会被开火。如果你用,它不会发射 add_opinion_modifer to add tyrrany.
|
Character |
| on_tyranny_gained_tyrant_only | 当暴政是由代码而非脚本引起的时,这场战斗会为暴君开火一次。如果你用,它不会发射 add_opinion_modifer to add tyrrany.
|
Character |
| on_revoke_attempted_started_war | 因为角色拒绝撤销头衔并为此宣战。
|
War |
| on_retract_vassal_attempted_started_war | 拒绝撤回附庸尝试并为此宣战的角色会被点火。
|
War |
| on_absorb_clan_attempted_started_war | 拒绝吸收氏族尝试并为此宣战的角色会被点火。
|
War |
| on_split_clan_attempted_started_war | 因为角色拒绝分裂氏族的尝试并为此宣战。
|
War |
| on_unit_entering_province | 当单位进入省份时,所有角色(带领侧翼或子单位)都会开火。
|
War |
| on_command_unit | 当角色被派去指挥侧翼时,会开火。
|
War |
| on_command_subunit | 当角色被赋予指挥子单位时,触发点火。
|
War |
| on_alternate_start | 在游戏设置结束时(就在“欢迎界面”出现前)随机/破碎世界生成的第一个角色触发触发。
|
Alternate Start |
| on_crusade_preparation_starts | 当Crusade开始准备时,会被发射。所有Crusades/Jihads/GHWs的火灾,无论它们是否有准备阶段——使用 uses_new_crusade = yes trigger to limit effects.
|
War, Crusade |
| on_crusade_preparation_ends | Fires when a Crusade ends preparation.
|
War, Crusade |
| on_crusade_canceled | Fires when a Crusade is canceled.
|
War, Crusade |
| on_crusade_monthly | 每个月一次,Crusade准备或活动时会开火。
|
War, Crusade |
| on_crusade_target_changes | 当Crusade目标变换(无论是脚本、失效,或目标继承者继承)时触发。紧接着发生 crusade_target_char and crusade_target_title scopes are updated).
|
War, Crusade |
| on_pledge_crusade_participation | 当角色承诺参与时,即使战争已经开始,它也会点火。当角色因加入战争而自动宣忠时,不会触发。
|
War, Crusade |
| on_pledge_crusade_defense | 当角色承诺保卫crusade目标时,即使战争已经开始,也会触发。当角色因加入战争而自动宣忠时,不会触发。
|
War, Crusade |
| on_unpledge_crusade_participation | 当角色取消参与承诺时触发,包括死亡和转化时自动解除承诺。
|
War, Crusade |
| on_unpledge_crusade_defense | 当角色解除防御承诺时,包括死亡和转化时自动解除承诺,触发该卡。
|
War, Crusade |
| on_excommunicate_interaction | 当有人通过硬编码的外交互动被逐出教会时,会被触发。
|
Religion |
| on_character_renamed | 当玩家重新命名角色时触发。这包括“新生儿”事件。
|
Control |
| on_title_renamed | 当玩家重新命名头衔时,会被触发。这包括通过标题画面进行更名。
|
Control |
| on_province_renamed | 当玩家重新命名省份时触发。这包括通过省份视图进行更名。
|
Control |
| on_artifact_renamed | Fires when a player renames an artifact.
|
Control |
| on_bloodline_renamed | Fires when a player renames a bloodline.
|
Control |
| on_employer_change | 当发现雇主变更时开除。其中 trigger = { FROM = { character = no } } 这可以用来触发任何新生成角色的事件,但不一定适用于通过硬编码方式创建的角色。
|
Character |
| on_host_change | Fires when a change of host has been detected. on_employer_change 如果角色在最后一次检查后雇主和宿主都被更改,则会被优先解雇。其中 trigger = { FROM = { character = no } } 这可以用来触发任何新生成角色的事件,包括通过硬编码方式创建的角色。
|
Character |
| on_wonder_construction_start | Triggers when a wonder begins construction of any stage.
|
Wonder |
| on_wonder_destroyed | Triggers when a wonder is destroyed.
|
Wonder |
| on_wonder_loot_start | Triggers when looting of a wonder starts
|
Wonder |
| on_wonder_owner_change | 当角色成为奇迹的主人时触发。
|
Wonder |
| on_wonder_renamed | Triggers when a wonder is renamed
|
Wonder |
| on_Wonder_restore_finish | Triggers when resotration of a wonder finishes
|
Wonder |
| on_wonder_restore_start | Triggers when resotration of a wonder starts
|
Wonder |
| on_wonder_stage_finish | Triggers when a wonder finishes building a stage.
|
Wonder |
| on_wonder_stage_loot_finish | Triggers when looting of a wonder stage finishes
|
Wonder |
| on_wonder_stage_loot_start | Triggers when looting of a new wonder stage starts
|
Wonder |
| on_wonder_upgrade_destroyed | Triggers when an upgrade is destroyed in a wonder.
|
Wonder |
| on_wonder_upgrade_finish | Triggers when a wonder upgrade finishes construction.
|
Wonder |
| on_wonder_upgrade_start | 当奇观开始建造升级时触发。
|
Wonder |
| 历史 | 角色 • 家族 • 省份 • 头衔 • 剧本 |
| 脚本 | 指令 • 条件 • 作用域 • 修正 • 事件 • 决议 |
| 常规 | 定义 • 游戏规则 • 另类开局 • 宗教 • 文化 • 政体 • 特质 • 血脉 • 科技 • 法律 • 建筑 • 宣战理由 • 朝贡国 • 单位 • 目标 • 疾病 • 死亡 • 荣誉头衔 • 社团 • 宝物 • 地图外政权 • 内阁成员 • 贸易路线 • 继承 • 奇观 • 称号 |
| 图像/音效/本地化 | 地图 • 图形 • 盾徽 • 肖像 • 界面 • 小地图 • 音乐 • 本地化 |
| 其他 | 故障排除 • 验证器 • 控制台指令 • 编辑游戏存档 • Steam创意工坊 • EU4转档器模组制作 |
AttributesCharacterCommandsConditionConditionsDefinesEU4转档器模组制作Event targetHoldingsIncapableJargonLocalizationModsPatch 2.0Patch 2.6Patch 3.0ScopesSteam创意工坊The ValidatorTraitsTwinWitcher Kings作用域修正内阁成员模组制作决议模组制作剧本模组制作单位模组制作历史模组制作另类开局模组制作图形模组制作地图外政权模组制作地图模组制作头衔模组制作奇观模组制作宗教模组制作定义宝物模组制作宣战理由模组制作家族模组制作小地图模组制作建筑模组制作指令控制台指令政体模组制作故障排除文化模组制作朝贡国类型模组制作本地化条件模组制作死亡模组制作法律模组制作游戏规则模组制作特质模组制作界面模组制作疾病模组制作目标模组制作盾徽模组制作省份模组制作