Wiki

trigger · has_decision

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has active selected decision

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

has_decision 常用于检查某个决策是否处于激活状态,从而控制后续决策、国策或事件的可用性,避免重复触发或形成互斥逻辑。例如在 mod 中某个国家需要先激活"外交准备"决策才能解锁下一阶段的战争选项:

available = {
    has_decision = foreign_preparation_decision
}

配合关系

  • [has_active_mission](/wiki/trigger/has_active_mission):决策与任务往往配套使用,两者结合可同时检查国家当前的"决策+任务"激活状态,避免逻辑缺口。
  • [activate_decision](/wiki/effect/activate_decision):通常在 effect 块中用此命令激活某决策,再在后续条件中用 has_decision 验证其是否已激活,形成激活→检查的闭环。
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision):针对目标国家的决策激活后,配合 has_decision 在对应 scope 下确认决策是否生效,常见于外交类 mod。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):国策完成后才允许激活某决策,再用 has_decision 检查该决策是否已激活,两者共同构成多阶段解锁链条。

常见坑

  1. 决策 token 写错或大小写不匹配has_decision 的参数必须与 decisions 文件中定义的 decision key 完全一致(HOI4 脚本区分大小写),写错 key 不会报错但永远返回 false,导致条件无法满足且难以排查。
  2. has_active_mission 混淆使用:普通决策(decision)和任务(mission)是两种不同类型,has_decision 不能检查 mission 类型的决策,必须改用 has_active_mission,否则条件始终不成立。

Hands-On Notes

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.

Hands-On Usage

has_decision is commonly used to check whether a specific decision is in an active state, thereby controlling the availability of subsequent decisions, focuses, or events and avoiding duplicate triggers or conflicting logic. For example, in a mod where a nation must first activate the "foreign_preparation_decision" decision to unlock the next phase of war options:

available = {
    has_decision = foreign_preparation_decision
}

Synergy

  • [has_active_mission](/wiki/trigger/has_active_mission): Decisions and missions are often used together. Combining both allows simultaneous checking of a nation's current "decision + mission" activation state, preventing logical gaps.
  • [activate_decision](/wiki/effect/activate_decision): Typically used in effect blocks to activate a decision, then verified in subsequent conditions with has_decision to confirm whether it has been activated, forming a closed loop of activation → verification.
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision): After activating a decision targeting a specific nation, use has_decision within the corresponding scope to confirm whether the decision takes effect. This is common in diplomatic mods.
  • [has_completed_focus](/wiki/trigger/has_completed_focus): A focus must be completed before allowing a decision to be activated. Then use has_decision to check whether that decision has been activated. Both together form a multi-stage unlock chain.

Common Pitfalls

  1. Misspelled decision token or case mismatch: The parameter for has_decision must exactly match the decision key defined in the decisions file (HOI4 scripts are case-sensitive). Misspelling the key will not produce an error but will always return false, causing the condition to never be met and making debugging difficult.
  2. Confusing with has_active_mission: Regular decisions and missions are two different types. has_decision cannot check mission-type decisions; you must use has_active_mission instead. Otherwise, the condition will never evaluate to true.