Event modding:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.8
无编辑摘要
(文本替换 - 替换“[[Category:”为“[[分类:”)
第205行: 第205行:


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[ 分类:Modding]]

2022年12月5日 (一) 15:50的版本

事件在/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
			}
		}
	}