Event modding:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.8
无编辑摘要
无编辑摘要
第1行: 第1行:
{{Version|1.8}}
{{Version|1.8}}
Events are defined in {{path|events}}游戏中有不同的四种事件类型:
事件在{{path|events}} 中定义。 游戏中有不同的四种事件类型:
* country_event(国家事件)
* country_event(国家事件)
* news_event(新闻事件)
* news_event(新闻事件)
第6行: 第6行:
* state_event(省份事件)
* state_event(省份事件)
<code>state_event</code> 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.
<code>state_event</code> 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 ==
== 命名空间(Namespace) ==
All events are defined in namespaces which need to to be declared first. Example: <code>add_namespace = germany</code>
所有的事件都要在命名空间中事先定义。例如:<code>add_namespace = germany</code>
== Attributes ==
== 属性 ==
==== id ====
==== id ====
(Type: string) A unique identifier for the event.
( 数据类型: 字符串) 一个事件的独一无二的标识符。
==== title ====
==== 标题(title) ====
(Type: string or triggered text) Can either be a plain localization key for the event's title or a block with a trigger: <code>{ text = event_1_t trigger = { date > 1940.1.1 }}</code>, which will only use the given title if the trigger is true. Can appear multiple times.
( 数据类型: 字符串 or triggered text) Can either be a plain localization key for the event's title or a block with a trigger: <code>{ text = event_1_t trigger = { date > 1940.1.1 }}</code>, which will only use the given title if the trigger is true. Can appear multiple times.
==== desc ====
==== 描述(desc) ====
(Type: string or triggered text) Defines the event's description text. Same syntax as <code>title</code>.
( 数据类型: 字符串 or triggered text) Defines the event's description text. Same syntax as <code>title</code>.
==== picture ====
==== 图片(picture) ====
(Type: string) The picture to use in the event popup.
( 数据类型: 字符串) The picture to use in the event popup.
==== trigger ====
==== 触发器(trigger) ====
(Type: AND trigger, default: <code>{ }</code>) The event can only happen if the trigger evaluates to true. The console command <code>event</code> overrides this trigger.
( 数据类型: AND trigger, 默认: <code>{ }</code>) The event can only happen if the trigger evaluates to true. The console command <code>event</code> overrides this trigger.
==== mean_time_to_happen ====
==== mean_time_to_happen ====
(Type: [[#Mean time to happen 2|MTTH]], default: { days = 1 }) Calculates a value in days (see below). Events are evaluated every {{hover|NCountry.EVENT_PROCESS_OFFSET|20}} days per country and state. On each check the probability of the event firing is 20/MTTH.
( 数据类型: [[#Mean time to happen 2|MTTH]], 默认: { days = 1 }) Calculates a value in days (see below). Events are evaluated every {{hover|NCountry.EVENT_PROCESS_OFFSET|20}} days per country and state. On each check the probability of the event firing is 20/MTTH.


==== fire_only_once ====
==== 只触发一次(fire_only_once) ====
(Type: boolean, default: no) If false, the event can fire multiple times.
( 数据类型: boolean, 默认: no) If false, the event can fire multiple times.
==== is_triggered_only ====
==== 只能被触发(is_triggered_only) ====
(Type: boolean, default: no) If true, the event cannot randomly happen through <code>mean_time_to_happen</code>, it must be triggered explicitly in an effect.
( 数据类型: boolean, 默认: no) If true, the event cannot randomly happen through <code>mean_time_to_happen</code>, it must be triggered explicitly in an effect.
==== timeout_days ====
==== 超时天数(timeout_days) ====
(Type: number, default: {{hover|NGame.EVENT_TIMEOUT_DEFAULT|13}}) Number of days for the recipient to respond. After the timeout, the first option gets selected.
( 数据类型: number, 默认: {{hover|NGame.EVENT_TIMEOUT_DEFAULT|13}}) Number of days for the recipient to respond. After the timeout, the first option gets selected.
==== fire_for_sender ====
==== 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.
( 数据类型: boolean, 默认: yes) If false, the event will not be shown to the sending country, even if it is a major event.
==== hidden ====
==== 隐藏(hidden) ====
(Type: boolean, default: no) The event will not be shown but can still cause other side effects, like triggering different events.
( 数据类型: boolean, 默认: no) The event will not be shown but can still cause other side effects, like triggering different events.
==== exclusive ====
==== exclusive ====
(Type: boolean, default: no) TODO
( 数据类型: boolean, 默认: no) TODO
==== major ====
==== 主要(major) ====
(Type: boolean, default: no) If true, the event will be shown to all countries.
( 数据类型: boolean, 默认: no) If true, the event will be shown to all countries.
==== show_major ====
==== show_major ====
(Type: AND trigger, default: <code>{ }</code>) Limits which countries a major event is shown to.
( 数据类型: AND trigger, 默认: <code>{ }</code>) Limits which countries a major event is shown to.
==== option ====
==== 选项(option) ====
(Type: event option) An option for the event that the receiver can select, see below.
( 数据类型: event option) An option for the event that the receiver can select, see below.
==== immediate ====
==== immediate ====
(Type: event option) This event option happens unconditionally when the event fires.
( 数据类型: event option) This event option happens unconditionally when the event fires.
== Option ==
== 选项(Option) ==
Additionally to the attributes listed below, options may contain arbitrary [[commands|effects]].
Additionally to the attributes listed below, options may contain arbitrary [[commands|effects]].
==== name ====
==== 名称(name) ====
(Type: string) The localization key of the option's name.
( 数据类型: 字符串) The localization key of the option's name.
==== trigger ====
==== 触发器(trigger) ====
(Type: AND trigger, default: <code>{ }</code>) Controls whether this option is available.
( 数据类型: AND trigger, 默认: <code>{ }</code>) Controls whether this option is available.
==== ai_chance ====
==== AI意愿(ai_chance) ====
(Type: [[AI_modding#AI_chance|AI chance]], default: <code>{ base = 1 }</code>) The weight for the AI to pick this option. The probability of each option is its weight divided by the sum of all weights.
( 数据类型: [[AI_modding#AI_chance|AI chance]], 默认: <code>{ base = 1 }</code>) 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 ====
==== original_recipient_only ====
(Type: boolean, default: no) For major events, this option is only available to the direct recipient.
( 数据类型: boolean, 默认: no) For major events, this option is only available to the direct recipient.


== Mean time to happen ==
== Mean time to happen ==
第57行: 第57行:
=== Attributes ===
=== Attributes ===
==== base ====
==== base ====
(Type: number (with 3 decimal places), default: 1) The base value of the calculation, before applying any modifiers.
( 数据类型: number (with 3 decimal places), 默认: 1) The base value of the calculation, before applying any modifiers.
==== factor ====
==== factor ====
An alias for <code>base</code>.
An alias for <code>base</code>.
==== days ====
==== days ====
(Type: number) Sets <code>base</code> to the specified value but does not recognize decimal places.
( 数据类型: number) Sets <code>base</code> to the specified value but does not recognize decimal places.
==== months ====
==== months ====
(Type: number) Sets <code>base</code> to 30 times the value but does not recognize decimal places.
( 数据类型: number) Sets <code>base</code> to 30 times the value but does not recognize decimal places.
==== years ====
==== years ====
(Type: number) Sets <code>base</code> to 365 times the value but does not recognize decimal places.
( 数据类型: number) Sets <code>base</code> to 365 times the value but does not recognize decimal places.
==== modifier ====
==== modifier ====
A modifier block combines its components like an AND trigger. The only exceptions are <code>factor</code> and <code>add</code>. Both are scoped variables, and if the trigger components evaluate to true, the current MTTH value is multiplied by <code>factor</code> before adding <code>add</code>. 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 <code>add</code> after a previous modifier set the value to zero.
A modifier block combines its components like an AND trigger. The only exceptions are <code>factor</code> and <code>add</code>. Both are scoped variables, and if the trigger components evaluate to true, the current MTTH value is multiplied by <code>factor</code> before adding <code>add</code>. 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 <code>add</code> after a previous modifier set the value to zero.
第89行: 第89行:
</pre>
</pre>


== Examples==
== 样例 ==
=== Country event ===
=== Country event ===
<pre>
<pre>

2020年9月4日 (五) 21:25的版本

事件在/Hearts of Iron IV/events中定义。游戏中有不同的四种事件类型:

  • 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)

所有的事件都要在命名空间中事先定义。例如:add_namespace = germany

属性

id

(数据类型: 字符串) 一个事件的独一无二的标识符。

标题(title)

(数据类型: 字符串 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)

(数据类型: 字符串 or triggered text) Defines the event's description text. Same syntax as title.

图片(picture)

(数据类型: 字符串) The picture to use in the event popup.

触发器(trigger)

(数据类型: AND trigger, 默认: { }) The event can only happen if the trigger evaluates to true. The console command event overrides this trigger.

mean_time_to_happen

(数据类型: MTTH, 默认: { 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)

(数据类型: boolean, 默认: no) If false, the event can fire multiple times.

只能被触发(is_triggered_only)

(数据类型: boolean, 默认: no) If true, the event cannot randomly happen through mean_time_to_happen, it must be triggered explicitly in an effect.

超时天数(timeout_days)

(数据类型: number, 默认: 13) Number of days for the recipient to respond. After the timeout, the first option gets selected.

fire_for_sender

(数据类型: boolean, 默认: yes) If false, the event will not be shown to the sending country, even if it is a major event.

隐藏(hidden)

(数据类型: boolean, 默认: no) The event will not be shown but can still cause other side effects, like triggering different events.

exclusive

(数据类型: boolean, 默认: no) TODO

主要(major)

(数据类型: boolean, 默认: no) If true, the event will be shown to all countries.

show_major

(数据类型: AND trigger, 默认: { }) Limits which countries a major event is shown to.

选项(option)

(数据类型: event option) An option for the event that the receiver can select, see below.

immediate

(数据类型: event option) This event option happens unconditionally when the event fires.

选项(Option)

Additionally to the attributes listed below, options may contain arbitrary effects.

名称(name)

(数据类型: 字符串) The localization key of the option's name.

触发器(trigger)

(数据类型: AND trigger, 默认: { }) Controls whether this option is available.

AI意愿(ai_chance)

(数据类型: AI chance, 默认: { 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

(数据类型: boolean, 默认: 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

(数据类型: number (with 3 decimal places), 默认: 1) The base value of the calculation, before applying any modifiers.

factor

An alias for base.

days

(数据类型: number) Sets base to the specified value but does not recognize decimal places.

months

(数据类型: number) Sets base to 30 times the value but does not recognize decimal places.

years

(数据类型: 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 }
		}
	}

样例

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
			}
		}
	}