Wiki

trigger · has_custom_difficulty_setting

Definition

  • Supported scope:any
  • Supported target:any

Description

Returns true if the game has the specified custom difficulty on: 
Example: has_custom_difficulty_setting = TheAxisIndustry

实战 · 配合 · 坑

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

实战用法

has_custom_difficulty_setting 主要用于自定义难度系统的 mod 中,根据玩家在游戏开始时选择的难度选项来动态调整事件触发、国策解锁或生产加成等内容。例如一个轴心国工业强化模组可以通过此 trigger 检测玩家是否启用了对应的难度选项,再决定是否触发额外的工厂建设事件。

# 在某事件的 trigger 块中,检测玩家是否开启了轴心国工业增强难度选项
trigger = {
    has_custom_difficulty_setting = TheAxisIndustry
}

配合关系

  • [has_any_custom_difficulty_setting](/wiki/trigger/has_any_custom_difficulty_setting):当需要判断"只要有任意一个自定义难度被启用"时,与本 trigger 搭配使用,可构成互补的宽严两档判断逻辑。
  • [has_game_rule](/wiki/trigger/has_game_rule):自定义难度系统通常与游戏规则系统并存,两者常组合在 AND/OR 块中,共同筛选当前对局的设置组合。
  • [difficulty](/wiki/trigger/difficulty):原版难度等级与自定义难度选项往往需要同时校验,确保 mod 逻辑在不同难度配置下都能正确响应。
  • [if](/wiki/effect/if):在 effect 块中配合 if 的条件分支,根据本 trigger 的返回值决定是否执行某段效果代码。

常见坑

  1. 选项名称大小写敏感has_custom_difficulty_setting 的参数值必须与在 custom_difficulty 定义文件中声明的选项名完全一致(包括大小写),写错任何一个字母都会静默返回 false,且游戏不会报错提示,极难排查。
  2. 作用域误解:该 trigger 虽然支持 any scope,但它检测的是全局游戏设置而非某个具体国家或州的状态,因此不需要也不应当在特定国家 scope 内嵌套使用,否则容易与其他 scope 相关 trigger 混淆,误以为结果与当前 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

has_custom_difficulty_setting is primarily used in mods that implement custom difficulty systems, dynamically adjusting event triggers, focus tree unlocks, or production bonuses based on the difficulty options selected by the player at game start. For example, an Axis industrial enhancement mod can use this trigger to detect whether the player has enabled the corresponding difficulty option, then decide whether to trigger additional factory construction events.

# In the trigger block of an event, detect whether the player has enabled the Axis industrial enhancement difficulty option
trigger = {
    has_custom_difficulty_setting = TheAxisIndustry
}

Synergy

  • [has_any_custom_difficulty_setting](/wiki/trigger/has_any_custom_difficulty_setting): When you need to check "whether any single custom difficulty is enabled", pair it with this trigger to create complementary strict and lenient validation logic.
  • [has_game_rule](/wiki/trigger/has_game_rule): Custom difficulty systems typically coexist with the game rules system; both are commonly combined within AND/OR blocks to jointly filter the current session's configuration combination.
  • [difficulty](/wiki/trigger/difficulty): Vanilla difficulty levels and custom difficulty options often need to be validated simultaneously to ensure mod logic responds correctly across different difficulty configurations.
  • [if](/wiki/effect/if): Within effect blocks, pair with if conditional branches to decide whether to execute a segment of effect code based on the return value of this trigger.

Common Pitfalls

  1. Option name case sensitivity: The parameter value of has_custom_difficulty_setting must match exactly (including case) the option name declared in the custom_difficulty definition file. A single misspelled character will silently return false, and the game will not report an error, making it extremely difficult to debug.
  2. Scope misunderstanding: Although this trigger supports any scope, it checks global game settings rather than the state of a specific country or state; therefore it should not be nested within a specific country scope, otherwise it easily causes confusion with other scope-related triggers, leading to the mistaken belief that the result is tied to the current scope.