Wiki

trigger · has_built

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

checks country has built a set number (at least) of a certain type of building since taking goal 
has_built = { 
  type = building_type 
  value = 42 
}

实战 · 配合 · 坑

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

实战用法

has_built 常用于国家焦点或任务链中,验证玩家/AI 是否已按要求完成了一定数量的建筑投资,例如"完成工业化目标后才能解锁下一阶段焦点"或"军工任务要求建造指定数量的军工厂"。以下示例展示在焦点的 available 块中检查是否已建造至少 3 座军工厂:

available = {
    has_built = {
        type = arms_factory
        value = 3
    }
}

配合关系

  • [building_count_trigger](/wiki/trigger/building_count_trigger)has_built 统计的是自接取目标以来新建数量,而 building_count_trigger 统计的是当前总存量,两者配合可同时约束"现有基础"与"新增投入",避免老玩家绕过建造要求。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):常作为前置条件与 has_built 并列放在 available 块,确保玩家先完成相关焦点后再触发建造检查逻辑。
  • [activate_mission](/wiki/effect/activate_mission):在 effect 块中激活一个以 has_built 为完成条件的任务,形成"激活任务→追踪建造进度→达成后触发奖励"的完整任务链流程。
  • [has_active_mission](/wiki/trigger/has_active_mission):在 availablelimit 中配合使用,确保只有当相应任务处于激活状态时才对 has_built 进行评估,防止条件在任务外被意外满足。

常见坑

  1. 计数起点误解has_built 统计的是"接取目标(goal)后"才开始建造的数量,而非历史总建造量。如果在任务激活前已经建好的建筑不会被计入,新手常误以为已有建筑能直接满足条件,导致任务永远无法完成。
  2. type 填写错误type 必须填写游戏内部定义的建筑 key(如 industrial_complexarms_factory),直接填写显示名称或拼错 key 时脚本不会报错但条件永远为假,调试时极难发现。

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_built is commonly used in national focuses or mission chains to verify whether the player/AI has completed the required amount of building construction, such as "unlocking the next focus stage only after completing industrialization targets" or "military industry missions requiring construction of a specified number of arms factories". The following example demonstrates checking whether at least 3 arms factories have been built in the available block of a focus:

available = {
    has_built = {
        type = arms_factory
        value = 3
    }
}

Synergy

  • [building_count_trigger](/wiki/trigger/building_count_trigger): has_built counts newly constructed buildings since the goal was accepted, while building_count_trigger counts current total stock. Using both together allows simultaneous constraints on "existing foundation" and "new investment", preventing veteran players from circumventing construction requirements.
  • [has_completed_focus](/wiki/trigger/has_completed_focus): Commonly serves as a prerequisite condition placed alongside has_built in the available block, ensuring the player completes the related focus before triggering the construction check logic.
  • [activate_mission](/wiki/effect/activate_mission): Activates a mission with has_built as its completion condition in an effect block, forming a complete mission chain flow of "activate mission → track construction progress → trigger reward upon completion".
  • [has_active_mission](/wiki/trigger/has_active_mission): Used together in available or limit blocks to ensure has_built is only evaluated when the corresponding mission is in active status, preventing the condition from being unexpectedly satisfied outside the mission context.

Common Pitfalls

  1. Misunderstanding the counting origin: has_built counts buildings constructed after accepting the goal, not the historical total. Buildings already completed before mission activation are not counted. Newcomers often mistakenly assume existing buildings directly satisfy the condition, causing missions to never complete.
  2. Incorrect type specification: type must use the building key defined in the game (such as industrial_complex, arms_factory). Using display names or misspelling the key will not cause script errors but the condition will always be false, making it extremely difficult to debug.