Skill: gym114514/hoi-mod-maker (version 1.0.3)

--- name: hoi4-mod-maker description: HOI4 mod全流程技能。国策树/民族精神/人物/事件/决议/本地化/变量/调试。触发：HOI4、钢铁雄心、钢4、国策、国策树、民族精神、焦点树、focus tree、national_focus、ideas、spirits、events、decisions、localisation、inner circle、连续焦点、replace_path、modding、Paradox metadata: version: "1.0.3" changelog: | 1.0.0 初版 — 含完整国策树/民族精神/事件/决议/本地化/调试技能；设计指南含坐标系统/动态定位/真实架构/递进奖励；黄金法则7条；templates参考模式；修复BOM/skill加载问题；去除机械拼装误导 --- # HOI4 Complete Mod-Maker Skill **触发关键词**: HOI4 mod, 钢铁雄心4, 钢4, 国策, 国策树, 民族精神, 焦点树, focus tree, national_focus, ideas, spirits, events, decisions, localisation, inner circle, 连续焦点, replace_path, Paradox modding --- ## ⚠ 国策树布局黄金法则（每次生成前必读） > AI 在生成国策树时最常见的错误。生成代码前，**必须确认以下七点全部满足**： 1. **图标尺寸**：每个国策图标是一个**以坐标 (x,y) 为中心的 2×2 正方形**。即图标左边界在 `x-1`，右边界在 `x+1`，上边界在 `y+1`，下边界在 `y-1`。**左右相邻（同行）时 x 差必须 >= 2，否则图标重叠**；上下相邻时 y 差 >= 1 即可。同一焦点块内紧凑排列时 x 间距用 2（最小合法值）。 2. **`relative_position_id` 是首选**：除非有充分理由（固定窗口锚点、避免 offset 继承等），一律使用 `relative_position_id = <父节点ID>` + 小的 x/y 偏移量。**绝对坐标只用于树的根节点或没有父节点的主干焦点**。 3. **前置国策必须存在**：每个 `prerequisite = { focus = XXX }` 引用的 `XXX` 必须在同一个国策树文件中实际定义。**不得凭空捏造 focus ID**，也不得使用其他国家的 focus ID 作为前置。生成完成后，对照 `examples/09_focus_tree_design_guide.md` 的检查清单逐条验证。 4. **禁止长线性链**：同一条路径上**连续节点不得超过 3 个**（即 A->B->C 之后必须出现分支或汇合）。超过 3 个连续节点会让玩家感到单调，且视觉上形成难看的长竖线。如需表达「递进过程」，用分支+汇合代替直线延伸。 5. **子节点数量上限**：单个焦点的直接子节点（同一 prerequisite 指向同一父节点）**不得超过 5 个**。超过 5 个时，将部分子节点改为二级分支（先汇到中间节点，再展开）。 6. **树深度要求**：单个国策树的**主路径深度应 >= 5 层**，建议 6-10 层。浅层树（<5层）会让玩家缺乏战略规划感。通过添加中间节点、分支选择、汇聚节点来增加深度。 7. **不同板块间距**：同一 `focus_tree` 内的不同分支（如政治/工业/军事），**根节点 x 坐标差应 >= 6**。不同 `focus_tree` 文件之间，使用不同的 `initial_show_position` 错开显示。**严禁不同板块的国策左右相邻且 x 差 < 2**，这会导致视觉混乱。 --- ## Skill Meta | 属性 | 值 | |------|----| | **版本** | 7.2 | | **更新** | 2026-04-26 | | **游戏版本** | HOI4 1.14+ | | **覆盖范围** | 国策树 / 民族精神 / 人物 / 事件 / 决议 / 本地化 / 变量 / 调试 | | **参考文件** | 74 原版国策树 + 10 语法参考 + 12 注释示例 | | **特色能力** | 布局设计 / 原版ID查询 / 代码生成 / 递进奖励设计 / 兼容性指导 | ### 典型使用场景 → 推荐路径 | 用户意图 | 推荐路径 | |---------|----------| | 做国策树 | 09设计指南 → 布局规划 → 代码生成 → 检查清单 | | 图标重叠 | 09设计指南 → 坐标系统/间距规则 | | 查原版国策ID | `references/vanilla_focus_trees/` → 搜索对应国家.txt | | 条件偏移 | 09设计指南(动态与条件定位) → advanced_syntax.md | | 修改原版树 | 查原版ID → replace_path/同ID追加 | | 写民族精神 | 02注释示例 → ideas_syntax.md → 08导入详解 | | 内圈焦点 | 09设计指南(真实架构模式) → germany.txt参考 | | 完成效果写法 | focus_complete_guide.md / dictionary.md | | 本地化编码 | 04本地化详解 → UTF-8 BOM | | mod不生效 | 调试技巧 → error.log | --- ## 快速开始 ### Mod 基础文件结构 ``` your_mod/ ├── descriptor.mod # Mod 描述符（必需） ├── thumbnail.png # 封面图（推荐 256x256） ├── common/ │ ├── national_focus/ # 国策树 .txt │ ├── ideas/ # 民族精神 .txt │ ├── characters/ # 人物定义 .txt │ ├── unit_leader/ # 领导人特质 .txt │ ├── decisions/ # 决议 .txt │ └── modifiers/ # 自定义修正值 ├── events/ # 事件 .txt ├── localisation/ │ ├── english/ # 英文本地化 .yml │ └── simp_chinese/ # 中文本地化 .yml ├── interface/ # GFX 图标定义 └── gfx/ └── goals/ # 国策图标图片 ``` ### descriptor.mod 模板 ``` name = "Your Mod Name" version = "0.2.0" # changelog: 扩展黄金法则至7条；去除模板机械拼装；新增孤立节点/碰撞检测；BOM清理修复skill加载 tags = { "National Focus" "Gameplay" } picture = "thumbnail.png" ``` --- ## 代码规范 ### 基础语法 ``` <attribute> = <argument> # 数值/字符串/布尔值/代码块 ``` ### 编码要求 | 文件类型 | 编码 | |---------|------| | 脚本文件 (.txt) | UTF-8 无 BOM | | 本地化文件 (.yml) | UTF-8 带 BOM | ### 缩进规范 - 开闭括号同一缩进层级 - 代码块内部增加一层缩进（Tab 或 4空格） - 一行不要有多于一个括号 ### 注释 ``` # 单行注释（无多行注释） cost = 10 # TODO: 检查平衡性 ``` ### 常量定义 ``` @base_cost = 10 focus = { id = POL_focus cost = @base_cost } ``` --- ## 文件结构 ### 加载顺序 ``` Base Game → DLCs → User Directory → Mods ``` 文件名排序：ASCII 字符顺序，`00_` 前缀先加载，`zz_` 后加载。 --- ## 国策树 > 📄 **完整语法**: `references/focus_complete_guide.md` — Focus Tree 结构、节点字段、定位方式、前置条件、互斥、available、bypass、completion_reward 完整效果列表、内圈焦点、连续焦点、Search Filters > > 📄 **高级语法**: `references/advanced_syntax.md` — 备选图标、默认树、内圈窗口、快捷方式、嵌入窗口、连续焦点位置 > > 📄 **形式化语法**: `references/syntax.md` — BNF 语法 + Joint/Shared Focus + 11 个常见陷阱 > > 📄 **布局设计**: `examples/09_focus_tree_design_guide.md` — 坐标系统、间距、4步方法论、视口导航、动态定位、真实架构模式、递进奖励设计、原版数据分析 ### 最小可用模板 ``` focus_tree = { id = {TAG}_focus country = { factor = 0 modifier = { add = 10 tag = {TAG} } } default = no initial_show_position = { x = 500 y = 300 } focus = { id = {TAG}_root icon = GFX_goal_generic_political_pressure x = 0 y = 0 cost = 5 search_filters = { FOCUS_FILTER_POLITICAL } completion_reward = { add_political_power = 50 } } focus = { id = {TAG}_child prerequisite = { focus = {TAG}_root } relative_position_id = {TAG}_root x = 0 y = 1 icon = GFX_goal_generic_authoritarian cost = 10 completion_reward = { add_political_power = 100 } } } ``` ### 递进奖励（Progressive Reward） > 📄 **完整设计指南**: `examples/09_focus_tree_design_guide.md` → 递进奖励设计章节 ``` 三层奖励结构： 🪨 过程层 → cost=5, 1基建/10-15XP/25PP（克制，推动继续走） 📦 阶段层 → cost=10, 1-2工厂+科技加成/50PP+25XP（阶段性成果） 🏆 终点层 → cost=10-15, 3-4工厂+科技+50-100XP+100PP（终极目标） 核心原则：递进 ≠ 加量，是把相同总量重新分配——中间少给，终点多给 ``` ### 建筑效果（正确语法） > 📄 **完整参考**: `references/focus_complete_guide.md` → 建筑效果章节 ``` # ❌ 错误写法：random_owned_controlled_state + state = 762 # ✅ 正确写法：在 state scope 内直接调用 add_building_construction # 指定州建造（推荐） 123 = { add_extra_state_shared_building_slots = 1 # 先扩容（如需） add_building_construction = { type = industrial_complex # 民用工厂 level = 1 instant_build = yes } } 124 = { add_extra_state_shared_building_slots = 2 add_building_construction = { type = arms_factory level = 2 instant_build = yes } } # 遍历所有符合条件的州 # every_owned_state = { # limit = { free_building_slots = { building = industrial_complex size > 0 } } # add_building_construction = { type = industrial_complex level = 1 instant_build = yes } # } # 建筑类型：industrial_complex / arms_factory / dockyard # infrastructure / air_base / naval_base / bunker / coastal_bunker ``` ### 可持久/连续国策 > 📄 **完整参考**: `references/focus_complete_guide.md` → Continuous Focus 章节 ``` # 连续焦点（continuous = yes）：完成10个常规国策后解锁，激活期间持续生效 focus = { id = continuous_army_xp icon = GFX_focus_generic_army_xp x = 0 y = 0 continuous = yes # 关键标记 cost = 0 # 连续焦点必须为 0 search_filters = { FOCUS_FILTER_ARMY_XP } # ✅ 用 modifier = {} 提供持续效果（不是 completion_reward） modifier = { army_experience_gain_factor = 0.05 } } # 可取消的持久国策（带 cancel 块） focus = { id = TAG_mobilization cost = 30 cancel = { # ❗ 被取消时触发 add_stability = -0.05 } cancel_if_invalid = yes # 条件失效时自动取消 ai_will_do = { factor = 0 } # AI 不会自动选（玩家决策） } # 可取消属性 cancelable = yes # 可手动取消（默认） cancelable = no # 不可取消（内圈选择等） ``` --- ## 民族精神 > 📄 **完整语法**: `references/ideas_syntax.md` | **注释示例**: `examples/02_ideas_annotated.md` | **导入详解**: `examples/08_importing_ideas_annotated.md` ### Ideas 类型 | 类型 | 槽位 | 说明 | |------|------|------| | `country` | 无限制 | 国家精神 | | `army/navy/air` | 各1个 | 军种精神（需DLC） | | `political_advisor` | 1个 | 政治顾问 | | `theorist` | 1个 | 理论家 | | [REDACTED_SECRET] | 各1个 | 军事首脑 | ### 国家精神模板 ``` ideas = { country = { {TAG}_spirit_name = { allowed = { original_tag = {TAG} always = no } allowed_civil_war = { always = no } removal_cost = -1 picture = generic_authoritarian_regime modifier = { political_power_gain = 0.10 stability_factor = 0.05 } } } } ``` --- ## 人物系统 > 📄 **注释示例**: `examples/06_characters_annotated.md` ### 角色类型 | 角色类型 | 说明 | |----------|------| | `country_leader` | 国家领导人 | | `corps_commander` | 军级指挥官 | | `field_marshal` | 陆军元帅 | | `navy_leader` | 海军指挥官 | | `advisor` | 顾问 | ### 完整人物定义 ``` characters = { {TAG}_character = { name = "Character Name" portraits = { civilian = { large = "GFX_portrait_{TAG}_char" } army = { large = "GFX_portrait_{TAG}_char" } } country_leader = { ideology = despotism traits = { trait_name } expire = "1965.1.1.1" id = -1 } corps_commander = { traits = { cavalry_officer war_hero } skill = 2 attack_skill = 2 defense_skill = 2 planning_skill = 2 logistics_skill = 1 } } } ``` --- ## 领导人特质 > 📄 **注释示例**: `examples/07_leader_traits_annotated.md` ### 特质类型 | 类型 | 获得方式 | |------|----------| | `personality_trait` | 开局随机 | | `status_trait` | 战斗获得 | | `assignable_trait` | 手动分配 | | `terrain_trait` | 地形战斗 | ### 特质定义模板 ``` leader_traits = { trait_name = { type = land trait_type = personality_trait attack_skill = 1 modifier = { planning_speed = 0.10 } } } ``` --- ## 本地化 > 📄 **详细指南**: `references/localisation_guide.md` | **注释示例**: `examples/04_localisation_annotated.md` ### YML 格式 ```yaml l_english: {TAG}_focus_name:0 "Focus Display Name" {TAG}_focus_name_desc:0 "Detailed description..." ``` ### 编码：本地化文件必须 UTF-8 带 BOM + LF > ⚠️ **AI 生成 .yml 本地化文件时必须遵守此格式，零例外：** > > | 属性 | 值 | > |------|-----| > | **编码** | UTF-8 with BOM（文件开头三个隐藏字节 `\xEF\xBB\xBF`） | > | **换行符** | LF（`\n`，不是 CRLF `\r\n`） | > | **文件路径示例** | `localisation/simp_chinese/{TAG}_l_simp_chinese.yml` | > > **为什么必须带 BOM**：Paradox Launcher 读取 .yml 本地化文件时依赖 BOM 识别 UTF-8。 > 无 BOM 的文件在游戏中直接显示为乱码，无法事后修复。 > > **生成后自检命令**： > ```powershell > $bytes = [System.IO.File]::ReadAllBytes("path\to\file.yml") > if ($bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) { > Write-Host "✅ BOM 正确" > } else { > Write-Host "❌ 缺少 BOM，请重新生成并确保编辑器保存为 UTF-8 with BOM" > } > ``` > > **常见错误避坑**： > - ❌ VSCode 保存为「UTF-8」（无 BOM）→ 游戏中文乱码 > - ❌ 记事本 / Notepad 保存为 ANSI/GBK → 中文完全无法显示 > - ❌ LF/CRLF 混用 → 部分游戏版本解析异常 > - ✅ 正确：VSCode 选「UTF-8 with BOM」，底部状态栏 CRLF 改为 LF ### 颜色与图标 ```yaml §R红色§! §G绿色§! §B蓝色§! §Y黄色§! §H高亮§! £pol_power £stability £civilian_factory ``` --- ## 事件 > 📄 **事件参考**: `references/events_guide.md` | **注释示例**: `examples/03_events_annotated.md` ### 国家事件模板 ``` add_namespace = {TAG}_events country_event = { id = {TAG}_events.1 title = {TAG}_events.1_title desc = {TAG}_events.1_desc picture = generic_event is_triggered_only = yes option = { name = {TAG}_events.1_option_a add_political_power = 100 } } ``` --- ## 决议 > 📄 **注释示例**: `examples/05_decisions_annotated.md` ### 决议模板 ``` decisions = { {TAG}_category = { icon = GFX_goal_generic_major_alliance {TAG}_decision = { available = { tag = {TAG} } visible = { has_war_with = GER } cost = 50 complete_effect = { transfer_state = { state = 123 target = ROOT } } } } } ``` --- ## 变量与动态修饰符 > 📄 **动态修饰符**: `references/dynamic_modifiers.md` | **脚本效果**: `references/scripted_effects.md` | **脚本触发器**: `references/scripted_triggers.md` ### 变量操作 ``` set_variable = { var = {TAG}_var value = 10 } add_to_variable = { var = {TAG}_var value = 5 } subtract_from_variable = { var = {TAG}_var value = 3 } clamp_variable = { var = {TAG}_var min = 0 max = 100 } ``` ### 动态修饰符 ``` add_dynamic_modifier = { modifier = {TAG}_modifier days = 365 } remove_dynamic_modifier = { modifier = {TAG}_old_modifier } ``` --- ## 调试技巧 ### 启用调试模式 Steam 启动选项加 `-debug` ### 控制台命令 ``` debug_yesmen # AI 总是接受 debug_events # 显示事件 ID tdebug # 显示调试信息 error # 打开错误日志 ``` ### 错误日志 ``` Windows: C:\Users\<用户名>\Documents\Paradox Interactive\Hearts of Iron IV\logs\error.log ``` --- ## 参考文档 ### 语法参考 | 文件 | 内容 | |------|------| | `references/focus_complete_guide.md` | **国策树完整语法**（结构/字段/效果/内圈/连续焦点） | | `references/focus_syntax_complete.md` | 国策树语法（含Joint/Shared/波兰示例） | | `references/advanced_syntax.md` | 高级语法（备选图标/默认树/内圈窗口/快捷方式/嵌入窗口/连续焦点位置） | | `references/syntax.md` | 形式化语法 + BNF + 11个常见陷阱 | | `references/dictionary.md` | 效果/触发器语义字典（169效果 + 79触发器 + 作用域） | | `references/ideas_syntax.md` | Ideas 完整语法 | | `references/localisation_guide.md` | 本地化详细指南 | | `references/events_guide.md` | 事件系统参考 | | `references/dynamic_modifiers.md` | 动态修正完整语法 | | `references/scripted_effects.md` | 脚本效果完整语法 | | `references/scripted_triggers.md` | 脚本触发器完整语法 | ### 示例与模板 | 文件 | 内容 | |------|------| | `examples/09_focus_tree_design_guide.md` | **布局设计指南**（坐标/间距/视口/动态定位/真实架构/递进奖励/原版数据分析） | | \examples/templates.md\ | **基础模板+经典子模块** 国策+民族精神+建筑效果+5个可组装子模块 | | `examples/snippet_library.md` | 代码片段库 | | `examples/01_focus_tree_annotated.md` | 国策树注释示例 | | `examples/02_ideas_annotated.md` | 民族精神注释示例 | | `examples/03_events_annotated.md` | 事件注释示例 | | `examples/04_localisation_annotated.md` | 本地化注释示例 | | `examples/05_decisions_annotated.md` | 决议注释示例 | | `examples/06_characters_annotated.md` | 人物系统注释示例 | | `examples/07_leader_traits_annotated.md` | 领导人特质注释示例 | | `examples/08_importing_ideas_annotated.md` | Ideas 导入详解 | | `examples/10_dynamic_modifiers_annotated.md` | 动态修饰符注释示例 | | `examples/complete_mod_example.md` | 完整 mod 示例 | | `examples/complete_tutorial.md` | 完整教程 | | `examples/focus_real_examples.md` | 原版国策真实示例 | | `examples/ideas_real_examples.md` | 原版精神真实示例 | | `examples/events_real_examples.md` | 原版事件真实示例 | ### 原版参考 | 文件 | 内容 | |------|------| | `references/vanilla_focus_trees/` | **74个原版国策树文本** | | `references/vanilla_focus_trees/README.md` | 原版国策树索引表 | | `tools/validator.md` | 验证清单 | ### 官方参考 - Wiki: https://hoi4.paradoxwikis.com/Modding - 本地文件: `Hearts of Iron IV/common/` ### 推荐工具 - VS Code + CWTools 扩展 - Notepad++ - WinMerge --- **版本**: 7.2 | **更新**: 2026-04-26

path: README.md
content: # HOI4 Mod-Maker Skill 完整示例文档

**版本**: 7.1  
**更新时间**: 2026-04-25 13:15 (Asia/Shanghai)

---

## 📚 文档导航

本 Skill 包含完整的 HOI4 modding 文档和示例，帮助你从零开始创建完整的 mod。

### 🎓 学习路径

```
1. SKILL.md → 语法速查表 + 整体概览
   ↓
2. examples/01_focus_tree_annotated.md → 国策树详解
   ↓
3. examples/02_ideas_annotated.md → Ideas系统详解
   ↓
4. examples/03_events_annotated.md → 事件系统详解
   ↓
5. examples/04_localisation_annotated.md → 本地化详解
   ↓
6. examples/05_decisions_annotated.md → 决议系统详解
   ↓
7. examples/06_characters_annotated.md → 人物系统详解
   ↓
8. examples/07_leader_traits_annotated.md → 领导人特质详解
   ↓
9. examples/08_importing_ideas_annotated.md → 民族精神导入详解
   ↓
10. examples/09_focus_tree_design_guide.md → 国策树规划设计 ← 新增
   ↓
11. examples/complete_tutorial.md → 完整实战案例
```

---

## 📂 文件结构

```
hoi4-mod-maker/
│
├── SKILL.md                              # 主入口 + Meta + 使用场景
│   ├── Skill Meta（版本/能力/场景表）
│   ├── 快速开始
│   ├── 代码规范
│   ├── 国策树指南
│   ├── 民族精神
│   ├── 本地化
│   ├── 事件
│   ├── 决议
│   ├── 变量与动态修饰符
│   ├── 调试技巧
│   └── 常用模板
│
├── references/                            # 参考文档
│   ├── focus_syntax_complete.md         # 国策树完整语法（17.2 KB）
│   ├── advanced_syntax.md               # 高级语法特性（15.8 KB）
│   ├── syntax.md                        # 形式化语法 + BNF + 11个陷阱（25.7 KB）
│   ├── dictionary.md                    # 效果/触发器字典 169+79（18.9 KB）
│   ├── ideas_syntax.md                  # Ideas完整语法（13.8 KB）
│   ├── localisation_guide.md            # 本地化指南（8.6 KB）
│   ├── events_guide.md                  # 事件系统参考（12.0 KB）
│   ├── dynamic_modifiers.md             # 动态修正语法
│   ├── scripted_effects.md              # 脚本效果语法
│   ├── scripted_triggers.md             # 脚本触发器语法
│   ├── quick_reference.md               # 快速参考卡片（新增）
│   └── vanilla_focus_trees/             # 原版国策树参考库
│       ├── README.md                    # 索引表（74个国家分类索引）
│       ├── germany.txt                  # 德国 (german_focus, 437焦点)
│       ├── soviet.txt                   # 苏联 (soviet_focus, 311焦点)
│       ├── japan.txt                    # 日本 (japan_wtt_focus, 450焦点)
│       ├── italy.txt                    # 意大利 (italian_focus, 314焦点)
│       ├── usa.txt                      # 美国
│       ├── uk.txt                       # 英国
│       ├── france.txt                   # 法国
│       ├── poland.txt                   # 波兰
│       ├── spain.txt                    # 西班牙
│       ├── generic.txt                  # 通用树
│       └── ... (共74个文件)
│
└── examples/                             # 详细示例（带注释）
    ├── 01_focus_tree_annotated.md       # 国策树详解（16.9 KB）
    ├── 02_ideas_annotated.md            # Ideas详解（22.5 KB）
    ├── 03_events_annotated.md           # 事件详解（14.0 KB）
    ├── 04_localisation_annotated.md     # 本地化详解（8.3 KB）
    ├── 05_decisions_annotated.md        # 决议详解（13.3 KB）
    ├── 06_characters_annotated.md       # 人物系统详解（13.0 KB）
    ├── 07_leader_traits_annotated.md    # 领导人特质详解（15.2 KB）
    ├── 08_importing_ideas_annotated.md  # 民族精神导入详解（12.3 KB）
    ├── 09_focus_tree_design_guide.md   # 国策树规划设计指南（60+ KB）
    ├── complete_tutorial.md             # 完整mod教程（17.7 KB）
    ├── complete_mod_example.md          # 完整mod示例（13.3 KB）
    ├── focus_real_examples.md           # 真实国策示例（16.6 KB）
    ├── ideas_real_examples.md           # 真实Ideas示例（13.5 KB）
    ├── events_real_examples.md          # 真实事件示例（13.0 KB）
    └── snippet_library.md               # 代码片段库（新增）

└── tools/                                # 工具和脚本（新增）
    └── validator.md                     # 验证检查清单
```

**总计**: 约 **400+ KB**，**109 文件**（含74个原版国策树 + 11个参考文档 + 16个注释示例 + 2个工具文档）

---

## 📖 各文档内容概览

### 1. 主文档 (SKILL.md)

**适合**: 所有用户（必读）

**包含**:
- ✅ 快速开始指南
- ✅ 完整代码规范
- ✅ 所有系统的基础语法
- ✅ 调试技巧和控制台命令
- ✅ 常用模板（可直接复制使用）

**特色**:
- 语法速查表
- 文件结构说明
- 编码规范
- 最佳实践建议

---

### 2. 国策树详解 (01_focus_tree_annotated.md)

**适合**: 想深入理解国策系统的用户

**包含**:
- ✅ 6个真实游戏示例（法国、日本、意大利、苏联、德国、Generic）
- ✅ 每个字段的详细注释
- ✅ 高级特性：内圈焦点、快捷方式、连续焦点
- ✅ 条件偏移、建筑建造、变量追踪
- ✅ UI优化技巧

**特色**:
- 所有示例均来自游戏本体
- 每个示例都有详细注释
- 包含复杂逻辑的实现方法

**示例列表**:
1. 基础国策结构（法国）
2. 条件建筑建造（法国）
3. 条件偏移（意大利）
4. 复杂快捷方式（日本）
5. 连续焦点（Generic）
6. 内圈焦点（德国）

---

### 3. Ideas详解 (02_ideas_annotated.md)

**适合**: 想创建民族精神、顾问、设计商的用户

**包含**:
- ✅ 6个真实游戏示例（法国、海军精神、陆军精神、政治顾问、理论家、设计商）
- ✅ 所有字段详细说明
- ✅ allowed、visible、available的区别
- ✅ 内战处理规则
- ✅ AI权重配置

**特色**:
- 涵盖所有ideas类型
- 详细的条件逻辑说明
- 完整的本地化示例

**示例列表**:
1. 国家精神基础（法国）
2. 海军学院精神
3. 陆军学院精神
4. 政治顾问
5. 理论家
6. 设计商

---

### 4. 事件详解 (03_events_annotated.md)

**适合**: 想创建复杂事件链的用户

**包含**:
- ✅ 8个真实游戏示例（波兰、Generic）
- ✅ 多描述文本实现
- ✅ 条件选项、事件链
- ✅ MTTH计算、省份事件
- ✅ 变量使用技巧

**特色**:
- 复杂事件逻辑的实现方法
- 效果预览技术
- 事件链设计模式

**示例列表**:
1. 基础国家事件（波兰）
2. 复杂选项逻辑（波兰）
3. 条件执行效果（波兰）
4. 多描述文本事件（Generic）
5. MTTH事件
6. 省份事件
7. 新闻事件
8. 带变量事件

---

### 5. 本地化详解 (04_localisation_annotated.md)

**适合**: 需要创建多语言支持的用户

**包含**:
- ✅ 完整的YML格式说明
- ✅ 所有颜色代码
- ✅ 图标代码
- ✅ 变量插值方法
- ✅ 中文本地化技巧

**特色**:
- 快速参考表（颜色、图标）
- 常见错误和解决方法
- 文件组织最佳实践

---

### 6. 决议详解 (05_decisions_annotated.md)

**适合**: 想创建动态决议系统的用户

**包含**:
- ✅ 6个完整示例
- ✅ 省份决议、外交决议
- ✅ 可升级决议系统
- ✅ 超时机制
- ✅ AI权重配置

**特色**:
- 多种决议类型的实现
- 状态管理技巧
- 完整的本地化支持

---

### 7. 人物系统详解 (06_characters_annotated.md)

**适合**: 想创建自定义领导人和将领的用户

**包含**:
- ✅ 8个真实游戏示例（波兰、德国）
- ✅ 国家领导人定义
- ✅ 军事指挥官（军级、元帅级）
- ✅ 海军指挥官
- ✅ 顾问系统
- ✅ 头像系统
- ✅ 性别支持
- ✅ 条件可见性
- ✅ 多角色支持
- ✅ 在效果中设置领导人

**特色**:
- 一人可担任多个角色
- DLC锁定、国策解锁的条件控制
- 完整的头像系统（大头像、小头像）

**示例列表**:
1. 国家领导人（波兰）
2. 军级指挥官（波兰）
3. 陆军元帅（波兰）
4. 海军指挥官（波兰）
5. 政治顾问（波兰）
6. 多角色人物（德国）
7. 条件可见性（德国）
8. 性别支持（波兰）

---

### 8. 领导人特质详解 (07_leader_traits_annotated.md)

**适合**: 想创建自定义特质系统的用户

**包含**:
- ✅ 8个完整示例
- ✅ 4种特质类型系统
- ✅ 6种技能系统
- ✅ 修正值系统
- ✅ 单位修正值（sub_unit_modifiers）
- ✅ 经验获得条件（gain_xp）
- ✅ 互斥特质
- ✅ 前置条件
- ✅ GUI布局
- ✅ 海军特质系统

**特色**:
- 完整的特质类型分类
- 技能因子控制升级概率
- 地形特质自动获得经验
- 可分配特质需要政治点数成本

**示例列表**:
1. 个性特质（基础）
2. 地形特质（山地）
3. 可分配特质（后勤专家）
4. 状态特质（冬季专家）
5. 海军特质（水面突袭者）
6. 技能系统示例
7. 单位修正值示例
8. GUI布局示例

---

### 9. 民族精神导入详解 (08_importing_ideas_annotated.md)

**适合**: 想在国策/事件中使用民族精神的用户

**包含**:
- ✅ 8个使用场景
- ✅ 在国策中添加民族精神
- ✅ 在事件中添加民族精神
- ✅ 临时民族精神（定时移除）
- ✅ 多级民族精神系统
- ✅ 动态修饰符系统
- ✅ 从其他Mod导入
- ✅ 兼容性检查
- ✅ 条件自动移除

**特色**:
- 完整的工作流程
- 永久 vs 临时 vs 动态的选择
- 多级升级系统的实现
- Mod兼容性最佳实践

**示例列表**:
1. 永久民族精神
2. 定时民族精神
3. 条件自动移除
4. 多级系统
5. 动态修饰符
6. 作用域限定
7. Mod导入
8. 兼容性检查

---

### 10. 国策树规划设计指南 (09_focus_tree_design_guide.md)

**适合**: 想学习如何设计国策树布局，避免图标重合的用户

**包含**:
- ✅ 坐标系统详解（x/y轴、相对定位）
- ✅ 节点尺寸与间距规则
- ✅ 布局规划方法论（4步骤）
- ✅ 常见问题与解决方案（4大问题）
- ✅ 2个完整实战案例（政治三分支、工业多层分叉）
- ✅ 设计检查清单（视觉、功能、代码质量）
- ✅ 进阶技巧（累积计算、条件偏移、模块化设计）
- ✅ **视口与导航设计**（initial_show_position/shortcut/continuous_focus_position/inlay_window）
- ✅ **动态与条件定位**（offset/if-else链/visible/3种设计模式/空间预留/常见陷阱）
- ✅ **真实游戏架构模式**（内圈/条件分支/环形/嵌入窗口/连续焦点，5种完整代码骨架）

**特色**:
- **先规划，后编码**的方法论
- ASCII草图可视化设计
- 坐标唯一性检查算法
- 连线交叉的解决方案
- 互斥链的标准布局模板
- 5种原版游戏布局模式的完整代码骨架
- offset/visible 的决策树和检查清单

**章节列表**:
1. 坐标系统详解
2. 节点尺寸与间距
3. 布局规划方法论
4. 常见问题与解决方案
5. 实战案例
6. 设计检查清单
7. 进阶技巧
8. 视口与导航设计
9. 动态与条件定位
10. 真实游戏架构模式
11. 参考资源

---

### 11. 完整教程 (complete_tutorial.md)

**适合**: 想从零开始创建完整mod的用户

**包含**:
- ✅ 虚构国家 "威塞克斯共和国" 完整实现
- ✅ 国策树（政治+工业分支）
- ✅ 民族精神系统
- ✅ 事件链
- ✅ 本地化（英文+中文）
- ✅ 自定义修正值

**特色**:
- 约350行完整代码
- 可直接使用的模板
- 双语言支持

---

## 🎯 使用指南

### 场景1: 我想快速了解语法

👉 阅读 `SKILL.md` 的"代码规范"和"常用模板"章节

### 场景2: 我想创建国策树

1. 阅读 `01_focus_tree_annotated.md` 理解基础结构
2. 参考 `focus_real_examples.md` 看复杂示例
3. 使用 `complete_tutorial.md` 中的模板开始编写

### 场景3: 我想创建民族精神

1. 阅读 `02_ideas_annotated.md` 理解字段含义
2. 参考 `ideas_real_examples.md` 看真实实现
3. 注意 `allowed`、`visible`、`available` 的区别

### 场景4: 我想创建事件链

1. 阅读 `03_events_annotated.md` 理解事件机制
2. 学习 `FROM` 作用域和事件链设计
3. 使用 `hidden_effect` 隐藏实现细节

### 场景5: 我想支持多语言

1. 阅读 `04_localisation_annotated.md`
2. 使用颜色代码和图标增强可读性
3. 测试编码（UTF-8 带 BOM）

### 场景6: 我想添加决议系统

1. 阅读 `05_decisions_annotated.md`
2. 选择合适的决议类型（普通/省份/外交）
3. 设计AI权重逻辑

### 场景7: 我想创建自定义领导人

1. 阅读 `06_characters_annotated.md`
2. 定义人物 + country_leader 角色
3. 准备头像图片（128x128 PNG）
4. 通过国策或事件设置领导人

### 场景8: 我想创建自定义特质

1. 阅读 `07_leader_traits_annotated.md`
2. 确定特质类型（个性/状态/可分配/地形）
3. 设置技能加成和修正值
4. 定义GUI布局（可选）

### 场景9: 我想导入民族精神

1. 阅读 `08_importing_ideas_annotated.md`
2. 选择合适的方式（永久/临时/动态）
3. 在国策或事件中添加
4. 设置移除条件（可选）

### 场景10: 我想规划设计国策树布局

1. 阅读 `09_focus_tree_design_guide.md`
2. 绘制ASCII草图规划结构
3. 应用布局算法分配坐标
4. 使用检查清单验证设计
5. 编写代码并测试

### 场景11: 我想查原版国策的 focus ID

1. 打开 `references/vanilla_focus_trees/README.md` 查索引表
2. 找到目标国家对应的 .txt 文件
3. 用编辑器搜索 focus ID 或 `prerequisite`
4. 也可全局搜索整个 `vanilla_focus_trees/` 文件夹

### 场景12: 我想修改原版国策树

1. 在 `vanilla_focus_trees/` 中找到原版文件
2. 找到要修改的 focus ID
3. 方式A：同ID追加（只覆盖特定焦点，不破坏其他内容）
4. 方式B：`replace_path`（完全替换整个树，注意兼容性）
5. 参考 `09_focus_tree_design_guide.md` 的布局规则避免重叠

### 场景13: 我想做内圈/嵌入窗口/连续焦点

1. 阅读 `09_focus_tree_design_guide.md` 的「真实游戏架构模式」章节
2. 选择对应模式（内圈/条件分支/环形/嵌入窗口/连续焦点）
3. 参考对应原版文件（德国=内圈、意大利=环形、波兰=嵌入窗口、苏联=连续焦点）
4. 复制代码骨架，修改为国家tag和焦点内容

### 场景14: 我想做条件偏移/动态布局

1. 阅读 `09_focus_tree_design_guide.md` 的「动态与条件定位」章节
2. 选择模式：平行替换 / 渐进展开 / 扇形展开
3. 用 `offset` + `if/else_if/else` 实现条件偏移
4. 用 `visible` 控制分支的显示/隐藏
5. 注意空间预留，避免条件分支出现时重叠

### 场景15: 我想快速查阅常用语法

👉 查看 `references/quick_reference.md` - 一页速查卡片

包含：
- 国策树核心字段（必需/可选）
- Ideas 核心字段
- Events 核心字段
- 常用效果/触发器速查
- 颜色与图标代码速查表
- 布局间距速查表
- 常见错误速查
- 文件位置速查
- 调试命令速查

### 场景16: 我想复制代码模板

👉 查看 `examples/snippet_library.md` - 可直接复用的模板库

包含：
- 完整国策树模板（最小可用/政治三分支/工业分支/军事分支）
- 民族精神模板（永久/临时/条件触发）
- 事件模板（简单事件/条件事件/事件链）
- 决议模板（普通/省份）
- 完整本地化模板（英文+中文）
- 人物模板（国家领导人/多角色人物）
- 效果片段库（政治/军事/经济/外交）
- 触发器片段库（国家/领土/科技/时间/逻辑）

### 场景17: 我想验证我的代码

👉 查看 `tools/validator.md` - 完整检查清单

包含：
- 文件基础检查（编码、结构、命名）
- 语法检查（括号、ID、字段拼写）
- 国策树检查（坐标、前置、互斥、布局）
- Ideas 检查（类型、条件、图标）
- Events 检查（结构、作用域、触发）
- 本地化检查（编码、键值对、格式）
- 作用域检查（ROOT、FROM、省份作用域）
- PowerShell 自动化检查脚本
- 错误日志分析指南

---

## 🔧 调试技巧

### 快速检查清单

- [ ] 文件编码：UTF-8 带 BOM
- [ ] 括号匹配：使用编辑器检查
- [ ] ID唯一性：避免重复ID
- [ ] 本地化：所有文本都有对应键
- [ ] 作用域：检查 `ROOT`、`FROM`、`THIS`

### 常见错误

| 错误 | 原因 | 解决 |
|------|------|------|
| 乱码 | 编码错误 | 使用 UTF-8 带 BOM |
| 语法错误 | 括号不匹配 | 使用编辑器检查 |
| 无效效果 | 拼写错误 | 对照字典检查 |
| 不显示 | 条件不满足 | 检查 `visible` |

---

## 📊 数据来源

本 Skill 整合了以下游戏本地文件：

### 原版国策树参考库 (`references/vanilla_focus_trees/`)

全部 74 个国家的完整国策树原始文本，可直接搜索 focus ID、布局坐标、前置关系。
详见 `vanilla_focus_trees/README.md`。

| 重点参考文件 | 用途 |
|-------------|------|
| `germany.txt` | 内圈焦点、快捷方式、互斥焦点 |
| `japan.txt` | 条件分支互锁、快捷方式 |
| `soviet.txt` | 连续焦点、建筑焦点、变量追踪 |
| `italy.txt` | 环形布局、嵌入窗口 |
| `poland.txt` | 嵌入窗口、条件分支 |
| `france.txt` | 基础结构、临时精神 |
| `spain.txt` | 内战双线布局 |
| `generic.txt` | 通用树、连续焦点基础示例 |

### 其他参考文件

| 来源 | 内容 |
|------|------|
| `air_spirits.txt` | 空军精神、研究加成 |
| `army_spirits.txt` | 陆军精神、显示条件 |
| `navy_spirits.txt` | 海军精神、学说要求 |
| `focus_l_english.yml` | 本地化格式 |

---

## ✨ 核心能力

现在这个 skill 可以帮助你：

✅ **理解语法** - 从基础到高级的完整覆盖  
✅ **编写代码** - 直接生成正确的 HOI4 代码  
✅ **发现问题** - 识别常见错误和不规范写法  
✅ **提供示例** - 真实游戏代码 + 完整教程  
✅ **指导调试** - 调试技巧和错误排查方法  
✅ **最佳实践** - 编码规范、文件组织、命名约定  
✅ **多语言支持** - 英文+中文本地化示例  
✅ **真实参考** - 74个原版国策树 + 注释示例  
✅ **布局设计** - 坐标规划、内圈/嵌入窗口/连续焦点等高级布局  
✅ **原版ID查询** - 快速搜索任何原版 focus ID 和前置关系  
✅ **兼容性指导** - replace_path、同ID追加、DLC锁定  
✅ **完整工作流** - 从设计规划到编码实现到测试调试  

---

## 🚀 快速开始

### 第一个 mod（5分钟）

1. 创建 `descriptor.mod`
2. 复制 `complete_tutorial.md` 中的代码
3. 放入正确的文件夹
4. 使用 `-debug` 启动测试

### 第一个国策（2分钟）

1. 复制 `SKILL.md` 中的模板
2. 修改 ID 和效果
3. 添加本地化
4. 测试

---

## 📝 维护说明

### 更新频率

- HOI4 大版本更新时同步更新
- 发现新特性或错误时及时修正
- 用户反馈的问题及时处理

### 版本历史

- **v7.1** (2026-04-25): 新增快速参考卡片、代码片段库、验证工具；优化文档导航；更新README结构
- **v7.0** (2026-04-25): 新增原版国策树参考库（74国）、Skill Meta、使用场景表；增强设计指南（视口导航/动态定位/架构模式3章）
- **v6.0** (2026-04-24): 新增国策树规划设计指南，解决图标重合问题
- **v5.0** (2026-04-24): 添加人物系统、领导人特质、民族精神导入详解
- **v4.0** (2026-04-24): 添加详细注释示例，真实游戏代码
- **v3.0** (2026-04-24): 整合 Wiki 信息，完善结构
- **v2.0** (2026-04-23): 扩展为完整 mod-maker 框架
- **v1.0** (2026-04-23): 初始版本，国策树基础

---

**祝你 modding 愉快！** 🎮


path: _meta.json
content: ownerId: local
slug: hoi4-mod-maker
version: 1.0.3
publishedAt: 1745776420000

path: tools/validator.md
content: # HOI4 Modding 验证检查清单

> 在测试前手动检查的常见问题清单。

---

## ✅ 文件基础检查

### 编码检查
- [ ] 本地化文件(.yml)使用 **UTF-8 带 BOM**
- [ ] 其他文件(.txt)使用 **UTF-8 无 BOM**
- [ ] 文件头部无乱码字符

### 文件结构
- [ ] 所有文件在正确目录下
- [ ] 文件名无空格或特殊字符
- [ ] descriptor.mod 存在且格式正确

---

## 📝 语法检查

### 括号匹配
- [ ] 所有 `{` 都有对应 `}`
- [ ] 嵌套层级正确缩进
- [ ] 使用编辑器的括号高亮功能检查

**示例（正确）**：
```hoi4
focus = {
    id = test_focus
    completion_reward = {
        add_political_power = 100
    }
}
```

**示例（错误）**：
```hoi4
focus = {
    id = test_focus
    completion_reward = {
        add_political_power = 100
    }
    # 缺少闭合括号
```

### ID 唯一性
- [ ] 所有 focus ID 唯一
- [ ] 所有 ideas ID 唯一
- [ ] 所有事件 ID 唯一
- [ ] 无重复定义

**检查方法**：
```powershell
# 在 mod 目录下运行
Get-ChildItem -Recurse -Filter "*.txt" | Select-String "id\s*=" | Group-Object
```

### 字段拼写
- [ ] 所有字段名拼写正确
- [ ] 数值参数无拼写错误
- [ ] 布尔值使用 `yes` 或 `no`

---

## 🎯 国策树检查

### 坐标系统
- [ ] 所有焦点有 x 和 y 坐标
- [ ] 根节点使用绝对坐标
- [ ] 子节点使用 relative_position_id
- [ ] **y 值必须递增**（子节点 > 父节点）

### 前置关系
- [ ] 所有前置焦点 ID 存在
- [ ] prerequisite 语法正确
- [ ] 无循环依赖

**正确语法**：
```hoi4
prerequisite = { focus = parent_focus }
prerequisite = { focus = parent_focus1 focus = parent_focus2 }  # AND关系
```

### 互斥关系
- [ ] mutually_exclusive 双向声明
- [ ] 所有互斥焦点 ID 存在

**正确示例**：
```hoi4
# 焦点A
focus = {
    id = focus_a
    mutually_exclusive = { focus = focus_b }
}

# 焦点B
focus = {
    id = focus_b
    mutually_exclusive = { focus = focus_a }  # 双向声明
}
```

### 布局检查
- [ ] 图标不重叠（x间距至少 ±1）
- [ ] 连线不交叉（复杂情况用 x间距 ±2）
- [ ] 分支布局清晰

---

## 💡 Ideas 检查

### 类型定义
- [ ] ideas 类型正确（country/army/navy/air/political_advisor 等）
- [ ] 槽位限制正确（顾问类通常只有 1 个槽位）

### 条件逻辑
- [ ] `allowed` 只在定义时检查
- [ ] `visible` 控制是否显示
- [ ] `available` 控制是否可选
- [ ] 三者逻辑关系正确

**区别**：
```hoi4
allowed = { original_tag = POL }      # 定义时检查
visible = { has_war = yes }           # 显示条件
available = { has_political_power > 100 }  # 可选条件
```

### 图标
- [ ] GFX 引用存在
- [ ] 图片文件在正确位置
- [ ] 图片尺寸正确（通常 56x56）

---

## 🎲 事件检查

### 事件结构
- [ ] add_namespace 声明存在
- [ ] 事件 ID 格式正确（`命名空间.数字`）
- [ ] 所有 option 至少有一个

### 作用域
- [ ] `ROOT` 使用正确（事件接收方）
- [ ] `FROM` 使用正确（事件触发方）
- [ ] 随机作用域逻辑正确

**作用域示例**：
```hoi4
country_event = {
    id = poland_events.1
    
    option = {
        name = poland_events.1_option_a
        
        # ROOT = 波兰（事件接收方）
        add_political_power = 50
        
        # FROM = 德意志（事件触发方）
        FROM = {
            add_opinion_modifier = {
                target = ROOT
                modifier = pol_ger_cooperation
            }
        }
    }
}
```

### 触发条件
- [ ] trigger 逻辑正确
- [ ] MTTH 计算合理
- [ ] mean_time_to_happen 配置正确

---

## 🌐 本地化检查

### 编码
- [ ] 文件使用 UTF-8 带 BOM
- [ ] 无乱码字符
- [ ] 引号使用正确

### 键值对
- [ ] 所有本地化键存在对应文本
- [ ] 格式为 `键:0 "文本"`
- [ ] 无重复键定义

**检查缺失键**：
```powershell
# 查找代码中的本地化键
Get-ChildItem -Recurse -Filter "*.txt" | Select-String "\w+_\w+" | ForEach-Object {
    $key = $_ -replace '.*?(\w+_\w+).*', '$1'
    $key
} | Sort-Object -Unique
```

### 颜色与图标
- [ ] 所有颜色代码正确闭合 `§!`
- [ ] 图标代码正确 `£icon`
- [ ] 格式化符号正确 `\n`

---

## 🔧 作用域检查

### 国家作用域
- [ ] `ROOT` - 效果执行者
- [ ] `FROM` - 效果触发者
- [ ] `THIS` - 当前上下文
- [ ] `PREV` - 上一个作用域

### 省份作用域
- [ ] 使用 `123 = { }` 格式
- [ ] 省份 ID 正确
- [ ] 效果适用正确（省份效果 vs 国家效果）

**常见错误**：
```hoi4
# 错误：省份效果用在国家作用域
add_political_power = 100
add_infrastructure = 1  # 这是省份效果

# 正确：先进入省份作用域
123 = {
    add_infrastructure = 1
}
add_political_power = 100  # 国家效果
```

---

## 📁 文件组织检查

### 目录结构
```
{mod}/
├── descriptor.mod              ✓
├── thumbnail.png               ✓ (推荐)
├── common/
│   ├── national_focus/         ✓
│   ├── ideas/                  ✓
│   ├── characters/             ✓
│   └── decisions/              ✓
├── events/                     ✓
└── localisation/
    ├── english/                ✓
    └── simp_chinese/           ✓
```

### 文件命名
- [ ] 使用小写字母和下划线
- [ ] 避免空格
- [ ] 有意义的名称

**推荐**：`{tag}_focus.txt`, `{tag}_ideas.txt`

---

## 🔍 错误日志检查

### 启用调试模式
1. Steam 启动选项添加：`-debug`
2. 游戏内按 `~` 打开控制台
3. 输入 `error` 查看错误日志

### 常见错误类型

| 错误信息 | 原因 | 解决 |
|---------|------|------|
| `Unknown effect: add_political_powr` | 拼写错误 | 修正为 `add_political_power` |
| `Missing }` | 括号不匹配 | 检查括号配对 |
| `Invalid focus ID: ger_focus_` | ID 不存在 | 检查 ID 拼写 |
| `Could not open file` | 编码错误 | 使用 UTF-8 |
| `Unknown trigger: taggg` | 拼写错误 | 修正为 `tag` |

### 错误日志位置
```
C:\Users\{用户名}\Documents\Paradox Interactive\Hearts of Iron IV\logs\error.log
```

---

## 📋 最终检查清单

在发布前检查：

### 功能性
- [ ] 所有焦点可完成
- [ ] 所有效果正确触发
- [ ] 事件链正常工作
- [ ] 决议可用
- [ ] 本地化显示正确

### 兼容性
- [ ] 无重复 ID（与原版或其他 mod）
- [ ] 不覆盖原版关键文件（除非有意）
- [ ] DLC 检查正确

### 平衡性
- [ ] 焦点成本合理
- [ ] 效果不过度强化
- [ ] 前置条件合理

### 用户体验
- [ ] 描述文本清晰
- [ ] 图标无重叠
- [ ] 无误导性提示

---

## 🛠️ 常用检查命令

### PowerShell 快速检查
```powershell
# 检查重复 ID
Get-ChildItem -Recurse -Filter "*.txt" | Select-String "id\s*=" | Group-Object | Where-Object { $_.Count -gt 1 }

# 检查括号匹配
Get-ChildItem -Recurse -Filter "*.txt" | ForEach-Object {
    $content = Get-Content $_.FullName -Raw
    $open = ($content.ToCharArray() | Where-Object { $_ -eq '{' }).Count
    $close = ($content.ToCharArray() | Where-Object { $_ -eq '}' }).Count
    if ($open -ne $close) {
        Write-Host "Bracket mismatch in: $($_.Name)"
    }
}

# 查找缺失的本地化键
$keys = Get-ChildItem -Recurse -Filter "*.txt" | Select-String "\w+_\w+" | ForEach-Object {
    $_ -replace '.*?(\w+_\w+).*', '$1'
} | Sort-Object -Unique

$localized = Get-ChildItem -Recurse -Filter "*.yml" | Get-Content

$keys | ForEach-Object {
    if ($localized -notmatch $_) {
        Write-Host "Missing localization: $_"
    }
}
```

---

## 📚 参考资源

- **完整文档**: `SKILL.md`
- **详细示例**: `examples/` 目录
- **原版参考**: `references/vanilla_focus_trees/`
- **快速参考**: `references/quick_reference.md`
- **代码片段**: `examples/snippet_library.md`

---

**提示**：保存此清单，每次创建新 mod 时逐项检查！


path: references/advanced_syntax.md
content: # HOI4 高级语法参考

本文档整合了从 Wiki 和游戏本地文件提取的高级语法特性。

---

## 目录

1. [Focus Tree 高级特性](#focus-tree-高级特性)
2. [Inner Circle 内圈焦点](#inner-circle-内圈焦点)
3. [Shortcut 快捷方式](#shortcut-快捷方式)
4. [Inlay Window 嵌入窗口](#inlay-window-嵌入窗口)
5. [Continuous Focus 连续焦点](#continuous-focus-连续焦点)
6. [Effect 作用域完整列表](#effect-作用域完整列表)
7. [变量系统](#变量系统)
8. [动态修饰符](#动态修饰符)
9. [高级效果示例](#高级效果示例)

---

## Focus Tree 高级特性

### alternate_icon_set（备选图标集）

```
focus_tree = {
    id = german_focus
    
    # 允许玩家切换到备选图标风格
    alternate_icon_set = FOCUS_ICON_SET_HISTORICAL_KEY_FOCUS
    # 或使用自定义：
    # alternate_icon_set = FOCUS_ALTERNATE_ICONS
    
    # 本地化键：
    # FOCUS_ALTERNATE_ICONS -> 切换按钮文本
    # GFX_FOCUS_ALTERNATE_ICONS -> 切换按钮图标
}
```

### default 树（默认树）

```
focus_tree = {
    id = generic_focus
    
    # 设为默认树，无专属树的国家使用此树
    default = yes
    
    # DLC 检查示例（波兰DLC）
    country = {
        factor = 0
        
        modifier = {
            add = 10
            OR = {
                has_dlc = "No Step Back"
                has_dlc = "Poland: United and Ready"
            }
            original_tag = POL
        }
    }
}
```

---

## Inner Circle 内圈焦点

德国内圈焦点是围绕中心焦点的小型辅助焦点，用于角色政治系统。

### 基础语法

```
focus = {
    id = GER_inner_circle_focus_1
    
    # 标记为内圈焦点
    inner_circle = yes
    
    # 内圈焦点通常 cost 较低
    cost = 20        # 实际天数 = 20 × 7 = 140天
    
    icon = GFX_focus_ger_inner_circle
    
    # 内圈焦点位置相对于中心焦点
    x = 1
    y = 0
    relative_position_id = GER_rearmament
    
    completion_reward = {
        add_political_power = 25
        set_country_flag = ger_inner_circle_1_done
    }
}
```

### 内圈时间常量

```
# 在文件顶部定义常量（实际天数 = 值 × 7）
@inner_circle_time_tier_1 = 20    # 140天
@inner_circle_time_tier_2 = 20    # 140天  
@inner_circle_time_tier_3 = 40    # 280天

focus = {
    id = GER_inner_tier_1
    inner_circle = yes
    cost = @inner_circle_time_tier_1
    # ...
}
```

### 内圈窗口定义

```
focus_tree = {
    id = german_focus
    
    # 内圈焦点显示区域
    inlay_window = {
        id = ger_inner_circle_inlay_window
        position = { x = 4500 y = 1150 }
    }
}
```

---

## Shortcut 快捷方式

快捷方式允许玩家快速定位到特定焦点分支。

### 定义快捷方式

```
focus_tree = {
    id = german_focus
    
    # 快捷方式定义
    shortcut = {
        name = GER_historical_path_shortcut
        target = GER_remilitarize_the_rhineland
        
        # 滚轮缩放因子（可选）
        scroll_wheel_factor = 0.469
        
        # 显示条件（可选）
        trigger = {
            always = yes
        }
    }
    
    shortcut = {
        name = GER_economic_path_shortcut
        target = GER_construct_the_reichsautobahn
        scroll_wheel_factor = 0.75
    }
    
    shortcut = {
        name = GER_oppose_hitler_shortcut
        target = GER_oppose_hitler
        scroll_wheel_factor = 0.55
        
        # DLC 条件
        trigger = {
            NOT = { has_dlc = "Gotterdammerung" }
        }
    }
    
    # 多个快捷方式可指向不同目标（根据条件显示）
    shortcut = {
        name = GER_oppose_hitler_shortcut
        target = GER_oppose_hitler_ww
        scroll_wheel_factor = 0.485
        trigger = {
            has_dlc = "Gotterdammerung"
        }
    }
}
```

### 本地化

```yaml
# 本地化文件
GER_historical_path_shortcut:0 "历史路线"
GER_economic_path_shortcut:0 "经济建设"
GER_oppose_hitler_shortcut:0 "反对希特勒"
```

---

## Inlay Window 嵌入窗口

嵌入窗口用于在焦点树中创建特殊显示区域（如德国内圈、波兰意志斗争等）。

### 定义嵌入窗口

```
focus_tree = {
    id = polish_focus
    
    # 嵌入窗口定义
    inlay_window = {
        id = pol_will_of_the_people_inlay_window
        position = { x = 1000 y = 800 }
        
        # 可选：定义大小
        size = { width = 400 height = 300 }
    }
}
```

---

## Continuous Focus 连续焦点

连续焦点是一种特殊焦点类型，在完成10个常规焦点后解锁，持续消耗政治点数并提供持续效果。

### 基础结构

```
focus_tree = {
    id = german_focus
    
    # 连续焦点显示位置
    continuous_focus_position = { x = 500 y = 1300 }
    
    # 连续焦点定义
    focus = {
        id = GER_continuous_industrial_effort
        icon = GFX_focus_generic_production
        x = 0
        y = 0
        
        # 标记为连续焦点
        continuous = yes
        
        # 连续焦点不消耗天数，而是每天消耗1政治点数
        # cost 字段对连续焦点无效
        
        completion_reward = {
            # 持续效果
            # 通常使用 modifier
        }
        
        # 连续焦点效果通过 modifier 实现
        modifier = {
            production_speed_factory_factor = 0.10
            production_speed_arms_factory_factor = 0.10
        }
    }
}
```

### 连续焦点完整示例

```
focus_tree = {
    id = generic_focus
    
    continuous_focus_position = { x = 500 y = 1300 }
    
    # 军事经验连续焦点
    focus = {
        id = continuous_army_xp
        icon = GFX_focus_generic_army_xp
        x = 0
        y = 0
        continuous = yes
        
        modifier = {
            army_experience_gain_factor = 0.05
        }
        
        search_filters = { FOCUS_FILTER_ARMY_XP }
    }
    
    focus = {
        id = continuous_navy_xp
        icon = GFX_focus_generic_navy_xp
        x = 1
        y = 0
        continuous = yes
        
        modifier = {
            navy_experience_gain_factor = 0.05
        }
        
        search_filters = { FOCUS_FILTER_NAVY_XP }
    }
    
    focus = {
        id = continuous_air_xp
        icon = GFX_focus_generic_air_xp
        x = 2
        y = 0
        continuous = yes
        
        modifier = {
            air_experience_gain_factor = 0.05
        }
        
        search_filters = { FOCUS_FILTER_AIR_XP }
    }
    
    # 资源连续焦点
    focus = {
        id = continuous_resource_oil
        icon = GFX_focus_generic_oil
        x = 3
        y = 0
        continuous = yes
        
        modifier = {
            oil_factor = 0.05
        }
        
        search_filters = { FOCUS_FILTER_INTERNATIONAL_TRADE }
    }
}
```

### 连续焦点限制

- 解锁条件：完成10个常规焦点
- 每天消耗：1 政治点数
- 效果：仅在激活时生效
- 数量：同时只能激活一个连续焦点
- 切换：可随时切换，无额外消耗

---

## Effect 作用域完整列表

### 国家作用域

```
# 切换到特定国家
GER = { add_political_power = 100 }

# 所有国家
every_country = {
    limit = { tag = POL }
    # 效果
}

# 随机国家
random_country = {
    limit = { has_stability > 0.5 }
    # 效果
}

# 所有其他国家
every_other_country = {
    limit = { has_war_with = ROOT }
    # 效果
}

# 所有邻国
every_neighbor_country = {
    limit = { is_subject = no }
    # 效果
}

# 所有敌对国家
every_enemy_country = {
    # 效果
}

# 所有占领国（核心被占领）
every_occupied_country = {
    # 效果
}

# 所有附属国
every_subject_country = {
    # 效果
}

# 所有阵营成员
every_faction_member = {
    # 效果
}
```

### 省份作用域

```
# 所有省份
every_state = {
    limit = { is_owned_by = ROOT }
    # 效果
}

# 随机省份
random_state = {
    prioritize = { 123 124 125 }  # 优先选择
    limit = {
        free_building_slots = {
            building = industrial_complex
            size > 0
        }
    }
    # 效果
}

# 所有拥有省份
every_owned_state = {
    limit = { is_core_of = ROOT }
    # 效果
}

# 所有核心省份
every_core_state = {
    limit = { is_owned_by = ROOT }
    # 效果
}

# 所有控制省份
every_controlled_state = {
    # 效果
}

# 随机拥有且控制省份
random_owned_controlled_state = {
    prioritize = { 86 87 88 }
    limit = {
        free_building_slots = {
            building = industrial_complex
            size > 0
            include_locked = yes
        }
    }
    # 效果
}
```

### 单位指挥官作用域

```
# 所有单位指挥官
every_unit_leader = {
    limit = { has_trait = cautious = yes }
    # 效果
}

# 所有陆军指挥官
every_army_leader = {
    # 效果
}

# 所有海军指挥官
every_navy_leader = {
    # 效果
}
```

### 特工作用域

```
# 所有特工
every_operative = {
    limit = { is_active = yes }
    # 效果
}

# 随机特工
random_operative = {
    # 效果
}
```

### 军事工业组织作用域（1.13+）

```
# 所有MIO
every_military_industrial_organization = {
    limit = { has_trait = tank_manufacturer }
    # 效果
}

# 随机MIO
random_military_industrial_organization = {
    # 效果
}
```

---

## 变量系统

### 变量操作效果

```
completion_reward = {
    # 设置变量
    set_variable = {
        var = POL_economy_var
        value = 10
        tooltip = economy_var_tt    # 自定义提示
    }
    
    # 增加变量值
    add_to_variable = {
        var = POL_economy_var
        value = 5
    }
    
    # 减少变量值
    subtract_from_variable = {
        var = POL_economy_var
        value = 3
    }
    
    # 乘法
    multiply_variable = {
        var = POL_economy_var
        value = 2
    }
    
    # 除法
    divide_variable = {
        var = POL_economy_var
        value = 10
    }
    
    # 取模
    modulo_variable = {
        var = POL_economy_var
        value = 100
    }
    
    # 四舍五入
    round_variable = POL_economy_var
    
    # 限制范围
    clamp_variable = {
        var = POL_economy_var
        min = 0
        max = 100
    }
    
    # 设置随机值
    set_variable_to_random = {
        var = random_num
        min = 0
        max = 100
        integer = yes    # 整数
    }
    
    # 清除变量
    clear_variable = POL_economy_var
}
```

### 临时变量

```
completion_reward = {
    # 设置临时变量（事件结束后清除）
    set_temp_variable = {
        temp_var = num_owned_states
        value = num_owned_states
    }
    
    # 临时变量操作
    add_to_temp_variable = {
        temp_var = my_temp
        value = 10
    }
}
```

### 变量作为作用域

```
# 将作用域存储到变量
set_variable = { target_country = THIS }

# 使用变量作为作用域
var:target_country = { add_political_power = 100 }

# 在效果中使用变量
add_to_faction = var:target_country
```

---

## 动态修饰符

### 定义动态修饰符

```
# common/dynamic_modifiers/example_modifiers.txt

POL_war_economy_modifier = {
    # 使用变量的修饰符
    consumer_goods_factor = var:POL_war_economy_var
    
    # 静态值
    production_speed_factory_factor = 0.10
    
    # 条件修饰符
    production_speed_arms_factory_factor = {
        value = 0.10
        triggered_by = {
            has_country_flag = pol_military_buildup
        }
    }
}

GER_economy_of_conquest_modifier = {
    # 触发式修饰符
    production_speed_factory_factor = {
        value = 0.05
        triggered_by = { has_war = yes }
    }
    
    # 对特定国家
    attack_bonus_against = {
        value = 0.10
        triggered_by = {
            FROM = { is_subject_of = ROOT }
        }
    }
}
```

### 添加/移除动态修饰符

```
completion_reward = {
    # 添加动态修饰符
    add_dynamic_modifier = {
        modifier = POL_war_economy_modifier
        scope = ROOT           # 可选，默认为ROOT
        days = 365             # 可选，持续天数
    }
    
    # 移除动态修饰符
    remove_dynamic_modifier = {
        modifier = POL_war_economy_modifier
    }
    
    # 强制更新（变量值变化后立即生效）
    force_update_dynamic_modifier = yes
}
```

---

## 高级效果示例

### 完整的复杂国策效果

```
focus = {
    id = POL_four_year_plan
    icon = GFX_focus_POL_four_year_plan
    x = 0
    y = 0
    cost = 5
    
    search_filters = { FOCUS_FILTER_INDUSTRY FOCUS_FILTER_RESEARCH }
    
    completion_reward = {
        # 科技加成
        add_tech_bonus = {
            name = POL_four_year_plan_bonus
            bonus = 1.0
            uses = 1
            category = construction_tech
        }
        
        # 时间限制的民族精神
        add_timed_idea = {
            idea = POL_four_year_plan_idea
            days = 1460    # 4年
        }
        
        # 设置变量
        set_variable = {
            var = POL_economy_level
            value = 1
        }
        
        # 条件效果
        if = {
            limit = {
                has_tech = construction_tech1
            }
            add_building_construction = {
                type = industrial_complex
                level = 2
                instant_build = yes
                state = 86
            }
        }
        
        # 隐藏效果
        hidden_effect = {
            set_country_flag = pol_four_year_plan_done
            
            # 仅调试日志
            if = {
                limit = { is_debug = yes }
                log = "Poland completed Four Year Plan"
            }
        }
        
        # 自定义提示
        custom_effect_tooltip = POL_four_year_plan_tt
        
        # 循环所有核心省份
        every_core_state = {
            limit = {
                is_fully_controlled_by = ROOT
                free_building_slots = {
                    building = infrastructure
                    size > 2
                }
            }
            random_select_amount = 3    # 随机选择3个
            add_building_construction = {
                type = infrastructure
                level = 1
                instant_build = yes
            }
        }
        
        # 对所有邻国的效果
        every_neighbor_country = {
            limit = {
                NOT = { has_war_with = ROOT }
            }
            add_opinion_modifier = {
                target = ROOT
                modifier = pol_economic_cooperation
            }
        }
    }
    
    # 自定义完成提示
    complete_tooltip = {
        add_political_power = 50
        custom_effect_tooltip = POL_four_year_plan_display_tt
    }
}
```

### 内圈焦点与变量追踪

```
focus = {
    id = GER_inner_circle_industry
    inner_circle = yes
    icon = GFX_focus_ger_inner_industry
    x = 0
    y = 0
    relative_position_id = GER_rearmament
    cost = @inner_circle_time_tier_1
    
    completion_reward = {
        # 增加追踪变量
        add_to_variable = {
            var = GER_inner_circle_progress
            value = 1
        }
        
        # 条件效果
        if = {
            limit = {
                check_variable = {
                    var = GER_inner_circle_progress
                    value > 5
                }
            }
            add_political_power = 100
            custom_effect_tooltip = GER_inner_circle_complete_tt
        }
        
        # 显示顾问提示
        show_ideas_tooltip = GER_hjalmar_schacht
        
        # 解锁决策提示
        unlock_decision_category_tooltip = GER_economic_decisions
        
        # 隐藏效果
        hidden_effect = {
            set_state_flag = ger_industrial_focus
            
            # 条件创建部队模板
            if = {
                limit = {
                    has_tech = infantry_equipment_1
                }
                create_division_template = {
                    name = "Infanterie-Division"
                    is_locked = yes
                    regiments = {
                        infantry = 3
                    }
                }
            }
        }
    }
}
```

### 建筑建造完整示例

```
completion_reward = {
    # 随机省份建造（带优先级）
    random_owned_controlled_state = {
        prioritize = { 762 }    # 上西里西亚
        limit = {
            free_building_slots = {
                building = industrial_complex
                size > 0
                include_locked = yes
            }
        }
        add_extra_state_shared_building_slots = 1
        add_building_construction = {
            type = industrial_complex
            level = 1
            instant_build = yes
        }
        set_state_flag = POL_develop_upper_silesia
    }
    
    # 多个省份建造（随机选择数量）
    every_owned_state = {
        limit = {
            is_core_of = ROOT
            free_building_slots = {
                building = arms_factory
                size > 0
            }
        }
        random_select_amount = 3
        add_building_construction = {
            type = arms_factory
            level = 1
            instant_build = yes
        }
    }
    
    # 铁路建设
    build_railway = {
        level = 1
        path = { 9508 6558 3483 }
    }
    
    # 添加资源
    add_resource = {
        type = steel
        amount = 24
        state = 762
    }
}
```

---

## 搜索过滤器完整列表

```
FOCUS_FILTER_POLITICAL           # 政治
FOCUS_FILTER_RESEARCH            # 研究
FOCUS_FILTER_INDUSTRY            # 工业
FOCUS_FILTER_STABILITY           # 稳定度
FOCUS_FILTER_WAR_SUPPORT          # 战争支持度
FOCUS_FILTER_MANPOWER            # 人力
FOCUS_FILTER_ANNEXATION          # 吞并
FOCUS_FILTER_INTERNAL_AFFAIRS    # 内部事务
FOCUS_FILTER_ARMY_XP             # 陆军经验
FOCUS_FILTER_NAVY_XP             # 海军经验
FOCUS_FILTER_AIR_XP              # 空军经验
FOCUS_FILTER_BALANCE_OF_POWER    # 权力平衡
FOCUS_FILTER_POLITICAL_CHARACTER # 政治人物
FOCUS_FILTER_MILITARY_CHARACTER  # 军事人物
FOCUS_FILTER_INTERNATIONAL_TRADE # 国际贸易
FOCUS_FILTER_HISTORICAL          # 历史路线
```

---

**最后更新**: 2026-04-24


path: references/dictionary.md
content: # HOI4 Effects & Triggers Dictionary

Source: Official HOI4 documentation (`effects_documentation.md` / `triggers_documentation.md`)

---

## Effects

Total: 169 curated entries

| Effect | Scope | Description |
|--------|-------|-------------|
| `add_political_power` | COUNTRY | add political power to country |
| `add_command_power` | COUNTRY | add command power to country |
| `add_stability` | COUNTRY | Adds the stability to the country in scope |
| `add_war_support` | COUNTRY | Adds the war support to the country in scope |
| `add_popularity` | COUNTRY | add popularity to an ideology in a country |
| `add_ideas` | COUNTRY | add idea(s) to country |
| `add_timed_idea` | COUNTRY | Add a time-limited idea to country in scope |
| `army_experience` | COUNTRY | add army experience for country |
| `navy_experience` | COUNTRY | add naval experience for country |
| `air_experience` | COUNTRY | add air experience for country |
| `add_research_slot` | COUNTRY | Adds a research slot (negative values subtracts) |
| `add_tech_bonus` | COUNTRY | adds a limited use tech bonus |
| `add_doctrine_cost_reduction` | COUNTRY | adds a limited use cost reduction for doctrines |
| `add_manpower` | STATE, COUNTRY | Adds manpower to the country in scope or locally on a state |
| `add_building_construction` | STATE | Starts building construction for amount of levels in specified state |
| `add_extra_state_shared_building_slots` | STATE | add extra shared building slot to state |
| `add_resource` | STATE, COUNTRY | Adds/removes resource production to state |
| `build_railway` | any | Builds/adds railway level between two provinces or along a path |
| `country_event` | COUNTRY | Fires a country event |
| `add_dynamic_modifier` | STATE, COUNTRY, CHARACTER | adds a dynamic modifier to the containing scope |
| `remove_dynamic_modifier` | STATE, COUNTRY, CHARACTER | removes a dynamic modifier |
| `force_update_dynamic_modifier` | STATE, COUNTRY, CHARACTER | updates the modifiers in current scope |
| `set_country_flag` | COUNTRY | set country flag |
| `clr_country_flag` | COUNTRY | clear country flag |
| `set_state_flag` | STATE | set state flag |
| `set_global_flag` | any | set global flag |
| `set_cosmetic_tag` | COUNTRY | Sets country cosmetic tag |
| `drop_cosmetic_tag` | COUNTRY | Drops country cosmetic tag |
| `unlock_national_focus` | COUNTRY | unlocks a focus for a country |
| `complete_national_focus` | COUNTRY | completes a focus for a country |
| `uncomplete_national_focus` | COUNTRY | uncompletes a focus for a country |
| `load_focus_tree` | COUNTRY | Sets what focus tree a country uses |
| `reduce_focus_completion_cost` | COUNTRY | Reduce the cost needed to complete a specific focus |
| `add_autonomy_score` | COUNTRY | Adds exact freedom score to the autonomy |
| `add_autonomy_ratio` | COUNTRY | Adds % freedom score to the autonomy |
| `set_autonomy` | COUNTRY | makes autonomy of specified level and country |
| `release_autonomy` | COUNTRY | releases specified country with specified level of autonomy |
| `add_compliance` | STATE | add compliance to a state |
| `add_resistance` | STATE | add resistance to a state |
| `add_state_core` | COUNTRY | add core on state |
| `add_state_claim` | COUNTRY | add claim on state |
| `remove_state_core` | COUNTRY | remove core on state |
| `remove_state_claim` | COUNTRY | remove claim on state |
| `annex_country` | COUNTRY | annex a country |
| `puppet` | COUNTRY | Puppets specified country |
| `release_puppet` | COUNTRY | releases specified country as puppet using states you own |
| `end_puppet` | COUNTRY | Stops specified country being a puppet of current country |
| `declare_war_on` | COUNTRY | declares war on specified country |
| `add_to_war` | COUNTRY | adds country to the specified war |
| `create_faction` | COUNTRY | creates a faction |
| `dismantle_faction` | COUNTRY | dismantles faction led by current country |
| `add_to_faction` | COUNTRY | adds specified country to faction |
| `leave_faction` | COUNTRY | Country leaves the faction |
| `give_guarantee` | COUNTRY | guarantees specified country |
| `give_military_access` | COUNTRY | gives military access to the specified country |
| `give_resource_rights` | COUNTRY | Gives rights to take resources from specified state |
| `set_variable` | any | Sets a variable to a value or another variable |
| `add_to_variable` | any | Adds a value or a variable to another one |
| `set_temp_variable` | any | Sets a temp variable to a value or another variable |
| `add_to_temp_variable` | any | Adds a value or a variable to a temp variable |
| `clear_variable` | any | Clears a variable |
| `multiply_variable` | any | Multiplies a variable to a value or another variable |
| `subtract_from_variable` | any | Subtracts a value or a variable to another one |
| `hidden_effect` | any | Effect not shown in tooltips |
| `effect_tooltip` | any | Shows just tooltip of effects |
| `custom_effect_tooltip` | any | custom_effect_tooltip = MY_TOOLTIP |
| `if` | any | a conditional effect |
| `while_loop_effect` | any | Runs the effect as long as a trigger is true |
| `random` | any | a random effect |
| `random_list` | any | Picks a random effect from the list based on weight |
| `random_controlled_state` | COUNTRY | Executes children effects on random controlled state |
| `random_owned_controlled_state` | COUNTRY | Executes children effects on random owned and controlled state |
| `random_state` | any | Executes children effects on a random state |
| `every_state` | any | Executes children effects on every State |
| `every_owned_state` | COUNTRY | Executes children effects on every State owned by the country |
| `every_controlled_state` | COUNTRY | Executes children effects on every State controlled by the country |
| `every_allied_country` | COUNTRY | Executes effects on every allied country |
| `every_enemy_country` | COUNTRY | Executes children effects on every enemy Country |
| `every_subject_country` | COUNTRY | Executes children effects on every subject Country |
| `show_ideas_tooltip` | COUNTRY | show what idea does |
| `unlock_decision_tooltip` | COUNTRY | show what decision does |
| `unlock_decision_category_tooltip` | COUNTRY | localizes name of category and displays tooltip |
| `set_politics` | COUNTRY | set_politics |
| `hold_election` | COUNTRY | Immediately holds an election in the target country |
| `set_party_name` | COUNTRY | change partyname for an ideology in a country |
| `set_political_party` | COUNTRY | set popularity of a political party |
| `add_to_tech_sharing_group` | COUNTRY | Adds country to technology sharing group |
| `set_occupation_law` | STATE, COUNTRY | Sets the occupation law |
| `set_resistance` | STATE | set resistance of a state |
| `cancel_resistance` | STATE | cancels resistance activity for a core country |
| `create_intelligence_agency` | COUNTRY | create an Intelligence Agency |
| `upgrade_intelligence_agency` | COUNTRY | add an upgrade to the Intelligence Agency |
| `division_template` | COUNTRY | add a division template to country |
| `delete_units` | COUNTRY | deletes units that uses a specific template |
| `add_units_to_division_template` | COUNTRY | Add units to division template for a country |
| `add_equipment_to_stockpile` | COUNTRY | Add or remove equipment from country stockpiles |
| `add_equipment_bonus` | COUNTRY | Adds the specified equipment bonuses |
| `add_equipment_production` | COUNTRY | Creates a new production line for the input equipment |
| `modify_building_resources` | COUNTRY | Modifies resource output of specific building |
| `set_nationality` | COUNTRY, CHARACTER | Transfer from one country to another for the character |
| `add_nationality` | CHARACTER | Add the specified nationality to the scoped-in operative |
| `add_relation_modifier` | COUNTRY | Adds a static modifier between current scope and target |
| `add_opinion_modifier` | COUNTRY | Add opinion modifier(s) to target(s) |
| `remove_opinion_modifier` | COUNTRY | Remove opinion modifier from target |
| `add_collaboration` | COUNTRY | Adds the collaboration in a target country |
| `add_advisor_role` | COUNTRY, CHARACTER | add advisor role to character |
| `remove_advisor_role` | COUNTRY, CHARACTER | remove advisor role from character |
| `add_country_leader_role` | COUNTRY, CHARACTER | add country leader role to character |
| `remove_country_leader_role` | COUNTRY, CHARACTER | Remove country leader role from character |
| `add_country_leader_trait` | COUNTRY, CHARACTER | Add country leader trait |
| `remove_country_leader_trait` | COUNTRY, CHARACTER | Remove country leader trait |
| `swap_country_leader_traits` | CHARACTER | swap 2 traits on a country leader |
| `set_country_leader_name` | COUNTRY | changes the name of country leader |
| `set_country_leader_description` | COUNTRY | changes the description of country leader |
| `set_country_leader_portrait` | COUNTRY | changes the portrait of country leader |
| `add_corps_commander_role` | COUNTRY, CHARACTER | add corps commander role to character |
| `add_field_marshal_role` | COUNTRY, CHARACTER | add field marshall role to character |
| `add_naval_commander_role` | COUNTRY, CHARACTER | Add naval commander to character |
| `set_province_controller` | COUNTRY | set controller for province |
| `set_state_controller` | COUNTRY | set controller for state |
| `set_state_owner` | COUNTRY | set owner for state |
| `set_research_slots` | COUNTRY | Sets the number of research slots |
| `add_named_threat` | COUNTRY | Adds country threat |
| `add_threat` | COUNTRY | Adds country threat |
| `retire_character` | COUNTRY | Un-assigns a character from a nation |
| `promote_character` | COUNTRY, CHARACTER | promotes character to the head of their political party |
| `ai_message` | COUNTRY | ai message |
| `log` | any | Print message to game.log, console |
| `activate_decision` | COUNTRY | Activates specified decision for scope country |
| `activate_mission` | COUNTRY | Activates mission, ignoring normal trigger conditions |
| `remove_mission` | COUNTRY | Removes mission without running complete or timeout effects |
| `start_civil_war` | COUNTRY | start a civil war |
| `set_rule` | COUNTRY | Adds rule to country |
| `clear_rule` | COUNTRY | Clears rule added by set_rule |
| `set_party_rule` | COUNTRY | Adds rule to the country's party |
| `set_major` | COUNTRY | Sets mandatory major country flag |
| `set_capital` | COUNTRY | move capital to state |
| `become_exiled_in` | COUNTRY | Become exile in target nation |
| `end_exile` | COUNTRY | Ends the exile of the current scope's country |
| `remove_exile_tag` | CHARACTER | remove exile tag from scope unit leader |
| `set_border_war` | STATE | starts a border war in a state |
| `start_border_war` | any | start a border war between two states |
| `cancel_border_war` | any | cancel border war between two states |
| `damage_building` | STATE, COUNTRY | Damages a building in a targeted state or province |
| `remove_building` | STATE, COUNTRY | Removes a building in a targeted state or province |
| `add_mines` | COUNTRY | Add mines to a strategic region |
| `launch_nuke` | COUNTRY | launch nuke at a state |
| `send_equipment` | COUNTRY | Sends to target scope specified amount of equipment |
| `send_equipment_fraction` | COUNTRY | Sends to target scope specified fraction of equipment |
| `add_fuel` | COUNTRY | add fuel to the country |
| `set_fuel` | COUNTRY | set fuel for country |
| `set_fuel_ratio` | COUNTRY | Set country's current fuel ratio relative to its capacity |
| `add_nuclear_bombs` | COUNTRY | add nukes to country |
| `set_technology` | COUNTRY | sets technology level(s) on country |
| `inherit_technology` | COUNTRY | Copies over technology state from target |
| `add_breakthrough_progress` | COUNTRY | Add breakthrough progress to one specialization |
| `add_breakthrough_points` | COUNTRY | Add breakthrough points to one specialization |

---

## Triggers

Total: 79 curated entries

| Trigger | Scope | Description |
|---------|-------|-------------|
| `has_completed_focus` | COUNTRY | has country completed focus |
| `has_focus_tree` | COUNTRY | Does current country have the specified focus tree |
| `has_government` | COUNTRY | does country government belong to ideology group |
| `original_tag` | COUNTRY | original tag is (for civil wars checks) |
| `is_subject` | COUNTRY | Checks if the country is subject of any other country |
| `is_subject_of` | COUNTRY | Checks if the country is subject of specified country |
| `has_subject` | COUNTRY | Checks if the country has for subject the given country |
| `has_war` | COUNTRY | is country at war |
| `has_war_with` | COUNTRY | is countries at war |
| `has_capitulated` | COUNTRY | checks if the country has capitulated |
| `is_in_faction_with` | COUNTRY | check if member of same faction as specified country |
| `is_faction_leader` | COUNTRY | check if country leads a faction |
| `any_allied_country` | COUNTRY | Check if any allied country meets the trigger |
| `any_other_country` | any | check if any other country meets the trigger |
| `any_country` | any | check if any country meets the trigger |
| `any_enemy_country` | COUNTRY | check if any enemy country meets the trigger |
| `any_neighbor_country` | COUNTRY | check if any neighbor country meets the trigger |
| `any_subject_country` | COUNTRY | check if any subject country meets the trigger |
| `controls_state` | COUNTRY | check controller for state(s) |
| `is_owned_and_controlled_by` | STATE | check if state is owned by |
| `is_owned_by` | STATE | check if state is owned by |
| `is_core_of` | STATE | Checks if state is core of country |
| `is_controlled_by` | STATE | check if state is controlled by |
| `is_fully_controlled_by` | STATE | Checks if state is fully controlled by specified tag |
| `is_capital` | STATE | Is scope state a capital |
| `has_full_control_of_state` | COUNTRY | check controller for state(s) |
| `is_on_continent` | STATE | is state located on continent |
| `is_in_home_area` | STATE | Checks if first province is connected to capital |
| `is_coastal` | STATE | check if state is coastal |
| `num_of_controlled_factories` | COUNTRY | check the number of factories in controlled states |
| `num_of_factories` | COUNTRY | Check amount of available factories |
| `free_building_slots` | STATE | checks building for available construction levels |
| `has_country_flag` | COUNTRY | has country flag been set |
| `has_state_flag` | STATE | has state flag been set |
| `has_global_flag` | any | has global flag been set |
| `has_character_flag` | CHARACTER | has a character flag been set |
| `is_ai` | COUNTRY | Checks if country is AI controlled |
| `is_historical_focus_on` | any | check if the historical focus is active |
| `has_dlc` | any | Checks if player has a DLC |
| `has_dynamic_modifier` | STATE, COUNTRY, CHARACTER | has a dynamic modifier |
| `check_variable` | any | Compares a variable to a number or another variable |
| `has_variable` | any | Checks if a variable exists in a scope |
| `has_country_leader` | COUNTRY | check if country has leader with specified ID |
| `has_political_power` | COUNTRY | check amount of political power |
| `has_stability` | COUNTRY | check value of stability 0-1 |
| `has_war_support` | COUNTRY | check value of war_support 0-1 |
| `has_manpower` | COUNTRY | check amount of manpower |
| `has_equipment` | COUNTRY | checks for amount of equipment stored |
| `has_navy_size` | COUNTRY | Checks for amount of ships |
| `has_army_size` | COUNTRY | checks for amount of divisions |
| `has_opinion` | COUNTRY | check what opinion the country has towards a specified country |
| `has_tech_bonus` | COUNTRY | checks if the country has a bonus for the specified technology |
| `is_exiled_in` | COUNTRY | Checks if scope country is a government in exile in target tag |
| `has_resistance` | STATE | returns true if state has a resistance |
| `is_claimed_by` | STATE | Checks if state is claimed by country |
| `owns_state` | COUNTRY | check owner for state(s) |
| `has_border_war` | STATE, COUNTRY | Checks if there is any border wars for country/state |
| `is_demilitarized_zone` | STATE | checks if a state is a demilitarized zone |
| `has_template` | COUNTRY | Check if country has a division template of specific name |
| `has_character` | COUNTRY | Returns true if scoped country has character |
| `has_attache` | COUNTRY | Has attache from any other country |

---

## Key Effects Examples

### add_building_construction

```txt
add_building_construction = {
    type = industrial_complex
    level = 2
    instant_build = yes
}

# For specific state
{state_id} = {
    add_building_construction = {
        type = infrastructure
        level = 1
        instant_build = yes
    }
}
```

### add_timed_idea

```txt
add_timed_idea = {
    idea = my_idea_id
    days = 365
}
# or
add_timed_idea = {
    idea = my_idea_id
    years = 1
    months = 2
    days = 5
}
```

### country_event

```txt
country_event = {
    id = germany.75
    days = 5
    random_days = 2
}
```

### add_tech_bonus

```txt
add_tech_bonus = {
    bonus = 0.5
    uses = 2
    category = cat_mechanized_equipment
    name = bonus_name
}

add_tech_bonus = {
    bonus = 0.75
    uses = 1
    category = armor
    ahead_reduction = 0.5
    name = bonus_name
}
```

### random_owned_controlled_state

```txt
random_owned_controlled_state = {
    limit = {
        is_core_of = ROOT
        free_building_slots = {
            building = industrial_complex
            size > 0
            include_locked = yes
        }
    }
    prioritize = { 295 }
    add_extra_state_shared_building_slots = 2
    add_building_construction = {
        type = arms_factory
        level = 2
        instant_build = yes
    }
}
```

### add_to_variable

```txt
# Local variable
add_to_variable = { var = my_var value = 10 }

# Global variable
add_to_variable = { global.HABSBURG_economy_consumer_goods_factor = -0.1 }

# Cross-country modifier
add_to_variable = {
    var = BEL.COG_belgian_congo_colonial_dynamic_modifier_research_speed_factor
    value = 0.03
}
```

### set_technology

```txt
set_technology = {
    infantry_weapons = 1
    cavalry_1 = 1
    tech_support = 1
    tech_engineers = 1
}
```

---

## Key Triggers Examples

### has_completed_focus

```txt
has_completed_focus = POL_seize_control_of_the_state
```

### original_tag

```txt
# Case-sensitive: must use exact game tag
original_tag = COG    # CORRECT
original_tag = cog     # WRONG
```

### is_subject_of

```txt
is_subject_of = GER
```

### free_building_slots

```txt
free_building_slots = {
    building = industrial_complex
    size > 0
    include_locked = yes
}
```

### check_variable

```txt
check_variable = { global.HABSBURG_economy_consumer_goods_factor > 0.5 }
check_variable = { my_var = 42 }
check_variable = { my_var > 10 }
```

path: references/dynamic_modifiers.md
content: # HOI4 动态修正 (Dynamic Modifiers) 完整语法参考

**版本**: 1.0
**更新**: 2026-04-24
**来源**: 游戏本体文件 + Paradox Wiki

---

## 一、概述

**动态修正**是一种可以在游戏运行时动态应用和移除的修饰符系统。与普通修正（modifiers）不同，动态修正：

- ✅ 可以通过效果（effect）添加和移除
- ✅ 支持条件启用（`enable`）和条件移除（`remove_trigger`）
- ✅ 可以限定作用域（`scope`）
- ✅ 可以设置持续时间（`days`）
- ✅ 可以应用于：国家、州、指挥官、特殊项目

**典型用途**：
- 国策树的奖励效果
- 事件的临时增益/减益
- 占领政策的负面影响
- 特殊项目的持续效果

---

## 二、文件位置

```
common/
└── dynamic_modifiers/
    ├── 0_dynamic_modifiers.txt          # 基础/通用动态修正
    ├── aat_dynamic_modifiers.txt        # Arms Against Tyranny DLC
    ├── bba_dynamic_modifiers.txt        # By Blood Alone DLC
    ├── GoE_dynamic_modifiers.txt        # Gates of Hell DLC
    ├── HABSBURG_dynamic_modifiers.txt   # 哈布斯堡王朝Mod
    └── ...其他DLC/Mod的动态修正
```

---

## 三、定义语法

### 3.1 完整结构

```paradox
# ============================================
# 动态修正定义语法
# ============================================

dynamic_modifier_id = {
    # ---------- 可选：显示 ----------
    icon = GFX_modifiers_xxx          # UI图标（可选）
    
    # ---------- 启用条件（可选）----------
    # 只有当 enable 块内的条件满足时，修正才会生效
    # 如果不写 enable，默认 always = yes
    enable = {
        always = yes                  # 默认：总是启用
        # 或自定义条件
        tag = GER                     # 示例：仅特定国家
        has_completed_focus = xxx     # 示例：已完成特定国策
    }
    
    # ---------- 移除条件（可选）----------
    # 当 remove_trigger 条件满足时，修正会被移除
    # 示例：占领结束后移除占领惩罚
    remove_trigger = {
        OWNER = {
            original_tag = CAT        # 原来的国家标签
        }
    }
    
    # ---------- 攻击者修正（可选）----------
    # 如果设为 yes，此修正会影响参与战斗的所有人
    # 即使他们不在这个州
    attacker_modifier = no            # 默认 no
    
    # ---------- 修正值列表 ----------
    # 这里写所有要应用的修正值
    # 可以是国家修正、州修正、或指挥官修正
    
    # --- 国家修正示例 ---
    political_power_gain = 0.1       # 政治 power 获取 +10%
    consumer_goods_factor = -0.05     # 消费品工厂需求 -5%
    production_speed_buildings_factor = 0.15  # 建筑速度 +15%
    
    # --- 州修正示例（需要 local_ 前缀）---
    local_building_slots_factor = 0.25        # 建筑槽位 +25%
    local_factories = 2                       # 额外工厂 +2
    state_resources_factor = 0.1             # 资源产出 +10%
    local_manpower = 0.2                      # 本地人力 +20%
    local_production_speed_industrial_complex_factor = 0.2  # 工业复合体速度 +20%
    
    # --- 指挥官修正示例 ---
    armor_value = 0.5                         # 装甲值 +0.5
    defense = 1                               # 防御 +1
    attack = 2                                # 攻击 +2
    organization = 10                         # 组织度 +10
    
    # --- 抵抗/顺从度修正（占领相关）---
    compliance_growth = 0.05                # 顺从度增长 +5%
    resistance_growth = 0.1                  # 抵抗增长 +10%
    resistance_target = 0.2                  # 抵抗目标 +20%
    resistance_decay = 0.05                   # 抵抗衰减 +5%
    
    # --- 资源修正（临时）---
    temporary_state_resource_oil = sabotaged_oil    # 临时资源减少
}
```

### 3.2 简化形式

```paradox
# 如果不需要 enable/remove_trigger，可以用简化形式：
simple_modifier = {
    icon = GFX_idea_xxx
    political_power_gain = 0.1
    production_speed_buildings_factor = 0.15
}

# 等价于：
simple_modifier = {
    enable = { always = yes }
    icon = GFX_idea_xxx
    political_power_gain = 0.1
    production_speed_buildings_factor = 0.15
}
```

### 3.3 条件修正

```paradox
# 带条件的修正：当 enable 条件满足时应用
conditional_modifier = {
    enable = {
        has_completed_focus = GER_four_year_plan  # 仅在完成特定国策后生效
    }
    
    icon = GFX_idea_man_five_year_plan_industry
    
    political_power_gain = 0.05
    production_speed_buildings_factor = 0.15
    industrial_capacity_factory = -0.02
    production_factory_efficiency_gain_factor = BUL_foreign_industry_production_efficiency_modifier
}
```

---

## 四、应用语法

### 4.1 基本用法

```paradox
# 在任何效果块中使用
effect = {
    # 添加动态修正到当前作用域
    add_dynamic_modifier = {
        modifier = my_modifier  # 修正的 ID
    }
}

# 移除动态修正
effect = {
    remove_dynamic_modifier = {
        modifier = my_modifier
    }
}
```

### 4.2 带作用域（scope）

```paradox
# scope 参数：指定修正应用于哪个国家
# 默认为当前效果的作用域
effect = {
    # 示例1：应用于特定国家
    add_dynamic_modifier = {
        modifier = FIN_confederation_of_finno_russian_republics_dm
        scope = ROOT              # 应用于 ROOT（国策树所属国）
    }
    
    # 示例2：应用于事件目标
    add_dynamic_modifier = {
        modifier = my_modifier
        scope = FROM              # 应用于 FROM
    }
    
    # 示例3：应用于特定标签
    add_dynamic_modifier = {
        modifier = ITA_libyan_railway_modifier
        scope = ITA              # 固定应用于意大利
    }
}
```

### 4.3 带持续时间（days）

```paradox
# days 参数：修正在指定天数后自动移除
effect = {
    # 示例1：持续730天（约2年）
    add_dynamic_modifier = {
        modifier = DEN_economic_crisis_dynamic_modifier
        days = 730
    }
    
    # 示例2：持续30天
    add_dynamic_modifier = {
        modifier = temporary_boost
        days = 30
    }
    
    # 示例3：同时指定 scope 和 days
    add_dynamic_modifier = {
        modifier = ITA_libyan_railway_modifier
        days = 730
        scope = ITA
    }
}
```

### 4.4 完整参数

```paradox
effect = {
    add_dynamic_modifier = {
        modifier = xxx                    # 必填：修正ID
        scope = ROOT                     # 可选：作用域（默认当前作用域）
        days = 365                       # 可选：持续天数（不写则永久）
    }
}

effect = {
    remove_dynamic_modifier = {
        modifier = xxx                   # 必填：修正ID
        scope = ROOT                     # 可选：作用域
    }
}
```

---

## 五、真实游戏代码示例

### 5.1 国家级动态修正（民族精神形式）

```paradox
# 文件：common/dynamic_modifiers/0_dynamic_modifiers.txt

# ============================================
# 示例1：保加利亚外资工业（作为民族精神使用）
# ============================================
BUL_foreign_industry_dynamic_modifier = {
    enable = { always = yes }
    
    icon = GFX_idea_man_five_year_plan_industry
    
    # 政治 power 获取 +5%
    political_power_gain = 0.05
    
    # 建筑速度（从变量读取）
    production_speed_buildings_factor = BUL_foreign_industry_construction_speed_modifier
    
    # 军工厂产能 -2%
    industrial_capacity_factory = -0.02
    
    # 生产效率增益（从变量读取）
    production_factory_efficiency_gain_factor = BUL_foreign_industry_production_efficiency_modifier
    
    # 最大效率上限（从变量读取）
    production_factory_max_efficiency_factor = BUL_foreign_industry_production_efficiency_modifier
    
    # 消费品工厂需求（从变量读取）
    consumer_goods_factor = BUL_foreign_industry_consumer_goods_modifier
}

# ============================================
# 示例2：自治州状态（占领相关）
# ============================================
autonomous_state = {
    enable = { always = yes }
    
    icon = GFX_modifiers_sabotaged_resource
    
    # 可招募人口 -50%
    recruitable_population_factor = -0.5
    
    # 建筑槽位 -25%
    local_building_slots_factor = -0.25
    
    # 资源产出 -25%
    state_resources_factor = -0.25
    
    # 建筑速度 -25%
    state_production_speed_buildings_factor = -0.25
    
    # 移除条件：原国家为加泰罗尼亚/加利西亚/巴斯克时移除
    remove_trigger = {
        OWNER = {
            OR = {
                original_tag = CAT
                original_tag = GLC
                original_tag = BAS
            }
        }
    }
}
```

### 5.2 州级动态修正（占领惩罚）

```paradox
# ============================================
# 示例3：库尔德斯坦 agitation（抵抗活动）
# ============================================
kurdish_agitation = {
    enable = { always = yes }
    
    icon = GFX_modifiers_tur_kurdish_agitation
    
    # 抵抗增长 +3%
    resistance_growth = 0.03
    
    # 抵抗目标 10%
    resistance_target = 0.1
    
    # 抵抗衰减 -10%（负数=增长）
    resistance_decay = -0.1
    
    # 资源产出 -15%
    state_resources_factor = -0.15
}

# ============================================
# 示例4：库尔德斯坦叛乱（严重）
# ============================================
kurdish_separatism = {
    enable = { always = yes }
    
    icon = GFX_modifiers_tur_kurdish_separatism
    
    # 顺从度增长 -5%
    compliance_growth = -0.05
    
    # 抵抗增长 +5%
    resistance_growth = 0.05
    
    # 抵抗目标 20%
    resistance_target = 0.20
    
    # 抵抗衰减 -20%
    resistance_decay = -0.20
    
    # 资源产出 -33%
    state_resources_factor = -0.33
    
    # 禁止战略重部署
    disable_strategic_redeployment = 1
}

# ============================================
# 示例5：基础设施条件触发
# ============================================
dense_rural_infrastructure = {
    enable = { always = yes }
    
    # 移除条件：基础设施 > 4 时移除
    remove_trigger = {
        ROOT = {
            infrastructure > 4
        }
    }
    
    icon = GFX_modifiers_SOV_civilian_labor_in_defense
    
    # 非核心补给影响 +40%
    local_non_core_supply_impact_factor = 0.4
}
```

### 5.3 国策中的应用

```paradox
# 文件：common/national_focus/italy.txt
# 示例：利比亚铁路建设

ITA_libyan_railway = {
    # ... 国策定义 ...
    
    completion_reward = {
        # 添加动态修正到意大利国家
        # 持续730天，作用域 ITA
        add_dynamic_modifier = {
            modifier = ITA_libyan_railway_modifier
            days = 730
            scope = ITA
        }
        
        custom_effect_tooltip = ITA_libyan_railway_tt
    }
}

# ============================================
# 文件：common/national_focus/denmark.txt
# 示例：经济危机

DEN_economic_crisis = {
    # ... 国策定义 ...
    
    completion_reward = {
        # 添加730天的经济危机修正
        add_dynamic_modifier = {
            modifier = DEN_economic_crisis_dynamic_modifier
            days = 730
        }
    }
}

# ============================================
# 文件：common/national_focus/finland.txt
# 示例：芬诺俄罗斯共和国联邦

FIN_confederation = {
    # ... 国策定义 ...
    
    completion_reward = {
        # 添加到 ROOT（芬兰）
        add_dynamic_modifier = {
            modifier = FIN_confederation_of_finno_russian_republics_dm
            scope = ROOT
        }
        
        # 同时给俄罗斯添加
        hidden_effect = {
            RUS = {
                add_dynamic_modifier = {
                    modifier = FIN_confederation_of_finno_russian_republics_dm
                    scope = ROOT
                }
            }
        }
    }
}
```

---

## 六、常用修正字段速查表

### 6.1 国家级修正

| 字段 | 类型 | 说明 | 示例值 |
|------|------|------|--------|
| `political_power_gain` | 百分比 | 政治 power 获取 | `0.1` (+10%) |
| `consumer_goods_factor` | 百分比 | 消费品工厂需求 | `-0.05` (-5%) |
| `production_speed_buildings_factor` | 百分比 | 建筑速度 | `0.15` (+15%) |
| `industrial_capacity_factory` | 百分比 | 军工厂产能 | `-0.02` (-2%) |
| `production_factory_efficiency_gain_factor` | 百分比 | 生产效率增长 | `0.1` (+10%) |
| `army_core_attack_factor` | 百分比 | 陆军核心攻击 | `0.1` (+10%) |
| `army_core_defence_factor` | 百分比 | 陆军核心防御 | `0.1` (+10%) |
| `training_time_factor` | 百分比 | 训练时间 | `-0.1` (-10%) |
| `experience_gain_navy_factor` | 百分比 | 海军经验获取 | `0.1` (+10%) |

### 6.2 州级修正（需要 `local_` 前缀）

| 字段 | 类型 | 说明 | 示例值 |
|------|------|------|--------|
| `local_building_slots_factor` | 百分比 | 建筑槽位 | `0.25` (+25%) |
| `local_factories` | 数字 | 额外工厂数 | `2` |
| `state_resources_factor` | 百分比 | 资源产出 | `0.1` (+10%) |
| `local_manpower` | 百分比 | 本地人力 | `0.2` (+20%) |
| `local_non_core_manpower` | 百分比 | 非核心人力 | `0.25` (+25%) |
| `local_supply_impact_factor` | 百分比 | 补给影响 | `0.5` (+50%) |
| `local_production_speed_industrial_complex_factor` | 百分比 | 工业复合体速度 | `0.2` (+20%) |
| `local_non_core_supply_impact_factor` | 百分比 | 非核心补给 | `0.4` (+40%) |

### 6.3 占领/抵抗修正

| 字段 | 类型 | 说明 | 示例值 |
|------|------|------|--------|
| `compliance_growth` | 百分比 | 顺从度增长 | `0.05` (+5%) |
| `resistance_growth` | 百分比 | 抵抗增长 | `0.1` (+10%) |
| `resistance_target` | 百分比 | 抵抗目标 | `0.2` (20%) |
| `resistance_decay` | 百分比 | 抵抗衰减 | `0.15` (+15%) |
| `disable_strategic_redeployment` | 布尔 | 禁止战略重部署 | `1` |

### 6.4 指挥官修正

| 字段 | 类型 | 说明 | 示例值 |
|------|------|------|--------|
| `armor_value` | 数字 | 装甲值 | `0.5` |
| `defense` | 数字 | 防御 | `1` |
| `attack` | 数字 | 攻击 | `2` |
| `organization` | 数字 | 组织度 | `10` |

---

## 七、最佳实践

### 7.1 命名规范

```paradox
# 国家级修正：以国家标签开头
GER_war_economy = { ... }
FRA_five_year_plan = { ... }

# 州级修正：描述性名称
kurdish_separatism = { ... }
occupied_territory_penalty = { ... }

# 功能性修正
temporary_boost = { ... }
research_bonus_modifier = { ... }
```

### 7.2 图标命名

```paradox
# 国家修正（民族精神）：使用 GFX_idea_
icon = GFX_idea_man_five_year_plan_industry

# 州修正（占领相关）：使用 GFX_modifiers_
icon = GFX_modifiers_tur_kurdish_agitation
icon = GFX_modifiers_sabotaged_resource
```

### 7.3 与变量的结合

```paradox
# 保加利亚示例：用变量控制动态修正强度
BUL_foreign_industry_dynamic_modifier = {
    enable = { always = yes }
    icon = GFX_idea_man_five_year_plan_industry
    
    # 从变量读取修正值
    production_speed_buildings_factor = BUL_foreign_industry_construction_speed_modifier
    production_factory_efficiency_gain_factor = BUL_foreign_industry_production_efficiency_modifier
    consumer_goods_factor = BUL_foreign_industry_consumer_goods_modifier
}

# 在国策中设置变量
completion_reward = {
    set_variable = { BUL_foreign_industry_construction_speed_modifier = 0.15 }
    set_variable = { BUL_foreign_industry_production_efficiency_modifier = 0.1 }
    set_variable = { BUL_foreign_industry_consumer_goods_modifier = -0.05 }
    
    add_dynamic_modifier = {
        modifier = BUL_foreign_industry_dynamic_modifier
    }
}
```

### 7.4 条件启用的正确用法

```paradox
# ✅ 正确：使用 enable 条件
conditional_modifier = {
    enable = {
        has_completed_focus = MY_national_focus_id
    }
    production_speed_buildings_factor = 0.1
}

# ✅ 正确：使用 remove_trigger
temporary_penalty = {
    enable = { always = yes }
    
    # 条件满足时移除
    remove_trigger = {
        date > 1939.1.1
    }
    
    political_power_gain = -0.1
}

# ❌ 错误：在 enable 中使用复杂逻辑
# 应该在国策/事件的 available 块中处理
```

---

## 八、调试技巧

### 8.1 修正不生效的常见原因

1. **忘记定义**：修正ID必须在 `common/dynamic_modifiers/` 中定义
2. **enable 条件不满足**：检查 enable 块的条件
3. **remove_trigger 已触发**：检查移除条件
4. **作用域错误**：使用 `scope` 参数指定正确的作用域
5. **已存在相同修正**：移除旧修正后再添加

### 8.2 调试命令

```paradox
# 在控制台查看当前国家的动态修正
# debug_mode 后使用以下命令查看

# 查看国家级动态修正
has_dynamic_modifier = { modifier = xxx }

# 查看特定修正是否激活
has_country_modifier = xxx
```

### 8.3 常见错误

```paradox
# ❌ 错误1：修正ID不存在
add_dynamic_modifier = {
    modifier = NONEXISTENT_modifier  # 会报错！
}

# ✅ 正确：先在 dynamic_modifiers 中定义
# common/dynamic_modifiers/my_modifiers.txt
my_modifier = {
    political_power_gain = 0.1
}

# 然后再使用
add_dynamic_modifier = {
    modifier = my_modifier
}

# ❌ 错误2：days 参数类型错误
add_dynamic_modifier = {
    modifier = my_modifier
    days = "30"  # 错误：字符串类型
}

# ✅ 正确：使用数字
add_dynamic_modifier = {
    modifier = my_modifier
    days = 30
}

# ❌ 错误3：scope 写错
add_dynamic_modifier = {
    modifier = my_modifier
    scope = "ROOT"  # 错误：引号
}

# ✅ 正确：不加引号
add_dynamic_modifier = {
    modifier = my_modifier
    scope = ROOT
}
```

---

## 九、相关文件关联

| 文件类型 | 位置 | 说明 |
|----------|------|------|
| 动态修正定义 | `common/dynamic_modifiers/*.txt` | 修正的完整定义 |
| 国策奖励 | `common/national_focus/*.txt` | 常见的应用位置 |
| 事件效果 | `events/*.txt` | 事件中添加/移除 |
| 决议效果 | `common/decisions/*.txt` | 决议中添加/移除 |

---

**文档版本**: 1.0
**更新日期**: 2026-04-24
**维护者**: AI Agent (HOI Mod-Maker Skill)


path: references/events_guide.md
content: # HOI4 事件系统完整参考

## 目录

1. [文件结构](#文件结构)
2. [命名空间](#命名空间)
3. [国家事件](#国家事件)
4. [新闻事件](#新闻事件)
5. [事件触发](#事件触发)
6. [选项系统](#选项系统)
7. [常用效果](#常用效果)
8. [示例代码](#示例代码)

---

## 文件结构

```
events/{mod_name}_events.txt
events/{mod_name}_news.txt
```

### 文件头

```
# 事件文件 - {Mod名称}
# 添加命名空间声明
add_namespace = {mod_name}
```

---

## 命名空间

### 声明命名空间

```
add_namespace = poland_crisis
```

### 事件ID格式

```
{namespace}.{number}

# 示例
poland_crisis.1      # 命名空间.编号
poland_crisis.2
```

### 命名空间作用

- 防止事件ID冲突
- 便于组织和调试
- 允许其他mod引用

---

## 国家事件

### 基础模板

```
country_event = {
    id = {namespace}.{number}
    title = {event_title_key}
    desc = {event_desc_key}
    picture = {GFX_name}
    
    is_triggered_only = yes
    
    option = {
        name = {option_key}
        {effects}
    }
}
```

### 完整模板

```
country_event = {
    id = poland_crisis.1
    title = poland_crisis.1_title
    desc = poland_crisis.1_desc
    picture = generic_event
    
    # 触发条件（可选）
    trigger = {
        tag = POL
        date > 1939.1.1
        has_completed_focus = POL_beck_ribbentrop_path
    }
    
    # 平均触发时间（可选）
    mean_time_to_happen = {
        days = 30
        
        modifier = {
            add = 15
            has_stability < 0.5
        }
        
        modifier = {
            factor = 0.5
            has_war_with = GER
        }
    }
    
    # 是否仅触发（可选）
    is_triggered_only = yes
    
    # 是否隐藏（可选）
    hidden = no
    
    # 选项
    option = {
        name = poland_crisis.1_option_a
        
        # 效果
        add_political_power = 50
        
        # 隐藏效果
        hidden_effect = {
            set_country_flag = poland_crisis_flag
        }
        
        # 触发其他事件
        country_event = {
            id = poland_crisis.2
            days = 3
        }
    }
    
    option = {
        name = poland_crisis.1_option_b
        add_stability = 0.05
    }
}
```

---

## 新闻事件

### 新闻事件模板

```
news_event = {
    id = news.100
    title = news.100_title
    desc = news.100_desc
    picture = generic_event
    
    # 新闻事件特有字段
    
    # 是否显示主要新闻（可选）
    major = yes
    
    # 发送给谁
    # 默认发送给所有国家
    # 可用限定：
    # - filter = news_poland      # 使用预定义筛选器
    # - tag = GER POL             # 特定国家
    
    option = {
        name = news.100_option_a
    }
}
```

### 新闻事件完整示例

```
news_event = {
    id = news.poland_war
    title = news.poland_war_title
    desc = news.poland_war_desc
    picture = generic_war
    
    major = yes
    
    option = {
        name = news.option_interesting
        trigger = {
            tag = GER
        }
    }
    
    option = {
        name = news.option_interesting
        trigger = {
            tag = SOV
        }
    }
    
    option = {
        name = news.option_interesting
    }
}
```

---

## 事件触发

### 从焦点触发

```
focus = {
    id = POL_danzig_or_war
    
    completion_reward = {
        country_event = {
            id = poland_crisis.1
            days = 1
        }
    }
}
```

### 从效果触发

```
# 立即触发
country_event = { id = poland_crisis.1 }

# 延迟触发
country_event = {
    id = poland_crisis.1
    days = 7
    random_days = 3    # 额外随机天数
}

# 从隐藏效果触发
hidden_effect = {
    country_event = {
        id = poland_crisis.1
        days = 1
    }
}
```

### 从决议触发

```
{decision_id} = {
    complete_effect = {
        country_event = { id = poland_crisis.1 }
    }
}
```

### 从其他事件触发

```
option = {
    name = poland_crisis.1_option_a
    country_event = {
        id = poland_crisis.2
        days = 3
    }
}
```

### 从on_action触发

```
# 在 common/on_actions/ 中定义
on_actions = {
    on_startup = {
        effect = {
            country_event = {
                id = poland_crisis.1
                days = 1
            }
        }
    }
}
```

---

## 选项系统

### 基础选项

```
option = {
    name = {option_key}
    {effects}
}
```

### 带触发条件的选项

```
option = {
    name = poland_crisis.1_option_a
    
    # 只有满足条件的选项才显示
    trigger = {
        political_power > 100
    }
    
    # 执行效果
    add_political_power = -100
}
```

### 带AI权重的选项

```
option = {
    name = poland_crisis.1_option_a
    
    # AI选择权重
    ai_chance = {
        factor = 5
        
        modifier = {
            add = 10
            has_war_with = GER
        }
        
        modifier = {
            factor = 0
            has_stability < 0.3
        }
    }
}
```

### 隐藏选项

```
option = {
    name = poland_crisis.1_hidden_option
    
    # 对玩家隐藏但AI可选（不常用）
    hidden = yes
}
```

---

## 常用效果

### 政治类

```
# 政治点数
add_political_power = 100
add_political_power = -50

# 稳定度/战争支持度
add_stability = 0.05
add_war_support = 0.05
add_stability = -0.10

# 意识形态支持度
add_popularity = {
    ideology = fascism
    popularity = 0.10
}

# 切换意识形态
set_politics = {
    ruling_party = fascism
    elections_allowed = no
}
```

### 民族精神

```
# 添加
add_ideas = POL_sanacja_regime

# 移除
remove_ideas = POL_sanacja_regime

# 临时添加
add_timed_idea = {
    idea = POL_economic_boost
    days = 365
}

# 交换（先移除再添加）
swap_ideas = {
    remove_idea = POL_economic_crisis
    add_idea = POL_economic_recovery
}
```

### 领土操作

```
# 核心领土
{state_id} = {
    add_core_by = ROOT
    add_claim_by = ROOT
}

# 移交领土
transfer_state = {
    target = GER
    state = 9          # 但泽
}

# 获得领土
transfer_state = {
    state = 10
    target = POL
}
```

### 外交关系

```
# 观感修正
GER = {
    add_opinion_modifier = {
        target = ROOT
        modifier = POL_german_cooperation
    }
}

# 保证独立
create_guarantee = { target = CZE }

# 宣战
create_wargoal = {
    type = annex_everything
    target = GER
}

# 加入阵营
add_to_faction = GER

# 创建阵营
create_faction = POL_international_block
```

### 军事类

```
# 经验值
army_experience = 25
navy_experience = 25
air_experience = 25

# 人力
add_manpower = 50000
add_manpower = -10000

# 创建师
create_unit = {
    division = "波兰第一步兵师"
    division_template = "步兵师模板"
    start_province = { x y }
    amount = 1
}
```

### 标记系统

```
# 国家标记
set_country_flag = poland_crisis_flag
clr_country_flag = poland_crisis_flag

# 带过期时间的标记
set_country_flag = {
    flag = poland_crisis_flag
    days = 365
    value = 1    # 可选，用于变量
}

# 全局标记
set_global_flag = world_war_started

# 检查标记（在触发条件中）
has_country_flag = poland_crisis_flag
```

### 科技与研究

```
# 研究加成
add_tech_bonus = {
    name = POL_industrial_bonus
    bonus = 0.5
    uses = 1
    category = industrial
}

# 解锁科技
set_technology = {
    infantry_equipment_1 = 1
    basic_machine_tools = 1
}

# 研究槽位
add_research_slot = 1
```

---

## 示例代码

### 完整事件示例

```
# 命名空间声明
add_namespace = poland_crisis

# 事件1：但泽危机
country_event = {
    id = poland_crisis.1
    title = poland_crisis.1_title
    desc = poland_crisis.1_desc
    picture = generic_diplomatic
    
    trigger = {
        tag = POL
        date > 1939.1.1
        NOT = { has_war_with = GER }
        9 = { is_owned_by = POL }    # 但泽
    }
    
    mean_time_to_happen = {
        days = 30
        modifier = {
            factor = 0.5
            has_war_with = SOV
        }
    }
    
    is_triggered_only = no
    
    option = {
        name = poland_crisis.1_refuse
        
        # 德波关系恶化
        GER = {
            add_opinion_modifier = {
                target = ROOT
                modifier = poland_refused_danzig
            }
        }
        
        # 触发德国反应事件
        hidden_effect = {
            GER = {
                country_event = {
                    id = poland_crisis.2
                    days = 1
                }
            }
        }
        
        # 增加战争支持度
        add_war_support = 0.10
    }
    
    option = {
        name = poland_crisis.1_accept
        
        # 失去但泽
        transfer_state = {
            state = 9
            target = GER
        }
        
        # 政治点数惩罚
        add_political_power = -100
        
        # 稳定度下降
        add_stability = -0.10
        
        # 德波关系改善
        GER = {
            add_opinion_modifier = {
                target = ROOT
                modifier = poland_accepted_danzig
            }
        }
    }
}

# 事件2：德国的反应
country_event = {
    id = poland_crisis.2
    title = poland_crisis.2_title
    desc = poland_crisis.2_desc
    picture = generic_war
    
    is_triggered_only = yes
    
    option = {
        name = poland_crisis.2_war
        
        # 对波兰宣战
        create_wargoal = {
            type = annex_everything
            target = POL
        }
        
        # 创建战争目标后触发战争
        hidden_effect = {
            declare_war_on = {
                target = POL
                type = annex_everything
            }
        }
        
        # 触发新闻事件
        news_event = {
            id = news.poland_war
            days = 1
        }
    }
    
    option = {
        name = poland_crisis.2_wait
        
        # 德波关系进一步恶化
        POL = {
            add_opinion_modifier = {
                target = ROOT
                modifier = german_hostility
            }
        }
    }
}
```

### 对应本地化文件

```yaml
l_english:
 # 事件1
 poland_crisis.1_title:0 "但泽归属问题"
 poland_crisis.1_desc:0 "德国向我们提出了但泽归属问题，声称但泽应当回归德国。我们必须做出决定..."
 poland_crisis.1_refuse:0 "拒绝他们的无理要求！"
 poland_crisis.1_accept:0 "接受他们的条件..."
 
 # 事件2
 poland_crisis.2_title:0 "波兰的拒绝"
 poland_crisis.2_desc:0 "波兰拒绝了我们对但泽的要求！"
 poland_crisis.2_war:0 "那就用战争解决！"
 poland_crisis.2_wait:0 "暂时等待..."
```

---

## 高级技巧

### 链式事件

```
# 事件A触发事件B，事件B触发事件C
country_event = {
    id = chain.1
    
    option = {
        name = chain.1_option
        country_event = { id = chain.2 days = 3 }
    }
}

country_event = {
    id = chain.2
    
    option = {
        name = chain.2_option
        country_event = { id = chain.3 days = 3 }
    }
}
```

### 条件效果

```
option = {
    name = event.1_option
    
    if = {
        limit = { political_power > 100 }
        add_political_power = -100
        add_stability = 0.05
    }
    else = {
        add_stability = -0.05
    }
}
```

### 随机效果

```
option = {
    name = event.1_option
    
    random_effect = {
        chance = 50
        add_political_power = 100
    }
    random_effect = {
        chance = 50
        add_stability = 0.10
    }
}
```

### 对象操作

```
# 对特定国家执行效果
GER = {
    add_opinion_modifier = {
        target = ROOT
        modifier = diplomatic_tension
    }
}

# 获取随机国家
random_country = {
    limit = {
        is_neighbor_of = ROOT
        is_at_war_with = no
    }
    add_opinion_modifier = {
        target = ROOT
        modifier = improved_relations
    }
}
```


path: references/focus_complete_guide.md
content: # 国策树完整语法参考

> 本文件从 SKILL.md 拆分而来，包含国策树的完整语法细节。
> 日常使用请直接查阅本文件；SKILL.md 仅保留黄金法则和导航。

---

## Focus Tree 结构

```
focus_tree = {
    id = polish_focus
    
    # === 国家权重 ===
    country = {
        factor = 0
        modifier = {
            add = 10
            tag = POL
        }
    }
    
    # === 默认树 ===
    default = no
    
    # === 初始视口 ===
    initial_show_position = {
        x = 500
        y = 300
    }
    # 或使用焦点锚点：
    initial_show_position = {
        focus = POL_starting_focus
    }
    
    # === 连续焦点位置 ===
    continuous_focus_position = { x = 100 y = 1300 }
    
    # === 内圈窗口（德国特有）===
    inlay_window = {
        id = ger_inner_circle_inlay_window
        position = { x = 4500 y = 1150 }
    }
    
    # === 备选图标（可选）===
    alternate_icon_set = FOCUS_ICON_SET_HISTORICAL_KEY_FOCUS
    
    # === 快捷方式（可选）===
    shortcut = {
        name = POL_historical_path_shortcut
        target = POL_political_base
        scroll_wheel_factor = 0.469
        trigger = { always = yes }
    }
    
    # === 共享焦点引用（可选）===
    shared_focus = baltic_industrial_base
    
    # === 焦点定义 ===
    focus = { ... }
    focus = { ... }
}
```

## Focus 节点完整字段

### 必需字段

```
focus = {
    id = POL_focus_name       # 唯一标识符
    icon = GFX_focus_POL      # 图标 GFX
    x = 2                     # 横坐标（绝对或相对）
    y = 0                     # 纵坐标
    cost = 10                 # 天数成本（实际天数 = cost × 7）
}
```

### 定位方式（默认用相对定位）

> ⚠️ **`relative_position_id` 是默认首选**：除根节点外，**一律优先使用相对定位**。绝对坐标只在没有父节点时才用。相对定位让树可以整体平移、后期插入节点时不影响子节点坐标。

**绝对定位**（仅用于根节点或无父节点的主干焦点）：
```
focus = {
    id = POL_root_focus
    x = 0
    y = 0
    cost = 5
}
```

**相对定位**：
```
focus = {
    id = POL_child_focus
    relative_position_id = POL_root_focus
    x = 0        # 偏移：负=左，正=右
    y = 1        # 偏移：向下
    cost = 10
}
```

### 前置条件

> ⚠️ **必须验证**：所有 `prerequisite` 引用的 focus ID 必须在当前国策树文件中**实际定义**。生成前先确认 ID 存在，绝不凭空捏造。

```
# 单一前置
prerequisite = { focus = POL_parent }

# 多重前置（AND 关系）
prerequisite = { focus = POL_focus1 focus = POL_focus2 }

# 或关系（满足任一组）
prerequisite = { focus = POL_path_a }
prerequisite = { focus = POL_path_b }
```

### 互斥焦点

```
focus = {
    id = POL_democratic_path
    
    mutually_exclusive = { 
        focus = POL_fascist_path 
        focus = POL_communist_path 
    }
}
```

**注意**：互斥需要双向声明！

### 可用条件

```
available = {
    tag = POL
    
    # 时间条件
    date > 1936.1.1
    
    # 政治条件
    has_political_power > 50
    has_government = democracy
    fascism > 0.3
    
    # 稳定度/战争支持度
    has_stability > 0.5
    has_war_support > 0.3
    
    # 领土条件
    controls_state = 123
    owns_state = 123
    123 = { is_owned_by = ROOT }
    
    # 已完成焦点
    has_completed_focus = POL_other_focus
    
    # 已研究科技
    has_tech = infantry_equipment_1
    
    # 工厂数量
    num_of_controlled_factories > 50
    
    # 标记
    has_country_flag = pol_flag_name
    has_global_flag = world_war_started
    
    # 意识形态支持度
    get_popularity = {
        ideology = fascism
        value > 0.3
    }
    
    # 逻辑组合
    OR = {
        has_stability > 0.7
        has_war_support > 0.5
    }
    
    NOT = { has_war_with = GER }
    
    AND = {
        controls_state = 123
        controls_state = 124
    }
}
```

### 跳过条件

```
bypass = {
    custom_trigger_tooltip = {
        tooltip = POL_focus_bypass_tt
        has_tech = infantry_equipment_1
    }
}
```

### 完成效果

```
completion_reward = {
    # ===== 政治效果 =====
    add_political_power = 100
    add_stability = 0.05
    add_war_support = 0.05
    
    # 意识形态
    add_popularity = {
        ideology = fascism
        popularity = 0.10
    }
    
    set_politics = {
        ruling_party = fascism
        elections_allowed = no
    }
    
    # ===== 民族精神 =====
    add_ideas = POL_new_spirit
    remove_ideas = POL_old_spirit
    
    add_timed_idea = {
        idea = POL_temp_boost
        days = 365
    }
    
    # ===== 科技效果 =====
    add_tech_bonus = {
        name = POL_tech_bonus
        bonus = 1.0
        uses = 1
        category = industry
    }
    
    add_research_slot = 1
    
    # ===== 建筑效果（正确写法）=====
    # ❌ 错误写法：random_owned_controlled_state 里用 state = 762
    # ✅ 正确写法：用具体 state ID 作为 scope，在其内部调用 add_building_construction

    # 写法一：指定具体省份/州（推荐）
    # 在 state scope 内调用建筑效果
    123 = {
        add_extra_state_shared_building_slots = 1    # 先扩容（如果槽位已满）
        add_building_construction = {
            type = industrial_complex              # 建筑类型
            level = 1                               # 建造等级
            instant_build = yes                     # 瞬间完成（国策中推荐）
        }
    }

    124 = {
        add_extra_state_shared_building_slots = 2
        add_building_construction = {
            type = arms_factory
            level = 2
            instant_build = yes
        }
    }

    # 写法二：多个州同时建造（遍历）
    every_owned_state = {
        limit = {
            is_capital = no
            free_building_slots = {
                building = industrial_complex
                size > 0
                include_locked = yes
            }
        }
        add_building_construction = {
            type = industrial_complex
            level = 1
            instant_build = yes
        }
    }

    # 写法三：随机选择一个州
    random_owned_controlled_state = {
        prioritize = { 123 124 125 }
        limit = {
            free_building_slots = {
                building = air_base
                size > 5
            }
        }
        add_building_construction = {
            type = air_base
            level = 6
            instant_build = yes
        }
        set_state_flag = GER_expanding_luftwaffe_flag
    }

    # 建筑类型参考：
    # industrial_complex (民用工厂) / arms_factory (军用工厂)
    # dockyard (船坞) / infrastructure (基础设施)
    # air_base (空军基地) / naval_base (海军基地)
    # bunker (陆上要塞) / coastal_bunker (海岸要塞)
    # anti_air_building (防空炮)

    # ===== 资源效果（正确写法）=====
    # ❌ 错误写法：add_resource 里用 state = 762
    # ✅ 正确写法：在 state scope 内调用 add_resource
    762 = {
        add_resource = {
            type = steel
            amount = 24
        }
    }

    # 也可以给首都加资源：
    1 = {
        add_resource = {
            type = chromium
            amount = 12
        }
    }
    
    # ===== 铁路建设 =====
    build_railway = {
        level = 1
        path = { 9508 6558 3483 }
    }
    
    # ===== 军事效果 =====
    army_experience = 25
    navy_experience = 25
    air_experience = 25
    add_manpower = 50000
    
    # ===== 外交效果 =====
    GER = {
        add_opinion_modifier = {
            target = ROOT
            modifier = pol_german_cooperation
        }
    }
    
    create_guarantee = { target = CZE }
    
    create_wargoal = {
        type = annex_everything
        target = GER
    }
    
    # ===== 阵营效果 =====
    create_faction = POL_international_block
    add_to_faction = GER
    
    # ===== 领土效果 =====
    transfer_state = {
        state = 123
        target = GER
    }
    
    123 = {
        add_core_by = ROOT
        add_claim_by = ROOT
    }
    
    # ===== 事件效果 =====
    country_event = {
        id = poland_events.1
        days = 7
        random_days = 3
    }
    
    # ===== 标记效果 =====
    set_country_flag = pol_focus_done
    set_country_flag = {
        flag = pol_focus_variant
        days = 365
        value = 1
    }
    set_global_flag = world_event_happened
    
    # ===== 条件效果 =====
    if = {
        limit = { has_government = fascism }
        add_political_power = 150
    }
    else = {
        add_political_power = 50
    }
    
    # ===== 隐藏效果 =====
    hidden_effect = {
        set_country_flag = pol_hidden_flag
    }
    
    # ===== 自定义提示 =====
    custom_effect_tooltip = POL_focus_custom_tt
    
    # ===== 显示顾问提示 =====
    show_ideas_tooltip = GER_hjalmar_schacht
    
    # ===== 解锁决策提示 =====
    unlock_decision_category_tooltip = POL_economic_decisions
}
```

### 内圈焦点（Inner Circle）

```
focus = {
    id = GER_inner_circle_1
    inner_circle = yes
    icon = GFX_focus_ger_inner_circle
    x = 0
    y = 0
    relative_position_id = GER_center_focus
    cost = 20    # 内圈焦点通常 cost 较低
    
    completion_reward = {
        add_political_power = 25
    }
}

# 时间常量定义
@inner_circle_time_tier_1 = 20    # 140天
@inner_circle_time_tier_2 = 40    # 280天
```

### 可持久国策（Persistent Focus / Continuous Focus）

可持久国策分为两种：**Continuous Focus**（连续焦点）和 **Persistent Focus**（持久焦点）。

#### Continuous Focus（连续焦点）

连续焦点在完成10个常规国策后解锁，效果在激活期间**持续生效**，每天消耗1政治点数。

```
focus_tree = {
    continuous_focus_position = { x = 500 y = 1300 }  # 连续焦点在地图上的位置

    focus = {
        id = continuous_army_xp
        icon = GFX_focus_generic_army_xp
        x = 0
        y = 0
        continuous = yes                               # 标记为连续焦点

        cost = 0                                       # 连续焦点 cost 必须为 0
        cancelable = no                               # 不可取消（可选，默认 no）
        available_if_capitulated = yes                 # 投降后可用（可选）

        ai_will_do = {                                 # AI 行为配置
            factor = 1
            modifier = {
                add = 10
                tag = GER
            }
        }

        search_filters = {                             # 搜索过滤器（重要！）
            FOCUS_FILTER_ARMY_XP                       # 必须对应焦点效果类型
            FOCUS_FILTER_MANPOWER
        }

        # ✅ 连续焦点使用 modifier = {} 提供持续效果
        # ❌ 不要用 completion_reward，它只生效一次
        modifier = {
            army_experience_gain_factor = 0.05
            mobilization_speed = 0.10
        }
    }
}
```

**Continuous Focus 的特殊规则**：
- `cost` 必须为 0（continuous focus 本身不消耗时间）
- 使用 `modifier = {}` 提供持续效果，而非 `completion_reward`
- 必须指定 `search_filters`（影响显示分类和 AI 选卡逻辑）
- `continuous = yes` 与 `relative_position_id` 不兼容

#### Persistent Focus（持久焦点，可被取消型）

另一种可持久国策：国策开始后持续执行（期间消耗政治点数），但可以被取消，取消时触发 `cancel` 效果。

```
focus = {
    id = TAG_mobilization_focus
    icon = GFX_goal_generic_mobilization
    cost = 30                                    # 持续 210 天

    # 国策进行中的效果（每天生效）
    completion_reward = {
        add_war_support = 0.05
        army_experience = 25
    }

    # 完成后的一次性效果
    # （如果需要额外效果）

    cancel = {                                    # ❗ 被取消时触发的效果
        add_stability = -0.05
        custom_effect_tooltip = TAG_mobilization_cancelled_tt
    }

    cancel_if_invalid = yes                       # 条件不满足时自动取消（可选）
    will_lead_to_war_with = TAG                   # 完成后对某国宣战（可选）

    ai_will_do = {
        factor = 0                                  # AI 不会自动选择（如果需要玩家决策）
        modifier = {
            add = 10
            has_war = yes
        }
    }
}
```

**cancel 块的典型用途**：
- 退还部分资源（用标记追踪）
- 触发负面事件
- 显示提示信息

**cancel_if_invalid 用法**：
- 当国策的 available 条件不再满足时，是否自动取消
- `cancel_if_invalid = yes`：自动取消，触发 `cancel` 效果
- `cancel_if_invalid = no`：国策暂停，直到条件恢复

#### cancelable 字段（可取消属性）

控制国策是否可以被玩家手动取消：

```
cancelable = yes        # 可取消（玩家可随时停止）
cancelable = no         # 不可取消（必须完成或条件失效）
```

默认 `cancelable = yes`。设置为 `no` 用于强制完成的国策（如内圈选择）。

**ai_will_do 完整语法**：

```
ai_will_do = {
    factor = 1                              # 基础权重因子

    modifier = {                            # 修正器（可叠加）
        add = 10                            # 加法修正
        multiply = 2                        # 乘法修正（2x 权重）
        tag = GER                           # 仅对特定国家生效
        NOT = { has_completed_focus = XXX } # 取反
        has_war = yes                       # 战争时权重修正
        has_government = fascism             # 特定政体时生效
        date > 1940.1.1                     # 特定日期后生效
    }
}
```

**常见 ai_will_do 组合**：

```
# AI 总是选择（factor = 0 但 modifier add 修正为正）
ai_will_do = {
    factor = 0
    modifier = { add = 100 }
}

# AI 从不选择
ai_will_do = {
    factor = 0
}

# 战时才选
ai_will_do = {
    factor = 1
    modifier = {
        add = 10
        has_war = yes
        NOT = { has_war = yes }
        add = -100
    }
}
```

### Search Filters 完整列表

```
FOCUS_FILTER_POLITICAL           # 政治
FOCUS_FILTER_RESEARCH            # 研究
FOCUS_FILTER_INDUSTRY            # 工业
FOCUS_FILTER_STABILITY           # 稳定度
FOCUS_FILTER_WAR_SUPPORT         # 战争支持度
FOCUS_FILTER_MANPOWER            # 人力
FOCUS_FILTER_ANNEXATION          # 吞并
FOCUS_FILTER_INTERNAL_AFFAIRS    # 内部事务
FOCUS_FILTER_ARMY_XP             # 陆军经验
FOCUS_FILTER_NAVY_XP             # 海军经验
FOCUS_FILTER_AIR_XP              # 空军经验
FOCUS_FILTER_BALANCE_OF_POWER    # 权力平衡
FOCUS_FILTER_POLITICAL_CHARACTER # 政治人物
FOCUS_FILTER_MILITARY_CHARACTER  # 军事人物
FOCUS_FILTER_INTERNATIONAL_TRADE # 国际贸易
FOCUS_FILTER_HISTORICAL          # 历史路线
FOCUS_FILTER_INNER_CIRCLE        # 德国内圈
```


path: references/focus_syntax_complete.md
content: # HOI4 国策树完整语法参考

本文档整合了官方 Wiki 和游戏本地文件的所有国策树语法细节。

---

## 目录

1. [Focus Tree 结构](#focus-tree-结构)
2. [Focus 节点](#focus-节点)
3. [Joint Focus 联合焦点](#joint-focus-联合焦点)
4. [Shared Focus 共享焦点](#shared-focus-共享焦点)
5. [Effect 效果参考](#effect-效果参考)
6. [Trigger 触发器参考](#trigger-触发器参考)
7. [示例代码](#示例代码)

---

## Focus Tree 结构

### 完整模板

```
focus_tree = {
    # === 树标识 ===
    id = polish_focus              # 树的唯一 ID
    
    # === 国家权重 ===
    country = {
        factor = 0                 # 基础权重（0 = 不使用）
        
        # 权重修正（满足条件时添加）
        modifier = {
            add = 10
            tag = POL
        }
        
        # 多国家共享示例
        modifier = {
            add = 10
            OR = {
                tag = POL
                tag = SLO
            }
        }
        
        # DLC 检查示例
        modifier = {
            add = 10
            tag = POL
            OR = {
                has_dlc = "No Step Back"
                has_dlc = "Poland: United and Ready"
            }
        }
    }
    
    # === 默认树标志 ===
    default = no                   # yes = 无专属树的国家使用此树
    
    # === 初始显示位置 ===
    initial_show_position = {
        x = 500
        y = 300
    }
    # 或使用焦点作为锚点：
    initial_show_position = {
        focus = POL_starting_focus
    }
    
    # === 连续焦点位置（可选）===
    continuous_focus_position = {
        x = 100
        y = 50
    }
    
    # === 引用共享焦点（可选）===
    shared_focus = {shared_focus_id}
    # 可引用多个：
    shared_focus = {shared_focus1}
    shared_focus = {shared_focus2}
    
    # === 焦点定义 ===
    focus = { ... }
    focus = { ... }
    joint_focus = { ... }
}
```

### Country 权重详解

```
country = {
    factor = 0                     # 基础权重
    
    modifier = {
        add = 10                    # 添加的权重值
        tag = POL                   # 国家标签
    }
    
    modifier = {
        add = 10
        original_tag = POL          # 使用原始标签（支持内战双方）
    }
    
    modifier = {
        factor = 5                  # 乘法修正
        has_dlc = "No Step Back"    # DLC 检查
    }
}
```

**权重逻辑**：
- 最终权重 = factor + 所有满足条件的 modifier.add
- 只有最高权重的树会被使用
- 如果权重相同，文件名 ASCII 码靠后的胜出

---

## Focus 节点

### 必需字段

```
focus = {
    id = POL_focus_id              # 唯一标识符（必填）
    icon = GFX_focus_POL_focus     # 图标（必填，可用现有 GFX）
    x = 2                          # 横坐标（必填）
    y = 0                          # 纵坐标（必填）
    cost = 10                      # 完成天数（必填，实际天数 = cost × 7）
}
```

### 定位方式

**方式1：绝对定位**
```
focus = {
    id = POL_focus_1
    icon = GFX_goal_generic_construction
    x = 2          # 树坐标系中的绝对位置
    y = 0
    cost = 5
}
```

**方式2：相对定位**
```
focus = {
    id = POL_focus_2
    icon = GFX_goal_generic_construction
    
    relative_position_id = POL_focus_1    # 锚点焦点
    
    x = 0              # 相对于锚点的偏移（-表示左，+表示右）
    y = 1              # 向下一行
    
    cost = 10
}
```

**相对定位规则**：
- `x` 负值 = 左侧，正值 = 右侧
- `y` 正值 = 下方（通常为正）
- 适用于需要平移整条分支的场景

### 前置条件 (Prerequisite)

**单一前置**：
```
prerequisite = { focus = POL_parent_focus }
```

**多重前置（AND 关系）**：
```
prerequisite = { 
    focus = POL_focus1 
    focus = POL_focus2 
}
```

**或关系（满足任一组）**：
```
prerequisite = { focus = POL_path_a }
prerequisite = { focus = POL_path_b }
```

**组合使用**：
```
# 需要 (A AND B) OR (C AND D)
prerequisite = { focus = POL_focus_a focus = POL_focus_b }
prerequisite = { focus = POL_focus_c focus = POL_focus_d }
```

### 互斥 (Mutually Exclusive)

```
focus = {
    id = POL_path_democratic
    
    mutually_exclusive = { 
        focus = POL_path_fascist 
        focus = POL_path_communist 
    }
}

focus = {
    id = POL_path_fascist
    
    mutually_exclusive = { 
        focus = POL_path_democratic 
        focus = POL_path_communist 
    }
}

focus = {
    id = POL_path_communist
    
    mutually_exclusive = { 
        focus = POL_path_democratic 
        focus = POL_path_fascist 
    }
}
```

**注意**：互斥需要双向声明，每个焦点都要列出其他互斥焦点。

### 可用条件 (Available)

```
available = {
    # 基础条件
    tag = POL
    
    # 时间条件
    date > 1936.1.1
    
    # 政治条件
    has_political_power > 50
    has_government = democracy
    fascism > 0.3
    
    # 稳定度/战争支持度
    has_stability > 0.5
    has_war_support > 0.3
    
    # 领土条件
    controls_state = 123
    owns_state = 123
    123 = { is_owned_by = ROOT }
    
    # 已完成焦点
    has_completed_focus = POL_other_focus
    
    # 已研究科技
    has_tech = infantry_equipment_1
    
    # 工厂数量
    num_of_owned_factories > 50
    
    # 国家标记
    has_country_flag = pol_flag_name
    
    # 全局标记
    has_global_flag = world_war_started
    
    # 意识形态支持度
    get_popularity = {
        ideology = fascism
        value > 0.3
    }
    
    # 或条件
    OR = {
        has_stability > 0.7
        has_war_support > 0.5
    }
    
    # 且条件
    AND = {
        controls_state = 123
        controls_state = 124
    }
    
    # 非条件
    NOT = {
        has_war_with = GER
    }
}
```

### 跳过条件 (Bypass)

```
bypass = {
    # 满足条件时自动完成焦点
    custom_trigger_tooltip = {
        tooltip = POL_focus_bypass_tt
        has_tech = infantry_equipment_1
    }
}

# 本地化
POL_focus_bypass_tt:0 "已研究步兵装备 I"
```

### 完成效果 (Completion Reward)

```
completion_reward = {
    # === 政治效果 ===
    add_political_power = 100
    add_stability = 0.05
    add_war_support = 0.05
    
    # === 意识形态 ===
    add_popularity = {
        ideology = fascism
        popularity = 0.10
    }
    
    set_politics = {
        ruling_party = fascism
        elections_allowed = no
    }
    
    # === 民族精神 ===
    add_ideas = POL_spirit_name
    remove_ideas = POL_old_spirit
    
    add_timed_idea = {
        idea = POL_temporary_boost
        days = 365
    }
    
    # === 建筑效果 ===
    random_owned_controlled_state = {
        prioritize = { 123 124 125 }
        limit = {
            free_building_slots = {
                building = industrial_complex
                size > 0
                include_locked = yes
            }
        }
        add_extra_state_shared_building_slots = 1
        add_building_construction = {
            type = industrial_complex
            level = 1
            instant_build = yes
        }
        set_state_flag = POL_state_developed
    }
    
    # === 资源效果 ===
    add_resource = {
        type = steel
        amount = 24
        state = 762
    }
    
    # === 铁路建设 ===
    build_railway = {
        path = { 9508 6558 3483 }
    }
    
    # === 科技效果 ===
    add_tech_bonus = {
        name = POL_tech_bonus
        bonus = 1.0         # 100% 研究速度
        uses = 1
        category = industry
    }
    
    add_research_slot = 1
    
    # === 军事效果 ===
    army_experience = 25
    navy_experience = 25
    air_experience = 25
    
    add_manpower = 50000
    
    # === 外交效果 ===
    GER = {
        add_opinion_modifier = {
            target = ROOT
            modifier = pol_german_cooperation
        }
    }
    
    create_guarantee = { target = CZE }
    
    create_wargoal = {
        type = annex_everything
        target = GER
    }
    
    # === 阵营效果 ===
    create_faction = POL_international_block
    
    add_to_faction = GER
    
    # === 领土效果 ===
    transfer_state = {
        state = 123
        target = GER
    }
    
    123 = {
        add_core_by = ROOT
        add_claim_by = ROOT
    }
    
    # === 事件效果 ===
    country_event = {
        id = poland_events.1
        days = 7
        random_days = 3
    }
    
    news_event = {
        id = news.poland_war
        days = 1
    }
    
    # === 标记效果 ===
    set_country_flag = pol_focus_done
    
    set_country_flag = {
        flag = pol_focus_variant
        days = 365         # 过期天数（可选）
        value = 1          # 标记值（可选，用于变量）
    }
    
    set_global_flag = world_event_happened
    
    # === 变量效果 ===
    set_variable = {
        var = POL_economy_var
        value = 10
    }
    
    add_to_variable = {
        var = POL_economy_var
        value = 5
    }
    
    # === 条件效果 ===
    if = {
        limit = {
            has_government = fascism
        }
        add_political_power = 150
    }
    else = {
        add_political_power = 50
    }
    
    # === 循环效果 ===
    every_owned_state = {
        limit = {
            is_core_of = ROOT
            free_building_slots = {
                building = infrastructure
                size > 2
            }
        }
        add_building_construction = {
            type = infrastructure
            level = 1
            instant_build = yes
        }
    }
    
    # === 隐藏效果 ===
    hidden_effect = {
        set_country_flag = pol_hidden_flag
    }
    
    # === 自定义提示 ===
    custom_effect_tooltip = POL_focus_custom_tt
}
```

### 行为标志

```
focus = {
    id = POL_focus_name
    
    # 投降后仍可用
    available_if_capitulated = yes
    
    # 可取消（默认 no）
    cancelable = yes
    
    # 条件失效时取消
    cancel_if_invalid = yes
    
    # 条件失效时暂停但保留进度
    continue_if_invalid = yes
    
    # 即使与其他焦点效果冲突也允许
    will_lead_to_war_with = GER
    
    # ...
}
```

### Search Filters

```
search_filters = { 
    FOCUS_FILTER_POLITICAL 
    FOCUS_FILTER_STABILITY 
}

# 可用过滤器：
FOCUS_FILTER_POLITICAL      # 政治
FOCUS_FILTER_INDUSTRY       # 工业
FOCUS_FILTER_RESEARCH       # 研究
FOCUS_FILTER_STABILITY      # 稳定度
FOCUS_FILTER_WAR_SUPPORT    # 战争支持度
FOCUS_FILTER_MANPOWER       # 人力
FOCUS_FILTER_ANNEXATION     # 吞并
FOCUS_FILTER_HISTORICAL     # 历史路线
FOCUS_FILTER_INNER_CIRCLE   # 德国内圈
```

### AI 权重

```
ai_will_do = {
    factor = 10           # 基础权重
    
    modifier = {
        add = 5           # 权重加成
        has_war_with = GER
    }
    
    modifier = {
        factor = 0         # 权重归零（永不选择）
        has_stability < 0.3
    }
    
    modifier = {
        factor = 2        # 权重翻倍
        has_government = fascism
    }
}
```

---

## Joint Focus 联合焦点

联合焦点用于阵营共享机制，阵营领袖发起，成员同时完成。

### 完整模板

```
joint_focus = {
    id = HAB_joint_economy
    icon = GFX_focus_generic_economy
    x = 5
    y = 3
    cost = 10
    
    # === 前置条件 ===
    prerequisite = { focus = HAB_economic_base }
    
    # === 发起者触发条件 ===
    joint_trigger = {
        is_faction_leader = yes
        num_faction_members > 1
        has_dlc = "No Step Back"
    }
    
    # === 成员触发条件 ===
    member_trigger = {
        is_faction_member = yes
        NOT = { is_faction_leader = yes }
    }
    
    # === 发起者完成效果 ===
    completion_reward_joint_originator = {
        add_political_power = 100
        
        every_faction_member = {
            limit = { NOT = { is_faction_leader = yes } }
            add_political_power = 50
        }
        
        add_named_threat = { threat = 2 name = HAB_expansionism }
    }
    
    # === 成员完成效果 ===
    completion_reward_joint_member = {
        add_political_power = 50
    }
    
    # === 可用条件（双方都要满足）===
    available = {
        is_in_faction = yes
    }
    
    # === AI 权重 ===
    ai_will_do = {
        factor = 10
    }
}
```

---

## Shared Focus 共享焦点

共享焦点定义在单独文件中，可被多个焦点树引用。

### 定义共享焦点

```
# 文件: common/national_focus/shared_focuses.txt

shared_focus = {
    id = baltic_industrial_base
    
    icon = GFX_goal_generic_construction
    x = 0
    y = 0
    cost = 5
    
    # 与普通焦点相同的所有字段
    completion_reward = {
        random_owned_controlled_state = {
            add_building_construction = {
                type = industrial_complex
                level = 1
                instant_build = yes
            }
        }
    }
}
```

### 引用共享焦点

```
focus_tree = {
    id = estonian_focus
    
    country = {
        factor = 0
        modifier = {
            add = 10
            tag = EST
        }
    }
    
    # 引用共享焦点
    shared_focus = baltic_industrial_base
    
    # 本土焦点
    focus = {
        id = EST_local_focus
        prerequisite = { focus = baltic_industrial_base }
        # ...
    }
}
```

---

## Effect 效果参考

### 政治效果

| Effect | 说明 | 示例 |
|--------|------|------|
| `add_political_power` | 政治点数 | `100` |
| `add_stability` | 稳定度 | `0.05` (5%) |
| `add_war_support` | 战争支持度 | `0.05` |
| `add_popularity` | 意识形态支持度 | `{ ideology = fascism popularity = 0.10 }` |
| `set_politics` | 设置政体 | `{ ruling_party = fascism elections_allowed = no }` |

### 工业效果

| Effect | 说明 | 示例 |
|--------|------|------|
| `add_building_construction` | 建造建筑 | `{ type = industrial_complex level = 1 instant_build = yes }` |
| `add_resource` | 添加资源 | `{ type = steel amount = 24 state = 762 }` |
| `add_extra_state_shared_building_slots` | 增加建筑槽 | `1` |
| `build_railway` | 建铁路 | `{ path = { 9508 6558 } }` |

### 科技效果

| Effect | 说明 | 示例 |
|--------|------|------|
| `add_tech_bonus` | 科技加成 | `{ name = bonus bonus = 1.0 uses = 1 category = industry }` |
| `add_research_slot` | 研究槽位 | `1` |
| `set_technology` | 解锁科技 | `{ infantry_equipment_1 = 1 }` |

### 军事效果

| Effect | 说明 | 示例 |
|--------|------|------|
| `army_experience` | 陆军经验 | `25` |
| `navy_experience` | 海军经验 | `25` |
| `air_experience` | 空军经验 | `25` |
| `add_manpower` | 人力 | `50000` |
| `add_ideas` | 添加精神 | `POL_spirit_name` |

---

## Trigger 触发器参考

### 国家触发器

| Trigger | 说明 | 示例 |
|---------|------|------|
| `tag` | 国家标签 | `POL` |
| `original_tag` | 原始标签 | `POL` |
| `has_political_power` | 政治点数 | `> 50` |
| `has_stability` | 稳定度 | `> 0.5` |
| `has_war_support` | 战争支持度 | `> 0.3` |
| `has_government` | 意识形态 | `fascism` |
| `has_completed_focus` | 已完成焦点 | `POL_focus_name` |
| `has_tech` | 已研究科技 | `infantry_equipment_1` |
| `num_of_owned_factories` | 工厂数量 | `> 50` |
| `has_country_flag` | 国家标记 | `pol_flag_name` |
| `has_global_flag` | 全局标记 | `world_war_started` |

### 领土触发器

| Trigger | 说明 | 示例 |
|---------|------|------|
| `controls_state` | 控制省份 | `123` |
| `owns_state` | 拥有省份 | `123` |
| `is_owned_by` | 所有者 | `POL` (在省份范围内) |
| `is_on_continent` | 大洲 | `europe` |

---

## 示例代码

### 波兰历史国策树示例

```
focus_tree = {
    id = polish_historical_focus
    
    country = {
        factor = 0
        modifier = {
            add = 10
            tag = POL
        }
    }
    
    default = no
    
    # === 政治分支 ===
    focus = {
        id = POL_seize_control_of_the_state
        icon = GFX_focus_generic_political_pressure
        x = 0
        y = 0
        cost = 5
        
        search_filters = { FOCUS_FILTER_POLITICAL }
        
        completion_reward = {
            add_political_power = 50
            add_stability = 0.05
        }
    }
    
    focus = {
        id = POL_authoritarian_consolidation
        prerequisite = { focus = POL_seize_control_of_the_state }
        icon = GFX_focus_generic_authoritarian_regime
        x = -1
        y = 1
        relative_position_id = POL_seize_control_of_the_state
        cost = 10
        
        mutually_exclusive = { focus = POL_democratic_reform }
        
        available = {
            has_government = neutrality
        }
        
        completion_reward = {
            add_political_power = 100
            add_ideas = POL_authoritarian_regime
        }
    }
    
    focus = {
        id = POL_democratic_reform
        prerequisite = { focus = POL_seize_control_of_the_state }
        icon = GFX_goal_support_democracy
        x = 1
        y = 1
        relative_position_id = POL_seize_control_of_the_state
        cost = 10
        
        mutually_exclusive = { focus = POL_authoritarian_consolidation }
        
        available = {
            NOT = { has_government = fascism }
            NOT = { has_government = communism }
        }
        
        completion_reward = {
            add_stability = 0.10
            add_popularity = {
                ideology = democratic
                popularity = 0.15
            }
            add_ideas = POL_democratic_spirit
        }
    }
    
    # === 工业分支 ===
    focus = {
        id = POL_four_year_plan
        icon = GFX_focus_POL_four_year_plan
        x = 3
        y = 0
        cost = 5
        
        search_filters = { FOCUS_FILTER_INDUSTRY FOCUS_FILTER_RESEARCH }
        
        completion_reward = {
            add_tech_bonus = {
                name = POL_four_year_plan
                bonus = 1.0
                uses = 1
                category = construction_tech
            }
            add_timed_idea = {
                idea = POL_four_year_plan_idea
                days = 1460
            }
        }
    }
    
    focus = {
        id = POL_industrial_expansion
        prerequisite = { focus = POL_four_year_plan }
        icon = GFX_goal_generic_construct_civ_factory
        x = 3
        y = 1
        relative_position_id = POL_four_year_plan
        cost = 10
        
        search_filters = { FOCUS_FILTER_INDUSTRY }
        
        completion_reward = {
            random_owned_controlled_state = {
                prioritize = { 86 87 88 89 90 91 92 807 }
                limit = {
                    free_building_slots = {
                        building = industrial_complex
                        size > 0
                        include_locked = yes
                    }
                }
                add_extra_state_shared_building_slots = 1
                add_building_construction = {
                    type = industrial_complex
                    level = 1
                    instant_build = yes
                }
            }
        }
    }
}
```

---

**最后更新**: 2026-04-24


path: references/ideas_syntax.md
content: # HOI4 Ideas 完整语法参考

## 目录

1. [文件结构](#文件结构)
2. [Idea 类型](#idea-类型)
3. [国家精神 (country)](#国家精神-country)
4. [军事精神](#军事精神)
5. [顾问系统](#顾问系统)
6. [设计商系统](#设计商系统)
7. [常用 Modifier 速查表](#常用-modifier-速查表)
8. [示例代码](#示例代码)

---

## 文件结构

```
common/ideas/{filename}.txt

ideas = {
    country = { ... }
    army = { ... }
    navy = { ... }
    air = { ... }
    political_advisor = { ... }
    theorist = { ... }
    chief_of_staff = { ... }
    army_chief = { ... }
    navy_chief = { ... }
    air_chief = { ... }
}
```

---

## Idea 类型

| 类型 | 槽位 | 说明 |
|------|------|------|
| `country` | 无限制 | 国家精神，可同时拥有多个 |
| `army` | 1个 | 陆军精神（需DLC） |
| `navy` | 1个 | 海军精神（需DLC） |
| `air` | 1个 | 空军精神（需DLC） |
| `political_advisor` | 1个 | 政治顾问 |
| `theorist` | 1个 | 理论家 |
| `chief_of_staff` | 1个 | 参谋长 |
| `army_chief` | 1个 | 陆军首脑 |
| `navy_chief` | 1个 | 海军首脑 |
| `air_chief` | 1个 | 空军首脑 |

---

## 国家精神 (country)

### 基础模板

```
{TAG}_{idea_name} = {
    # 可用性限制
    allowed = {
        original_tag = {TAG}
        always = no          # 防止其他国家获取
    }
    
    # 内战时的处理
    allowed_civil_war = {
        always = no          # 内战双方都不继承
    }
    
    # 移除花费（-1 = 不可移除）
    removal_cost = -1
    
    # 图标（使用现有GFX或自定义）
    picture = generic_political_reform
    
    # 效果修正
    modifier = {
        political_power_gain = 0.10
        stability_factor = 0.05
        consumer_goods_factor = 0.05
    }
    
    # 对特定国家的修正
    targeted_modifier = {
        tag = GER
        attack_bonus_against = 0.10
        defense_bonus_against = 0.05
    }
}
```

### allowed 字段详解

```
allowed = {
    # 原始国家标签
    original_tag = POL
    
    # 多国家共享
    OR = {
        original_tag = POL
        original_tag = RSI
        original_tag = RDS
    }
    
    # 条件限制
    has_government = fascism
    is_subject = no
}
```

### removal_cost

```
removal_cost = -1      # 不可移除（永久精神）
removal_cost = 0       # 免费移除
removal_cost = 50      # 需要50政治点数移除
removal_cost = 150     # 需要150政治点数移除
```

### name 字段（引用其他idea名称）

```
# 使用其他idea的名称和描述
POL_economic_crisis_v2 = {
    name = POL_economic_crisis    # 引用 POL_economic_crisis 的名称/描述
    
    allowed = { original_tag = POL }
    
    modifier = {
        consumer_goods_factor = 0.20
        production_speed_buildings_factor = -0.20
    }
}
```

---

## 军事精神

### 陆军精神模板

```
army = {
    {TAG}_army_spirit = {
        allowed = {
            original_tag = {TAG}
        }
        
        picture = generic_army
        
        # 允许移除和更换
        removal_cost = 100
        
        modifier = {
            army_org_factor = 0.05
            army_morale_factor = 0.05
            land_terrain_attack = 0.05
            land_terrain_defense = 0.05
        }
        
        # 对特定国家加成
        targeted_modifier = {
            tag = SOV
            attack_bonus_against = 0.10
        }
    }
}
```

### 海军精神模板

```
navy = {
    {TAG}_navy_spirit = {
        allowed = { original_tag = {TAG} }
        
        picture = generic_navy
        
        modifier = {
            naval_hit_chance_factor = 0.05
            naval_speed_factor = 0.05
            screening_efficiency_factor = 0.05
            mine_laying_efficiency_factor = 0.10
            mine_effectiveness_factor = 0.10
        }
    }
}
```

### 空军精神模板

```
air = {
    {TAG}_air_spirit = {
        allowed = { original_tag = {TAG} }
        
        picture = generic_air
        
        modifier = {
            air_mission_efficiency_factor = 0.05
            air_ace_generation_chance_factor = 0.10
            fighter_air_attack_factor = 0.05
            fighter_air_defence_factor = 0.05
        }
    }
}
```

---

## 顾问系统

### 政治顾问模板

```
political_advisor = {
    {TAG}_{advisor_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{advisor_name}
        
        # 可选：意识形态倾向
        fascist = yes              # 增加法西斯支持度
        # communist = yes
        # democratic = yes
        # neutrality = yes
        
        modifier = {
            fascism_drift = 0.10
            # communism_drift = 0.10
            # democratic_drift = 0.10
            # neutrality_drift = 0.10
            
            # 或稳定度加成
            stability_weekly = 0.10
            war_support_weekly = 0.05
            
            # 或派系加成
            passive_faction_political_cost = -0.15
        }
    }
}
```

### 理论家模板

```
theorist = {
    {TAG}_{theorist_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{theorist_name}
        
        modifier = {
            army_experience_gain_factor = 0.05
            # navy_experience_gain_factor = 0.05
            # air_experience_gain_factor = 0.05
            
            # 或研究加成
            land_doctrine_research_speed = 0.10
            # naval_doctrine_research_speed = 0.10
            # air_doctrine_research_speed = 0.10
        }
    }
}
```

### 参谋长模板

```
chief_of_staff = {
    {TAG}_cos_name = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        modifier = {
            command_capacity = 0.10        # 指挥容量
            staff_planning_max = 0.10      # 参谋计划
            supply_grace = 0.10            # 补给储备
        }
    }
}
```

### 军队首脑模板

```
army_chief = {
    {TAG}_army_chief_name = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        modifier = {
            army_attack_factor = 0.05
            army_defence_factor = 0.05
            army_org_factor = 0.05
            land_terrain_attack = 0.05
            
            # 或特定地形
            land_terrain_plains_attack = 0.10
            land_terrain_forest_attack = 0.10
            land_terrain_hills_attack = 0.10
            land_terrain_mountain_attack = 0.10
            land_terrain_urban_attack = 0.10
        }
    }
}

navy_chief = {
    {TAG}_navy_chief_name = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        modifier = {
            naval_attack_factor = 0.05
            naval_defence_factor = 0.05
            carrier_capacity_factor = 0.10
            naval_speed_factor = 0.05
        }
    }
}

air_chief = {
    {TAG}_air_chief_name = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        modifier = {
            air_attack_factor = 0.05
            air_defence_factor = 0.05
            carrier_traffic_efficiency_factor = 0.10
            air_mission_efficiency_factor = 0.05
        }
    }
}
```

---

## 设计商系统

### 坦克设计商

```
tank_manufacturer = {
    {TAG}_{manufacturer_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        removal_cost = 200           # 设计商更换成本较高
        
        modifier = {
            # 正面效果
            tank_reliability_factor = 0.15
            tank_armor_factor = 0.10
            tank_max_speed_factor = 0.05
            
            # 研究加成
            tank_research_speed_factor = 0.10
            
            # 负面效果（可选）
            tank_build_cost_factor = 0.05
        }
    }
}
```

### 船舶设计商

```
ship_manufacturer = {
    {TAG}_{manufacturer_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        removal_cost = 200
        
        modifier = {
            # 船体特性
            ship_reliability_factor = 0.10
            ship_max_speed_factor = 0.05
            ship_anti_air_factor = 0.10
            
            # 研究加成
            naval_research_speed_factor = 0.10
        }
    }
}
```

### 飞机设计商

```
aircraft_manufacturer = {
    {TAG}_{manufacturer_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        removal_cost = 200
        
        modifier = {
            # 飞机特性
            fighter_air_attack_factor = 0.10
            fighter_air_defence_factor = 0.05
            
            # 或轰炸机
            bomber_air_attack_factor = 0.10
            
            # 研究加成
            air_research_speed_factor = 0.10
        }
    }
}
```

### 工业设计商

```
industrial_concern = {
    {TAG}_{industrial_name} = {
        allowed = { original_tag = {TAG} }
        
        picture = GFX_{name}
        
        removal_cost = 150
        
        modifier = {
            # 工业研究
            industrial_research_speed = 0.10
            
            # 生产速度
            production_speed_industrial_complex_factor = 0.05
            production_speed_arms_factory_factor = 0.05
            
            # 或资源开采
            oil_factor = 0.10
            steel_factor = 0.10
            aluminum_factor = 0.10
        }
    }
}
```

---

## 常用 Modifier 速查表

### 政治类

| Modifier | 说明 | 范围 |
|----------|------|------|
| `political_power_gain` | 政治点数增益 | 0.1 = +10% |
| `stability_factor` | 稳定度加成 | 0.05 = +5% |
| `war_support_factor` | 战争支持度 | 0.05 = +5% |
| `consumer_goods_factor` | 消费品比例 | 0.05 = +5% |
| `fascism_drift` | 法西斯倾向 | 0.1 = 每日+0.1% |
| `communism_drift` | 共产主义倾向 | 同上 |
| `democratic_drift` | 民主倾向 | 同上 |
| `neutrality_drift` | 中立倾向 | 同上 |

### 工业类

| Modifier | 说明 |
|----------|------|
| `production_speed_buildings_factor` | 建筑速度 |
| `production_speed_industrial_complex_factor` | 民用工厂速度 |
| `production_speed_arms_factory_factor` | 军用工厂速度 |
| `industrial_capacity_factory` | 工厂产出 |
| `industrial_speed_factory` | 工厂效率 |
| `research_speed_factor` | 研究速度 |

### 陆军类

| Modifier | 说明 |
|----------|------|
| `army_org_factor` | 组织度 |
| `army_morale_factor` | 士气（恢复） |
| `army_attack_factor` | 攻击 |
| `army_defence_factor` | 防御 |
| `land_terrain_attack` | 地形攻击（所有） |
| `land_terrain_plains_attack` | 平原攻击 |
| `land_terrain_forest_attack` | 森林攻击 |
| `land_terrain_hills_attack` | 丘陵攻击 |
| `land_terrain_mountain_attack` | 山地攻击 |
| `land_terrain_urban_attack` | 城市攻击 |
| `attack_bonus_against` | 对特定国家攻击 |

### 海军类

| Modifier | 说明 |
|----------|------|
| `naval_hit_chance_factor` | 命中率 |
| `naval_speed_factor` | 速度 |
| `naval_attack_factor` | 攻击 |
| `naval_defence_factor` | 防御 |
| `screening_efficiency_factor` | 屏蔽效率 |
| `carrier_traffic_efficiency_factor` | 航母甲板效率 |
| `mine_laying_efficiency_factor` | 布雷效率 |
| `submarine_visibility_factor` | 潜艇可见度 |

### 空军类

| Modifier | 说明 |
|----------|------|
| `air_mission_efficiency_factor` | 任务效率 |
| `air_ace_generation_chance_factor` | 王牌生成 |
| `fighter_air_attack_factor` | 战斗机攻击 |
| `fighter_air_defence_factor` | 战斗机防御 |
| `bomber_air_attack_factor` | 轰炸机攻击 |

---

## 示例代码

### 完整国家精神示例

```
ideas = {
    country = {
        POL_sanacja_regime = {
            allowed = {
                original_tag = POL
                always = no
            }
            
            allowed_civil_war = {
                always = no
            }
            
            removal_cost = -1
            
            picture = generic_authoritarian_regime
            
            modifier = {
                political_power_gain = 0.10
                stability_factor = 0.05
                war_support_factor = 0.05
                
                # 负面效果
                democratic_drift = -0.05
                communism_drift = -0.05
                
                # 军事相关
                army_org_factor = 0.05
            }
            
            targeted_modifier = {
                tag = GER
                defense_bonus_against = 0.10
            }
        }
    }
}
```

### 完整顾问示例

```
ideas = {
    political_advisor = {
        POL_edward_smigly = {
            allowed = {
                original_tag = POL
            }
            
            picture = GFX_POL_edward_smigly
            
            neutrality = yes
            
            modifier = {
                neutrality_drift = 0.10
                stability_weekly = 0.10
                passive_faction_political_cost = -0.15
            }
        }
    }
}
```

### 完整设计商示例

```
ideas = {
    tank_manufacturer = {
        POL_PZInz = {
            allowed = {
                original_tag = POL
            }
            
            picture = GFX_POL_PZInz
            
            removal_cost = 200
            
            modifier = {
                tank_reliability_factor = 0.15
                tank_armor_factor = 0.10
                tank_max_speed_factor = 0.05
                tank_research_speed_factor = 0.10
                
                # 成本增加
                tank_build_cost_factor = 0.05
            }
        }
    }
}
```


path: references/localisation_guide.md
content: # HOI4 本地化完整指南

## 目录

1. [文件结构](#文件结构)
2. [YML 格式规范](#yml-格式规范)
3. [语言代码](#语言代码)
4. [文本格式标记](#文本格式标记)
5. [变量引用](#变量引用)
6. [本地化类型](#本地化类型)
7. [最佳实践](#最佳实践)

---

## 文件结构

```
localisation/
├── english/
│   ├── focus_l_english.yml          # 焦点名称
│   ├── ideas_l_english.yml          # 民族精神
│   ├── events_l_english.yml         # 事件文本
│   ├── decisions_l_english.yml      # 决议名称
│   └── {mod}_l_english.yml          # mod专用
│
├── simp_chinese/
│   ├── focus_l_simp_chinese.yml
│   ├── ideas_l_simp_chinese.yml
│   └── {mod}_l_simp_chinese.yml
│
└── {language}/
    └── {mod}_l_{language}.yml
```

---

## YML 格式规范

### 基础格式

```yaml
l_english:
 key_name:0 "Display Text"
 key_name_desc:0 "Description text goes here..."
```

### 格式要点

1. **冒号后必须有空格**：
   ```yaml
   # 正确
   focus_id:0 "Focus Name"
   
   # 错误
   focus_id:0"Focus Name"
   focus_id:0"Focus Name"
   ```

2. **版本号**：`0` 是标准版本号，也可以使用 `1`、`2` 等
   
3. **引号**：文本必须用双引号包裹

4. **换行**：每个条目独占一行

---

## 语言代码

| 代码 | 语言 | 文件后缀 |
|------|------|----------|
| `l_english` | 英语 | `_l_english.yml` |
| `l_simp_chinese` | 简体中文 | `_l_simp_chinese.yml` |
| `l_french` | 法语 | `_l_french.yml` |
| `l_german` | 德语 | `_l_german.yml` |
| `l_spanish` | 西班牙语 | `_l_spanish.yml` |
| `l_japanese` | 日语 | `_l_japanese.yml` |
| `l_korean` | 韩语 | `_l_korean.yml` |
| `l_polish` | 波兰语 | `_l_polish.yml` |
| `l_russian` | 俄语 | `_l_russian.yml` |
| `l_braz_por` | 巴西葡语 | `_l_braz_por.yml` |

---

## 文本格式标记

### 颜色代码

```yaml
# 红、绿、蓝、黄、白、高亮、灰色、橙色、青色
red_text:0 "§R这是红色文本§!"
green_text:0 "§G这是绿色文本§!"
blue_text:0 "§B这是蓝色文本§!"
yellow_text:0 "§Y这是黄色文本§!"
white_text:0 "§W这是白色文本§!"
highlight:0 "§H这是高亮文本§!"
gray_text:0 "§g这是灰色文本§!"
orange_text:0 "§O这是橙色文本§!"
cyan_text:0 "§C这是青色文本§!"
```

### 常用颜色用途

| 颜色 | 代码 | 用途 |
|------|------|------|
| §G绿色 | §G | 正面效果、增益 |
| §R红色 | §R | 负面效果、惩罚 |
| §Y黄色 | §Y | 数值、重要信息 |
| §H高亮 | §H | 标题、关键词 |
| §B蓝色 | §B | 友方国家 |

### 文本样式

```yaml
# 换行
multiline_text:0 "第一行\n第二行\n第三行"

# 图标（使用效果图标）
with_icon:0 "获得 §Y+5%§! 稳定度\n£stability_texticon"

# Tab缩进（不常用）
tabbed_text:0 "标题:\t内容"
```

### 常用图标代码

```yaml
# 资源图标
£oil        # 石油
£aluminum   # 铝
£rubber     # 橡胶
£tungsten   # 钨
£steel      # 钢铁
£chromium   # 铬

# 政治图标
£pol_power  # 政治点数
£stability  # 稳定度
£war_support # 战争支持度

# 军事图标
£command_power # 指挥点数
£manpower   # 人力
£army_experience # 陆军经验
£navy_experience # 海军经验
£air_experience  # 空军经验

# 建筑图标
£civilian_factory  # 民用工厂
£military_factory  # 军用工厂
£infrastructure    # 基础设施
£air_base          # 空军基地
£naval_base        # 海军基地
```

---

## 变量引用

### 基础变量

```yaml
# 数字变量
gain_pp:0 "获得 §Y$VALUE$§! 政治点数"

# 国家名称
nation_name:0 "[Root.GetName] 完成了改革"

# 特定国家名
other_nation:0 "[GER.GetName] 对我们提出了要求"

# 领导人名称
leader_name:0 "[Root.GetLeader] 发表了演讲"
```

### 在代码中使用

```
# 效果中使用变量
custom_effect_tooltip = {
    text = gain_pp_tt
    add_political_power = var:gain_amount
}
```

```yaml
# 本地化变量
gain_pp_tt:0 "获得 §Y$VALUE$§! 政治点数"
```

### 复杂变量示例

```yaml
# 多变量文本
complex_text:0 "[Root.GetName] 将 §Y$AMOUNT$§! 个师部署到 $STATE$"

# 百分比显示
percentage_text:0 "稳定度: §G$PERCENT|%.1f$§!"
```

---

## 本地化类型

### 焦点 (Focus)

```yaml
l_english:
 # 焦点名称
 POL_seize_control_of_the_state:0 "掌控国家权力"
 
 # 焦点描述
 POL_seize_control_of_the_state_desc:0 "萨纳奇亚政权必须巩固其对国家各部门的控制..."
```

### 民族精神 (Ideas)

```yaml
l_english:
 # 精神名称
 POL_sanacja_regime:0 "萨纳奇亚政权"
 
 # 精神描述
 POL_sanacja_regime_desc:0 "皮尔斯基执政以来的威权统治..."
```

### 事件 (Events)

```yaml
l_english:
 # 事件标题
 poland_crisis.1_title:0 "但泽危机"
 
 # 事件描述
 poland_crisis.1_desc:0 "德国向我们提出了但泽归属问题..."
 
 # 选项文本
 poland_crisis.1_option_a:0 "拒绝他们的要求"
 poland_crisis.1_option_b:0 "接受他们的条件"
```

### 决议 (Decisions)

```yaml
l_english:
 # 决议名称
 POL_danzig_ultimatum:0 "但泽最后通牒"
 
 # 决议描述
 POL_danzig_ultimatum_desc:0 "向波兰发出最后通牒..."
```

### 修正值 (Modifiers)

```yaml
l_english:
 # 修正值名称
 POL_german_cooperation:0 "德波合作"
 
 # 修正值描述（可选）
 POL_german_cooperation_desc:0 "与德国建立了合作关系"
```

### 工具提示 (Tooltips)

```yaml
l_english:
 # 自定义提示
 POL_september_war_tt:0 "§H九月战役§!\n§Y德国将对波兰宣战§!"
```

---

## 最佳实践

### 1. 文件组织

```yaml
# 按功能分文件
focus_l_english.yml      # 焦点
ideas_l_english.yml      # 民族精神
events_l_english.yml     # 事件
decisions_l_english.yml  # 决议
```

### 2. 命名规范

```yaml
# 使用一致的命名前缀
POL_historical_focus      # 国家前缀
poland_crisis.1_title    # 事件命名空间.编号_类型
POL_german_cooperation   # modifier用国家前缀
```

### 3. 描述文本结构

```yaml
# 焦点描述通常包含：
# 1. 历史背景
# 2. 游戏效果说明
# 3. 后续影响提示
POL_seize_control_of_the_state_desc:0 "皮尔斯基执政以来的威权统治必须得到巩固。\n\n§H效果:§!\n§G+10%§! 政治点数增益\n§G+5%§! 稳定度\n§R+5%§! 消费品需求"
```

### 4. 中文本地化要点

```yaml
l_simp_chinese:
 # 使用中文标点
 focus_name:0 "掌控国家"
 
 # 避免全角字母数字
 bad_example:0 "获得１００点数"    # 错误
 good_example:0 "获得100点数"     # 正确
 
 # 保持术语一致性
 # stable → 稳定度
 # war_support → 战争支持度
 # political_power → 政治点数
 # consumer_goods → 消费品
```

### 5. 条件文本

```yaml
# 使用[Scope]处理条件性文本
# 注意：复杂条件文本通常在代码中处理
dynamic_text:0 "[Root.GetName]的改革"
```

---

## 完整示例文件

### focus_l_english.yml

```yaml
l_english:
 # 波兰焦点树
 POL_seize_control_of_the_state:0 "掌控国家权力"
 POL_seize_control_of_the_state_desc:0 "萨纳奇亚政权必须巩固其对国家各部门的控制，确保政权的稳定性。\n\n§H效果:§!\n§G+10%§! 政治点数增益\n§G+5%§! 稳定度\n我们可以创建阵营"
 
 POL_four_year_economic_plan:0 "四年经济计划"
 POL_four_year_economic_plan_desc:0 "实施全面的工业化计划，加强波兰的经济实力。\n\n§H效果:§!\n获得 §Y四年计划§! 民族精神\n§G+1§! 民用工厂"
```

### focus_l_simp_chinese.yml

```yaml
l_simp_chinese:
 # 波兰焦点树
 POL_seize_control_of_the_state:0 "掌控国家权力"
 POL_seize_control_of_the_state_desc:0 "萨纳奇亚政权必须巩固其对国家各部门的控制，确保政权的稳定性。\n\n§H效果:§!\n§G+10%§! 政治点数增益\n§G+5%§! 稳定度\n我们可以创建阵营"
 
 POL_four_year_economic_plan:0 "四年经济计划"
 POL_four_year_economic_plan_desc:0 "实施全面的工业化计划，加强波兰的经济实力。\n\n§H效果:§!\n获得 §Y四年计划§! 民族精神\n§G+1§! 民用工厂"
```

---

## 常见问题

### Q: 修改后不生效？

1. 检查文件编码（必须是 UTF-8 with BOM）
2. 检查冒号后空格
3. 检查引号闭合
4. 重启游戏

### Q: 如何查看已有的key？

- 英文：`localisation/english/`
- 使用文本搜索工具查找key

### Q: 如何处理特殊字符？

```yaml
# 使用转义或避免特殊字符
# YAML支持的转义字符
escape_example:0 "引号: \" 换行: \n"
```


path: references/quick_reference.md
content: # HOI4 Modding 快速参考卡片

> 最常用的语法和参数，一页速查。

---

## 🎯 国策树核心字段

### Focus Tree 必需字段
```hoi4
focus_tree = {
    id = {tag}_focus                    # 树ID
    country = { factor = 0; modifier = { add = 10 tag = {TAG} } }
    default = no                       # 是否通用树
}
```

### Focus 节点必需字段
```hoi4
focus = {
    id = {TAG}_focus_name              # 唯一ID
    icon = GFX_focus_generic           # 图标
    x = 0                              # 横坐标
    y = 0                              # 纵坐标
    cost = 10                          # 天数成本
}
```

### 常用可选字段
```hoi4
# 前置条件
prerequisite = { focus = {parent_id} }

# 互斥焦点
mutually_exclusive = { focus = {other_id} }

# 可用条件
available = { tag = {TAG} has_stability > 0.5 }

# 完成效果
completion_reward = { add_political_power = 100 }

# 相对定位
relative_position_id = {parent_id}
x = -1  y = 1                         # 左下

# 内圈焦点
inner_circle = yes

# 连续焦点
continuous = yes
```

---

## 💡 Ideas 核心字段

### 国家精神
```hoi4
ideas = {
    country = {
        {TAG}_spirit_name = {
            modifier = {
                political_power_gain = 0.10
                stability_factor = 0.05
            }
            removal_cost = -1          # 永久
        }
    }
}
```

### 顾问
```hoi4
political_advisor = {
    {TAG}_advisor_name = {
        picture = GFX_idea_generic
        cost = 150
        modifier = { neutrality_drift = 0.10 }
        trait = { inspiring_figure }
    }
}
```

---

## 🎲 Events 核心字段

### 国家事件
```hoi4
add_namespace = {tag}_events

country_event = {
    id = {tag}_events.1
    title = {tag}_events.1_title
    desc = {tag}_events.1_desc
    
    is_triggered_only = yes
    
    option = {
        name = {tag}_events.1_option_a
        add_political_power = 50
    }
}
```

### 常用触发器
```hoi4
tag = {TAG}                           # 国家标签
has_stability > 0.5                   # 稳定度
has_war_support > 0.3                 # 战争支持度
has_political_power > 50             # 政治点数
has_government = fascism              # 意识形态
controls_state = 123                  # 控制省份
has_completed_focus = {id}           # 完成焦点
has_country_flag = {flag}            # 国家标记
date > 1936.1.1                      # 日期条件
```

---

## 📝 Localisation 格式

### YML 文件格式
```yaml
l_english:
 {id}:0 "Display Name"
 {id}_desc:0 "Description text..."

l_simp_chinese:
 {id}:0 "显示名称"
 {id}_desc:0 "描述文本..."
```

### 常用颜色代码
```yaml
§R 红色 §!          §G 绿色 §!
§B 蓝色 §!          §Y 黄色 §!
§H 高亮 §!          §! 结束颜色
```

### 常用图标
```yaml
£pol_power 政治点数    £stability 稳定度
£manpower 人力         £civilian_factory 民工
£military_factory 军工 £research_research 科技
```

---

## 🔧 常用效果

### 政治效果
```hoi4
add_political_power = 100
add_stability = 0.05
add_war_support = 0.05
set_politics = { ruling_party = fascism }
```

### 军事效果
```hoi4
army_experience = 25
add_manpower = 50000
create_wargoal = { type = annex_everything target = GER }
```

### 经济效果
```hoi4
add_tech_bonus = { name = bonus_id bonus = 1.0 uses = 1 }
add_resource = { type = steel amount = 24 state = 762 }
```

### 民族精神
```hoi4
add_ideas = {spirit_id}
remove_ideas = {spirit_id}
add_timed_idea = { idea = {id} days = 365 }
```

### 标记操作
```hoi4
set_country_flag = {flag_name}
clr_country_flag = {flag_name}
set_global_flag = {flag_name}
```

---

## 🎨 布局速查

### 推荐间距
| 场景 | x间距 | y间距 |
|------|-------|-------|
| 单分支 | ±1 | +1 |
| 多分支 | ±2 | +1 |
| 互斥链 | ±1 | +1 |
| 复杂树 | ±3~4 | +2 |

### 坐标规则
- ✅ y值必须递增（子节点 > 父节点）
- ✅ x值可正可负（负左正右）
- ✅ 使用relative_position_id便于重构
- ❌ 避免绝对坐标（除根节点外）

---

## ⚠️ 常见错误

### 编码问题
- ❌ 本地化文件必须 UTF-8 带 BOM
- ✅ 其他文件 UTF-8 无 BOM

### ID 命名
- ✅ 使用国家前缀：`{TAG}_focus_name`
- ✅ 语义化命名：`political_reform`, `industrial_expansion`
- ❌ 避免纯数字或特殊字符

### 作用域
- `ROOT` = 效果执行者
- `FROM` = 效果触发者（如事件的发送方）
- `THIS` = 当前上下文对象

---

## 📚 文件位置速查

```
{mod}/
├── common/
│   ├── national_focus/*.txt        # 国策树
│   ├── ideas/*.txt                 # 民族精神
│   ├── characters/*.txt            # 人物
│   └── decisions/*.txt             # 决议
├── events/*.txt                    # 事件
└── localisation/
    ├── english/*_l_english.yml     # 英文
    └── simp_chinese/*_l_simp_chinese.yml  # 中文
```

---

## 🔍 调试命令

```
-debug          # 启用调试模式
debug_yesmen    # AI 接受所有请求
tdebug          # 显示调试信息
error           # 打开错误日志
```

**错误日志位置**：
```
C:\Users\{用户名}\Documents\Paradox Interactive\Hearts of Iron IV\logs\error.log
```

---

**完整文档**: `SKILL.md` | **详细示例**: `examples/` | **原版参考**: `references/vanilla_focus_trees/`


path: references/scripted_effects.md
content: # HOI4 脚本效果 (Scripted Effects) 完整语法参考

**版本**: 1.0
**更新**: 2026-04-24
**来源**: 游戏本体文件 + Paradox Wiki

---

## 一、概述

**脚本效果**是一种可重用的效果块定义，类似于编程语言中的函数或过程。

### 核心特点

- 📦 **可复用**：一次定义，多次使用
- 🔧 **可参数化**：支持输入参数
- 🌍 **作用域控制**：自动处理 ROOT/PREV/FROM 上下文
- 📁 **文件组织**：按国家或通用分类

### 与普通效果的区别

```paradox
# 普通效果：直接写在效果块中
completion_reward = {
    add_political_power = 100
    add_manpower = 5000
}

# 脚本效果：先定义，再调用
# 定义（common/scripted_effects/）
my_reward_effect = {
    add_political_power = 100
    add_manpower = 5000
}

# 调用
completion_reward = {
    my_reward_effect = yes
}
```

---

## 二、文件位置

```
common/
└── scripted_effects/
    ├── 00_scripted_effects.txt          # 通用脚本效果
    ├── GER_scripted_effects.txt          # 德国专用
    ├── FRA_scripted_effects.txt          # 法国专用
    ├── USA_scripted_effects.txt          # 美国专用
    └── ...其他国家的脚本效果
```

**建议**：通用效果放 `00_scripted_effects.txt`，国家特定的放对应文件。

---

## 三、定义语法

### 3.1 基础定义

```paradox
# 文件：common/scripted_effects/00_scripted_effects.txt

# ============================================
# 基础脚本效果
# ============================================

# 效果名称 = { 效果内容 }
my_first_effect = {
    # 这里写任何效果
    add_political_power = 50
    add_war_support = 0.05
}

# 效果可以包含多个步骤
complex_effect = {
    add_political_power = 100
    add_manpower = 5000
    set_country_flag = my_flag
    custom_effect_tooltip = my_effect_tt
}
```

### 3.2 带参数的效果

```paradox
# 文件：common/scripted_effects/00_scripted_effects.txt

# ============================================
# 带参数的效果（使用 [?] 语法）
# ============================================

# 参数名 = 默认值（可选）
add_n_resources = {
    # resource_type 参数，默认为 oil
    add_resource = {
        type = oil
        amount = 10
        state = PREV
    }
}

# 多个参数
grant_technology_bonus = {
    # tech_category 参数
    # bonus_amount 参数
    add_tech_bonus = {
        name = my_tech_bonus
        bonus = bonus_amount
        uses = 2
        category = tech_category
    }
}

# 在使用时传入参数
effect = {
    grant_technology_bonus = {
        tech_category = industry
        bonus_amount = 0.5
    }
}
```

### 3.3 完整示例

```paradox
# ============================================
# 完整示例：工厂转换效果
# ============================================

replace_civ_with_arms_factories = {
    # 随机选择5个有民用工厂的州
    random_owned_controlled_state = {
        limit = {
            is_fully_controlled_by = ROOT
            industrial_complex > 0
        }
        remove_building = {
            type = industrial_complex
            level = 1
        }
        add_building_construction = {
            type = arms_factory
            level = 1
            instant_build = yes
        }
    }

    random_owned_controlled_state = {
        limit = {
            is_fully_controlled_by = ROOT
            industrial_complex > 0
        }
        remove_building = {
            type = industrial_complex
            level = 1
        }
        add_building_construction = {
            type = arms_factory
            level = 1
            instant_build = yes
        }
    }

    # ... 重复5次
}
```

---

## 四、作用域系统

### 4.1 基础作用域

```paradox
# 脚本效果内部的作用域
my_effect = {
    # ROOT = 调用此效果时的当前作用域
    # 示例：在国家效果块中调用，ROOT = 国家
    ROOT = { add_political_power = 100 }
    
    # PREV = 上一个作用域
    # 示例：在州效果块中调用，PREV = 州
    PREV = { add_manpower = 1000 }
    
    # FROM = 触发效果的源头
    FROM = { has_war = yes }
}
```

### 4.2 实际应用

```paradox
# 文件：common/scripted_effects/00_scripted_effects.txt

# 国家 scope 中使用
give_money_and_pop = {
    # ROOT = 国家
    add_political_power = 50
    add_manpower = 5000
    add_civilian_factories = 1
}

# 州 scope 中使用
develop_state = {
    # PREV = 州
    add_extra_state_shared_building_slots = 2
    add_building_construction = {
        type = industrial_complex
        level = 2
        instant_build = yes
    }
}

# 复杂作用域
inherit_wars = {
    hidden_effect = {
        # 对所有与 PREV（当前作用域）处于防御战的国家
        every_country = {
            limit = {
                has_defensive_war_with = PREV
            }
            # ROOT = 这些国家
            ROOT = {
                # 对这些国家宣战
                declare_war_on = { target = PREV type = annex_everything }
            }
        }
        # 对所有与 ROOT 处于进攻战的国家
        every_country = {
            limit = {
                has_offensive_war_with = ROOT
            }
            # 宣战到 ROOT
            declare_war_on = { target = ROOT type = annex_everything }
        }
    }
}
```

---

## 五、调用语法

### 5.1 基本调用

```paradox
# 在国策/事件/决议中调用
completion_reward = {
    # 简单调用
    my_effect = yes
}

# 调用带参数的效果
completion_reward = {
    grant_technology_bonus = {
        tech_category = industry
        bonus_amount = 0.5
    }
}
```

### 5.2 在不同位置调用

```paradox
# 国策中调用
my_focus = {
    completion_reward = {
        replace_civ_with_arms_factories = yes
    }
}

# 事件中调用
country_event = {
    id = my_events.1
    option = {
        name = accept
        replace_civ_with_arms_factories = yes
    }
}

# 决议中调用
my_decision = {
    effect = {
        replace_civ_with_arms_factories = yes
    }
}

# 触发器中调用（通过 scripted_effect）
trigger = {
    has_completed_focus = MY_focus
    custom_trigger_tooltip = {
        tooltip = my_effect_tt
        my_scripted_effect = yes
    }
}
```

---

## 六、常用脚本效果库

### 6.1 工厂转换

```paradox
# 民用工厂转军用工厂（5个）
replace_civ_with_arms_factories = {
    random_owned_controlled_state = {
        limit = {
            is_fully_controlled_by = ROOT
            industrial_complex > 0
        }
        remove_building = {
            type = industrial_complex
            level = 1
        }
        add_building_construction = {
            type = arms_factory
            level = 1
            instant_build = yes
        }
    }
    # 重复5次...
}

# 军用工厂转民用工厂（3个）
replace_arms_with_civ_factories = {
    random_owned_controlled_state = {
        limit = {
            is_fully_controlled_by = ROOT
            arms_factory > 0
        }
        remove_building = {
            type = arms_factory
            level = 1
        }
        add_building_construction = {
            type = industrial_complex
            level = 1
            instant_build = yes
        }
    }
    # 重复3次...
}
```

### 6.2 AI 策略设置

```paradox
# 民主国家AI策略
GER_democratic_nations_ai_strategies = {
    # 减少对苏联的围堵
    add_ai_strategy = {
        type = contain
        id = "SOV"
        value = -800
    }
    # 保护波兰
    add_ai_strategy = {
        type = protect
        id = "POL"
        value = -200
    }
    # 忽视波兰
    add_ai_strategy = {
        type = ignore
        id = "POL"
        value = 200
    }
    # 联盟波兰
    add_ai_strategy = {
        type = alliance
        id = "POL"
        value = -200
    }
}
```

### 6.3 继承战争

```paradox
ROOT_inherit_current_scope_wars_effect = {
    custom_effect_tooltip = ROOT_inherit_current_scope_wars_effect
    hidden_effect = {
        # 防御战：继承方对敌人宣战
        every_country = {
            limit = {
                has_defensive_war_with = PREV
            }
            ROOT = { declare_war_on = { target = PREV type = annex_everything } }
        }
        # 进攻战：敌人对继承方宣战
        every_country = {
            limit = {
                has_offensive_war_with = PREV
            }
            declare_war_on = { target = ROOT type = annex_everything }
        }
    }
}
```

---

## 七、真实游戏代码示例

### 7.1 国策中的脚本效果

```paradox
# 文件：common/national_focus/usa.txt

USA_production_effort = {
    id = USA_production_effort
    icon = GFX_goal_generic_production
    x = 1
    y = 0
    cost = 35
    
    completion_reward = {
        # 调用脚本效果：5个民用工厂转军用工厂
        replace_civ_with_arms_factories = yes
    }
}
```

### 7.2 事件中的脚本效果

```paradox
# 文件：events/usa_events.txt

country_event = {
    id = usa_events.5
    title = USA_industrial_mobilization_title
    desc = USA_industrial_mobilization_desc
    
    is_triggered_only = yes
    
    trigger = {
        tag = USA
        has_completed_focus = USA_production_effort
    }
    
    option = {
        name = USA_mobilize_industry
        
        # 调用工厂转换效果
        replace_civ_with_arms_factories = yes
        
        # 添加额外效果
        add_war_support = 0.05
        add_political_power = 50
    }
}
```

### 7.3 决议中的脚本效果

```paradox
# 文件：common/decisions/usa_decisions.txt

USA_convert_factories = {
    name = USA_convert_factories
    icon = generic_factory
    
    available = {
        has_war = yes
    }
    
    cost = 35
    
    days_remove = 90
    
    modifier = {
        consumer_goods_factor = 0.10
    }
    
    complete_effect = {
        replace_civ_with_arms_factories = yes
    }
}
```

---

## 八、最佳实践

### 8.1 命名规范

```paradox
# 通用效果：以动词或功能命名
replace_civ_with_arms_factories = { ... }
give_money_and_pop = { ... }
setup_ai_strategies = { ... }

# 国家特定效果：以国家标签开头
GER_democratic_nations_ai_strategies = { ... }
FRA_develop_paris = { ... }
USA_manhattan_project = { ... }

# 带参数的效果：动词短语
add_n_factories_to_state = { ... }
grant_technology_bonus = { ... }
set_state_as_core = { ... }
```

### 8.2 作用域处理

```paradox
# ✅ 正确：明确使用 ROOT/PREV/FROM
my_effect = {
    ROOT = { add_political_power = 50 }
    every_owned_state = {
        PREV = { add_manpower = 1000 }
    }
}

# ❌ 避免：隐式作用域可能导致混淆
my_effect = {
    add_political_power = 50  # 作用域不明确
}
```

### 8.3 隐藏效果

```paradox
# 使用 hidden_effect 隐藏复杂的实现细节
my_effect = {
    custom_effect_tooltip = my_effect_tt
    
    hidden_effect = {
        # 复杂的内部逻辑
        set_variable = { my_var = 1 }
        add_to_variable = { my_var = 2 }
        set_country_flag = my_flag
    }
}
```

### 8.4 组合使用

```paradox
# 在脚本效果中调用其他脚本效果
common_upgrade = {
    replace_civ_with_arms_factories = yes
    add_extra_state_shared_building_slots = 1
}

special_upgrade = {
    # 调用基础效果
    common_upgrade = yes
    
    # 添加特殊效果
    add_research_slot = 1
    set_technology = {
        improved_infantry_weapons = 1
        tech_engineers = 1
    }
}
```

---

## 九、调试技巧

### 9.1 常见错误

```paradox
# ❌ 错误1：效果名称拼写错误
completion_reward = {
    my_effect = yes  # 如果 my_effect 未定义，会报错
}

# ❌ 错误2：参数缺失
my_effect = {
    add_resource = {
        type = resource_type  # 必须是具体类型，不是变量名
        amount = 10
        state = PREV
    }
}

# 正确：
add_resource = {
    type = oil
    amount = 10
    state = PREV
}

# ❌ 错误3：作用域引用错误
my_effect = {
    add_manpower = 1000  # 在国家 scope 中可以，但州 scope 中可能错误
}
```

### 9.2 调试方法

```paradox
# 1. 使用 custom_effect_tooltip 显示提示
my_effect = {
    custom_effect_tooltip = my_effect_tt
}

# 2. 使用日志输出
log = "Effect triggered!"

# 3. 分解复杂效果
complex_effect = {
    hidden_effect = {
        set_country_flag = debug_flag_1
    }
    custom_effect_tooltip = step_1_tt
    
    hidden_effect = {
        set_country_flag = debug_flag_2
    }
    custom_effect_tooltip = step_2_tt
}
```

---

## 十、相关文件关联

| 文件类型 | 位置 | 说明 |
|----------|------|------|
| 脚本效果定义 | `common/scripted_effects/*.txt` | 效果块的定义 |
| 国策奖励 | `common/national_focus/*.txt` | 常见的调用位置 |
| 事件效果 | `events/*.txt` | 事件中的调用 |
| 决议效果 | `common/decisions/*.txt` | 决议中的调用 |
| 脚本触发器 | `common/scripted_triggers/*.txt` | 类似的概念 |

---

**文档版本**: 1.0
**更新日期**: 2026-04-24
**维护者**: AI Agent (HOI Mod-Maker Skill)


path: references/scripted_triggers.md
content: # HOI4 脚本触发器 (Scripted Triggers) 完整语法参考

**版本**: 1.0
**更新**: 2026-04-24
**来源**: 游戏本体文件 + Paradox Wiki

---

## 一、概述

**脚本触发器**是一种可重用的条件判断块，类似于编程语言中的函数或布尔表达式。

### 核心特点

- 🔍 **可复用**：一次定义，多次使用
- 🔧 **可参数化**：支持输入参数
- 🌍 **作用域控制**：自动处理 ROOT/PREV/FROM 上下文
- 📁 **文件组织**：按国家或通用分类

### 与脚本效果的区别

| 特性 | 脚本效果 | 脚本触发器 |
|------|----------|------------|
| **返回值** | 无（执行操作） | 布尔值（true/false） |
| **用途** | 执行一系列效果 | 检查条件是否满足 |
| **使用位置** | 效果块、触发器块 | 触发器块、limit 块 |

### 与普通触发器的区别

```paradox
# 普通触发器：直接写在触发器块中
available = {
    has_completed_focus = MY_focus
    num_of_controlled_factories > 50
}

# 脚本触发器：先定义，再调用
# 定义（common/scripted_triggers/）
my_condition = {
    has_completed_focus = MY_focus
    num_of_controlled_factories > 50
}

# 调用
available = {
    my_condition = yes
}
```

---

## 二、文件位置

```
common/
└── scripted_triggers/
    ├── 00_scripted_triggers.txt          # 通用脚本触发器
    ├── GER_scripted_triggers.txt          # 德国专用
    ├── FRA_scripted_triggers.txt          # 法国专用
    └── ...其他国家的脚本触发器
```

**建议**：通用触发器放 `00_scripted_triggers.txt`，国家特定的放对应文件。

---

## 三、定义语法

### 3.1 基础定义

```paradox
# 文件：common/scripted_triggers/00_scripted_triggers.txt

# ============================================
# 基础脚本触发器
# ============================================

# 触发器名称 = { 条件内容 }
my_first_trigger = {
    # 这里写任何触发器条件
    has_completed_focus = MY_focus
    has_war = no
}

# 触发器可以包含多个条件（AND 关系）
complex_trigger = {
    has_completed_focus = MY_focus
    NOT = { has_country_flag = MY_flag }
    num_of_controlled_factories > 10
}
```

### 3.2 带参数触发器

```paradox
# ============================================
# 带参数的触发器
# ============================================

# 检查国家是否有特定标签
is_tag = {
    tag = target_tag
}

# 检查是否在特定洲
is_on_continent_check = {
    is_on_continent = target_continent
}

# 在使用时传入参数
trigger = {
    is_tag = {
        target_tag = GER
    }
}
```

### 3.3 复杂条件

```paradox
# ============================================
# 复杂条件示例
# ============================================

# 检查是否可以切换到民主政体
check_has_focus_tree_to_switch_to_democratic = {
    # 排除不能切换的国家
    NOT = { tag = MAN }
    NOT = { tag = FRA }
    NOT = { tag = USA }
    NOT = { tag = ENG }
    NOT = { tag = CAN }
    NOT = { tag = SAF }
    NOT = { tag = AST }
    NOT = { tag = NZL }
    NOT = { tag = RAJ }
    NOT = { tag = CZE }
    
    # DLC 相关排除
    NOT = {
        AND = {
            tag = JAP
            has_dlc = "Waking the Tiger"
        }
    }
    NOT = {
        AND = {
            tag = GER
            has_dlc = "Waking the Tiger"
        }
    }
}
```

---

## 四、作用域系统

### 4.1 基础作用域

```paradox
# 脚本触发器内部的作用域
my_trigger = {
    # ROOT = 调用此触发器时的当前作用域
    # 示例：在国家触发器中调用，ROOT = 国家
    ROOT = { has_war = yes }
    
    # THIS = 触发器定义所在的对象
    THIS = { is_controlled_by = ROOT }
    
    # FROM = 触发效果的源头
    FROM = { has_war = yes }
}
```

### 4.2 实际应用

```paradox
# 国家 scope 中使用
can_switch_to_democratic = {
    NOT = { tag = MAN }
    has_completed_focus = MY_democratic_path
}

# 州 scope 中使用
has_developed_infrastructure = {
    infrastructure > 3
    industrial_complex > 2
}

# 限制块中使用
random_owned_controlled_state = {
    limit = {
        # 这里可以使用脚本触发器
        has_developed_infrastructure = yes
    }
}
```

---

## 五、调用语法

### 5.1 基本调用

```paradox
# 在触发器块中调用
available = {
    my_trigger = yes
}

# 调用带参数的效果
trigger = {
    is_tag = {
        target_tag = GER
    }
}
```

### 5.2 在不同位置调用

```paradox
# 国策可用条件
my_focus = {
    available = {
        my_trigger = yes
    }
}

# 限制块（limit）
random_owned_controlled_state = {
    limit = {
        my_state_trigger = yes
    }
}

# 事件触发条件
country_event = {
    trigger = {
        my_trigger = yes
    }
}

# 决议条件
my_decision = {
    available = {
        my_trigger = yes
    }
}
```

---

## 六、常用脚本触发器库

### 6.1 国策树切换检查

```paradox
# 检查是否可以切换到特定政体
check_has_focus_tree_to_switch_to_democratic = {
    NOT = { tag = MAN }
    NOT = { tag = FRA }
    NOT = { tag = USA }
    NOT = { tag = ENG }
    NOT = { tag = JAP }
    NOT = { tag = GER }
    NOT = { tag = SOV }
    # ... 更多排除
}

check_has_focus_tree_to_switch_to_fascism = {
    NOT = { tag = JAP }
    NOT = { tag = GER }
    NOT = { tag = MAN }
    # ...
}

check_has_focus_tree_to_switch_to_communism = {
    NOT = { tag = PRC }
    NOT = { tag = SIK }
    NOT = { tag = MAN }
    NOT = { tag = SOV }
    # ...
}
```

### 6.2 关系检查

```paradox
# 检查 ROOT 是否可以对 THIS 发动战争目标
can_ROOT_get_wargoal_on_THIS = {
    exists = yes
    NOT = { is_in_faction_with = ROOT }
    NOT = { is_subject_of = ROOT }
}

# 检查是否是与 JAP 的盟友
is_JAP_or_ally_of_JAP = {
    OR = {
        tag = JAP
        is_in_faction_with = JAP
        is_subject_of = JAP
    }
}
```

### 6.3 边界冲突

```paradox
# 检查是否是边界冲突的防御方
is_border_conflict_defender_vs_FROM = {
    has_variable = ROOT.defender_state_vs_@FROM
}

# 检查是否发起了边境事件
has_not_initiated_border_incident_with_FROM = {
    custom_trigger_tooltip = {
        tooltip = not_initiated_border_incident_with_FROM
        NOT = {
            any_state = {
                check_variable = { FROM.defender_state_vs_@PREV = id }
            }
        }
    }
}
```

### 6.4 军事单位检查

```paradox
# 检查 ROOT 在当前州是否有至少1个师
has_ROOT_at_least_1_div_in_current_state_scope = {
    custom_trigger_tooltip = {
        tooltip = at_least_one_division_in_state
        ROOT = {
            divisions_in_state = {
                state = PREV
                size > 0
            }
        }
    }
}
```

---

## 七、真实游戏代码示例

### 7.1 国策中的脚本触发器

```paradox
# 文件：common/national_focus/MY_focus.txt

MY_democratic_path = {
    id = MY_democratic_path
    icon = GFX_goal_generic_democracy
    x = 2
    y = 0
    cost = 35
    
    # 使用脚本触发器检查是否可用
    available = {
        check_has_focus_tree_to_switch_to_democratic = yes
    }
    
    completion_reward = {
        add_political_power = 50
    }
}

MY_fascist_path = {
    id = MY_fascist_path
    icon = GFX_goal_generic_fascism
    x = 4
    y = 0
    cost = 35
    
    available = {
        check_has_focus_tree_to_switch_to_fascism = yes
    }
    
    completion_reward = {
        add_political_power = 50
    }
}
```

### 7.2 限制块中的脚本触发器

```paradox
MY_national_effort = {
    id = MY_national_effort
    icon = GFX_goal_generic_production
    x = 3
    y = 1
    cost = 70
    
    prerequisite = {
        focus = MY_democratic_path
        focus = MY_fascist_path
    }
    
    completion_reward = {
        # 选择发展最好的州进行强化
        random_owned_controlled_state = {
            # 使用脚本触发器作为限制
            limit = {
                has_developed_infrastructure = yes
                is_fully_controlled_by = ROOT
            }
            
            add_extra_state_shared_building_slots = 2
            add_building_construction = {
                type = industrial_complex
                level = 2
                instant_build = yes
            }
        }
    }
}
```

### 7.3 事件中的脚本触发器

```paradox
# 文件：events/MY_events.txt

country_event = {
    id = MY_events.1
    title = MY_border_conflict_title
    
    # 使用脚本触发器作为触发条件
    trigger = {
        is_border_conflict_defender_vs_FROM = yes
    }
    
    mean_time_to_happen = {
        days = 30
    }
    
    option = {
        name = MY_escalate
        
        # 检查是否可以升级
        if = {
            limit = {
                is_border_conflict_defender_vs_FROM = yes
            }
            add_war_support = 0.05
        }
    }
}
```

---

## 八、最佳实践

### 8.1 命名规范

```paradox
# 通用触发器：描述性动词短语
can_switch_to_democratic = { ... }
has_developed_infrastructure = { ... }
is_border_conflict_defender = { ... }

# 国家特定触发器：以国家标签开头
GER_can_use_naval_treaty = { ... }
FRA_has_parliament_approval = { ... }
USA_can_declare_war = { ... }

# 带参数的触发器：动词短语
is_tag = { ... }
has_completed_focus = { ... }
is_on_continent_check = { ... }
```

### 8.2 组合使用

```paradox
# 使用 OR 组合
can_do_action = {
    OR = {
        my_trigger_1 = yes
        my_trigger_2 = yes
        my_trigger_3 = yes
    }
}

# 使用 AND 组合（默认）
can_do_action = {
    my_trigger_1 = yes
    my_trigger_2 = yes
    my_trigger_3 = yes
}

# 否定
cannot_do_action = {
    NOT = {
        my_trigger = yes
    }
}
```

### 8.3 避免的问题

```paradox
# ❌ 避免：过于复杂的触发器
too_complex = {
    OR = {
        AND = {
            condition1 = yes
            condition2 = yes
        }
        AND = {
            condition3 = yes
            NOT = { condition4 = yes }
        }
    }
}

# ✅ 推荐：分解为多个简单触发器
simple_condition_1 = {
    condition1 = yes
    condition2 = yes
}

simple_condition_2 = {
    condition3 = yes
    NOT = { condition4 = yes }
}

can_do_action = {
    OR = {
        simple_condition_1 = yes
        simple_condition_2 = yes
    }
}
```

### 8.4 性能优化

```paradox
# ❌ 避免：性能开销大的检查
expensive_check = {
    any_state = {
        check_variable = { var = 1 }
    }
}

# ✅ 推荐：使用 custom_trigger_tooltip 包装
has_variable_check = {
    custom_trigger_tooltip = {
        tooltip = has_variable_check_desc
        NOT = {
            any_state = {
                check_variable = { var = 1 }
            }
        }
    }
}
```

---

## 九、调试技巧

### 9.1 常见错误

```paradox
# ❌ 错误1：触发器名称拼写错误
available = {
    my_triger = yes  # 拼写错误！
}

# ❌ 错误2：参数缺失
is_tag = {
    # 缺少 target_tag 参数
}

# ❌ 错误3：作用域错误
my_trigger = {
    add_manpower = 1000  # 错误：触发器不能有效果！
}
```

### 9.2 调试方法

```paradox
# 1. 使用 custom_trigger_tooltip 显示条件
my_debug_trigger = {
    custom_trigger_tooltip = {
        tooltip = my_trigger_desc
        # 实际条件
        has_completed_focus = MY_focus
    }
}

# 2. 分解复杂条件
condition_1 = {
    has_completed_focus = MY_focus
}

condition_2 = {
    num_of_controlled_factories > 10
}

can_do_action = {
    condition_1 = yes
    condition_2 = yes
}
```

---

## 十、相关文件关联

| 文件类型 | 位置 | 说明 |
|----------|------|------|
| 脚本触发器定义 | `common/scripted_triggers/*.txt` | 触发器块的定义 |
| 国策可用条件 | `common/national_focus/*.txt` | 常见的调用位置 |
| 限制块 | `common/national_focus/*.txt` | 随机选择限制 |
| 事件触发 | `events/*.txt` | 事件触发条件 |
| 脚本效果 | `common/scripted_effects/*.txt` | 类似的概念 |

---

**文档版本**: 1.0
**更新日期**: 2026-04-24
**维护者**: AI Agent (HOI Mod-Maker Skill)


path: references/syntax.md
content: # HOI4 National Focus Tree Syntax Reference

## Table of Contents

1. [Top-Level Structure](#2-top-level-structure)
2. [focus_tree Fields](#3-focus_tree-fields)
3. [focus Node Complete Field Reference](#4-focus-node-complete-field-reference)
4. [Joint Focus Trees (joint_focus)](#5-joint-focus-trees)
5. [Shared Focus Trees (shared_focus)](#6-shared-focus-trees)
6. [German Inner Circle Mechanism](#7-german-inner-circle-mechanism)
7. [Effects](#8-effects)
8. [Triggers](#9-triggers)
9. [Variables and UI](#10-variables-and-ui)
10. [Common Pitfalls](#11-common-pitfalls)

---

## 1. File Locations

```
# Standard mod structure for national_focus files:
{mod_folder}/common/national_focus/
    generic.txt          # generic fallback focus tree
    usa.txt              # United States
    germany.txt          # Germany (with Inner Circle)
    soviet.txt           # Soviet Union
    nordic_shared.txt    # Nordic joint tree
    habsburg_joint.txt   # Austro-Hungarian joint tree
    congo_shared.txt     # Congo shared tree (Belgium/Congo)
    ... (73 countries total)
```

---

## 2. Top-Level Structure

```txt
focus_tree = {
    id = {tree_id}                    # tree identifier, e.g. "ger_focus", "nordic_shared_focus"
    country = {                       # AI weight allocation
        factor = 1
        modifier = {
            tag = {TAG} factor = 2
            OR = { tag = {TAG1} tag = {TAG2} } factor = 0
        }
    }
    default = yes|no                   # yes = load as generic fallback for all undefined countries
    reset_on_civilwar = yes|no          # yes = reset tree on civil war
    initial_show_position = { focus = {focus_id} }
    continuous_focus_position = { x = {n} y = {n} }
    search_filter_prios = { ... }

    # reference shared/joint focuses from other files
    shared_focus = {id}
    shared_focus = {id2}

    # local focus nodes
    focus = { ... }
    joint_focus = { ... }    # can mix focus and joint_focus in same tree
}
```

---

## 3. focus_tree Fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique tree identifier |
| `country` | block | AI weight allocation |
| `default` | bool | Load as generic fallback tree |
| `reset_on_civilwar` | bool | Reset on civil war |
| `initial_show_position` | block | Initial viewport anchor `{ focus = id }` |
| `continuous_focus_position` | block | Persistent focus button coordinates `{ x = n y = n }` |
| `shared_focus` | id | Reference shared/joint focus from other files (repeatable) |
| `search_filter_prios` | block | Filter priority ordering |

---

## 4. focus Node Complete Field Reference

```txt
focus = {
    id = {id}                              # unique identifier
    icon = GFX_{name}                       # GFX resource name
    x = {n}                                 # column position
    y = {n}                                 # row position (relative to y=0 row)
    relative_position_id = {id}             # relative positioning anchor
    cost = {n}                              # days (actual = x7 days; Inner Circle uses @constants)

    # ===== Prerequisites =====
    prerequisite = { focus = {id} }          # prerequisite focus (repeatable)
    mutually_exclusive = { focus = {id} }   # mutual exclusion (repeatable)

    # ===== Conditional Offsets =====
    # Multiple offsets: first matching trigger determines displayed position
    offset = {
        x = {n}  y = {n}
        trigger = { has_focus_tree = {tree_id} }
    }
    offset = {
        x = {n}  y = {n}
        trigger = { has_completed_focus = {id} }
    }

    # ===== Conditions =====
    available = { {trigger} }                # availability condition
    bypass = { {trigger} }                   # auto-bypass condition
    allow_branch = { {trigger} }             # branch permission
    cancel_if_invalid = yes|no               # yes = cancel on invalid (default: yes)
    continue_if_invalid = yes|no             # yes = continue if invalid (default: no)
    available_if_capitulated = yes|no        # yes = usable after capitulation

    # ===== AI Behavior =====
    ai_will_do = {
        base = {n}                            # base weight (default: 0 -- MUST SET)
        modifier = { factor = {n} {trigger} }
        modifier = { factor = 0 is_historical_focus_on = yes }  # off in historical mode
    }

    # ===== Search Filters =====
    search_filters = {
        FOCUS_FILTER_POLITICAL
        FOCUS_FILTER_INDUSTRY
        FOCUS_FILTER_RESEARCH
        FOCUS_FILTER_MANPOWER
        FOCUS_FILTER_ARMY_XP
        FOCUS_FILTER_NAVY_XP
        FOCUS_FILTER_AIR_XP
        FOCUS_FILTER_ANNEXATION
        FOCUS_FILTER_STABILITY
        FOCUS_FILTER_WAR_SUPPORT
        FOCUS_FILTER_INNER_CIRCLE
        FOCUS_FILTER_TVF_AUTONOMY
        FOCUS_FILTER_HISTORICAL
        FOCUS_FILTER_BALANCE_OF_POWER
        FOCUS_FILTER_POLITICAL_CHARACTER
        FOCUS_FILTER_PROPAGANDA
    }

    # ===== Dynamic Icon =====
    dynamic = yes
    icon = { trigger = { {trigger} } value = GFX_{name} }
    icon = { trigger = { {trigger} } value = GFX_{name2} }

    # ===== Text Icon =====
    text_icon = {style}

    # ===== Effect Blocks =====
    select_effect = { {effect} }              # immediate on selection (prevents AI stalling)
    complete_tooltip = { {effect} }           # tooltip only (no effect)
    completion_reward = { {effect} }           # main reward (all members share)
    hidden_effect = { {effect} }               # hidden reward (no tooltip shown)

    # ===== joint_focus specific =====
    joint_trigger = { {trigger} }              # joint tree membership check
    completion_reward_joint_originator = { {effect} }  # originator extra reward
    completion_reward_joint_member = { {effect} }      # member extra reward
}
```

---

## 5. Joint Focus Trees (joint_focus)

### 5.1 Nordic Model (Equal Allied Nations)

```txt
focus_tree = {
    id = nordic_shared_focus

    joint_focus = {
        id = NORDIC_northern_command
        dynamic = yes
        text_icon = NORDIC_focus_style

        x = -6
        y = 1
        relative_position_id = NORDIC_form_joint_alliance

        joint_trigger = { NORDIC_basic_joint_trigger = yes }

        # three-part reward
        completion_reward = {
            air_experience = 25
            navy_experience = 25
            army_experience = 25
            add_command_power = 25
        }
        completion_reward_joint_originator = {
            add_ideas = { NORDIC_command_ns }
            add_political_power = 100
        }
        completion_reward_joint_member = {
            add_political_power = 50
        }
    }
}
```

### 5.2 Austro-Hungarian Model (Multi-Relationship + Global Variables)

Three relationship modes:

```txt
available = {
    custom_trigger_tooltip = {
        tooltip = HABSBURG_is_subject_puppeteer_faction_leader_or_member_trigger_tt
        OR = {
            # Mode 1: Danubian Federation (allied + faction leader)
            AND = {
                is_faction_leader = yes
                any_allied_country = { HABSBURG_is_a_habsburg_viable_nation = yes }
            }
            # Mode 1 alt: not faction leader but allied to HUN or AUS
            AND = {
                is_faction_leader = no
                OR = {
                    AND = { is_in_faction_with = HUN HUN = { is_faction_leader = yes } }
                    AND = { is_in_faction_with = AUS AUS = { is_faction_leader = yes } }
                }
            }
            # Mode 2: Master (HUN/AUS with subject)
            AND = {
                original_tag = HUN
                any_subject_country = { HABSBURG_is_a_habsburg_viable_nation = yes }
            }
            # Mode 3: Subject (subject of HUN/AUS)
            AND = {
                is_subject = yes
                OR = { is_subject_of = HUN is_subject_of = AUS }
            }
        }
        HABSBURG_is_a_habsburg_viable_nation = yes
    }
}
```

### 5.3 Originator Check (Austro-Hungarian)

```txt
available = {
    custom_trigger_tooltip = {
        tooltip = HABSBURG_is_originator_country
        tag = global.AH_originator_country       # global var stores current originator
    }
    any_other_country = {
        OR = { is_in_faction_with = ROOT is_subject_of = ROOT }
        HABSBURG_is_a_habsburg_viable_nation = yes
    }
    is_subject = no
}
```

### 5.4 Global Variable System (Austro-Hungarian Exclusive)

All member nations share a single global counter, with the originator executing actual changes:

```txt
# member sees preview only
completion_reward = {
    effect_tooltip = {
        custom_effect_tooltip = HABSBURG_modify_economy_ns_intro
        add_to_variable = {
            global.HABSBURG_economy_consumer_goods_factor = -0.1
            tooltip = consumer_goods_factor_tt
        }
    }
}

# originator executes actual change
completion_reward_joint_originator = {
    hidden_effect = {
        custom_effect_tooltip = HABSBURG_modify_economy_ns_intro
        add_to_variable = {
            global.HABSBURG_economy_consumer_goods_factor = -0.1
            tooltip = consumer_goods_factor_tt
        }
    }
}

# global variable namespaces
global.HABSBURG_economy_*          # economic global
global.HABSBURG_army_*             # army global
global.HABSBURG_cavalry_*          # cavalry global
global.HABSBURG_industry_*          # industry global
global.AH_originator_country        # current originator tag
```

### 5.5 Conditional Rewards (Ideology Fork)

```txt
completion_reward_joint_originator = {
    IF = {
        limit = {
            ROOT = { OR = { has_government = democratic has_government = communism } }
        }
        add_stability = 0.1
        add_popularity = { ideology = democratic popularity = 0.15 }
        hidden_effect = { add_to_variable = { global.HABSBURG_xxx = 0.15 } }
    }
    IF = {
        limit = {
            ROOT = { OR = { has_government = neutrality has_government = fascism } }
        }
        add_ideas = HABSBURG_an_imperium_restored
        set_cosmetic_tag = HUN_EMPIRE      # change country cosmetic name
        IF = {
            limit = { NOT = { any_country = { is_subject_of = ROOT } } }
            effect_tooltip = { add_ideas = HABSBURG_imperial_integration }
        }
    }
}
```

---

## 6. Shared Focus Trees (shared_focus)

### 6.1 Congo Model (Master-Subject)

Asymmetric sharing: one country actually executes, the other previews + unlocks:

```txt
shared_focus = {
    id = CONGO_expand_villages
    dynamic = yes
    available = { original_tag = COG }     # only available to Congo
    available_if_capitulated = yes

    completion_reward = {
        IF = {
            limit = { original_tag = COG }
            COG_vast_uncentralized_nation_modifier_level_down = yes
            every_state = {
                limit = {
                    is_owned_and_controlled_by = ROOT
                    OR = { state = 295 state = 538 state = 718 }
                }
                add_extra_state_shared_building_slots = 1
            }
        }
        ELSE_IF = {
            limit = { original_tag = BEL COG = { is_subject_of = BEL } }
            # Belgium sees a preview of what Congo will gain
            effect_tooltip = {
                COG = { every_state = { ... } }
            }
        }
        # unlock the same focus for the other country
        hidden_effect = {
            BEL = { unlock_national_focus = CONGO_expand_villages }
        }
    }
}
```

### 6.2 unlock_national_focus Mechanism

Core of "one country completes, other country also completes":

```txt
hidden_effect = {
    # Congo completes -> unlock for Belgium
    BEL = { unlock_national_focus = CONGO_xxx }
    # Belgium completes -> unlock for Congo
    COG = { unlock_national_focus = CONGO_xxx }
    # track completion count
    CONGO_one_more_focus_done = yes
    # force refresh dynamic modifiers
    force_update_dynamic_modifier = yes
}
```

### 6.3 Cross-Country Dynamic Modifier Sharing

```txt
# Congo modifies a variable inside Belgium's dynamic modifier
add_to_variable = {
    var = BEL.COG_belgian_congo_colonial_dynamic_modifier_research_speed_factor
    value = 0.03
    tooltip = research_speed_factor_tt
}

# syntax: OTHER_TAG.modifier_name.field_name
```

---

## 7. German Inner Circle Mechanism

### 7.1 Core Constants

```txt
@inner_circle_time_tier_1 = 20     # tier 1/2 = 20 days
@inner_circle_time_tier_2 = 20
@inner_circle_time_tier_3 = 40     # tier 3 = 40 days
@inner_circle_days_to_start_focus = 14    # event trigger delay
@inner_circle_random_days = 14            # random float
@inner_circle_cd_days = 90               # cooldown days
```

### 7.2 Inner Circle Focus Structure

```txt
focus = {
    id = GER_party_chancellor_bormann
    icon = GFX_focus_GER_party_chancellor_bormann
    prerequisite = { focus = GER_fuhrerprinzip }
    mutually_exclusive = { focus = GER_party_chancellor_hess }
    x = 2  y = 0
    relative_position_id = GER_party_chancellor_hess
    cost = @inner_circle_time_tier_1    # = 2 days

    available = {
        if = {
            limit = { is_ai = yes }
            hidden_trigger = {
                NOT = { has_country_flag = GER_bormann_was_ascended_flag }
            }
        }
        has_government = fascism
        NOT = { has_country_leader = { ruling_only = yes character = GER_martin_bormann } }
        has_country_flag = GER_inner_circle_event_pending_flag
        GER_inner_circle_is_ascension_cd_over = yes   # cooldown check macro
        if = {
            limit = { has_country_flag = GER_inner_circle_cd_flag }
            custom_trigger_tooltip = {
                tooltip = GER_inner_circle_cd_days_tt
                NOT = { has_country_flag = GER_inner_circle_cd_flag }
            }
        }
    }

    cancel_if_invalid = no
    continue_if_invalid = no

    # KEY: prevents AI from stalling
    select_effect = { set_country_flag = GER_bormann_ascension_flag }

    search_filters = {
        FOCUS_FILTER_INNER_CIRCLE
        FOCUS_FILTER_POLITICAL_CHARACTER
        FOCUS_FILTER_POLITICAL
    }

    completion_reward = {
        custom_effect_tooltip = {
            localization_key = GER_ascension_of_character_tt
            CHARACTER = GER_martin_bormann
        }
        show_ideas_tooltip = GER_bormann_secretary_to_the_fuhrer
        custom_effect_tooltip = {
            localization_key = GER_ascension_of_character_focus_tt
            CHARACTER = GER_martin_bormann
        }
        hidden_effect = {
            # trigger succession event
            country_event = {
                id = GER_inner_circle_hess.01
                days = @inner_circle_days_to_start_focus
                random_days = @inner_circle_random_days
            }
            clr_country_flag = GER_hess_ascension_flag
            # set cooldown
            GER_inner_circle_set_ascension_cd = yes
            # prevent AI from repeating (cleared after ~4 years)
            set_country_flag = {
                flag = GER_hess_was_ascended_flag
                days = 1500
                value = 1
            }
        }
    }
}
```

### 7.3 Inner Circle Macros (defined by events)

| Macro | Purpose |
|-------|---------|
| `GER_inner_circle_is_ascension_cd_over = yes` | Check if cooldown ended |
| `GER_inner_circle_set_ascension_cd = yes` | Set 90-day cooldown |
| `GER_inner_circle_event_pending_flag` | Event pending flag |
| `GER_inner_circle_cd_flag` | Cooldown active flag |
| `GER_inner_circle_cd_days_tt` | Cooldown tooltip key |

### 7.4 show_ideas_tooltip Preview Mechanism

```txt
# in completion_reward: shows advisor preview
show_ideas_tooltip = GER_bormann_secretary_to_the_fuhrer

# with custom localization
custom_effect_tooltip = {
    localization_key = GER_ascension_of_character_tt
    CHARACTER = GER_martin_bormann
}
```

---

## 8. Effects

### 8.1 Political and Points

```txt
add_political_power = 50
add_command_power = 25
add_stability = 0.1
add_war_support = 0.1
add_popularity = { ideology = {type} popularity = {n} }
add_ideas = {idea}
remove_idea = {idea}
swap_country_leader_traits = { remove = {trait} add = {trait} }
```

### 8.2 Experience

```txt
army_experience = 25
navy_experience = 25
air_experience = 25
add_doctrine_cost_reduction = {
    name = {name}
    cost_reduction = 0.5
    uses = 1
    category = land_doctrine
}
```

### 8.3 Research

```txt
add_research_slot = 1
add_tech_bonus = {
    bonus = 0.5
    uses = 2
    category = cat_mechanized_equipment
    name = {bonus_name}
}
add_tech_bonus = {
    bonus = 0.75
    uses = 1
    category = armor
    ahead_reduction = 0.5     # reduce ahead-of-time penalty
    name = {bonus_name}
}
add_to_tech_sharing_group = {group_name}
```

### 8.4 Buildings and States

```txt
# Add available building slots
add_extra_state_shared_building_slots = 2

# Build in random state
random_owned_controlled_state = {
    limit = {
        is_core_of = ROOT
        is_owned_by = ROOT
        free_building_slots = {
            building = industrial_complex
            size > 1
            include_locked = yes
        }
    }
    prioritize = { 295 }     # prioritize specific state
    add_building_construction = {
        type = industrial_complex
        level = 2
        instant_build = yes
    }
}

# Build in specific state
random_controlled_state = {
    limit = { ... }
    prioritize = { 295 889 }
    add_building_construction = {
        type = naval_base
        province = {id}
        level = 3
        instant_build = yes
    }
}

# Direct state operation (state ID as key)
{state_id} = {
    add_extra_state_shared_building_slots = 1
    add_building_construction = {
        type = infrastructure
        level = 1
        instant_build = yes
    }
}

# Building types
industrial_complex    # civilian factory
arms_factory          # military factory
dockyard             # shipyard
air_base            # air base
naval_base          # naval base
anti_air_building   # anti-air
radar_station       # radar
synthetic_refinery  # synthetic refinery
fuel_silo           # fuel depot
supply_node         # supply hub
bunker              # bunker
coastal_bunker      # coastal bunker
infrastructure      # infrastructure
railway            # railway

# free_building_slots condition
free_building_slots = {
    building = {type}
    size > {n}
    include_locked = yes    # include locked slots
}
```

### 8.5 Resources

```txt
add_resource = {
    type = {oil|aluminium|rubber|steel|tungsten|chromium}
    amount = {n}
}
```

### 8.6 Railway and Supply

```txt
build_railway = {
    path = { {province_id} {province_id} {province_id} }
}
supply_node = {
    province = {id}
    level = {n}
}
```

### 8.7 Variables

```txt
set_variable = { {var} = {n} }
add_to_variable = { var = {path} value = {n} tooltip = {tt} }
set_temp_variable = { {var} = {n} }
add_to_temp_variable = { {var} = {n} }
check_variable = { {var} = {n} }
check_variable = { {var} > {n} }

# Variable reference paths
ROOT.xxx                    # current country
{gc}.xxx                    # global
{tag}.xxx                   # specific country
{state_id}.xxx             # specific state
{tag}.{modifier}.{field}   # modifier field (Congo model)
global.{varname}           # global variable (Habsburg model)
```

### 8.8 Division Templates

```txt
# Define template in focus reward
completion_reward = {
    division_template = {
        name = "Elite Grenadiers"
        override_model = GER_infantry_div_override
        regiment = { base = infantry size = 4 }
        regiment = { base = infantry size = 3 }
        obsolete = { infantry = { x = 0 y = 0 } }
    }
}
```

### 8.9 Events

```txt
country_event = {
    id = {event_file}.{n}    # file_name.event_number
    days = {n}
    random_days = {n}          # plus/minus random days
    hours = {n}
}

# reference other country event
ROOT = { country_event = { id = ww_congo.1 hours = 0 } }
```

### 8.10 Flags

```txt
set_country_flag = { flag = {name} days = {n} value = 1 }
clr_country_flag = {flag}
set_state_flag = { flag = {name} days = {n} }
set_global_flag = {flag}
```

### 8.11 Cosmetic Tag

```txt
set_cosmetic_tag = {TAG}    # change displayed country name (e.g. HUN_EMPIRE)
```

### 8.12 Autonomy and Compliance

```txt
add_autonomy_score = {
    value = +/-{n}             # positive = towards independence, negative = towards master
    localization = {key}
}
add_compliance = {n}         # increase compliance in occupied territory
```

### 8.13 UI Tooltips

```txt
custom_effect_tooltip = {
    localization_key = {key}
    CHARACTER = {tag}         # character parameter
}
custom_trigger_tooltip = {
    tooltip = {key}_tt
    {trigger}
}
show_ideas_tooltip = {idea}
unlock_decision_category_tooltip = {id}
```

---

## 9. Triggers

### 9.1 Focus-Related

```txt
has_completed_focus = {id}
has_focus_tree = {tree_id}
is_on_going_focus = {focus_id}
```

### 9.2 Political and Ideology

```txt
has_government = {communism|democratic|fascism|neutrality}
is_subject = yes|no
is_subject_of = {TAG}
has_subject = {TAG}
has_subject = yes
original_tag = {TAG}
any_country_with_original_tag = {
    original_tag_to_check = FRA
    has_capitulated = yes
}
```

### 9.3 Territory and States

```txt
controls_state = {id}
is_owned_and_controlled_by = {TAG}
is_owned_by = {id}
is_core_of = {TAG}
is_controlled_by = {TAG}
is_fully_controlled_by = {TAG}
has_full_control_of_state = {id}
is_capital = yes
```

### 9.4 Relations and Factions

```txt
is_in_faction_with = {TAG}
is_faction_leader = yes|no
any_allied_country = { {trigger} }
any_other_country = { {trigger} }
has_war_with = {TAG}
has_war = yes|no
has_capitulated = yes
```

### 9.5 Economic and Industry

```txt
num_of_controlled_factories > {n}
num_of_factories > {n}
num_of_available_buildings = {
    state = {id}
    type = industrial_complex
    size > 0
}
free_building_slots = { ... }
```

### 9.6 Flags

```txt
has_country_flag = {flag}
has_country_flag = {flag} = 1
has_state_flag = {flag}
has_global_flag = {flag}
has_character_flag = {flag}
```

### 9.7 Player and AI

```txt
is_ai = yes|no
is_historical_focus_on = yes
has_dlc = "Gotterdammerung"
```

### 9.8 Special

```txt
is_on_continent = {asia|europe|africa|north_america|south_america|oceania}
is_in_home_area = yes
is_owned_by = ROOT
```

---

## 10. Variables and UI

### 10.1 Conditional Blocks

```txt
# IF/ELSE_IF/ELSE (case-insensitive; both IF and if appear in game files)
if = { limit = { {trigger} } {effect} }
else_if = { limit = { {trigger} } {effect} }
else = { {effect} }

# Loop
while_loop_effect = {
    limit = { {trigger} }
    {effect}
}
```

### 10.2 Random Selection

```txt
random_owned_controlled_state = {
    limit = { {trigger} }
    prioritize = { {id} {id} }
    {effect}
}

random_controlled_state = {
    limit = { {trigger} }
    prioritize = { {id} }
    {effect}
}

random_state = { ... }

random_character = {
    limit = { {trigger} }
    {effect}
}
```

### 10.3 effect_tooltip vs hidden_effect

| Block | Executes | UI Shows |
|-------|----------|----------|
| `completion_reward` | Yes | Yes |
| `hidden_effect` | Yes | No |
| `complete_tooltip` | No | Yes (tooltip only) |
| `effect_tooltip` | No | Yes (preview only) |

---

## 11. Common Pitfalls

### 11.1 ai_will_do default factor is 0

All focuses have `ai_will_do.base` defaulting to 0. AI will NEVER auto-select without setting this.

### 11.2 cancel_if_invalid defaults to yes

When condition becomes invalid, without `cancel_if_invalid = no`, the focus is CANCELLED instead of paused.

### 11.3 available_if_capitulated defaults to no

After capitulation, focus trees are normally unavailable unless explicitly set.

### 11.4 Inner Circle focuses MUST have select_effect

Without `select_effect`, when the `available` condition is not met, the focus pauses with no recovery path.

### 11.5 offset trigger matching order

Multiple `offset` blocks match top-to-bottom. The FIRST matching one takes effect. Ensure all possible countries/states have corresponding offsets.

### 11.6 original_tag case sensitivity

Game `original_tag` trigger is case-sensitive: must match game tag exactly (e.g. `COG` cannot be written as `cog`).

### 11.7 relative_position_id is relative

`relative_position_id = GER_xxx` means the focus x/y is an offset from `GER_xxx` position, not from origin. Watch for cumulative offsets in chain dependencies.

### 11.8 Dynamic modifier variable naming

`add_to_variable = { var = BEL.COG_xxx }` means modify variable inside `BEL`'s country scope. Wrong spelling or nonexistent variables silently fail.

### 11.9 hidden_effect conditionals

Effects inside `hidden_effect` execute UNCONDITIONALLY. If you need conditional execution, nest the if INSIDE hidden_effect.

```txt
# WRONG: if outside hidden_effect does not affect hidden_effect execution
if = { limit = { ... } hidden_effect = { ... } }

# CORRECT: if inside hidden_effect
hidden_effect = {
    if = { limit = { ... } ... }
}
```

### 11.10 joint_focus available timing

`joint_focus` `available` is checked for ANY one member. When one member satisfies it, ALL members see it as available. `joint_trigger` checks if the current country is eligible.

---

## Appendix: Shared Focus Tree File List

| File | Countries | Relationship Model |
|------|-----------|-------------------|
| `nordic_shared.txt` | Finland/Sweden/Denmark/Norway | Equal allies |
| `habsburg_joint.txt` | Austria/Hungary/Czech/etc. | Three modes |
| `congo_shared.txt` | Belgium/Congo | Master-subject |
| `baltic_shared.txt` | Estonia/Latvia/Lithuania | Equal allies |
| `china_shared.txt` | China factions | TBD |
| `generic_joint.txt` | Multiple generic | TBD |

Official Wiki: hoi4.paradoxwikis.com

path: references/vanilla_focus_trees/00_titlebar_styles.txt
content: style = {
	name = default_style
	default = yes

	unavailable = GFX_focus_unavailable
	completed = GFX_focus_completed
	available = GFX_focus_can_start
	current = GFX_focus_current
}


###############
##### AAT #####
###############


style = {
	name = NORDIC_focus_style

	unavailable = GFX_focus_unavailable_joint
	completed = GFX_focus_completed_joint
	available = GFX_focus_can_start_joint
	current = GFX_focus_current_joint
}


###############
##### WW ######
###############


style = {
	name = CONGO_COG_focus_style

	unavailable = GFX_focus_unavailable_joint_COG
	completed = GFX_focus_completed_joint_COG
	available = GFX_focus_can_start_joint_COG
	current = GFX_focus_current_joint_COG
}


style = {
	name = CONGO_BEL_focus_style

	unavailable = GFX_focus_unavailable_joint_BEL
	completed = GFX_focus_completed_joint_BEL
	available = GFX_focus_can_start_joint_BEL
	current = GFX_focus_current_joint_BEL
}


style = {
	name = CONGO_BEL_COG_focus_style

	unavailable = GFX_focus_unavailable_joint_BEL_COG
	completed = GFX_focus_completed_joint_BEL_COG
	available = GFX_focus_can_start_joint_BEL_COG
	current = GFX_focus_current_joint_BEL_COG
}


style = {
	name = GER_inner_circle_focus_style

	unavailable = GFX_focus_unavailable_joint_GER_inner_circle
	completed = GFX_focus_completed_joint_GER_inner_circle
	available = GFX_focus_can_start_joint_GER_inner_circle
	current = GFX_focus_current_joint_GER_inner_circle
}

style = {
	name = SSB_AFG_focus_style

	unavailable = GFX_focus_unavailable_joint_AFG
	completed = GFX_focus_completed_joint_AFG
	available = GFX_focus_can_start_joint_AFG
	current = GFX_focus_current_joint_AFG
}

style = {
	name = SSB_PER_focus_style

	unavailable = GFX_focus_unavailable_joint_PER
	completed = GFX_focus_completed_joint_PER
	available = GFX_focus_can_start_joint_PER
	current = GFX_focus_current_joint_PER
}

style = {
	name = SSB_IRQ_focus_style

	unavailable = GFX_focus_unavailable_joint_IRQ
	completed = GFX_focus_completed_joint_IRQ
	available = GFX_focus_can_start_joint_IRQ
	current = GFX_focus_current_joint_IRQ
}

style = {
	name = SSB_TUR_focus_style

	unavailable = GFX_focus_unavailable_joint_TUR
	completed = GFX_focus_completed_joint_TUR
	available = GFX_focus_can_start_joint_TUR
	current = GFX_focus_current_joint_TUR
}

style = {
	name = SSB_AFG_IRQ_PER_TUR_focus_style

	unavailable = GFX_focus_unavailable_joint_AFG_IRQ_PER_TUR
	completed = GFX_focus_completed_joint_AFG_IRQ_PER_TUR
	available = GFX_focus_can_start_joint_AFG_IRQ_PER_TUR
	current = GFX_focus_current_joint_AFG_IRQ_PER_TUR
}

style = {
	name = GXC_focus_style

	unavailable = GFX_focus_unavailable_joint_GXC
	completed = GFX_focus_completed_joint_GXC
	available = GFX_focus_can_start_joint_GXC
	current = GFX_focus_current_joint_GXC
}

style = {
	name = GDC_focus_style

	unavailable = GFX_focus_unavailable_joint_GDC
	completed = GFX_focus_completed_joint_GDC
	available = GFX_focus_can_start_joint_GDC
	current = GFX_focus_current_joint_GDC
}

style = {
	name = GXC_GDC_focus_style

	unavailable = GFX_focus_unavailable_joint_GDC_GXC
	completed = GFX_focus_completed_joint_GDC_GXC
	available = GFX_focus_can_start_joint_GDC_GXC
	current = GFX_focus_current_joint_GDC_GXC
}

style = {
	name = MA_focus_style

	unavailable = GFX_focus_unavailable_joint_MA
	completed = GFX_focus_completed_joint_MA
	available = GFX_focus_can_start_joint_MA
	current = GFX_focus_current_joint_MA
}

path: references/vanilla_focus_trees/china_communist.txt
content: ### search_filters = {FOCUS_FILTER_POLITICAL}
### search_filters = {FOCUS_FILTER_RESEARCH}
### search_filters = {FOCUS_FILTER_INDUSTRY}
### search_filters = {FOCUS_FILTER_STABILITY}
### search_filters = {FOCUS_FILTER_WAR_SUPPORT}
### search_filters = {FOCUS_FILTER_MANPOWER}
### search_filters = {FOCUS_FILTER_ANNEXATION}

focus_tree = {
	id = china_communist_focus
	
	country = {
		factor = 0
		modifier = {
			add = 10
			AND = {
				tag = PRC
				has_dlc = "Waking the Tiger"
				NOT = {
					has_dlc = "No Compromise, No Surrender"
				}
			}
		}
	}
	

	default = no

	continuous_focus_position = { x = 20 y = 1000 }

#	focus = {
#		id = PRC_
#		icon = GFX_
#		prerequisite = { focus = }
#		mutually_exclusive = { focus =  }
#		x = -3
#		y = 0
#		relative_position_id = 
#
#		cost = 10
#
#		ai_will_do = {
#			factor = 1
#		}
#
#		available = {
#
#		}
#		
#		bypass = {
#
#		}
#
#		cancel_if_invalid = yes
#		continue_if_invalid = no
#		available_if_capitulated = no
#
#		complete_tooltip = {
#
#		}
#
#		completion_reward = {
#
#		}
#	}
	shared_focus = CHI_invite_foreign_investors

	focus = {
		id = PRC_strengthen_the_central_secretariat
		icon = GFX_goal_generic_intelligence_exchange
		x = 2
		y = 0

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			add_political_power = 120
		}
	}

	focus = {
		id = PRC_marxist_orthodoxy
		icon = GFX_goal_support_communism
		prerequisite = { focus = PRC_strengthen_the_central_secretariat }
		mutually_exclusive = { focus = PRC_agrarian_socialism focus = PRC_social_democracy_focus }
		x = -2
		y = 1
		relative_position_id = PRC_strengthen_the_central_secretariat

		cost = 10

		ai_will_do = {
			factor = 2
			modifier = {
				has_war_with = SOV
				factor = 0
			}
		}

		available = {
			has_government = communism
			SOV = { has_government = communism }
			OR = {
				is_subject = no
				is_subject_of = SOV
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			if = {
				limit = {
					original_tag = PRC
				}
				create_country_leader = {
					name = "Wang Ming"
					desc = "POLITICS_WANG_MING_DESC"
					picture = "GFX_portrait_prc_wang_ming"
					expire = "1965.1.1"
					ideology = marxism
					traits = {
						
					}
				}
			}
		}
	}

	focus = {
		id = PRC_soviet_leadership
		icon = GFX_focus_generic_soviet_politics
		prerequisite = { focus = PRC_marxist_orthodoxy }
		x = 0
		y = 1
		relative_position_id = PRC_marxist_orthodoxy

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			NOT = {
				has_war_with = SOV
			}
			SOV = { has_government = ROOT }
			OR = {
				is_subject = no
				is_subject_of = SOV
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			remove_ideas = PRC_power_struggles
		}
	}

	focus = {
		id = PRC_soviet_economic_aid
		icon = GFX_goal_generic_soviet_construction
		prerequisite = { focus = PRC_soviet_leadership }
		x = 0
		y = 2
		relative_position_id = PRC_marxist_orthodoxy

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			NOT = { has_war_with = SOV }
			SOV = { has_government = ROOT }
			OR = {
				is_subject = no
				is_subject_of = SOV
				is_in_faction_with = SOV
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_INDUSTRY }
		completion_reward = {
			if = {
				limit = { has_idea = PRC_the_long_march_1 }
				remove_ideas = PRC_the_long_march_1
			}
			else = {
				remove_ideas = PRC_the_long_march_2 
			}
		}
	}

	focus = {
		id = PRC_internationalism
		icon = GFX_focus_generic_join_comintern
		prerequisite = { focus = PRC_soviet_economic_aid }
		x = 0
		y = 3
		relative_position_id = PRC_marxist_orthodoxy

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			SOV = { has_government = ROOT }
			NOT = {
				has_war_with = SOV
			}
			OR = {
				is_subject = no
				is_subject_of = SOV
			}
			is_in_faction = no
		}

		bypass = {
			is_in_faction_with = SOV
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			SOV = { country_event = generic.2 }
		}
	}

	focus = {
		id = PRC_agrarian_socialism
		icon = GFX_focus_prc_agrarian_socialism
		prerequisite = { focus = PRC_strengthen_the_central_secretariat }
		mutually_exclusive = { focus = PRC_marxist_orthodoxy focus = PRC_social_democracy_focus }
		x = 0
		y = 1
		relative_position_id = PRC_strengthen_the_central_secretariat

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {
			NOT = {
				has_idea = PRC_the_long_march_1
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_INDUSTRY }
		completion_reward = {
			swap_ideas = {
				remove_idea = PRC_the_long_march_1
				add_idea = PRC_the_long_march_2
			}
		}
	}

	focus = {
		id = PRC_rectification_campaign
		icon = GFX_goal_generic_forceful_treaty
		prerequisite = { focus = PRC_agrarian_socialism }
		x = 0
		y = 1
		relative_position_id = PRC_agrarian_socialism

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {
			NOT = {
				has_idea = PRC_power_struggles
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			remove_ideas = PRC_power_struggles
		}
	}

	focus = {
		id = PRC_maoism
		icon = GFX_focus_prc_maoism
		prerequisite = { focus = PRC_rectification_campaign}
		x = 0
		y = 2
		relative_position_id = PRC_agrarian_socialism

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL FOCUS_FILTER_STABILITY }
		completion_reward = {
			add_stability = 0.1
			add_ideas = PRC_maoism
		}
	}

	focus = {
		id = PRC_socialism_with_chinese_characteristics
		icon = GFX_goal_generic_war_with_comintern
		prerequisite = { focus = PRC_maoism }
		x = 0
		y = 3
		relative_position_id = PRC_agrarian_socialism

		cost = 10

		ai_will_do = {
			factor = 4
			modifier = {
				is_faction_leader = yes
				factor = 0
			}
		}

		available = {
			is_subject = no
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			set_rule = { can_create_factions = yes }
			if = {
				limit = {
					is_in_faction = no
				}
				create_faction_from_template = {
					template = faction_template_government_of_national_defense
					name = PRC_mao_faction
				}
			}
		}
	}

	focus = {
		id = PRC_proclaim_the_peoples_republic
		icon = GFX_focus_prc_proclaim_the_peoples_republic 
		prerequisite = { focus = PRC_socialism_with_chinese_characteristics focus = PRC_internationalism }
		x = -1
		y = 4
		relative_position_id = PRC_agrarian_socialism

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			strength_ratio = {
				tag = event_target:WTT_current_china_leader
				ratio > 0.5
			}
			num_of_factories > 49
			NOT = { has_idea = PRC_the_long_march_1 }
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			set_cosmetic_tag = PRC_proclaimed
			hidden_effect = {
				news_event = { id = wtt_news.37 days = 3 random_days = 3 }
			}
		}
	}

	focus = {
		id = PRC_socialist_market_economy
		icon = GFX_goal_generic_consumer_goods
		prerequisite = { focus = PRC_proclaim_the_peoples_republic focus = PRC_remove_chiang_kai_shek }
		x = 2
		y = 5
		relative_position_id = PRC_agrarian_socialism

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			OR = {
				NOT = { has_completed_focus = PRC_coalition_government }
				WTT_is_ROOT_current_leader_of_china = yes
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_INDUSTRY }
		completion_reward = {
			IF = {
				limit = {
					NOT = {
						has_character = PRC_deng_xiaoping
					}
				}
				PRC = {
					PRC_deng_xiaoping = {
						set_nationality = ROOT
					}
				}
			}
			custom_effect_tooltip = available_political_advisor
			show_ideas_tooltip = PRC_deng_xiaoping
			if = {
				limit = { has_idea = PRC_the_long_march_1 }
				remove_ideas = PRC_the_long_march_1
			}
			if = {
				limit = { has_idea = PRC_the_long_march_2 }
				remove_ideas = PRC_the_long_march_2 
			}
		}
	}

	focus = {
		id = PRC_social_democracy_focus
		icon = GFX_focus_prc_social_democracy
		prerequisite = { focus = PRC_strengthen_the_central_secretariat }
		mutually_exclusive = { focus = PRC_agrarian_socialism focus = PRC_marxist_orthodoxy }
		x = 2
		y = 1
		relative_position_id = PRC_strengthen_the_central_secretariat

		cost = 10

		ai_will_do = {
			factor = 2
			modifier = {
				has_war_with = event_target:WTT_current_china_leader
				factor = 0
			} 
		}

		available = {
			has_government = communism
			OR = {
				is_subject = no
				is_subject_of = event_target:WTT_current_china_leader
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			if = {
				limit = {
					original_tag = PRC
				}
				create_country_leader = {
					name = "Zhang Lan"
					desc = "POLITICS_ZHANG_LAN_DESC"
					picture = "GFX_portrait_prc_zhang_lan"
					expire = "1965.1.1"
					ideology = marxism
					traits = {
						
					}
				}
			}
			set_politics = {
				ruling_party = communism
				elections_allowed = yes
			}
		}
	}

	focus = {
		id = PRC_coalition_government
		icon = GFX_focus_generic_diplomatic_treaty
		prerequisite = { focus = PRC_social_democracy_focus }
		x = 0
		y = 1
		relative_position_id = PRC_social_democracy_focus

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			if = {
				limit = {
					WTT_not_taking_over_national_leadership = no				
				}
				WTT_not_taking_over_national_leadership = yes
			}
			if = {
				limit = {
					WTT_not_china_leader_refused_to_give_up_national_leadership = no
				}
				WTT_not_china_leader_refused_to_give_up_national_leadership = yes
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_ANNEXATION }
		completion_reward = {
			event_target:WTT_current_china_leader = {
				country_event = wtt_prc.1
			}
			custom_effect_tooltip = enable_power_struggle
			hidden_effect = {
				WTT_setup_political_struggle = yes
				WTT_add_ROOT_to_political_struggle = yes
			}
		}
	}

	focus = {
		id = PRC_purge_the_radicals
		icon = GFX_goal_generic_political_pressure
		prerequisite = { focus = PRC_coalition_government }
		x = 0
		y = 2
		relative_position_id = PRC_social_democracy_focus

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			remove_ideas = PRC_power_struggles
		}
	}

	focus = {
		id = PRC_strengthen_the_left_wing_of_the_kmt
		icon = GFX_goal_generic_propaganda
		prerequisite = { focus = PRC_coalition_government }
		x = 2
		y = 2
		relative_position_id = PRC_social_democracy_focus

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {

		}

		bypass = {
			WTT_CHI_is_not_leader = yes
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			CHI = { add_stability = -0.05 } 
		}
	}

	focus = {
		id = PRC_remove_chiang_kai_shek
		icon = GFX_focus_prc_remove_chiang_kai_shek
		prerequisite = { focus = PRC_strengthen_the_left_wing_of_the_kmt }
		prerequisite = { focus = PRC_purge_the_radicals }
		x = 0
		y = 3
		relative_position_id = PRC_social_democracy_focus

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			WTT_has_politcal_support_points_30 = yes
			not = { is_subject_of = event_target:WTT_current_china_leader }
		}

		bypass = {
			OR = {
				WTT_CHI_is_not_leader = yes
				NOT = { CHI = { has_country_leader = { character = CHI_chiang_kaishek } } }
			}
		}

		cancel_if_invalid = no
		continue_if_invalid = yes
		available_if_capitulated = no

		completion_reward = {
			CHI = {
				kill_country_leader = yes
				custom_effect_tooltip = loses_political_support_points_15
				subtract_from_variable = { other_political_support = 15 }
			}
			WTT_political_struggle_recalculate_support = yes			
		}
	}

	focus = {
		id = PRC_land_redistribution
		icon = GFX_goal_generic_construction
		x = 10
		y = 0
		relative_position_id = PRC_strengthen_the_central_secretariat

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {
			NOT = { PRC_has_low_popular_support = yes }
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			PRC_low_popular_support_level_down = yes
		}
	}

	focus = {
		id = PRC_the_yanan_base_area
		icon = GFX_goal_generic_construct_infrastructure
		prerequisite = { focus = PRC_land_redistribution }
		x = 6
		y = 1
		relative_position_id = PRC_land_redistribution

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			1032 = { is_fully_controlled_by = ROOT }
			622 = { is_fully_controlled_by = ROOT }
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_INDUSTRY }
		complete_tooltip = {
			1032 = {
				IF = {
					limit = {
					1032 = { infrastructure < 4 }
						}
						add_building_construction = {
							type = infrastructure
							level = 2
							instant_build = yes
						}
				}
				add_extra_state_shared_building_slots = 1
			}
			622 = {
				IF = {
					limit = {
					622 = { infrastructure < 5 }
						}
						add_building_construction = {
							type = infrastructure
							level = 1
							instant_build = yes
						}
				}
			}
		}

		completion_reward = {
			1032 = {
				IF = {
					limit = {
					1032 = { infrastructure < 4 }
						}
						add_building_construction = {
							type = infrastructure
							level = 2
							instant_build = yes
						}
				}
				ELSE_IF = {
					limit = {
					1032 = { infrastructure < 5 }
						}
						add_building_construction = {
							type = infrastructure
							level = 1
							instant_build = yes
						}
				}
				add_extra_state_shared_building_slots = 1
			}
			622 = {
				IF = {
					limit = {
					622 = { infrastructure < 5 }
						}
						add_building_construction = {
							type = infrastructure
							level = 1
							instant_build = yes
						}
				}
			}
		}
	}

	focus = {
		id = PRC_prepare_for_war_with_japan
		icon = GFX_goal_generic_major_war
		prerequisite = { focus = PRC_the_yanan_base_area }
		x = -1
		y = 1
		relative_position_id = PRC_the_yanan_base_area

		cost = 10

		ai_will_do = {
			factor = 4
			modifier = {
				JAP = {
					has_government = communism
				}
				factor = 0
			}
		}

		available = {
			not = {
				is_subject_of = JAP
			}
		}

		bypass = {
			has_war_with = JAP
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_WAR_SUPPORT }
		completion_reward = {
			add_war_support = 0.1
		}
	}

	focus = {
		id = PRC_government_of_national_defense
		icon = GFX_focus_chi_united_front
		prerequisite = { focus = PRC_prepare_for_war_with_japan }
		x = 0
		y = 1
		relative_position_id = PRC_prepare_for_war_with_japan

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			NOT = {
				has_war_with = CHI
			}
			is_subject = no
		}

		bypass = {
			is_in_faction = yes
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			if = {
				limit = {
					event_target:WTT_current_china_leader = {
						is_puppet = no
						exists = yes
					}
				}
				event_target:WTT_current_china_leader = { country_event = wtt_prc.1 }
			}
			else = {
				set_rule = { can_create_factions = yes }
				create_faction_from_template = faction_template_government_of_national_defense
			}
		}
	}

	focus = {
		id = PRC_confrontation_with_the_warlords
		icon = GFX_goal_generic_more_territorial_claims
		prerequisite = { focus = PRC_government_of_national_defense }
		x = 0
		y = 2
		relative_position_id = PRC_prepare_for_war_with_japan

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			is_subject = no
		}

		bypass = {
			OR = {
				AND = {
					is_in_faction = yes
					not = { is_in_faction_with = CHI } #in any other faction that doesn't include CHI
				}
				AND = {
					YUN = {
						OR = {
							exists = no
							is_in_faction_with = ROOT
						}
					}
					GXC = {
						OR = {
							exists = no
							is_in_faction_with = ROOT
						}
					}
					SHX = {
						OR = {
							exists = no
							is_in_faction_with = ROOT
						}
					}
					XSM = {
						OR = {
							exists = no
							is_in_faction_with = ROOT
						}
					}
					SIK = {
						OR = {
							exists = no
							is_in_faction_with = ROOT
						}
					}
				}
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_POLITICAL }
		completion_reward = {
			hidden_effect = {
				if = {
					limit = {
						is_in_faction = no
					}
					set_rule = { can_create_factions = yes }
					create_faction = chinese_united_front
				}
			}
			every_country = {
				limit = {
					is_literally_china = yes
					is_in_faction = no
					NOT = {
						tag = ROOT
					}
				}
				country_event = wtt_prc.10
			}
		}
	}

	focus = {
		id = PRC_anti_japanese_expedition
		icon = GFX_focus_AST_war_japan
		prerequisite = { focus = PRC_prepare_for_war_with_japan}
		x = -3
		y = 1
		relative_position_id = PRC_prepare_for_war_with_japan

		cost = 10

		ai_will_do = {
			factor = 4
			modifier = {
				JAP = {
					has_government = communism
				}
				factor = 0
			}
		}

		available = {
			OR = {
				MAN = {
					OR = {
						is_subject_of = JAP
						has_cosmetic_tag = MAN_kwantung_army
					}
				}
				AND = {
					MAN = {
						exists = no
					}
					JAP = {
						owns_state = 612
						owns_state = 611
						owns_state = 610
					}
				}
			}
			NOT = {
				is_subject_of = JAP
			}
		}

		bypass = {
			has_war_with = JAP
			OR = {
				has_war_with = JAP
				AND = {
					MAN = {
						is_subject = no
					}
					JAP = {
						NOT = {
							owns_state = 525
							owns_state = 527
						}
					}
				}
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			unlock_decision_category_tooltip = PRC_anti_japanese_expedition
			set_country_flag = {
				flag = JAP_delay_sweep_for_communists
				days = 100
				value = 1
			}
		}
	}

	focus = {
		id = PRC_revolutionary_military_commission
		icon = GFX_goal_generic_occupy_states_ongoing_war
		prerequisite = { focus = PRC_confrontation_with_the_warlords focus = PRC_infiltration }
		x = 0
		y = 1
		relative_position_id = PRC_confrontation_with_the_warlords

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_revolutionary_military_commission
		}
	}

	focus = {
		id = PRC_provoke_japan
		icon = GFX_goal_generic_position_armies
		prerequisite = { focus = PRC_revolutionary_military_commission }
		prerequisite = { focus = PRC_anti_japanese_expedition }
		x = -3
		y = 1
		relative_position_id = PRC_revolutionary_military_commission

		cost = 10

		ai_will_do = {
			factor = 4
			modifier = {
				JAP = {
					has_government = communism
				}
				factor = 0
			}
		}

		available = {
			NOT = {
				is_subject_of = JAP #was fun while it lasted
			}
		}

		bypass = {
			OR = {
				has_war_with = JAP
				AND = {
					MAN = {
						is_subject = no
					}
					JAP = {
						NOT = {
							owns_state = 525
							owns_state = 527
						}
					}
				}
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_ANNEXATION }
		completion_reward = {
			unlock_decision_tooltip = { decision = PRC_provoke_japan show_effect_tooltip = yes }
		}
	}

	focus = {
		id = PRC_protracted_warfare
		icon = GFX_goal_generic_army_doctrines
		prerequisite = { focus = PRC_provoke_japan }
		mutually_exclusive = { focus = PRC_mobile_warfare }
		x = -1
		y = 1
		relative_position_id = PRC_provoke_japan

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_protracted_warfare
		}
	}

	focus = {
		id = PRC_mobile_warfare
		icon = GFX_goal_generic_cavalry
		prerequisite = { focus = PRC_provoke_japan }
		mutually_exclusive = { focus = PRC_protracted_warfare }
		x = 1
		y = 1
		relative_position_id = PRC_provoke_japan

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_mobile_warfare
		}
	}

	focus = {
		id = PRC_peoples_war
		icon = GFX_focus_generic_support_the_left_right
		prerequisite = { focus = PRC_protracted_warfare }
		x = -1
		y = 2
		relative_position_id = PRC_provoke_japan

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_peoples_war
		}
	}

	focus = {
		id = PRC_100_regiments_campaign
		icon = GFX_goal_generic_territory_or_war
		prerequisite = { focus = PRC_mobile_warfare }
		x = 1
		y = 2
		relative_position_id = PRC_provoke_japan

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			unlock_decision_tooltip = PRC_launch_100_regiments_campaign
		}
	}

	focus = {
		id = PRC_central_military_commission
		icon = GFX_goal_generic_defence
		prerequisite = { focus = PRC_revolutionary_military_commission }
		x = 0
		y = 1
		relative_position_id = PRC_revolutionary_military_commission

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			swap_ideas = {
				remove_idea = PRC_revolutionary_military_commission
				add_idea = PRC_central_military_commission
			}
		}
	}

	focus = {
		id = PRC_peoples_liberation_army
		icon = GFX_goal_generic_attack_allies
		prerequisite = { focus = PRC_central_military_commission }
		x = 0
		y = 1
		relative_position_id = PRC_central_military_commission

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			has_idea = PRC_red_army_weakened
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			remove_ideas = PRC_red_army_weakened
		}
	}

	focus = {
		id = PRC_peoples_volunteer_army
		icon = GFX_goal_generic_special_forces
		prerequisite = { focus = PRC_central_military_commission }
		x = 2
		y = 1
		relative_position_id = PRC_central_military_commission

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_peoples_volunteer_army
		}
	}

	focus = {
		id = PRC_military_intelligence_department
		icon = GFX_goal_generic_intelligence_exchange
		prerequisite = { focus = PRC_revolutionary_military_commission }
		x = 4
		y = 1
		relative_position_id = PRC_revolutionary_military_commission

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = yes

		search_filters = { FOCUS_FILTER_MANPOWER }
		completion_reward = {
			if = {
				limit = {
					NOT = {
						has_character = PRC_kang_sheng
					}
				}
				PRC = {
					PRC_kang_sheng = {
						set_nationality = ROOT
					}
				}
			}
			custom_effect_tooltip = available_political_advisor
			show_ideas_tooltip = PRC_kang_sheng
		}
	}

	focus = {
		id = PRC_central_security_bureau
		icon = GFX_goal_generic_political_pressure
		prerequisite = { focus = PRC_military_intelligence_department }
		x = 0
		y = 1
		relative_position_id = PRC_military_intelligence_department

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_STABILITY }
		completion_reward = {
			add_stability = 0.1
		}
	}

	focus = {
		id = PRC_focus_on_china
		icon = GFX_goal_generic_major_war
		prerequisite = { focus = PRC_the_yanan_base_area }
		x = 1
		y = 1
		relative_position_id = PRC_the_yanan_base_area

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			not = {
				is_subject_of = event_target:WTT_current_china_leader
			}
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		completion_reward = {
			add_ideas = PRC_focus_on_china
		}
	}

	focus = {
		id = PRC_exploit_the_weak_neighbours
		icon = GFX_goal_generic_territory_or_war
		prerequisite = { focus = PRC_focus_on_china }
		x = 1
		y = 1
		relative_position_id = PRC_focus_on_china

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			OR = {
				SHX = { can_ROOT_get_wargoal_on_THIS = yes }
				XSM = { can_ROOT_get_wargoal_on_THIS = yes }
			}
		}

		bypass = {
			OR = {
				has_war_with = SHX
				has_war_with = XSM
			}
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_ANNEXATION }
		completion_reward = {
			if = {
				limit = {
					SHX = { can_ROOT_get_wargoal_on_THIS = yes }
				}
				create_wargoal = {
					type = annex_everything
					target = SHX
				}
			}
			if = {
				limit = {
					XSM = { can_ROOT_get_wargoal_on_THIS = yes }
				}
				create_wargoal = {
					type = annex_everything
					target = XSM
				}
			}
		}
	}

	focus = {
		id = PRC_infiltration
		icon = GFX_focus_prc_infiltration
		prerequisite = { focus = PRC_focus_on_china }
		x = 0
		y = 2
		relative_position_id = PRC_focus_on_china

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			event_target:WTT_current_china_leader = {
				exists = yes
				NOT = {
					has_subject = ROOT
				}
			}
		}

		bypass = {
			event_target:WTT_current_china_leader = { tag = ROOT }
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_ANNEXATION }
		completion_reward = {
			unlock_decision_category_tooltip = PRC_infiltrate_nationalist_areas
			set_country_flag = {
				flag = CHI_delay_sweep_for_communists
				days = 90
				value = 1
			}
		}
	}

	focus = {
		id = PRC_enforce_the_three_rules
		icon = GFX_goal_generic_national_unity
		prerequisite = { focus = PRC_land_redistribution }
		x = 0
		y = 1
		relative_position_id = PRC_land_redistribution

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {
			NOT = { PRC_has_low_popular_support = yes }
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_STABILITY FOCUS_FILTER_WAR_SUPPORT }
		completion_reward = {
			PRC_low_popular_support_level_down = yes
		}
	}

	focus = {
		id = PRC_permit_opium_trade
		icon = GFX_goal_generic_forceful_treaty
		prerequisite = { focus = PRC_enforce_the_three_rules}
		mutually_exclusive = { focus = PRC_ban_the_opium_trade }
		x = -1
		y = 1
		relative_position_id = PRC_enforce_the_three_rules

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_INDUSTRY }
		completion_reward = {
			add_ideas = PRC_permit_opium_trade
			add_ideas = PRC_government_corruption
		}
	}

	focus = {
		id = PRC_ban_the_opium_trade
		icon = GFX_goal_generic_political_pressure
		mutually_exclusive = { focus = PRC_permit_opium_trade }
		prerequisite = { focus = PRC_enforce_the_three_rules }
		x = 1
		y = 1
		relative_position_id = PRC_enforce_the_three_rules

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_STABILITY }
		completion_reward = {
			add_stability = 0.05
		}
	}

	focus = {
		id = PRC_abolish_the_land_rent
		icon = GFX_focus_generic_support_the_left_right
		prerequisite = { focus = PRC_permit_opium_trade focus = PRC_ban_the_opium_trade }
		x = 0
		y = 2
		relative_position_id = PRC_enforce_the_three_rules

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {
			if = {
				limit = {
					has_idea = PRC_low_popular_support_1
				}
				has_idea = PRC_low_popular_support_1
			}
			if = {
				limit = {
					has_idea = PRC_low_popular_support_2
				}
				has_idea = PRC_low_popular_support_2
			}
			if = {
				limit = {
					has_idea = PRC_low_popular_support_3
				}
				has_idea = PRC_low_popular_support_3
			}
			if = {
				limit = {
					has_idea = PRC_low_popular_support_4
				}
				has_idea = PRC_low_popular_support_4
			}
			if = {
				limit = {
					has_idea = PRC_low_popular_support_5
				}
				has_idea = PRC_low_popular_support_5
			}
		}

		bypass = {
			NOT = { PRC_has_low_popular_support = yes }
		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = no

		search_filters = { FOCUS_FILTER_STABILITY FOCUS_FILTER_WAR_SUPPORT }
		completion_reward = {
			if = { limit = { has_idea = PRC_low_popular_support_1 } remove_ideas = PRC_low_popular_support_1 }
			else_if = { limit = { has_idea = PRC_low_popular_support_2 } remove_ideas = PRC_low_popular_support_2 }
			else_if = { limit = { has_idea = PRC_low_popular_support_3 } remove_ideas = PRC_low_popular_support_3 }
			else_if = { limit = { has_idea = PRC_low_popular_support_4 } remove_ideas = PRC_low_popular_support_4 }
			else = { remove_ideas = PRC_low_popular_support_5 }
		}
	}

	focus = {
		id = PRC_literacy_programs
		icon = GFX_focus_generic_socialist_science
		prerequisite = { focus = PRC_land_redistribution }
		x = -4
		y = 1
		relative_position_id = PRC_land_redistribution

		cost = 10

		ai_will_do = {
			factor = 4
		}

		available = {

		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = yes

		search_filters = { FOCUS_FILTER_RESEARCH }
		completion_reward = {
			add_research_slot = 1
		}
	}

	focus = {
		id = PRC_china_medical_university
		icon = GFX_focus_research
		prerequisite = { focus = PRC_literacy_programs }
		x = 0
		y = 1
		relative_position_id = PRC_literacy_programs

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			num_of_factories > 34
			amount_research_slots < 5
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = yes

		search_filters = { FOCUS_FILTER_RESEARCH }
		completion_reward = {
			add_research_slot = 1
		}
	}

	focus = {
		id = PRC_form_the_academy_of_sciences
		icon = GFX_goal_generic_scientific_exchange
		prerequisite = { focus = PRC_china_medical_university }
		x = 0
		y = 2
		relative_position_id = PRC_literacy_programs

		cost = 10

		ai_will_do = {
			factor = 1
		}

		available = {
			num_of_factories > 69
			amount_research_slots < 5
		}

		bypass = {

		}

		cancel_if_invalid = yes
		continue_if_invalid = no
		available_if_capitulated = yes

		search_filters = { FOCUS_FILTER_RESEARCH }
		completion_reward = {
			add_research_slot = 1

		}
	}
}


path: references/vanilla_focus_trees/ncns_ma_clique_joint_branch.txt
content: joint_focus = {
	id = MA_develop_inter_province_ties 
	icon = GFX_goal_generic_national_unity

	x = 31
	y = 0

	cost = 10

	text_icon = MA_focus_style

	allow_branch = {
		has_dlc = "No Compromise, No Surrender"
		OR = {
			tag = XSM
			tag = NXM
			tag = GSM
			tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 15 
	}

	search_filters = { FOCUS_FILTER_POLITICAL }

	offset = {
		x = 8
		y = 0
		trigger = {
			tag = XSM
		}
	}

	offset = {
		x = 17
		y = 0
		trigger = {
			tag = KHM
		}
	}

	offset = {
		x = 4
		y = 0
		trigger = {
			OR = {
				tag = GSM
				tag = NXM
			}
		}
	}

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

	completion_reward_joint_originator = {

	}

	completion_reward = {
		
		custom_effect_tooltip = CHI_modify_ma_clique_collective_modifier_tt
		add_to_variable = { CHI_ma_clique_collective_political_power_factor = 0.05 tooltip = political_power_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_production_speed_infrastructure_factor = 0.05 tooltip = production_speed_infrastructure_factor_tt }

		custom_effect_tooltip = generic_skip_one_line_tt

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = XSM
				}
			}
			add_opinion_modifier = {
				target = XSM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = NXM
				}
			}
			add_opinion_modifier = {
				target = NXM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = GSM
				}
			}
			add_opinion_modifier = {
				target = GSM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = KHM
				}
			}
			add_opinion_modifier = {
				target = KHM
				modifier = MA_family_ties_opm 
			}	
		}

	}

	completion_reward_joint_member = {

			

	}

}

joint_focus = {
	id = MA_unified_training_program
	icon = GFX_focus_PER_recruit_bakhtiari

	prerequisite = { focus = MA_develop_inter_province_ties }

	relative_position_id = MA_develop_inter_province_ties


	x = -1
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 5
	}

	search_filters = { }

	completion_reward = {

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			army_experience = 25
		}

		custom_effect_tooltip = generic_skip_one_line_tt
		
		custom_effect_tooltip = CHI_modify_ma_clique_collective_modifier_tt
		add_to_variable = { CHI_ma_clique_collective_conscription_factor = 0.05 tooltip = conscription_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_cavalry_defence_factor = 0.05 tooltip = cavalry_defence_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_army_core_defence_factor = 0.05 tooltip = army_core_defence_factor_tt }

	}

}

joint_focus = {
	id = MA_strenghten_regional_trade 
	icon = GFX_focus_generic_economic_recovery

	prerequisite = { focus = MA_develop_inter_province_ties }

	relative_position_id = MA_develop_inter_province_ties


	x = 1
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 10
	}

	search_filters = { }

	completion_reward_joint_originator = {
		
	}

	completion_reward = {
		
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			custom_effect_tooltip = MA_strenghten_regional_trade_tt
			every_owned_state = {
				limit = {
					is_controlled_by = ROOT 
					free_building_slots = {
						building = industrial_complex
						size > 0
						include_locked = yes 
					}
					is_capital = yes 
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = industrial_complex
					level = 1
					instant_build = yes
				}
			}
		}

	}

}

joint_focus = {
	id = MA_promises_of_mutual_defense
	icon = GFX_goal_generic_defence

	prerequisite = { focus = MA_strenghten_regional_trade }
	prerequisite = { focus = MA_unified_training_program }

	relative_position_id = MA_strenghten_regional_trade


	x = -1
	y = 1

	cost = 5

	text_icon = MA_focus_style

	available = {
		is_subject = no
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 1
		modifier = {
			factor = 0 
			any_country = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
					original_tag = SIK
				}
				is_ai = no 
			}
		}
		modifier = {
			factor = 0 
			is_historical_focus_on = yes 
		}
		modifier = {
			factor = 0 
			date < 1942.1.1 
		}
	}

	search_filters = { }

	completion_reward = {

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			add_political_power = 50
		}

		custom_effect_tooltip = generic_skip_one_line_tt

		custom_effect_tooltip = MA_promises_of_mutual_defense_tt
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = XSM
				}
			}
			IF = {
				limit = {
					XSM = {
						is_subject = no
					}
				}
				give_guarantee = XSM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = NXM
				}
			}
			IF = {
				limit = {
					NXM = {
						is_subject = no
					}
				}
				give_guarantee = NXM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = GSM
				}
			}
			IF = {
				limit = {
					GSM = {
						is_subject = no
					}
				}
				give_guarantee = GSM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = KHM
				}
			}
			IF = {
				limit = {
					KHM = {
						is_subject = no
					}
				}
				give_guarantee = KHM
			}
		}
		
	}

}

joint_focus = {
	id = MA_formalize_the_ma_clique_collective
	icon = GFX_focus_generic_treaty

	prerequisite = { focus = MA_promises_of_mutual_defense }

	relative_position_id = MA_promises_of_mutual_defense


	x = 0
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		is_subject = no
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 0
	}

	search_filters = { }

	completion_reward_joint_originator = {
		
		set_rule = { can_create_factions = yes }
		create_faction_from_template = {
			template = faction_template_regional_anti_communist
			name = MA_clique_collective_faction 
			icon = GFX_faction_logo_chinese_united_front
		}
		add_faction_initiative = 1

		every_other_country = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				exists = yes 
				is_subject = no
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			hidden_effect = {
				add_ai_strategy = {
					type = befriend
					id = ROOT
					value = 100
				}
				add_opinion_modifier = {
					target = ROOT
					modifier = MA_family_ties_2_opm
				}	
				ROOT = {
					add_ai_strategy = {
						type = befriend
						id = PREV
						value = 100
					}
				}
				country_event = { id = generic.5 hours = 6 random_hours = 12 }
			}
			custom_effect_tooltip = generic_invite_to_faction_tt
		}

	}

}




Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)