决议修改:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.5
无编辑摘要
无编辑摘要
第2行: 第2行:


==决议路径==
==决议路径==
 决议位于{{path|common/decisions}}决议路径位于 {{path|common/decisions/categories}}.
 决议位于{{path|common/decisions}} 决议 路径位于 {{path|common/decisions/categories}}


==创建决议组==
==创建决议组==

2020年8月18日 (二) 00:22的版本


决议路径

决议位于/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
     }
}

This will make the decision category only appear if you have more than 3 civilian factories regardless of whether the decisions inside meet their requirements.

创建决议

Decisions need to sit nestled inside a category - let's take our category of prospecting resources and give the country a decision to improve rural infrastructure:

find_resources = {
     develop_infrastructure = {
     
     }
}

决议效果

Decisions have effects using complete_effect. This is nestled inside the decision, and defines what will happen when the decision is selected. Let's give our option to improve rural infrastructure the effect of actually improving infrastructure in a random state for the cost of 500 manpower:

find_resources = {
     develop_infrastructure = {
          complete_effect = {
               random_owned_state = {
                    add_building_construction = { type = infrastructure level = 2 instant_build = yes }
               }
               add_manpower = -500
          }
      }
}

For more information on random_owned_state, see scopes, and for more information on add_building_construction and add_manpower, see commands

random_list effects

By default decisions use the same random seed everytime they are enacted. This means, if random_list is used in a decision, it will give the same result everytime. To prevent this, you can add fixed_random_seed = no to the decision. For example:

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

决议可用性

You will want to make some decisions available only under certain circumstances. For example, our decision to develop infrastructure should only be available if the country has more than 500 manpower to spend. This can be achieved by a available block, as follows:

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

For more information on has_manpower and other conditions, see conditions

决议花费

You may also want your decision to cost political power to begin. Let us give our decision the cost of 50 political power:

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

决议是否可见

A decision may not always need to be visible on the decision tab, to avoid cluttering it up. In order to avoid clutter we only want the decision to appear if the player has more than 0 manpower, as follows:

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

等一会再消失,或者过一会再回来

You may wish for your decision to remain in the category for a short while after it has been completed, or you may wish for it to return after a short time. Equally you might wish for your decision to only be used once. These can all be achieved as follows:

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

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:

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