Wiki

trigger · has_dlc

Definition

  • Supported scope:any
  • Supported target:none

Description

Checks if player has a DLC.
Example: has_dlc = "name of the dlc"

实战 · 配合 · 坑

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

实战用法

has_dlc 常用于 mod 中为特定 DLC 功能做兼容性保护,例如仅在玩家拥有某 DLC 时才显示对应的决议或国策选项,避免因缺少 DLC 而导致脚本报错或功能异常。它也常被用来在 allowed / available 块中动态启用或禁用某些界面元素,以实现"有 DLC 则增强,无 DLC 则回退"的体验分支。

# 仅在玩家拥有 Man the Guns DLC 时才允许执行某决议
available = {
    has_dlc = "Man the Guns"
    is_historical_focus_on = no
}

配合关系

  • [or](/wiki/trigger/or):与 or 搭配,可同时检测多个 DLC,只要玩家持有其中一个即满足条件,适合为功能相近的多个 DLC 提供统一的兼容入口。
  • [has_game_rule](/wiki/trigger/has_game_rule):常与 has_game_rule 并列使用,先检查 DLC 是否存在,再进一步判断对应的游戏规则是否开启,形成"DLC + 规则"双重门控。
  • [custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip):将 has_dlc 包裹在 custom_trigger_tooltip 中,可以用自定义本地化文本替换默认的 DLC 检测提示,让玩家更清楚地理解条件来源。
  • [if](/wiki/effect/if)(effect 侧)与 [if](/wiki/trigger/if)(trigger 侧):在 if 块的 limit 中嵌入 has_dlc,实现"有 DLC 时走 A 逻辑,无 DLC 时走 B 逻辑"的条件分支。

常见坑

  1. DLC 名称大小写/拼写必须与游戏内部字符串完全一致(例如 "Man the Guns" 而非 "Man The Guns"),哪怕一个字母大小写错误也会导致 trigger 永远返回假,且游戏不会给出任何报错提示,极难排查。
  2. 不要用它来判断 DLC 内容是否"生效"has_dlc 仅检测玩家是否拥有该 DLC,并不能反映相关游戏规则是否被手动关闭。若 mod 功能同时依赖 DLC 规则处于开启状态,必须额外搭配 has_game_rule 进行验证,否则在 DLC 规则被关闭的局里仍会误判为可用。

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_dlc is commonly used in mods to provide compatibility protection for DLC-specific features. For example, it displays certain decisions or national focus options only when the player owns a particular DLC, preventing script errors or malfunctions due to missing DLC. It's also frequently used within allowed / available blocks to dynamically enable or disable UI elements, implementing an "enhanced with DLC, fallback without DLC" experience branch.

# Only allow execution of a decision if player owns Man the Guns DLC
available = {
    has_dlc = "Man the Guns"
    is_historical_focus_on = no
}

Synergy

  • [or](/wiki/trigger/or): Pair with or to check multiple DLCs simultaneously; the condition is satisfied if the player owns any one of them. Ideal for providing a unified compatibility entry point for multiple DLCs with similar functionality.
  • [has_game_rule](/wiki/trigger/has_game_rule): Often used alongside has_game_rule in sequence—first verify DLC existence, then further check whether the corresponding game rule is enabled, creating a "DLC + rule" dual-gate mechanism.
  • [custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip): Wrap has_dlc inside custom_trigger_tooltip to replace the default DLC detection prompt with custom localization text, making it clearer to players what conditions apply.
  • [if](/wiki/effect/if) (effect side) and [if](/wiki/trigger/if) (trigger side): Embed has_dlc within the limit clause of an if block to implement conditional branching—"execute logic A with DLC, logic B without DLC".

Common Pitfalls

  1. DLC name case and spelling must match the in-game string exactly (e.g., "Man the Guns" not "Man The Guns"). Even a single character case mismatch will cause the trigger to always return false, and the game provides no error message, making it extremely difficult to debug.
  2. Do not use it to determine whether DLC content is "active": has_dlc only checks whether the player owns the DLC; it does not reflect whether related game rules have been manually disabled. If mod functionality depends on DLC rules being enabled, you must additionally pair it with has_game_rule for verification. Otherwise, in campaigns where the DLC rule is disabled, the condition will still incorrectly evaluate as available.