Files
WT-Offline/mod-dev-docs/en/01-quick-start.md
T

166 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 01 · Quick Start & Manifest Reference
> **Target Spec**: `format: 1` · `api_version: "0.1-experimental"` (experimental API; subject to breaking changes as core development progresses)
## 1. Core Concept: Additive Overlay Architecture
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 (`<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 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. Prerequisite: How to Unpack & Inspect Stock Game Files
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": {
"zh-CN": "我的第一个模组",
"en": "My First Mod"
},
"version": "0.1.0",
"author": "YourName",
"description": {
"zh-CN": "把对局银狮和研发点倍率调整为 2 倍。",
"en": "Doubles Silver Lions and Research Points battle rewards."
},
"api_version": "0.1-experimental",
"game_versions": ["2.61.0.*"]
}
```
4. Create `my-first-mod/server/tuning/battle.jsonc`:
```jsonc
{
"rewardMultiplierSilverLions": 2.0,
"rewardMultiplierResearchPoints": 2.0
}
```
5. Switch back to the launcher window (the Mods page refreshes automatically on focus, or click **Refresh**), enable your mod, and click **Launch**.
---
## 4. Complete Standard Folder Layout
Create only the subdirectories your mod actually uses—unused folders can be omitted completely:
```text
<mod-folder>/
├─ 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/
│ ├─ lang.vromfs.bin/
│ ├─ mis.vromfs.bin/
│ ├─ game.vromfs.bin/
│ ├─ ui/atlases.vromfs.bin/
│ └─ ui/images.vromfs.bin/
├─ 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.blk # optional root config.blk incremental patch (also accepts .patch.jsonc)
```
---
## 5. Full `mod.jsonc` Schema Reference
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 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 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` |
---
## 6. Automatically Computed Capability & Risk Badges (Additive Multi-Badge)
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.blk` (or `.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.