决议修改:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.5
无编辑摘要
无编辑摘要
第185行: 第185行:
For more on ''local_resource_factor'', see [[modifiers]]
For more on ''local_resource_factor'', see [[modifiers]]


==Targeted decisions==
== 目标决议==
Sometimes you want one decision to target multiple tags - rather than writing the same decision multiple times to target each country, you can instead use a targeted decision. In targeted decisions, ''FROM'' refers to (confusingly) the target of the decision, rather than the sender. Here's a new decision giving a country the ability to give Germany, the USA and Japan an infrastructure in a random state at the cost of 50 political power and 500 manpower for the sender:
Sometimes you want one decision to target multiple tags - rather than writing the same decision multiple times to target each country, you can instead use a targeted decision. In targeted decisions, ''FROM'' refers to (confusingly) the target of the decision, rather than the sender. Here's a new decision giving a country the ability to give Germany, the USA and Japan an infrastructure in a random state at the cost of 50 political power and 500 manpower for the sender:
  find_resources = {
  find_resources = {

2020年9月4日 (五) 11:27的版本


决议路径

决议位于/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_constructionadd_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 # Stays for 5 days before being removed

days_re_enable = 5 # Will show up in the interface and can be selected again after 5 days

fire_only_once = yes # Will not re-enable after being removed

导致战争的决议

If your decision leads to a nation declaring war on another nation, any of the following can be used to inform the targeted nation that a war is coming, as well as alert the AI to begin moving troops onto the border:

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

移除时的效果

After a decision has run its course (i.e. the days_remove you have set the decision to), you may want an effect to happen. Taking the example of our infrastructure decision, we want to return the manpower after 10 days:

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

决议修正

Using decisions you can have a modifier acting for only a certain amount of time. Using a modifier block does this for as long as the decision is active (set using the days_remove statement). Our current decision is getting a bit busy now, so here's a new one that gives a 10% resource production bonus for 200 days when activated, for the cost of 100 political power and can only be used once:

find_resources = {
     resource_spree = {
          cost = 100
          fire_only_once = yes
          modifier = {
               local_resources_factor = 0.1
          }
          days_remove = 200
     }
}

For more on local_resource_factor, see modifiers

目标决议

Sometimes you want one decision to target multiple tags - rather than writing the same decision multiple times to target each country, you can instead use a targeted decision. In targeted decisions, FROM refers to (confusingly) the target of the decision, rather than the sender. Here's a new decision giving a country the ability to give Germany, the USA and Japan an infrastructure in a random state at the cost of 50 political power and 500 manpower for the sender:

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

任务

Missions follow the same basic principle as decisions. These also sit inside a category - for missions we will build up a new category and a new mission, this time about Polish conquest of Berlin. Here is our complete mission inside a category - don't worry if it goes over your head, we'll break it down piece by piece:

polish_conquest = {                               # This is our category
     conquer_berlin = {                           # This is our mission id
          allowed = { tag = POL }                 # This mission is only allowed for Poland. Other countries will not be able to see it or activate it.
          available = {                           # Available here means as much as goal because:
               controls_state = 64                      # we can only finish this mission if we control state 64 (Berlin)
          }
          activation = {                          # The mission appears and starts counting down under these circumstances:
               has_war_with = GER                       # War with Germany
          }
          is_good = yes                           # This mission is color coded to be a positive thing (not a crisis)
          selectable_mission = yes                # This mission will complete when the player selects the mission rather than completing automatically
          days_mission_timeout = 100              # How many days before the mission fails?
          timeout_effect = {                      # What happens when we fail the mission?
               add_political_power = -50               # Lose 50 PP
          }
          complete_effect = {                    # What happens when we activate the mission i.e. mission success?
               add_political_power = 50               # Gain 50 PP
          }
     }
}

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"

完整例子

Below are all the final versions of decisions and missions in this wiki page, in one category:

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