(任务,以及决议的部分翻译) |
(→完整例子) |
||
第186行: | 第186行: | ||
==目标决议== | ==目标决议== | ||
有时你希望一个决 | 有时你希望一个决 议 针对多个TAG - 与其多次编写相同的决议来针对每个国家,不如使用一个有针对性的决议。在有针对性的决议中,FROM指的是(令人困惑的)决议的目标,而不是使用者。这里有一个新的决议,给予一个国家在随机状态下对德国、美国和日本其中之一增加基础设施的能力,代价是FROM(所得国)要付出50的政治点数和500的人力。 | ||
find_resources = { | find_resources = { | ||
help_others = { | help_others = { | ||
第243行: | 第243行: | ||
==任务== | ==任务== | ||
任务遵循与决议相同的基本原则。这些任务也位于一个类别中 - 对于任务,我们将建立一个新的 | 任务遵循与决议相同的基本原则。这些任务也位于一个类别中 - 对于任务,我们将建立一个新的 决议组 和一个新的任务,这次是关于波兰征服柏林的。下面是我们在一个 决议组 中的完整任务 - 如果你不明白,也不用担心,我们会把它逐个分解以讲解 : | ||
polish_conquest = { # 这是我们的决议组 | polish_conquest = { # 这是我们的决议组 | ||
conquer_berlin = { # 这是我们的任务id | conquer_berlin = { # 这是我们的任务id | ||
第286行: | 第286行: | ||
==完整例子== | ==完整例子== | ||
下面是本wiki页面中所有决议和任务的最终版本,归入一个决议组: | |||
find_resources = { | find_resources = { | ||
develop_infrastructure = { | develop_infrastructure = { |
2021年7月5日 (一) 17:02的版本
决议路径
决议位于/Hearts of Iron IV/common/decisions,决议组路径位于 /Hearts of Iron IV/common/decisions/categories。
创建决议组
所有的决议都需要进入可以容纳多个决议的决议组中,并且决议组可以拥有自己的图片和描述。一个基本的决议组如下所示。在这一页中,我们会使用寻找资源的决议组创建作为例子。想要创建决议组,你首先需要在decisions/categories文件夹下创建一个文件,可以是 00_decision_categories.txt或是其他文件。 决议组条目如下所示:
find_resources = { icon = generic_prospect_for_resources }
这是最简单的一种决议组,并且无论何种情况下都会出现。 You can also add conditions such as allowed, available, and visible like in normal decisions if you want the category to appear under specific circumstances. 例如:
find_resources = { icon = generic_prospect_for_resources available = { num_of_civilian_factories > 3 } }
这将使得决议组仅在你拥有多于三个民用工厂时才会出现,与决议组中的决议是否满足条件无关。
创建决议
决议需要位于决议组中——让我们拿上之前的寻找资源决议组,并加入一个给国家增加乡村基础设施的决议。
find_resources = { develop_infrastructure = { } }
决议效果
决议效果的代码是complete_effect。这条语句位于决议中,决定了当决议被选中时会发生的事情。让我们添加一个在选中时以500人力的代价增加基础设施的效果:
find_resources = { develop_infrastructure = { complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } } }
如果想更进一步了解random_owned_state,请查阅作用域,如果想了解关于add_building_construction和add_manpower的更多信息,请查阅指令。
随机效果(random_list effects)
默认情况下,决议启用时每次都是用相同的随机种子。这意味着,如果random_list
用在决议中,它每次产生的结果都是相同的。
为了避免这种情况发生,你可以在决议代码中添加fixed_random_seed = no
。
例如:
decision_category = { give_pp_or_experience_decision = { icon = generic_research available = { has_war = yes } fixed_random_seed = no complete_effect = { random_list = { 33 = { add_political_power = 10 } 33 = { army_experience = 10 } 33 = { air_experience = 10 } } } ai_will_do = { factor = 0 } } }
决议可用性
你可能想让某些决议在只满足某些条件的情况下才可用。例如,我们的发展基础设施的决议应当只能在国家有多于500人力的时候才可用。这可以用available语句实现,例子如下:
find_resources = { develop_infrastructure = { available = { has_manpower > 500 } complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } } }
如果想要进一步了解has_manpower和其他条件,参见条件。
决议花费
你可能也想让你的决议需要花政治点数启用。让我们给这个决议增加50政治点数的花费:
find_resources = { develop_infrastructure = { cost = 50 available = { has_manpower > 500 } complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } } }
决议是否可见
决议可能不总是要在决议栏中出现,否则会有些杂乱。为了做到这一点,我们只想让玩家拥有多于0的人力的时候才能看到这个决议,如下所示:
find_resources = { develop_infrastructure = { visible = { has_manpower > 0 } cost = 50 available = { has_manpower > 500 } complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } } }
等一会再消失,或者过一会再回来
你可能想让决议在完成后等一会再消失,或者你想让决议在完成后过一会再度出现,又或者你可能只想让这个决议使用一次,这些可以通过如下方式实现:
days_remove = 5 # 完成后维持5天再移除 days_re_enable = 5 # 将在5天后显示于界面中,可以再次选择 fire_only_once = yes #在移除后将不会重新出现
导致战争的决议
如果你的决议会导致一个国家对另一个国家宣战,下列语句都会告知将被宣战的国家一场战争即将到来,同时警告AI把部队移动到边界上:
war_with_on_remove = TAG # War is declared on the nation in the TAG when the decision is removed war_with_on_complete = TAG # War is declared on the nation in the TAG when the decision is completed war_with_on_timeout = TAG # War is declared on the nation in the TAG when the decision times out war_with_target_on_remove = yes # War is declared when the targeted decision is removed war_with_target_on_complete = yes # War is declared when the targeted decision is completed war_with_target_on_timeout = yes # War is declared when the targeted decision times out
移除时的效果
在一个决议执行完毕后(即你设置的决议的天数),你可能希望发生一个效果。以我们的基础设施决议为例,我们想在10天后归还人力:
find_resources = { develop_infrastructure = { visible = { has_manpower > 0 } cost = 50 available = { has_manpower > 500 } complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } days_remove = 10 remove_effect = { add_manpower = 500 } } }
决议修正
使用决议,你可以让一个修正只在一定时间内发挥作用。使用修正,只要决议处于激活状态(使用day_remove语句设置),就可以做到这一点。我们现在的决议已经有点忙了,所以这里建立一个新的决议,在激活后的200天内增加10%的战略资源获取率,代价是花费100政治点数。该决议只能使用一次:
find_resources = { resource_spree = { cost = 100 fire_only_once = yes modifier = { local_resources_factor = 0.1 } days_remove = 200 } }
关于local_resources_factor的更多信息,参见修正
目标决议
有时你希望一个决议针对多个TAG - 与其多次编写相同的决议来针对每个国家,不如使用一个有针对性的决议。在有针对性的决议中,FROM指的是(令人困惑的)决议的目标,而不是使用者。这里有一个新的决议,给予一个国家在随机状态下对德国、美国和日本其中之一增加基础设施的能力,代价是FROM(所得国)要付出50的政治点数和500的人力。
find_resources = { help_others = { target_trigger = { FROM = { OR = { tag = GER tag = USA tag = JAP } } } cost = 50 fire_only_once = yes complete_effect = { FROM = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } } add_manpower = -500 } } }
State targeted decisions
The following section is duplicated from a blogpost by Yard1.
State targeted decisions are very similar to country targeted decisions. In order to define a decision as a state targeted decision, you need to put:
state_target = yes
Then FROM will be a state scope, with target_trigger
and target_root_trigger
working like with country targeted decisions.
Just like with country targeted decisions, you can define targets (State IDs or variables) and /Hearts of Iron IV/target_array. Useful target arrays include:
core_states controlled_states owned_states
Each array can be prefixed with another scope (so eg. EQS.core_states
will scope to EQS’s core states, even if ROOT is something else), and you can use your own arrays too.
One extra key state targeted decisions have is on_map_mode. It has two possible values:
on_map_mode = map_only - will not show the decisions in the decision tab, and instead only put icons over the states in the 3d map on_map_mode = map_and_decisions_view - will show the decisions both on map and in the decision tab
Another key is highlight_color_while_active = 1
- seems to highlight the state as long as the decision is active, even after exiting the decision tab. Only used for missions in vanilla.
Activating targeted decisions
Since target_trigger is checked for every country it can have quite a heavy effect on performance. If you simply want to add a targeted decision against a specific country from a focus you can do it by using an effect.
activate_targeted_decision = { target = TAG decision = decision_to_activate }
Note: FROM can be used here in place of a tag
Notes on testing
Target triggers may not be evaluated immediately. When testing triggers, give the game some time to reprocess / evaluate it, rather than erroneously assuming a coding error right away. This explicitly includes after unlocking the visible/available triggers through another action (decision made, national focus completed, etc.).
任务
任务遵循与决议相同的基本原则。这些任务也位于一个类别中 - 对于任务,我们将建立一个新的决议组和一个新的任务,这次是关于波兰征服柏林的。下面是我们在一个决议组中的完整任务 - 如果你不明白,也不用担心,我们会把它逐个分解以讲解:
polish_conquest = { # 这是我们的决议组 conquer_berlin = { # 这是我们的任务id allowed = { tag = POL } # 这项任务只允许在波兰进行。其他国家将无法看到它或激活它 available = { # 这里的Available和goal中的一样,因为: controls_state = 64 # 只有控制了64号省份(柏林),我们才能完成这个任务 } activation = { # 在这种情况下,任务被激活并开始倒计时: has_war_with = GER # 与德国交战 } is_good = yes # 这个任务的颜色编码是有益事情(非危机) selectable_mission = yes # 这个任务将在玩家点选任务时完成,而非自动完成 days_mission_timeout = 100 # 距离任务失败前有多少天? timeout_effect = { # 当任务失败时会发生什么? add_political_power = -50 # 失去50点政治点数 } complete_effect = { # 当我们激活任务时,即任务成功时会发生什么? add_political_power = 50 # 获得50点政治点数 } } }
Localising categories, decisions and missions
- 主条目:Localisation
Both categories and decisions are localised in a similar way to focus trees. To localise our category and decision, we will have a localisation file as such:
find_resources:0 "Find Resources" find_resources_desc:0 "To increase the military might of our nation, we must find more natural resources within our borders to exploit" develop_infrastructure:0 "Develop Infrastructure" develop_infrastructure_desc:0 "In order to access our natural resources more effectively, we must develop rural infrastructure!" resource_spree:0 "Resource Spree" resource_spree_desc:0 "We should go on a resource spree to increase production for a short time"
Warning : the description for category is mandatory ; missing the "_desc" entry in localisation files will result on all other categories not printed at all.
Localising targeted decisions
We can use From to localise for our targeted country in targeted decisions, for example:
help_others:0 "Help [From.GetName] with their infrastructure" help_others_desc:0 "We should send some help to [From.GetName] for their rural infrastructure"
完整例子
下面是本wiki页面中所有决议和任务的最终版本,归入一个决议组:
find_resources = { develop_infrastructure = { visible = { has_manpower > 0 } cost = 50 available = { has_manpower > 500 } complete_effect = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } days_remove = 10 remove_effect = { add_manpower = 500 } } resource_spree = { cost = 100 fire_only_once = yes modifier = { local_resources_factor = 0.1 } days_remove = 200 } help_others = { target_trigger = { OR = { tag = GER tag = USA tag = JAP } } cost = 50 fire_only_once = yes complete_effect = { FROM = { random_owned_state = { add_building_construction = { type = infrastructure level = 2 instant_build = yes } } add_manpower = -500 } } } }
文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
地图 | 地图 • 省份 • 补给区域 • 战略区域 |
图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 离子效果 • 字体 |
装饰性 | 肖像 • 命名列表 • 音乐 • 音效 |
其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |