Wiki

trigger · has_tech

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has technology

实战 · 配合 · 坑

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

实战用法

has_tech 常用于国策、决议或事件的 available/trigger 块中,判断国家是否已研究特定科技以解锁进一步选项——例如限制某项海军国策仅在研发了舰载机技术后才可选取,或在事件中根据玩家是否掌握核物理技术给出不同选项。

# 示例:仅当国家已研究基础坦克技术时,该决议才可用
available = {
    has_tech = gw_artillery
}

配合关系

  • [can_research](/wiki/trigger/can_research):先用 has_tech 确认已有前置技术,再用 can_research 判断下一级科技是否可开始研究,两者组合能精确描述科技树进度的"已学/可学"状态。
  • [add_tech_bonus](/wiki/effect/add_tech_bonus):通常在 has_tech 验证某前置科技存在后,通过 effect 给予下一步科技加速奖励,形成"检测已有科技→奖励进一步研究"的完整链条。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):与 has_tech 并列放在 trigger 块中,同时要求完成特定国策且拥有特定科技,用于设置更严格的解锁条件。
  • [has_doctrine](/wiki/trigger/has_doctrine):与 has_tech 类似用于科技层面的条件检查,两者组合可区分"通用科技"与"条令科技",覆盖更全面的军事技术判断。

常见坑

  1. 科技 token 写错导致条件永远为假has_tech 的值必须是脚本中定义的技术 token(如 basic_tank_design),不能写科技的本地化显示名称或自行猜测名字,建议直接在 technologies/ 文件夹对应的 .txt 文件中查找准确 token。
  2. 在非 COUNTRY scope 中使用has_tech 只在国家 scope 下有效,若写在 owned_stateunit_leader 等子 scope 的 trigger 块内却未切换回国家 scope,条件将无法正确求值,需要用 owner/ROOT/FROM 等切换回 COUNTRY 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_tech is commonly used in the available/trigger blocks of focuses, decisions, or events to check whether a nation has researched a specific technology in order to unlock further options—for example, restricting a naval focus to only be selectable after researching carrier aircraft technology, or presenting different event options depending on whether the player possesses nuclear physics technology.

# Example: This decision is only available if the nation has researched basic artillery technology
available = {
    has_tech = gw_artillery
}

Synergy

  • [can_research](/wiki/trigger/can_research): First use has_tech to confirm that prerequisite technologies exist, then use can_research to determine whether the next-tier technology can begin research. Together, these two triggers can precisely describe the "learned/learnable" status of technology tree progression.
  • [add_tech_bonus](/wiki/effect/add_tech_bonus): Typically after has_tech verifies the existence of a prerequisite technology, use the effect to grant acceleration bonuses to the next technology, forming a complete chain of "detect existing tech → reward further research".
  • [has_completed_focus](/wiki/trigger/has_completed_focus): Place alongside has_tech within the trigger block to simultaneously require completion of a specific focus and possession of a specific technology, useful for setting stricter unlock conditions.
  • [has_doctrine](/wiki/trigger/has_doctrine): Similar to has_tech for technology-level condition checks. Together they can distinguish between "generic technologies" and "doctrine technologies", providing more comprehensive military technology assessment.

Common Pitfalls

  1. Typos in technology tokens causing conditions to always evaluate as false: The value for has_tech must be a technology token defined in the script (such as basic_tank_design), not the localization display name of the technology or a guessed name. It is recommended to look up the exact token directly in the corresponding .txt file within the technologies/ folder.
  2. Usage in non-COUNTRY scope: has_tech only functions within country scope. If written in the trigger block of a subscope like owned_state or unit_leader without switching back to country scope, the condition will fail to evaluate correctly. Use scope-switching commands like owner, ROOT, or FROM to return to COUNTRY scope before invoking the trigger.