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:
1 parent
69d95df88e
commit
65363ce9de
12 files changed
+1684
-268
No files matched your search
@@ -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`
|
||||
|
||||
Reference in new issue
Block a user