trigger · has_rule
Definition
- Supported scope:
any - Supported target:
none
Description
Checks if a rule set for a country.
Example: has_rule = can_puppet
has_ruleanynoneChecks if a rule set for a country.
Example: has_rule = can_puppet
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_rule 常用于在 mod 中根据游戏规则设置来动态调整 AI 行为或事件可用性,例如只有当规则允许傀儡化时才显示相关决议或事件选项。也适合用在 allowed / available 块中,确保某些功能在不同游戏规则配置下能正确开启或隐藏。
# 仅当规则允许傀儡时,该决议才可用
available = {
has_rule = can_puppet
is_subject = no
}
[has_game_rule](/wiki/trigger/has_game_rule):has_rule 检查的是针对具体国家生效的规则,而 has_game_rule 检查的是全局游戏规则选项,两者常并列使用以覆盖不同层级的规则判断。[custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip):当 has_rule 的原始提示文本不够直观时,包裹在此内可自定义向玩家显示的条件说明,提升 UI 可读性。[not](/wiki/trigger/not):常与 has_rule 搭配取反,用来表达"当某规则被禁止时"的分支逻辑,例如限制无法被傀儡的国家走特定科技路线。[or](/wiki/trigger/or):多个规则条件只需满足其一时,将数条 has_rule 嵌套在 or 块中,避免写重复的平行条件块。has_rule 的值必须是游戏内已定义的规则标识符(如 can_puppet),新手常把它与 has_game_rule 的选项值混淆,或自行填写不存在的字符串,导致条件永远为假且不报错,排查困难。every_state 或省份 scope 内调用时,若未先通过 OWNER 等方式切换回国家 scope,会得到非预期的判断结果。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_rule is commonly used in mods to dynamically adjust AI behavior or event availability based on game rules, such as only displaying relevant decisions or event options when rules permit puppeting. It also works well within allowed / available blocks to ensure certain features are correctly enabled or hidden under different game rule configurations.
# This decision is only available when rules allow puppeting
available = {
has_rule = can_puppet
is_subject = no
}
[has_game_rule](/wiki/trigger/has_game_rule): has_rule checks rules that apply to a specific nation, whereas has_game_rule checks global game rule options. They are often used together to cover different levels of rule verification.[custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip): When the native tooltip text for has_rule is not sufficiently intuitive, wrapping it in this allows you to customize the condition description displayed to players, improving UI readability.[not](/wiki/trigger/not): Frequently paired with has_rule to negate the condition, expressing logic like "when a certain rule is disabled." For example, restricting nations that cannot be puppeted from following specific tech paths.[or](/wiki/trigger/or): When multiple rule conditions only need to satisfy one of them, nest multiple has_rule statements within an or block to avoid writing redundant parallel condition blocks.has_rule must be a rule identifier defined in-game (such as can_puppet). Beginners often confuse it with option values from has_game_rule or fill in non-existent strings, causing the condition to always evaluate to false without error, making debugging difficult.every_state or province scopes, if you don't first switch back to nation scope via OWNER or similar methods, you may get unexpected evaluation results.