Wiki

trigger · difficulty

Definition

  • Supported scope:any
  • Supported target:none

Description

check if the difficulty is above or below specified value 0-2 (difficulty enum). Example: difficulty > 0 (above easy)

实战 · 配合 · 坑

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

实战用法

difficulty 常用于根据玩家当前难度自动调整 mod 平衡性,例如在较高难度下给 AI 额外加成,或在较低难度下解锁辅助性 tooltip 提示。也可用于成就/生涯系统中限制特定奖励只在较高难度下才能触发。

# 仅在普通难度及以上时,AI 才能获得某项特殊决议
available = {
    difficulty > 0
}

配合关系

  • [is_ironman](/wiki/trigger/is_ironman):铁人模式与高难度往往同时出现,两者配合可精确限定"硬核玩法"下才开放的内容。
  • [has_game_rule](/wiki/trigger/has_game_rule):自定义游戏规则可与难度共同构成复合条件,精细控制不同难度+规则组合下的行为。
  • [is_historical_focus_on](/wiki/trigger/is_historical_focus_on):历史模式与难度等级组合使用,可区分"历史+困难"等特定玩法场景。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):当 difficulty 用在隐藏逻辑中时,配合此 effect 向玩家展示与难度相关的说明文本,提升 mod 可读性。

常见坑

  1. 枚举值边界混淆:新手容易把 difficulty > 1 误读为"大于普通",实际应结合官方描述中 0-2 的枚举含义仔细对应,写错比较符号(如用 = 代替 ><)会导致条件永远不匹配。
  2. 在 country/state scope 下误以为需要切 scope:该 trigger 支持 any scope,不需要也不应该先切换到某个具体 scope 再调用,多余的 scope 嵌套不仅无意义,还可能引发解析警告。

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

difficulty is commonly used to automatically adjust mod balance based on the player's current difficulty level, such as granting AI bonuses at higher difficulties or unlocking helpful tooltips at lower difficulties. It can also be used in achievement/career systems to restrict specific rewards so they only trigger at higher difficulty levels.

# Only allow AI to access a certain special decision at Normal difficulty and above
available = {
    difficulty > 0
}

Synergy

  • [is_ironman](/wiki/trigger/is_ironman): Ironman mode and high difficulty often appear together; combining them allows precise control over content that only unlocks in "hardcore" playstyles.
  • [has_game_rule](/wiki/trigger/has_game_rule): Custom game rules can be combined with difficulty to form compound conditions, providing fine-grained control over behavior across different difficulty + rule combinations.
  • [is_historical_focus_on](/wiki/trigger/is_historical_focus_on): Using historical mode together with difficulty levels lets you distinguish specific playstyle scenarios such as "historical + hard".
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): When difficulty is used in hidden logic, pair it with this effect to display difficulty-related explanatory text to players, improving mod readability.

Common Pitfalls

  1. Confusion over enumeration boundaries: Beginners often misread difficulty > 1 as "greater than normal"; you should carefully cross-reference with the official documentation's 0-2 enumeration meanings. Using the wrong comparison operator (e.g., = instead of > or <) will cause the condition to never match.
  2. Mistakenly thinking scope switching is needed under country/state scope: This trigger supports any scope and does not require—nor should you—switch to a specific scope before calling it. Unnecessary scope nesting is not only pointless but may also trigger parsing warnings.