Events are defined in /Hearts of Iron IV/events. There are four different event types:
- country_event
- news_event
- unit_leader_event
- state_event
state_event
is evaluated for each state, all other types on the country level. News events can be separately hidden by the player, so they should be purely informational.
Namespace
All events are defined in namespaces which need to to be declared first. Example: add_namespace = germany
Attributes
id
(Type: string) A unique identifier for the event.
title
(Type: string or triggered text) Can either be a plain localization key for the event's title or a block with a trigger: { text = event_1_t trigger = { date > 1940.1.1 }}
, which will only use the given title if the trigger is true. Can appear multiple times.
desc
(Type: string or triggered text) Defines the event's description text. Same syntax as title
.
picture
(Type: string) The picture to use in the event popup.
trigger
(Type: AND trigger, default: { }
) The event can only happen if the trigger evaluates to true. The console command event
overrides this trigger.
mean_time_to_happen
(Type: MTTH, default: { days = 1 }) Calculates a value in days (see below). Events are evaluated every 20 days per country and state. On each check the probability of the event firing is 20/MTTH.
fire_only_once
(Type: boolean, default: no) If false, the event can fire multiple times.
is_triggered_only
(Type: boolean, default: no) If true, the event cannot randomly happen through mean_time_to_happen
, it must be triggered explicitly in an effect.
timeout_days
(Type: number, default: 13) Number of days for the recipient to respond. After the timeout, the first option gets selected.
fire_for_sender
(Type: boolean, default: yes) If false, the event will not be shown to the sending country, even if it is a major event.
(Type: boolean, default: no) The event will not be shown but can still cause other side effects, like triggering different events.
exclusive
(Type: boolean, default: no) TODO
major
(Type: boolean, default: no) If true, the event will be shown to all countries.
show_major
(Type: AND trigger, default: { }
) Limits which countries a major event is shown to.
option
(Type: event option) An option for the event that the receiver can select, see below.
immediate
(Type: event option) This event option happens unconditionally when the event fires.
Option
Additionally to the attributes listed below, options may contain arbitrary effects.
name
(Type: string) The localization key of the option's name.
trigger
(Type: AND trigger, default: { }
) Controls whether this option is available.
ai_chance
(Type: AI chance, default: { base = 1 }
) The weight for the AI to pick this option. The probability of each option is its weight divided by the sum of all weights.
original_recipient_only
(Type: boolean, default: no) For major events, this option is only available to the direct recipient.
Mean time to happen
The mean time to happen (MTTH) is calculated by starting with a base value and applying a chain of modifiers.
Attributes
base
(Type: number (with 3 decimal places), default: 1) The base value of the calculation, before applying any modifiers.
factor
An alias for base
.
days
(Type: number) Sets base
to the specified value but does not recognize decimal places.
months
(Type: number) Sets base
to 30 times the value but does not recognize decimal places.
years
(Type: number) Sets base
to 365 times the value but does not recognize decimal places.
modifier
A modifier block combines its components like an AND trigger. The only exceptions are factor
and add
. Both are scoped variables, and if the trigger components evaluate to true, the current MTTH value is multiplied by factor
before adding add
. Can appear multiple times and all applicable modifiers are applied in the order they were defined in. The calculation stops early if the intermediate value is zero after applying a modifier. This means it is not possible to increase the value again using add
after a previous modifier set the value to zero.
Example
mean_time_to_happen = { days = 500 modifier = { factor = 0.4 # If true multiply 500 by 0.4 = 200 NOT = { country_exists = SOV } } modifier = { factor = 0.4 # If true multiply 200 by 0.4 = 40 NOT = { country_exists = ENG } } modifier = { factor = 0.1 # If true multiply 40 by 0.1 = 4 NOT = { country_exists = ENG } NOT = { country_exists = SOV } } }
Examples
Country event
country_event = { # A unique event ID. # nuke_dropped is the namespace, which helps with organization. id = nuke_dropped.0 title = nuke_dropped.0.t # The localisable text that appears as a header desc = nuke_dropped.0.d # The localisable main text body that appears picture = GFX_report_event_election_vote # Image displayed alongside the text. is_triggered_only = yes # Optional : if set to "yes" the event will only occur by command hidden = yes # Optional : if set to "yes" no one will see the event fire_only_once = yes # Optional : if set to "yes" the event will never occur more than once immediate = { # Optional : all the following will occur once the event occurs if = { limit = { tag = ITA has_government = fascism FROM = { state = 378 } } set_country_flag = duce_nukedem_flag } news_event = { id = nuke_dropped.1 days = 1 } } option = { # This is an example of an option that has no function name = dummy_nuke_option.1.a # The localisable text that appears on the button. } option = { # This is an example of an option that has a function name = dummy_nuke_option.1.b # The localisable text that appears on the button. add_political_power = 100 } option = { # This is an example of an option that has a trigger trigger = { has_country_flag = nuked_before # This option will only appear if the condition is fulfilled. } name = dummy_nuke_option.1.c # The localisable text that appears on the button. add_stability = 0.05 } }
News event
news_event = { id = nuke_dropped.0 # The unique id. nuke_dropped is the namespace, which can be used for better organization, and is used in localisation. picture = GFX_news_event_nuke # Image displayed alongside the text. major = yes # Optional : if set to "yes" every country in the world will see this event is_triggered_only = yes # Optional : if set to "yes" the event will only occur by command hidden = yes # Optional : if set to "yes" no one will see the event fire_only_once = yes # Optional : if set to "yes" the event will never occur more than once immediate = { # Optional : all the following will occur once the event occurs if = { limit = { tag = ITA has_government = fascism FROM = { state = 378 } } set_country_flag = duce_nukedem_flag } news_event = { id = nuke_dropped.1 days = 1 } } option = { # This is an example of an option that has no function name = dummy_nuke_option.1.a # The localisable text that appears on the button. } option = { # This is an example of an option that has a function ( usually not done on a news event ) name = dummy_nuke_option.1.b # The localisable text that appears on the button. add_political_power = 100 } }
Multiple descriptions
desc = { #This is the first description, it will be used if the ace pilot is promoted in any country except the major ones (listed below). text = ace_promoted.1.d #this is the localisable text name, which needs to be unique. trigger = { #this is needed trigger. NOT = { tag = GER } #This means that the description will not trigger if the pilot is promoted in Germany, Italy, France, Japan, the United States, the United Kingdom or the Soviet Union. NOT = { tag = ITA } NOT = { tag = FRA } NOT = { tag = JAP } NOT = { tag = USA } NOT = { tag = ENG } NOT = { tag = SOV } } } desc = { #This is the second description, it will be used if the ace pilot is promoted in any major country (of the ones listed below). text = ace_promoted.1.d_major trigger = { OR = { tag = GER #This means that the description will only trigger if the pilot is promoted in Germany, Italy, France, Japan, the United States, the United Kingdom or the Soviet Union. tag = ITA tag = FRA tag = JAP tag = USA tag = ENG tag = SOV } } }
文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
地图 | 地图 • 省份 • 补给区域 • 战略区域 |
图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 离子效果 • 字体 |
装饰性 | 肖像 • 命名列表 • 音乐 • 音效 |
其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |