docs(mods): fix schema errors and expand bilingual mod handbook to full parity

Fix store.jsonc vehiclePacks nesting and gjn field name, matchingApiFunc callback argument order, and DaGui CSS @import/lowercase rules; add stock archive inspection steps, BR-to-mrank table, cloned vehicle walkthrough, tuning field reference, and official-map-selector full-stack trace while bringing en/01..07.md to full 1:1 parity with zh-CN/.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 11:25:54 +08:00
1 parent e79866b96e
commit a2fdcc1f15
15 files changed
+2320 -468

No files matched your search

+106 -46
View File
@@ -1,40 +1,87 @@
# 01 · Quick Start & Manifest Reference
> **Target Spec**: `format: 1` · `api_version: "0.1-experimental"` (experimental; subject to breaking changes)
> **Target Spec**: `format: 1` · `api_version: "0.1-experimental"` (experimental API; subject to breaking changes as core development progresses)
## 1. Additive Mod Architecture
## 1. Core Concept: Additive Overlay Architecture
WTOffline uses a **stackable, additive** mod architecture. Mods supply incremental patches and added files rather than replacing full `.vromfs.bin` archives:
WTOffline uses a **stackable, load-order additive** mod architecture. Mods supply incremental patches and added files to the client and server, and **do not replace whole stock `.vromfs.bin` archives**:
1. Before launching the game, the launcher starts from clean stock backups (`wtoffline/stock/`), applies core offline patches first, then layers every enabled mod's client patches and added files in the order shown on the **Mods** page;
2. Large 3D model and texture addons mount across drives with zero copying via **Windows NTFS Directory Junctions**;
3. The local server extracts static data from the overlaid packs, layers `server/tuning/*.jsonc` in the same order, and loads `server/index.ts` scripts;
4. Disabling a mod or switching presets cleanly unmounts junctions and restores stock packs.
1. Before launching the game, the launcher starts from clean stock backups (`<copy>/wtoffline/stock/`), applies core offline patches first, and then layers every enabled mod's client patches and added files in the exact order shown on the **Mods** page;
2. Large 3D model and texture addons mount across drives with zero file copying via **Windows NTFS Directory Junctions**;
3. When the local server starts, it automatically extracts static game data from the overlaid client packs, merges each mod's `server/tuning/*.jsonc` in the same order, and loads `server/index.ts` scripts;
4. When you disable a mod or switch presets, the launcher automatically unmounts junctions and restores clean files from `wtoffline/stock/` without corrupting the client copy.
- **Global repository**: defaults to `%APPDATA%\WTOffline Launcher\mods` (configurable to any drive under **Mods › Presets & repository**).
- **Per-client configuration**: toggles, load order, and presets live in each client's `<dataPath>/mods-config.json`.
- **Global mod repository**: defaults to `%APPDATA%\WTOffline Launcher\mods` (configurable to any drive under **Mods › Presets & repository**).
- **3 official templates seeded on first launch**: the first time the launcher initializes the global `mods/` folder, it automatically seeds **`example-vehicle-tweak`** (code-free vehicle & localization tweak), **`example-server-script`** (minimal server TypeScript mod), and **`official-map-selector`** (full-stack native DaGui modal + server map filter), all disabled by default. Click **Mods › Open mods folder** right away to inspect their code or duplicate one as a starting point!
- **Per-client configuration**: mod toggles, load order, and named presets are saved independently per client in `<dataFolder>/mods-config.json`.
---
## 2. Build Your First Mod in 5 Minutes
## 2. Prerequisite: How to Unpack & Inspect Stock Game Files
1. Open **Mods › Open mods folder** in the launcher.
2. Create a folder `my-first-mod` containing `mod.jsonc`:
Before tweaking vehicle stats, wiring tech-tree entries, or patching UI scripts, you need to look up stock internal vehicle IDs (for example, the US reserve light tank M2A4 is `us_m2a4`, and the M1A2 SEP V2 is `us_m1a2_sep2_abrams`) and stock file paths.
### 2.1 Where Stock Archives Live in the Game Client
Inside your War Thunder client folder (and offline copy folder), stock game data lives inside `.vromfs.bin` virtual filesystem archives:
| Stock Archive Path (relative to client root) | Key Contents Inside |
| --- | --- |
| `char.vromfs.bin` | Tech-tree layout (`config/shop.blk`), vehicle prices/RP/BR/modifications (`config/wpcost.blk`), unit classification tags (`config/unittags.blk`), items, and unlocks |
| `aces.vromfs.bin` | Tank models & armor (`gamedata/units/tankmodels/*.blk`), aircraft flight models (`gamedata/flightmodels/*.blk`), ships, shells, and missiles (`gamedata/weapons/...`) |
| `gui.vromfs.bin` | All client UI Quirrel scripts (`scripts/**/*.nut`), Handyman templates (`gui/**/*.tpl`), and DaGui stylesheets (`gui/**/*.css`) |
| `lang.vromfs.bin` | Localization tables (`lang/units.csv` vehicle names, `lang/menu.csv` UI strings, `lang/units_weaponry.csv` weapons & ammo names) |
| `ui/atlases.vromfs.bin` | Tech-tree and local web store vehicle silhouette icons (`gameuiskin/<unit_id>_ico.svg`) |
| `ui/images.vromfs.bin` | Stat-card and crew-slot vehicle portraits (`units/<unit_id>.ddsx`) |
> **Note on the backup folder**: Treat `<copy>/wtoffline/stock/` as read-only. The launcher relies on `wtoffline/stock/` to rebuild overlays and restore clean files when mods are disabled; modifying files inside `stock/` can prevent automatic restoration. Place all mod changes under `mods/<your-mod>/`.
### 2.2 Practical Ways to Inspect Stock Files
You can inspect stock `.blk`, `.csv`, and `.nut` files directly from your own local game installation:
1. **Local unpacking with community tools**:
Copy `char.vromfs.bin`, `aces.vromfs.bin`, or `gui.vromfs.bin` from your client into a separate scratch folder (avoid unpacking in-place inside the game directory) and use standard community `.vromfs.bin` / `.blk` unpacking tools to extract readable text `.blk` and `.nut` files, vehicle IDs, and tech-tree paths.
2. **5-line Node 24 snippet using `@wto/vromfs` + `@wto/blk` (if you cloned the WTOffline repo)**:
If you have the WTOffline repository checked out locally, run Node 24 from the repo root to decode any binary `.blk` straight out of a `.vromfs.bin` archive and print formatted text BLK:
```js
import { readFileSync } from 'node:fs';
import { getFile, NAME_MAP_PATH, readArchive } from './packages/vromfs/src/index.ts';
import { decodeBlk, formatBlkText, parseSharedNameMap } from './packages/blk/src/index.ts';
const ar = readArchive(readFileSync('C:/WarThunder/char.vromfs.bin'));
const dict = [...ar.files.entries()].find(([k]) => k.endsWith('.dict'))?.[1];
console.log(formatBlkText(decodeBlk(getFile(ar, 'config/wpcost.blk'), { names: ar.files.has(NAME_MAP_PATH) ? parseSharedNameMap(getFile(ar, NAME_MAP_PATH), dict).names : [], dictionary: dict })));
```
---
## 3. Build Your First Mod in 5 Minutes
1. Open **Mods › Open mods folder** in the launcher (you will already see the 3 official template folders inside for reference);
2. Create a new folder named `my-first-mod`;
3. Create the manifest file `my-first-mod/mod.jsonc`:
```jsonc
{
"format": 1,
"id": "demo.my-first-mod",
"name": { "en": "My First Mod", "zh-CN": "我的第一个模组" },
"name": {
"zh-CN": "我的第一个模组",
"en": "My First Mod"
},
"version": "0.1.0",
"author": "YourName",
"description": "Doubles Silver Lions and Research Points battle rewards.",
"description": {
"zh-CN": "把对局银狮和研发点倍率调整为 2 倍。",
"en": "Doubles Silver Lions and Research Points battle rewards."
},
"api_version": "0.1-experimental",
"game_versions": ["2.61.0.*"]
}
```
3. Create `my-first-mod/server/tuning/battle.jsonc`:
4. Create `my-first-mod/server/tuning/battle.jsonc`:
```jsonc
{
@@ -43,22 +90,22 @@ WTOffline uses a **stackable, additive** mod architecture. Mods supply increment
}
```
4. Return to the launcher (the Mods page refreshes automatically on focus), enable your mod, and click **Launch**.
5. Switch back to the launcher window (the Mods page refreshes automatically on focus, or click **Refresh**), enable your mod, and click **Launch**.
---
## 3. Standard Folder Layout
## 4. Complete Standard Folder Layout
Create only the folders your mod actually needs:
Create only the subdirectories your mod actually uses—unused folders can be omitted completely:
```text
<mod-folder>/
├─ mod.jsonc # Required: manifest
├─ server/ # Optional: server extensions
│ ├─ tuning/ # *.jsonc tuning overlays
│ └─ index.ts (or index.mjs / .js) # server script entry
└─ client/ # Optional: client extensions
├─ packs/ # .vromfs.bin additive overlays
├─ mod.jsonc # Required: mod manifest
├─ server/ # Optional: server-side extensions
│ ├─ tuning/ # incremental tuning overlays (*.jsonc)
│ └─ index.ts (or index.mjs / .js) # server script entry (auto-detected by default)
└─ client/ # Optional: client-side extensions
├─ packs/ # .vromfs.bin archive overlays
│ ├─ char.vromfs.bin/
│ ├─ aces.vromfs.bin/
│ ├─ gui.vromfs.bin/
@@ -67,39 +114,52 @@ Create only the folders your mod actually needs:
│ ├─ game.vromfs.bin/
│ ├─ ui/atlases.vromfs.bin/
│ └─ ui/images.vromfs.bin/
├─ addon/ # 3D model & texture pack (res/*.grp, res/*.dxp.bin)
├─ gui-patches/ # declarative GUI script patches
├─ exe-patches/ # declarative exe patches
├─ addon/ # 3D model & texture addon (res/*.grp, res/*.dxp.bin)
├─ gui-patches/ # incremental GUI script/tpl/css patches (same format as patches/gui)
├─ exe-patches/ # declarative exe patches (same format as patches/exe)
├─ files/ # optional companion skins/sights/sounds/missions
└─ config-blk.patch.jsonc # optional root config.blk patch
└─ config-blk.patch.jsonc # optional root config.blk incremental patch
```
---
## 4. `mod.jsonc` Schema Reference
## 5. Full `mod.jsonc` Schema Reference
Unknown fields are rejected by strict validation.
Manifest parsing enforces **strict whitelist validation**: typos or unknown keys are rejected immediately with a detailed error message on the Launcher Mods page.
| Field | Required | Type | Description |
| --- | --- | --- | --- |
| `format` | Yes | `1` | Manifest format version (currently `1`) |
| `id` | Yes | `string` | Globally unique ID matching `/^[a-z0-9][a-z0-9._-]{0,63}$/` |
| `name` | Yes | `string \| { [lang]: string }` | Display name (plain string or locale map) |
| `version` | Yes | `string` | Mod version (SemVer recommended) |
| `format` | Yes | `1` | Manifest schema version, currently fixed to integer `1` |
| `id` | Yes | `string` | Globally unique mod ID matching `/^[a-z0-9][a-z0-9._-]{0,63}$/` (lowercase letters, digits, `.`, `_`, `-`; must start with letter/digit; max 64 chars; `<author>.<mod-name>` recommended) |
| `name` | Yes | `string \| { [lang]: string }` | Display name as a plain string or locale map (e.g. `zh-CN`, `en`) |
| `version` | Yes | `string` | Mod version string (SemVer such as `0.1.0` recommended) |
| `author` | Yes | `string` | Author or team name |
| `description` | No | `string \| { [lang]: string }` | Short description |
| `api_version` | Yes | `string` | Target API tag, currently `"0.1-experimental"` |
| `game_versions` | No | `string[]` | Game version wildcards (e.g. `["2.61.0.*"]`); mismatch warns only |
| `requires` | No | `string[]` | Required dependency mod IDs (blocking error if missing/disabled) |
| `conflicts` | No | `string[]` | Incompatible mod IDs (blocking error if both enabled) |
| `load_after` | No | `string[]` | Recommended load-order predecessors (used by Auto-sort) |
| `load_before` | No | `string[]` | Recommended load-order successors |
| `server` | No | `{ entry?: string, tuning?: string }` | Custom relative paths for server script entry and tuning folder |
| `description` | No | `string \| { [lang]: string }` | Short summary as a plain string or locale map |
| `api_version` | Yes | `string` | Target API version tag, currently fixed to `"0.1-experimental"` |
| `game_versions` | No | `string[]` | Supported game build wildcards (e.g. `["2.61.0.*"]`); mismatches emit a warning without blocking launch |
| `requires` | No | `string[]` | Required dependency mod IDs: missing or disabled dependencies raise a **blocking error**; also enforces load order (emits a `dependency-order` warning if placed above its dependency and participates in **Auto-Sort**) |
| `conflicts` | No | `string[]` | Mutually incompatible mod IDs; enabling both raises a **blocking error** |
| `load_after` | No | `string[]` | Optional mods this mod should load after (lower in the list = higher priority); does not require them to be enabled, and participates in order hints & **Auto-Sort** |
| `load_before` | No | `string[]` | Optional mods this mod should load before; also participates in order hints & **Auto-Sort** |
| `server` | No | `{ entry?: string, tuning?: string }` | Explicit relative paths (no `..`) overriding default auto-detection of `server/index.{ts,mjs,js}` and `server/tuning` |
---
## 5. Load Order, Risk Badges & Conflict Detection
## 6. Automatically Computed Capability & Risk Badges (Additive Multi-Badge)
- **Priority**: items lower in the list load later and take higher priority.
- **Risk badges**: automatically inferred as `data`, `gui`, `script`, and `exe`.
- **Conflict checks**: missing/disabled dependencies and declared conflicts block launching; whole-file overrides warn; shared BLK/CSV/tuning overlays report informational merge notices.
After scanning each mod folder, the launcher computes capability badges automatically. **Badges are additive, not mutually exclusive**—for example, a mod with pack overlays and a server script displays both `data` and `script`, while `official-map-selector` displays `data`, `gui`, and `script`:
- **Data / Assets (`data`)**: contains `server/tuning/`, `client/packs/`, `client/addon/`, `client/files/`, or `client/config-blk.patch.jsonc` (a manifest-only mod with none of `gui`/`script`/`exe` also defaults to `data`);
- **UI Patches (`gui`)**: contains `client/gui-patches/`;
- **Server Script (`script`)**: contains an executable server JS/TS entry script;
- **Binary Patches (`exe`)**: contains `client/exe-patches/` (high-risk; guarded by the core offline isolation patch lock).
---
## 7. Load Order Rules & Conflict Detection
- **Load order & priority**: mods load **top-to-bottom; items lower in the list (larger index) load later and take higher priority**;
- **One-click Auto-Sort**: the launcher's **Auto-sort by dependencies** button topologically sorts mods using `requires`, `load_after`, and `load_before` together;
- **Additive merge** (`info`): when multiple mods patch the same BLK, CSV, or `tuning` file, their edits stack cleanly in load order;
- **Order & override warnings** (`warning`): emitted when a mod sits above a `requires` / `load_after` target, mismatches `game_versions`, or replaces an entire pack/companion file already modified by an earlier mod;
- **Blocking errors** (`error`): missing `requires` dependencies, disabled dependencies, or simultaneously enabled `conflicts` prevent launch and highlight the exact items to fix.