決議修改

本頁面所適用的版本可能已經過時,最後更新於1.5


決議路徑

決議位於/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 # 完成后维持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点政治点数
          }
     }
}

決議組、決議及任務的本地化

主條目:Localisation

決議組和決議都是以類似於國策樹的方式進行本地化。為了使我們的決議組和決議本地化,我們將有一個這樣的本地化文件:

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"

警告:決議組的描述是強制存在的;在本地化文件中缺少"_desc "條目將導致所有其他決議組完全不顯示。

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