Wiki

effect · set_technology

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

sets technology level(s) on country. example : set_technology = { 
	infantry_weapons = 1 
	infantry_weapons1 = 1 
	infantry_weapons2 = 1 
	improved_infantry_weapons = 1 
	popup = no # default is yes. if set to no, no pop up will display for player 
}

实战 · 配合 · 坑

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

实战用法

set_technology 最常见于开局脚本或事件中为国家批量补充科技,例如在历史模式开局时给某国解锁符合其时代背景的武器与支援连科技。它也常用于在内战分裂或傀儡创建时,将新生国家的科技状态初始化到与母国相近的水平,避免科技空白导致的 AI 异常。

# 某国通过国策获得初始步兵科技
focus = {
    id = GER_rearm
    ...
    completion_reward = {
        set_technology = {
            infantry_weapons = 1
            infantry_weapons1 = 1
            support_weapons = 1
            popup = no
        }
    }
}

配合关系

  • [add_tech_bonus](/wiki/effect/add_tech_bonus) —— 先用 set_technology 直接解锁基础科技,再用 add_tech_bonus 给予后续研究折扣,形成"给基础、减成本"的连贯激励链。
  • [add_research_slot](/wiki/effect/add_research_slot) —— 科技加速场景中两者搭配,先补足关键起点科技,再增加研究槽让 AI / 玩家能更快推进后续树。
  • [has_completed_focus](/wiki/trigger/has_completed_focus) —— 在条件判断中确认国策已完成后,再执行 set_technology,确保科技解锁仅在特定叙事节点触发。
  • [create_equipment_variant](/wiki/effect/create_equipment_variant) —— 解锁科技后立即创建对应装备变种,否则变种所依赖的科技若不存在会导致脚本报错或变种无效。

常见坑

  1. 科技 key 写错或遗漏等级:HOI4 的科技树中许多科技是分级的(如 infantry_weaponsinfantry_weapons1infantry_weapons2),只写父级不写子级,或把 key 拼错,游戏不会报显眼错误,但科技树 UI 会出现状态异常,研究树显示已研究却缺少实际效果,调试时极难排查。
  2. 在非 COUNTRY scope 下调用set_technology 只能在国家 scope 下执行,若误放在 STATE 或 CHARACTER scope 内(例如在 every_owned_state 循环体里直接调用),游戏会静默忽略或报 scope 错误,新手常因效果"消失"而困惑,需用 owner = { set_technology = { ... } } 回到国家 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

set_technology is most commonly used in startup scripts or events to bulk-grant technologies to nations, such as unlocking era-appropriate weapons and support technologies for a country during historical mode initialization. It is also frequently employed during civil wars, nation splits, or puppet creation to initialize the new nation's technology tree to a level comparable with its parent state, preventing AI anomalies caused by technology gaps.

# A nation acquires initial infantry technology through a focus
focus = {
    id = GER_rearm
    ...
    completion_reward = {
        set_technology = {
            infantry_weapons = 1
            infantry_weapons1 = 1
            support_weapons = 1
            popup = no
        }
    }
}

Synergy

  • [add_tech_bonus](/wiki/effect/add_tech_bonus) —— Use set_technology to directly unlock foundational technologies first, then apply add_tech_bonus to grant research discounts on subsequent techs, forming a coherent incentive chain of "provide basics, reduce costs."
  • [add_research_slot](/wiki/effect/add_research_slot) —— In technology acceleration scenarios, pair both effects together: first supplement critical prerequisite technologies, then increase research slots so the AI/player can advance the subsequent tree faster.
  • [has_completed_focus](/wiki/trigger/has_completed_focus) —— In conditional checks, confirm that the required focus is completed before executing set_technology, ensuring tech unlocks trigger only at specific narrative nodes.
  • [create_equipment_variant](/wiki/effect/create_equipment_variant) —— Create the corresponding equipment variant immediately after unlocking a technology; otherwise, if the technology that a variant depends on does not exist, the script may error or the variant becomes invalid.

Common Pitfalls

  1. Typos in technology keys or missing tier levels: In HOI4's technology tree, many technologies are tiered (e.g., infantry_weapons, infantry_weapons1, infantry_weapons2). Writing only the parent tier without child tiers, or misspelling the key, will not produce obvious errors, but the tech tree UI will display anomalous states—the research tree shows as researched while lacking actual effects. Debugging such issues is extremely difficult.
  2. Calling outside COUNTRY scope: set_technology can only execute within a country scope. If accidentally placed in a STATE or CHARACTER scope (for example, directly called within an every_owned_state loop body), the game will silently ignore it or report a scope error. Newcomers often become confused when the effect "disappears" and must use owner = { set_technology = { ... } } to return to country scope.