trigger · has_focus_tree
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
Does current country have the specified focus tree.
has_focus_treeCOUNTRYnoneDoes current country have the specified focus tree.
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_focus_tree 常见于多国共用同一套事件或决策的 mod 中,用来区分"只有拥有特定国策树的国家才能触发某条逻辑",避免效果错误地应用到使用默认树的国家。例如,当你为某个自定义阵营写了专属国策树,需要判断玩家是否已切换到该树:
# 在一个决策的 available 块中:
available = {
has_focus_tree = my_custom_focus_tree
has_completed_focus = my_custom_first_focus
}
[complete_national_focus](/wiki/effect/complete_national_focus):切换国策树后往往需要立即完成某个起始节点,与 has_focus_tree 搭配可以验证树已生效后再执行。[has_completed_focus](/wiki/trigger/has_completed_focus):两者经常并列出现,先确认国家使用的是目标树,再进一步检查树内某个具体节点是否完成,避免跨树节点名冲突导致误判。[has_country_flag](/wiki/trigger/has_country_flag):当同一国策树被多个标签共享时,用国家标志配合该 trigger 做更精细的分支判断,区分同树不同路线的国家。[exists](/wiki/trigger/exists):在 any_country / all_country 循环中,先用 exists 确认国家存在,再用 has_focus_tree 筛选目标,防止对已消亡国家执行判断引发报错。id 字段:has_focus_tree 接受的是国策树文件内 focus_tree = { id = ... } 定义的 id 值,而不是文件名本身;如果两者不同,条件永远返回假且不会有任何报错提示,极难排查。set_politics / load_focus_tree:新手常以为给国家分配了初始国策树脚本后所有国家自动拥有,实际上若没有在 history 文件或 on_action 中显式加载该树,has_focus_tree 在游戏开局就会失败,导致依赖它的所有逻辑全部跳过。Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
has_focus_tree is commonly used in mods where multiple nations share the same set of events or decisions. It restricts logic to only trigger for countries that possess a specific focus tree, preventing effects from being incorrectly applied to nations using the default tree. For example, if you've created a custom focus tree for a specific faction and need to verify whether the player has switched to it:
# In the available block of a decision:
available = {
has_focus_tree = my_custom_focus_tree
has_completed_focus = my_custom_first_focus
}
[complete_national_focus](/wiki/effect/complete_national_focus): After switching focus trees, you often need to immediately complete a starting node. Pairing this with has_focus_tree allows you to verify that the tree has taken effect before executing further actions.[has_completed_focus](/wiki/trigger/has_completed_focus): These two triggers frequently appear together. First confirm the country is using the target tree, then further check whether a specific node within that tree has been completed, preventing misidentification due to cross-tree node name conflicts.[has_country_flag](/wiki/trigger/has_country_flag): When the same focus tree is shared by multiple tags, use country flags in conjunction with this trigger for more granular branching logic, distinguishing between countries following different paths within the same tree.[exists](/wiki/trigger/exists): In any_country / all_country loops, first use exists to confirm the country exists, then use has_focus_tree to filter targets, preventing errors from attempting to evaluate conditions on deceased nations.id field: has_focus_tree accepts the id value defined by focus_tree = { id = ... } within the focus tree file, not the filename itself. If these differ, the condition will silently return false without any error message, making it extremely difficult to debug.set_politics / load_focus_tree: Beginners often assume that once an initial focus tree script is assigned to a country, all nations automatically possess it. However, if the tree is not explicitly loaded in the history file or through on_action, has_focus_tree will fail at game start, causing all logic depending on it to be skipped entirely.