feat(mods): support Dagor-style BLK patches and include compilation

Add native-style *.blk.patch.blk and client/config-blk.patch.blk incremental patching alongside compile-time include/includeOnce and Dagor @-directive expansion (@override, @override-last, @replace, @delete, @delete-last, @delete-all, @clone, @clone-last, @inherit, @after, @before, indexed paths, unquoted @ syntax, triple-quoted strings, packed hex colors, and CDK #/develop/gameBase/ paths) while preserving full *.blk.patch.jsonc backwards compatibility.
This commit is contained in:
N0VAN0M4LY committed 2026-12-04 02:36:16 +08:00
1 parent 69d95df88e
commit 65363ce9de
12 files changed
+1684 -268

No files matched your search

+110 -90
View File
@@ -12,7 +12,7 @@ War Thunder's Dagor Engine stores nearly all game configurations in **BLK (DataB
2. **Duplicate parameter names are allowed inside the same block**: for instance, `slaveUnit:t="launcher_a"` followed immediately by `slaveUnit:t="launcher_b"` (converting naively to a plain JSON object would overwrite the first key!);
3. **Duplicate sibling block names are allowed under the same parent**: most notably in `shop.blk`, where every army/aviation branch contains multiple sibling `range { ... }` blocks side by side.
Compare this 8-line stock text `.blk` excerpt (`us_m2a4` in `wpcost.blk`) side by side with its `.blk.patch.jsonc` patch operation:
Compare this 8-line stock text `.blk` excerpt (`us_m2a4` in `wpcost.blk`) side by side with its `.blk.patch.blk` incremental patch:
```blk
// Stock readable text BLK (excerpt from char.vromfs.bin -> config/wpcost.blk)
@@ -26,18 +26,11 @@ us_m2a4 {
}
```
```jsonc
// Matching incremental patch: client/packs/char.vromfs.bin/config/wpcost.blk.patch.jsonc
```blk
// Matching incremental patch (recommended): client/packs/char.vromfs.bin/config/wpcost.blk.patch.blk
// Touches ONLY us_m2a4's Realistic reward multiplier without clobbering other fields or other mods!
{
"ops": [
{
"op": "setParam",
"path": ["us_m2a4"],
"name": "rewardMulHistorical",
"value": { "type": "real", "value": 1.2 }
}
]
"@override:us_m2a4" {
"@override:rewardMulHistorical":r = 1.2
}
```
@@ -66,17 +59,79 @@ Place your files under `client/packs/<pack-path>/` matching the target archive's
The patcher determines how to process each file under `client/packs/<pack>/` by its filename suffix:
1. **`<target-path>.patch.jsonc` → Structured Incremental BLK Patch**: decodes the target `.blk` into a type-preserving tree, applies `ops` in order, and re-encodes a self-contained binary BLK;
1. **`<target-path>.patch.blk` (Recommended) or `<target-path>.patch.jsonc` → Incremental BLK Patch**: decodes the target `.blk` into a type-preserving tree, applies the patch in order, and re-encodes a self-contained binary BLK. Different mods may mix `.patch.blk` and `.patch.jsonc` on the same target and stack cleanly; within a single mod, pick one format per target file;
2. **`<target-path>.patch.csv` → Incremental Localization CSV Merge**: merges rows by column 0 (updating only the non-empty language columns you provide on existing keys, and appending new keys at the end);
3. **Any other file (e.g. `us_m2a4_mod_demo.blk`, `us_m2a4_mod_demo_ico.svg`) → Add or Replace File**:
- If the path ends with `.blk` and your source file is **plain text BLK** (for example, extracted and edited from your stock client), the builder automatically compiles it into **binary BLK** for the engine;
- If the path ends with `.blk` and your source file is **plain text BLK**, the builder automatically expands `include` / `includeOnce` and Dagor `@override:` / `@delete:` directives and compiles it into **binary BLK** for the engine;
- Binary `.blk` files and other assets (`.svg`, `.ddsx`, `.nut`, `.tpl`, `.css`) are written into the archive as-is.
---
## 4. Complete BLK Incremental Patch (`*.blk.patch.jsonc`) Reference
## 4. Complete BLK Incremental Patch Reference
### 4.1 Document Format & Path Addressing
Two incremental BLK patch formats are supported:
- **`*.blk.patch.blk` (Recommended)**: native Dagor BLK syntax with `include`, `@override:`, `@delete:`, and `@clone:`—compact and lets you paste stock BLK blocks directly;
- **`*.blk.patch.jsonc` (Compatible / Programmatic)**: structured JSONC op list, kept for backwards compatibility and automated generators.
### 4.1 Dagor-Style BLK Patches (`*.blk.patch.blk`) & `include` Compilation
Statements execute **strictly top-to-bottom in source order**, with identical rules in both `*.blk.patch.blk` and standalone text `.blk` files (unprefixed items always append/add; modifying existing items explicitly uses `@` directives).
#### ① File Inheritance (`include` / `includeOnce`)
| Syntax | Behavior |
| --- | --- |
| `include "germ_pzkpfw_maus.blk"` | Loads and expands the target `.blk` into the current block (resolved relative to the current pack directory; supports `../`, `/gamedata/...`, `#/gamedata/...`, and War Thunder CDK `#/develop/gameBase/...`). |
| `includeOnce "../common/smoke.blk"` | Same as `include`, but expands a given normalized path at most once per compilation. |
- `include` resolves against the live in-memory pack archive (stock files + earlier mods) as well as sibling `.blk` files in the same mod, with automatic circular-include detection;
- All `@` directives accept **both quoted** (`"@override:model":t = "..."`) and **unquoted** (`@override:model:t = "..."`, `@override:ikPilot { ... }`) Dagor syntax;
- Ideal for derived vehicles without copying thousands of stock lines:
```blk
// client/packs/aces.vromfs.bin/gamedata/units/tankmodels/germ_pzkpfw_walross.blk
include "germ_pzkpfw_maus.blk"
"@override:model":t = "pzkpfw_VIII_walross"
"@delete:commonWeapons" {}
commonWeapons {
// Paste new weapon blocks directly here
}
```
#### ② Parameter Directives
| Syntax | Behavior | Notes |
| --- | --- | --- |
| `slaveUnit:t = "extra"` | **Append param** | Preserves existing same-named params (for repeated keys) |
| `"@override:economicRankArcade":i = 18` | **Set / overwrite** | Replaces first match and deduplicates, or appends if absent (do not quote `:i` / `:r` numbers) |
| `"@override-last:slaveUnit":t = "new"` | **Overwrite last match** | Replaces only the last same-named param without touching earlier entries (appends if absent) |
| `"@delete:showOnlyWhenBought":b = no` | **Delete first** matching param | Dummy type/value is ignored; no-op if absent |
| `"@delete-last:slaveUnit":t = ""` | **Delete last** matching param | Removes only the last same-named param |
| `"@delete-all:slaveUnit":t = ""` | **Delete all** matching params | Removes every param with that name in the current block |
#### ③ Block Directives
| Syntax | Behavior | Notes |
| --- | --- | --- |
| `Weapon { ... }` | **Add child block** | Appends a new sibling block without clobbering existing same-named blocks |
| `"@override:us_m2a4" { ... }` | **Edit existing block** | Supports `name[index]` (e.g. `"@override:range[0]"`); creates the block when absent without an index |
| `"@override-last:Weapon" { ... }` | **Edit last matching block** | Edits the last sibling with that name (creates if absent) |
| `"@replace:commonWeapons" { ... }` | **Replace block in place** | Replaces the matched block in place (preserving sibling order); supports `name[index]` |
| `"@delete:commonWeapons" {}` | **Delete first** matching block | Supports `name[index]`; body must be empty |
| `"@delete-last:Weapon" {}` | **Delete last** matching block | Removes only the last sibling with that name; body must be empty |
| `"@delete-all:Weapon" {}` | **Delete all** same-named blocks | Removes all sibling blocks with that name; body must be empty |
| `"@clone:Weapon" { ... }` / `"@clone-last:Weapon" { ... }` | **Same-name clone** | Deep-clones the first/last sibling with that name, appends it, and applies body edits |
| `"@clone:us_m2a4->us_m2a4_mod" { ... }` | **Clone under new name** | Deep-clones source (supports relative `a/b/src` or root `/src`) into `newName` (replacing existing `newName` in place) and applies body edits |
| `"@inherit:base_weapon" {}` | **Inherit into block** | Copies params/blocks from a sibling or root template block into the current block (optional body applies overrides) |
| `"@after:<anchor>:<newName>" { ... }` / `"@before:<anchor>:<newName>" { ... }` | **Anchored insertion** | Inserts right after/before a sibling anchor (supports `anchor[index]` and `@clone:src->dst` as target) |
> **Typo Guard & Escaping**: Any unknown `"@xxx:..."` prefix fails immediately with a line number so misspelled directives are never silently baked into binary BLKs. Use `@@` to escape a literal leading `@`.
---
### 4.2 Structured JSONC Patches (`*.blk.patch.jsonc`, Backwards-Compatible Format)
#### Document Format & Path Addressing
```jsonc
{
@@ -302,21 +357,14 @@ Example `client/packs/lang.vromfs.bin/lang/units.csv.patch.csv`:
---
## 7. Patching Root `config.blk` (`client/config-blk.patch.jsonc`)
## 7. Patching Root `config.blk` (`client/config-blk.patch.blk` / `.jsonc`)
If your mod needs to adjust the client root `config.blk` (for example enabling sound mods via `sound{ enable_mod:b=yes }` or setting a custom hangar `hangarBlk:t="..."`), place a standard BLK patch at `client/config-blk.patch.jsonc`:
If your mod needs to adjust the client root `config.blk` (for example enabling sound mods via `sound{ enable_mod:b=yes }` or setting a custom hangar `hangarBlk:t="..."`), place a BLK patch at `client/config-blk.patch.blk` (recommended; `client/config-blk.patch.jsonc` is also supported):
```jsonc
{
"ops": [
{
"op": "setParam",
"path": ["sound"],
"name": "enable_mod",
"value": { "type": "bool", "value": true },
"createBlocks": true
}
]
```blk
// client/config-blk.patch.blk
"@override:sound" {
"@override:enable_mod":b = yes
}
```
@@ -339,12 +387,12 @@ mods/demo-standalone-m2a4/
└─ packs/
├─ aces.vromfs.bin/
│ └─ gamedata/units/tankmodels/
│ └─ us_m2a4_mod_demo.blk # ① Tank physics/armor/weapons (copied from stock us_m2a4.blk)
│ └─ us_m2a4_mod_demo.blk # ① Inherits stock us_m2a4.blk via include & boosts speed
├─ char.vromfs.bin/
│ └─ config/
│ ├─ wpcost.blk.patch.jsonc # ② Clone economy, BR, modifications & ammo racks
│ ├─ shop.blk.patch.jsonc # ③ Insert into US Army column 0 (Rank I)
│ └─ unittags.blk.patch.jsonc # ④ Clone unit class tags & test-drive mission
│ ├─ wpcost.blk.patch.blk # ② Clone economy, BR, modifications & ammo racks
│ ├─ shop.blk.patch.blk # ③ Insert into US Army column 0 (Rank I)
│ └─ unittags.blk.patch.blk # ④ Clone unit class tags & test-drive mission
└─ lang.vromfs.bin/
└─ lang/
└─ units.csv.patch.csv # ⑤ Localized _shop / _0 / _1 / _2 names
@@ -375,82 +423,54 @@ mods/demo-standalone-m2a4/
#### ① Tank Model Definition `client/packs/aces.vromfs.bin/gamedata/units/tankmodels/us_m2a4_mod_demo.blk`
Extract stock `gamedata/units/tankmodels/us_m2a4.blk` from `aces.vromfs.bin` using any method from Chapter 01 Section 2, and save it as `us_m2a4_mod_demo.blk`. Keep `model:t="m2a4"` at the top (so the engine reuses the stock M2A4 3D mesh and textures) and raise its speed and acceleration (plain text `.blk` compiles to binary automatically on build):
Inherit stock `us_m2a4.blk` directly via `include` (no need to unpack or copy thousands of stock lines) and override just its speed and acceleration (compiled to binary automatically on build):
```blk
model:t="m2a4"
// ... (keep the rest of stock us_m2a4.blk unchanged; tweak mobility below to feel the difference) ...
maxFwdSpeed:r=90.0
maxRevSpeed:r=25.0
maxAccel:r=12.0
include "us_m2a4.blk"
"@override:maxFwdSpeed":r = 90.0
"@override:maxRevSpeed":r = 25.0
"@override:maxAccel":r = 12.0
```
#### ② Economy & BR Patch `client/packs/char.vromfs.bin/config/wpcost.blk.patch.jsonc`
#### ② Economy & BR Patch `client/packs/char.vromfs.bin/config/wpcost.blk.patch.blk`
Use `cloneBlock` to copy `us_m2a4` (inheriting all weapons, shells, modifications, and backup settings), and set `reqAir` to `"us_m2a4"`, RP cost to `1000`, SL price to `500`, and all mode `mrank` values to `1` (displayed BR **1.3**):
Use `@clone:` to copy `us_m2a4` (inheriting all weapons, shells, modifications, and backup settings), and set `reqAir` to `"us_m2a4"`, RP cost to `1000`, SL price to `500`, and all mode `mrank` values to `1` (displayed BR **1.3**):
```jsonc
{
"ops": [
{
"op": "cloneBlock",
"from": ["us_m2a4"],
"toParent": [],
"newName": "us_m2a4_mod_demo",
"replaceExisting": true,
"ops": [
{ "op": "setParam", "path": [], "name": "reqAir", "value": "us_m2a4" },
{ "op": "setParam", "path": [], "name": "reqExp", "value": { "type": "int", "value": 1000 } },
{ "op": "setParam", "path": [], "name": "value", "value": { "type": "int", "value": 500 } },
{ "op": "setParam", "path": [], "name": "economicRank", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankArcade", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankHistorical", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankSimulation", "value": { "type": "int", "value": 1 } }
]
}
]
```blk
"@clone:us_m2a4->us_m2a4_mod_demo" {
"@override:reqAir":t = "us_m2a4"
"@override:reqExp":i = 1000
"@override:value":i = 500
"@override:economicRank":i = 1
"@override:economicRankArcade":i = 1
"@override:economicRankHistorical":i = 1
"@override:economicRankSimulation":i = 1
}
```
#### ③ Tech-Tree Slot Patch `client/packs/char.vromfs.bin/config/shop.blk.patch.jsonc`
#### ③ Tech-Tree Slot Patch `client/packs/char.vromfs.bin/config/shop.blk.patch.blk`
Insert `us_m2a4_mod_demo` into `country_usa -> army -> range[0]` right after `us_m3a1_stuart` (just before the `us_m5a1_stuart` Rank II break) with an explicit `reqAir: "us_m2a4"`, creating a clean Rank I side-branch arrow from `M2A4` without disturbing the stock Stuart chain:
Insert `us_m2a4_mod_demo` into `country_usa -> army -> range[0]` right after `us_m3a1_stuart` (just before the `us_m5a1_stuart` Rank II break) with an explicit `reqAir:t = "us_m2a4"`, creating a clean Rank I side-branch arrow from `M2A4` without disturbing the stock Stuart chain:
```jsonc
{
"ops": [
{
"op": "addBlock",
"path": ["country_usa", "army", "range[0]"],
"name": "us_m2a4_mod_demo",
"after": "us_m3a1_stuart",
"block": {
"params": [
{ "name": "rank", "value": { "type": "int", "value": 1 } },
{ "name": "reqAir", "value": "us_m2a4" }
]
```blk
"@override:country_usa" {
"@override:army" {
"@override:range[0]" {
"@after:us_m3a1_stuart:us_m2a4_mod_demo" {
rank:i = 1
reqAir:t = "us_m2a4"
}
}
]
}
}
```
#### ④ Unit Tags & Test-Drive Patch `client/packs/char.vromfs.bin/config/unittags.blk.patch.jsonc`
#### ④ Unit Tags & Test-Drive Patch `client/packs/char.vromfs.bin/config/unittags.blk.patch.blk`
Clone `us_m2a4` in `unittags.blk` so the new ID inherits `type:t="tank"`, `hangar_place:t="tank"`, the ground `testFlight` mission, and light-tank tags:
```jsonc
{
"ops": [
{
"op": "cloneBlock",
"from": ["us_m2a4"],
"toParent": [],
"newName": "us_m2a4_mod_demo",
"replaceExisting": true
}
]
}
```blk
"@clone:us_m2a4->us_m2a4_mod_demo" {}
```
#### ⑤ Localization Patch `client/packs/lang.vromfs.bin/lang/units.csv.patch.csv`
+111 -91
View File
@@ -12,7 +12,7 @@ Dagor 引擎使用自研的 **BLK(DataBlock)** 格式存储几乎所有游
2. **同一个块内允许出现多个同名参数**:例如 `slaveUnit:t="launcher_a"` 下面紧跟第二行 `slaveUnit:t="launcher_b"`(如果直接转成普通 JSON 对象,前一行就会被后一行覆盖丢失!);
3. **同一个父块下允许并列多个同名子块**:最典型的就是科技树 `shop.blk`,每个陆军/空军分支下并列着好几个同名的 `range { ... }` 子块。
对比下面这段 8 行原版文本 `.blk`(节选自 `wpcost.blk` 的 `us_m2a4`)与对应的 `.blk.patch.jsonc` 增量补丁,你立刻就能看懂两者的对应关系:
对比下面这段 8 行原版文本 `.blk`(节选自 `wpcost.blk` 的 `us_m2a4`)与对应的 `.blk.patch.blk` 增量补丁,你立刻就能看懂两者的对应关系:
```blk
// 原版可读文本 BLK(char.vromfs.bin -> config/wpcost.blk 节选)
@@ -26,18 +26,11 @@ us_m2a4 {
}
```
```jsonc
// 对应的增量补丁:client/packs/char.vromfs.bin/config/wpcost.blk.patch.jsonc
```blk
// 对应的增量补丁(推荐格式):client/packs/char.vromfs.bin/config/wpcost.blk.patch.blk
// 只修改 us_m2a4 的历史模式收益倍率,不会影响其他模组对别的字段或载具的改动
{
"ops": [
{
"op": "setParam",
"path": ["us_m2a4"],
"name": "rewardMulHistorical",
"value": { "type": "real", "value": 1.2 }
}
]
"@override:us_m2a4" {
"@override:rewardMulHistorical":r = 1.2
}
```
@@ -66,17 +59,79 @@ us_m2a4 {
构建器根据你在 `client/packs/<包>/` 下放置的文件名自动决定处理方式:
1. **`<原路径>.patch.jsonc` → BLK 结构化增量补丁**:解析目标 `.blk` 为保留完整类型的内存树,按 `ops` 逐条修改后重新编码为自包含二进制 BLK 写回;
1. **`<原路径>.patch.blk`(推荐)或 `<原路径>.patch.jsonc` → BLK 增量补丁**:解析目标 `.blk` 为保留完整类型的内存树,按顺序应用补丁并重新编码为自包含二进制 BLK 写回。不同模组可对同一目标混用 `.patch.blk` 与 `.patch.jsonc` 并按加载顺序叠加;单个模组内对同一目标请二选一;
2. **`<原路径>.patch.csv` → CSV 本地化增量合并**:按第 1 列词条键合并进目标 `.csv`(已有键只更新你填写的语言列,新键追加到表尾);
3. **其余文件(如 `us_m2a4_mod_demo.blk`、`us_m2a4_mod_demo_ico.svg`)→ 新增或替换文件**:
- 如果路径以 `.blk` 结尾且你的源文件是**可读文本 BLK**(如从原版客户端解包修改得到的),构建器会自动将其编译为游戏引擎所需的**二进制 BLK** 写进包内;
- 如果路径以 `.blk` 结尾且你的源文件是**可读文本 BLK**,构建器会自动展开其中的 `include` / `includeOnce` 与 `@override:` / `@delete:` 等 Dagor 指令,并编译为游戏引擎所需的**二进制 BLK** 写进包内;
- 如果已经是二进制 BLK,或是 `.svg` / `.ddsx` / `.nut` / `.tpl` / `.css`,则原样写入包内。
---
## 4. BLK 增量补丁(`*.blk.patch.jsonc`)完整手册
## 4. BLK 增量补丁完整手册
### 4.1 基本格式与路径寻址
构建器同时支持两套 BLK 增量补丁格式:
- **`*.blk.patch.blk`(首选推荐)**:Dagor 原生 BLK 语法,直接支持粘贴原版 BLK 子块、`include` 继承与 `@override:` / `@delete:` / `@clone:` 指令,写法最紧凑;
- **`*.blk.patch.jsonc`(向后兼容 / 脚本生成)**:结构化 JSONC 操作列表,适合自动化脚本生成与已有旧模组兼容。
### 4.1 Dagor 风格 BLK 增量补丁(`*.blk.patch.blk`)与 `include` 编译
所有语句**严格按源码从上到下顺序执行**,且在 `*.blk.patch.blk` 与新增文本 `.blk` 中**语义完全统一**(无前缀永远表示新增/追加,修改已有项显式使用 `@` 指令)。
#### ① 文件引入指令(`include` / `includeOnce`)
| 语法 | 作用 |
| --- | --- |
| `include "germ_pzkpfw_maus.blk"` | 在当前块位置读取并展开目标 `.blk`(相对当前文件在 pack 内的目录;也支持 `../`、包根路径 `/gamedata/...`、`#/gamedata/...` 及战雷 CDK 路径 `#/develop/gameBase/...`)。 |
| `includeOnce "../common/smoke.blk"` | 同 `include`,但在同一次编译链路中同一文件只展开一次。 |
- `include` 会直接查找当前 pack 内存档案(包含原版文件与前置模组修改后的结果)以及同模组内其他待写入 `.blk` 文件,且自动检测循环引用;
- 所有 `@` 指令同时支持**带引号**(`"@override:model":t = "..."`)和**不带引号**(`@override:model:t = "..."`、`@override:ikPilot { ... }`)两种战雷原生写法;
- 非常适合基于原版载具派生新车,无需复制几千行原版 `.blk`:
```blk
// client/packs/aces.vromfs.bin/gamedata/units/tankmodels/germ_pzkpfw_walross.blk
include "germ_pzkpfw_maus.blk"
"@override:model":t = "pzkpfw_VIII_walross"
"@delete:commonWeapons" {}
commonWeapons {
// 直接粘贴新的武器块即可
}
```
#### ② 参数(Param)指令
| 语法 | 作用 | 说明 |
| --- | --- | --- |
| `slaveUnit:t = "extra"` | **追加参数** | 保留已有同名参数,适合可重复键 |
| `"@override:economicRankArcade":i = 18` | **覆盖/设值** | 存在则覆盖首个并去重,不存在则新增(注意数值 `:i` / `:r` 不要加引号) |
| `"@override-last:slaveUnit":t = "new"` | **覆盖末项** | 只替换最后一个同名参数,不动前面同名项(不存在则追加) |
| `"@delete:showOnlyWhenBought":b = no` | **删除首个**同名参数 | 占位类型/值会被忽略,不存在则静默跳过 |
| `"@delete-last:slaveUnit":t = ""` | **删除末项**同名参数 | 只删最后一个同名参数 |
| `"@delete-all:slaveUnit":t = ""` | **删除全部**同名参数 | 清空当前块内全部同名参数 |
#### ③ 子块(Block)指令
| 语法 | 作用 | 说明 |
| --- | --- | --- |
| `Weapon { ... }` | **新增子块** | 追加同名子块(不会覆盖已有同名块) |
| `"@override:us_m2a4" { ... }` | **进入已有块修改** | 支持 `name[index]`(如 `"@override:range[0]"`);不带索引且块不存在时自动新建 |
| `"@override-last:Weapon" { ... }` | **进入末个同名块修改** | 修改最后一个同名子块(不存在则新建) |
| `"@replace:commonWeapons" { ... }` | **原地整块替换** | 原地替换为全新子块(保持原本排序位置);支持 `name[index]` |
| `"@delete:commonWeapons" {}` | **删除首个**匹配子块 | 支持 `name[index]`;花括号必须为空 |
| `"@delete-last:Weapon" {}` | **删除末个**同名子块 | 只删最后一个同名子块;花括号必须为空 |
| `"@delete-all:Weapon" {}` | **删除全部**同名子块 | 清空全部同名子块;花括号必须为空 |
| `"@clone:Weapon" { ... }` / `"@clone-last:Weapon" { ... }` | **同名克隆** | 深拷贝首个/末个同名子块并追加,在花括号内微调 |
| `"@clone:us_m2a4->us_m2a4_mod" { ... }` | **改名克隆** | 深拷贝源块(支持 `a/b/src` 相对路径与 `/root/src` 根路径)为新名(若目标已存在则原地替换),并在花括号内微调 |
| `"@inherit:base_weapon" {}` | **块内继承** | 将同级或根级模板块的内容拷入当前块(花括号内可继续写覆写语句) |
| `"@after:<锚点>:<新块名>" { ... }` / `"@before:<锚点>:<新块名>" { ... }` | **科技树锚点插队** | 插在指定兄弟块之后/之前(锚点支持 `name[index]`;也可写 `"@after:us_m2a4:@clone:us_m2a4->new_tank"`) |
> **拼写保护与转义**:任何未注册的 `"@xxx:..."` 前缀都会直接报带行号的错误(防止拼错指令被静默写入二进制);若极少数情况需要字面量以 `@` 开头,可用 `@@` 转义为单个 `@`。
---
### 4.2 JSONC 结构化增量补丁(`*.blk.patch.jsonc`,兼容与脚本生成格式)
#### 基本格式与路径寻址
```jsonc
{
@@ -302,21 +357,14 @@ CSV 补丁文件写法示例(`client/packs/lang.vromfs.bin/lang/units.csv.patc
---
## 7. 修改游戏根目录 `config.blk`(`client/config-blk.patch.jsonc`)
## 7. 修改游戏根目录 `config.blk`(`client/config-blk.patch.blk` / `.jsonc`)
如果模组需要调整游戏根目录的 `config.blk`(例如开启音效模组开关 `sound{ enable_mod:b=yes }` 或指定自定义机库 `hangarBlk:t="..."`),放一份标准 BLK 补丁到 `client/config-blk.patch.jsonc` 即可:
如果模组需要调整游戏根目录的 `config.blk`(例如开启音效模组开关 `sound{ enable_mod:b=yes }` 或指定自定义机库 `hangarBlk:t="..."`),放一份 BLK 补丁到 `client/config-blk.patch.blk`(推荐,同样兼容 `client/config-blk.patch.jsonc`)即可:
```jsonc
{
"ops": [
{
"op": "setParam",
"path": ["sound"],
"name": "enable_mod",
"value": { "type": "bool", "value": true },
"createBlocks": true
}
]
```blk
// client/config-blk.patch.blk
"@override:sound" {
"@override:enable_mod":b = yes
}
```
@@ -339,12 +387,12 @@ mods/demo-standalone-m2a4/
└─ packs/
├─ aces.vromfs.bin/
│ └─ gamedata/units/tankmodels/
│ └─ us_m2a4_mod_demo.blk # ① 载具物理/装甲/武器定义(基于原版 us_m2a4.blk 修改)
│ └─ us_m2a4_mod_demo.blk # ① 通过 include 继承原版 us_m2a4.blk 并调高极速
├─ char.vromfs.bin/
│ └─ config/
│ ├─ wpcost.blk.patch.jsonc # ② 克隆经济、分房权重、改装件与弹药架
│ ├─ shop.blk.patch.jsonc # ③ 挂入美系陆军第 1 列 I 级科技树
│ └─ unittags.blk.patch.jsonc # ④ 克隆载具分类标签与试车场配置
│ ├─ wpcost.blk.patch.blk # ② 克隆经济、分房权重、改装件与弹药架
│ ├─ shop.blk.patch.blk # ③ 挂入美系陆军第 1 列 I 级科技树
│ └─ unittags.blk.patch.blk # ④ 克隆载具分类标签与试车场配置
└─ lang.vromfs.bin/
└─ lang/
└─ units.csv.patch.csv # ⑤ 注册 _shop / _0 / _1 / _2 中英文名称
@@ -375,82 +423,54 @@ mods/demo-standalone-m2a4/
#### ① 载具实体参数 `client/packs/aces.vromfs.bin/gamedata/units/tankmodels/us_m2a4_mod_demo.blk`
按第 01 章第 2 节任一方式取出原版 `aces.vromfs.bin` 中的 `gamedata/units/tankmodels/us_m2a4.blk`(文本或二进制均可),另存为 `us_m2a4_mod_demo.blk`。保持顶部的 `model:t="m2a4"` 不变(这样它会直接复用原版 M2A4 的 3D 模型和贴图),把里面的最大前进速度和加速改快即可(文本 `.blk` 在构建时会自动编译为二进制 `.blk`):
直接用 `include "us_m2a4.blk"` 继承原版 `aces.vromfs.bin` 中的同目录 `us_m2a4.blk`(无需手工解包复制几千行原版文件),只用 `@override:` 调高最大前进速度和加速(构建时会自动展开并编译为二进制 `.blk`):
```blk
model:t="m2a4"
// ...(保留原版 us_m2a4.blk 其余内容不变,仅调高以下机动参数体验效果)...
maxFwdSpeed:r=90.0
maxRevSpeed:r=25.0
maxAccel:r=12.0
include "us_m2a4.blk"
"@override:maxFwdSpeed":r = 90.0
"@override:maxRevSpeed":r = 25.0
"@override:maxAccel":r = 12.0
```
#### ② 经济与权重补丁 `client/packs/char.vromfs.bin/config/wpcost.blk.patch.jsonc`
#### ② 经济与权重补丁 `client/packs/char.vromfs.bin/config/wpcost.blk.patch.blk`
用 `cloneBlock` 一键复制 `us_m2a4`(自动继承全部武器、弹种、改装件与备用车配置),并把研发前提设为 `us_m2a4`、研发点设为 `1000`、银狮价格设为 `500`、三模式分房权重设为 `1`(即面板 **1.3**):
用 `@clone:` 一键复制 `us_m2a4`(自动继承全部武器、弹种、改装件与备用车配置),并把研发前提设为 `us_m2a4`、研发点设为 `1000`、银狮价格设为 `500`、三模式分房权重设为 `1`(即面板 **1.3**):
```jsonc
{
"ops": [
{
"op": "cloneBlock",
"from": ["us_m2a4"],
"toParent": [],
"newName": "us_m2a4_mod_demo",
"replaceExisting": true,
"ops": [
{ "op": "setParam", "path": [], "name": "reqAir", "value": "us_m2a4" },
{ "op": "setParam", "path": [], "name": "reqExp", "value": { "type": "int", "value": 1000 } },
{ "op": "setParam", "path": [], "name": "value", "value": { "type": "int", "value": 500 } },
{ "op": "setParam", "path": [], "name": "economicRank", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankArcade", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankHistorical", "value": { "type": "int", "value": 1 } },
{ "op": "setParam", "path": [], "name": "economicRankSimulation", "value": { "type": "int", "value": 1 } }
]
}
]
```blk
"@clone:us_m2a4->us_m2a4_mod_demo" {
"@override:reqAir":t = "us_m2a4"
"@override:reqExp":i = 1000
"@override:value":i = 500
"@override:economicRank":i = 1
"@override:economicRankArcade":i = 1
"@override:economicRankHistorical":i = 1
"@override:economicRankSimulation":i = 1
}
```
#### ③ 科技树位置补丁 `client/packs/char.vromfs.bin/config/shop.blk.patch.jsonc`
#### ③ 科技树位置补丁 `client/packs/char.vromfs.bin/config/shop.blk.patch.blk`
在 `country_usa -> army -> range[0]` 的 I 级段末尾(`us_m3a1_stuart` 之后、`us_m5a1_stuart` 断线之前)插入新车块,并显式声明 `reqAir: "us_m2a4"`,游戏就会在不打断原有斯图亚特研发线的前提下,从 `M2A4` 连出一条侧支研发箭头指向你的新车:
在 `country_usa -> army -> range[0]` 的 I 级段末尾(`us_m3a1_stuart` 之后、`us_m5a1_stuart` 断线之前)插入新车块,并显式声明 `reqAir:t = "us_m2a4"`,游戏就会在不打断原有斯图亚特研发线的前提下,从 `M2A4` 连出一条侧支研发箭头指向你的新车:
```jsonc
{
"ops": [
{
"op": "addBlock",
"path": ["country_usa", "army", "range[0]"],
"name": "us_m2a4_mod_demo",
"after": "us_m3a1_stuart",
"block": {
"params": [
{ "name": "rank", "value": { "type": "int", "value": 1 } },
{ "name": "reqAir", "value": "us_m2a4" }
]
```blk
"@override:country_usa" {
"@override:army" {
"@override:range[0]" {
"@after:us_m3a1_stuart:us_m2a4_mod_demo" {
rank:i = 1
reqAir:t = "us_m2a4"
}
}
]
}
}
```
#### ④ 载具标签与试驾场补丁 `client/packs/char.vromfs.bin/config/unittags.blk.patch.jsonc`
#### ④ 载具标签与试驾场补丁 `client/packs/char.vromfs.bin/config/unittags.blk.patch.blk`
同样用 `cloneBlock` 从 `us_m2a4` 克隆出 `type:t="tank"`、机库车位 `hangar_place:t="tank"`、陆战试车场 `testFlight` 与轻坦标签:
同样用 `@clone:` 从 `us_m2a4` 克隆出 `type:t="tank"`、机库车位 `hangar_place:t="tank"`、陆战试车场 `testFlight` 与轻坦标签:
```jsonc
{
"ops": [
{
"op": "cloneBlock",
"from": ["us_m2a4"],
"toParent": [],
"newName": "us_m2a4_mod_demo",
"replaceExisting": true
}
]
}
```blk
"@clone:us_m2a4->us_m2a4_mod_demo" {}
```
#### ⑤ 多语言名称补丁 `client/packs/lang.vromfs.bin/lang/units.csv.patch.csv`