docs(mods): add standalone mod-dev-docs handbook and launcher quick-open button
This commit is contained in:
1 parent
5983e3f3e2
commit
aa952e7cca
26 files changed
+1619
-145
No files matched your search
@@ -0,0 +1,105 @@
|
||||
# 01 · Quick Start & Manifest Reference
|
||||
|
||||
> **Target Spec**: `format: 1` · `api_version: "0.1-experimental"` (experimental; subject to breaking changes)
|
||||
|
||||
## 1. Additive Mod Architecture
|
||||
|
||||
WTOffline uses a **stackable, additive** mod system and does **not** accept whole-pack `.vromfs.bin` replacements:
|
||||
|
||||
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.
|
||||
|
||||
- **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`.
|
||||
|
||||
---
|
||||
|
||||
## 2. Build Your First Mod in 5 Minutes
|
||||
|
||||
1. Open **Mods › Open mods folder** in the launcher.
|
||||
2. Create a folder `my-first-mod` containing `mod.jsonc`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"format": 1,
|
||||
"id": "demo.my-first-mod",
|
||||
"name": { "en": "My First Mod", "zh-CN": "我的第一个模组" },
|
||||
"version": "0.1.0",
|
||||
"author": "YourName",
|
||||
"description": "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`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"rewardMultiplierSilverLions": 2.0,
|
||||
"rewardMultiplierResearchPoints": 2.0
|
||||
}
|
||||
```
|
||||
|
||||
4. Return to the launcher (the Mods page refreshes automatically on focus), enable your mod, and click **Launch**.
|
||||
|
||||
---
|
||||
|
||||
## 3. Standard Folder Layout
|
||||
|
||||
Create only the folders your mod actually needs:
|
||||
|
||||
```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
|
||||
│ ├─ 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 pack (res/*.grp, res/*.dxp.bin)
|
||||
├─ gui-patches/ # declarative GUI script patches
|
||||
├─ exe-patches/ # declarative exe patches
|
||||
├─ files/ # optional companion skins/sights/sounds/missions
|
||||
└─ config-blk.patch.jsonc # optional root config.blk patch
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. `mod.jsonc` Schema Reference
|
||||
|
||||
Unknown fields are rejected by strict validation.
|
||||
|
||||
| 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) |
|
||||
| `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 |
|
||||
|
||||
---
|
||||
|
||||
## 5. Load Order, Risk Badges & Conflict Detection
|
||||
|
||||
- **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.
|
||||
@@ -0,0 +1,53 @@
|
||||
# 02 · Client Packs & BLK Incremental Patching
|
||||
|
||||
## 1. Supported `.vromfs.bin` Packs
|
||||
|
||||
Place overlays under `client/packs/<pack-path>/`:
|
||||
- **Always rebuilt from stock**: `char.vromfs.bin`, `aces.vromfs.bin`, `gui.vromfs.bin`
|
||||
- **On-demand backup & restore**: `lang.vromfs.bin`, `mis.vromfs.bin`, `game.vromfs.bin`, `ui/atlases.vromfs.bin`, `ui/images.vromfs.bin`
|
||||
|
||||
Because the local server extracts static datasets directly from the overlaid packs on startup, vehicles added or edited in `shop.blk` and `wpcost.blk` automatically flow into research trees, prices, modifications, AI pools, and offline store bundle GUIDs.
|
||||
|
||||
---
|
||||
|
||||
## 2. File Handling Rules
|
||||
|
||||
1. **`<target>.patch.jsonc`** — Type-preserving structured BLK patch applied to `<target>` inside the pack.
|
||||
2. **`<target>.patch.csv`** — Semicolon-separated localization CSV merger keyed by column 0.
|
||||
3. **Any other file** — Added or replaced directly. Plain text `.blk` files are compiled to binary BLK automatically before packing.
|
||||
|
||||
---
|
||||
|
||||
## 3. BLK Patch Operations (`*.blk.patch.jsonc`)
|
||||
|
||||
Every patch file has `{ "ops": [...] }`. Path segments support indexed sibling selectors such as `"range[2]"` (zero-based).
|
||||
|
||||
- **`setParam`**: `{ "op": "setParam", "path": [...], "name": "...", "value": ..., "createBlocks": false }`
|
||||
- **`addParam`**: appends a repeated parameter without removing existing entries (ideal for `slaveUnit`, `folder`, `aircraftGift`).
|
||||
- **`removeParam`**: removes all matching params by `name` (or only those matching optional `value`).
|
||||
- **`upsertBlock`**: finds or creates a block along `path` and merges `block.params` and `block.blocks`.
|
||||
- **`addBlock`**: inserts a new child block (`before` / `after` sibling anchor optional).
|
||||
- **`removeBlock`**: deletes the block at `path`.
|
||||
- **`cloneBlock`**: deep-clones an existing block (`from`) into `toParent` under `newName`, optionally applying nested `ops` rooted at the cloned block (fastest way to derive a modded vehicle in `wpcost.blk`).
|
||||
|
||||
### Explicit BLK Types
|
||||
|
||||
Use `{ "type": "<blkType>", "value": <val> }` whenever an exact Dagor BLK type is needed:
|
||||
`string`, `int`, `real`, `bool`, `int64`, `point2`, `point3`, `point4`, `ipoint2`, `ipoint3`, `ipoint4`, `color` (`[r,g,b,a]` or packed `0xAARRGGBB`), `matrix` (12 reals).
|
||||
|
||||
---
|
||||
|
||||
## 4. Localization CSV Patches (`*.csv.patch.csv`)
|
||||
|
||||
```csv
|
||||
"<ID|readonly|noverify>";"<English>";"<Chinese>";"<HChinese>"
|
||||
"my_custom_tank_shop";"M1A2 Mod";"M1A2 魔改型";"M1A2 魔改型"
|
||||
```
|
||||
|
||||
Existing keys update only the supplied non-empty language columns; new keys are appended cleanly.
|
||||
|
||||
---
|
||||
|
||||
## 5. Root `config.blk` Patches (`client/config-blk.patch.jsonc`)
|
||||
|
||||
Uses the exact same BLK patch format against `<copy>/config.blk`. The launcher backs up the stock `config.blk` automatically and restores it when no enabled mod patches it.
|
||||
@@ -0,0 +1,33 @@
|
||||
# 03 · Adding Custom 3D Vehicle Models & Textures
|
||||
|
||||
## 1. How 3D Asset Mounting Works
|
||||
|
||||
Verified directly against 2.61.0.x `aces.exe` (`dlContent.cpp`) and `config/settings.blk`:
|
||||
- Any addon path under `/pkg_user/` skips the `res/grp_hdr.vromfs.bin` check and directly scans `<addon>/res/` for all `.grp` (3D geometry/skeleton/collision) and `.dxp.bin` (DDSx texture) archives;
|
||||
- If a mod ships a compiled CDK `res/grp_hdr.vromfs.bin`, the patcher mounts it under `content/pkg_wto_<modId>` so the native `grp_hdr` loader handles it;
|
||||
- The patcher automatically registers all enabled mod addon folders in `aces.vromfs.bin` `config/settings.blk` (`addons`, `addons_no_check`, `addonsWithBasePath`).
|
||||
|
||||
### Cross-Drive Zero-Copy Mounting
|
||||
|
||||
Each mod's `client/addon/` is mounted into `<copy>/content/pkg_user/<safeModId>` via a **Windows NTFS Directory Junction**:
|
||||
- Works across drives (e.g. `mods/` on C: or D:, client on J:);
|
||||
- Requires no administrator privileges;
|
||||
- Uses 0 extra bytes and mounts/unmounts in ~1 ms without touching source files in `mods/`.
|
||||
|
||||
---
|
||||
|
||||
## 2. 6-Step Checklist for a Custom 3D Vehicle
|
||||
|
||||
1. **`client/addon/res/<unit>.grp` + `<unit>.dxp.bin`**: 3D model and textures exported via War Thunder CDK;
|
||||
2. **`client/packs/aces.vromfs.bin/gamedata/units/.../<unit>.blk`**: vehicle FM/DM/weapons (plain text BLK compiles automatically);
|
||||
3. **`client/packs/char.vromfs.bin/config/wpcost.blk.patch.jsonc`**: economy, BR, modifications (use `cloneBlock` from a similar stock vehicle);
|
||||
4. **`client/packs/char.vromfs.bin/config/shop.blk.patch.jsonc`** & **`unittags.blk.patch.jsonc`**: tech tree slot and unit tags;
|
||||
5. **`client/packs/lang.vromfs.bin/lang/units.csv.patch.csv`**: localized names (`_shop`, `_0`, `_1`, `_2`);
|
||||
6. **`client/packs/ui/atlases.vromfs.bin/gameuiskin/<lowercase_unit>_ico.svg`** & optional **`ui/images.vromfs.bin/units/<unit>.ddsx`**: silhouette icon (used in tech tree and local web store) and statcard image.
|
||||
|
||||
---
|
||||
|
||||
## 3. Native Skins, Sights & Companion Files Boundary
|
||||
|
||||
- Standalone user skins (`UserSkins/`), sights (`UserSights/`), and missions (`UserMissions/`) continue to use the game's native folders and are never managed or deleted by the launcher.
|
||||
- Large overhaul/vehicle mods may optionally bundle companion skins, sights, or sound banks under `client/files/`. Exclusive subdirectories under `UserSkins/`, `UserSights/`, and `UserMissions/` mount via cross-drive Junctions; any target colliding with a player-owned native file is skipped with a warning and never overwritten.
|
||||
@@ -0,0 +1,33 @@
|
||||
# 04 · Client GUI Patches & Declarative EXE Patches
|
||||
|
||||
> **Experimental Notice**: GUI script patches and declarative `exe` patches depend on target client builds and may need updates after game or core patches.
|
||||
|
||||
---
|
||||
|
||||
## 1. Extending Client UI (Recommended Pattern)
|
||||
|
||||
1. Place new standalone `.nut`, `.tpl`, and `.css` files under `client/packs/gui.vromfs.bin/` (keep paths lowercase to match stock archive conventions);
|
||||
2. Place minimal entry-point edits under `client/gui-patches/<patch-name>/` using `patch.jsonc` + `find.nut` / `replace.nut` fragments.
|
||||
|
||||
Core offline GUI patches always run first; mod GUI patches apply afterward in load order. Every `find` snippet must match uniquely once or the patch is skipped safely. `{{LOCAL_ENDPOINT}}` in replacement text expands to `127.0.0.1:<port>`.
|
||||
|
||||
### Mandatory Quirrel Bytecode Check
|
||||
|
||||
Before shipping any new or patched `.nut` script, compile the complete resulting script with `compilestring` via `sq.exe` to catch lexical scope conflicts, reserved keywords (such as `base`), and forward references that would otherwise hang login at "Loading":
|
||||
|
||||
```powershell
|
||||
& "build\quirrel-cli\bin\Release\sq.exe" -e "local f = compilestring(readfile('your_script.nut'), 'your_script.nut'); println('OK')"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Declarative EXE Patches (`client/exe-patches/`)
|
||||
|
||||
Mods reuse WTOffline's `@wto/exepatch` format (`patch.jsonc` with `id`, `title`, `features`, `requires`, and `variants` using `signature`, `string_ref`, or `within` locators). **Never distribute modified `aces.exe` binaries.**
|
||||
|
||||
### Core Isolation Lock (Hard Security Boundary)
|
||||
|
||||
1. Core offline and isolation patches are planned first and their byte ranges are locked;
|
||||
2. Any mod `exe` patch whose write range overlaps a protected core patch is **rejected** (`overlaps protected core patch`);
|
||||
3. Overlapping patches between two mods reject the later patch with the conflicting mod ID;
|
||||
4. Unmatched patterns on another game build are skipped cleanly and logged without breaking the core build.
|
||||
@@ -0,0 +1,31 @@
|
||||
# 05 · Server Code-Free Tuning Overlays
|
||||
|
||||
The local server stores all offline-defined economy, battle, store, marketplace, chest, redeem-code, clan, and limit values in **12 `.jsonc` tuning files**. Mods can overlay any of them under `server/tuning/<name>.jsonc` without writing code.
|
||||
|
||||
## 1. Merge Precedence
|
||||
|
||||
1. Shipped defaults (`apps/server/tuning/<name>.jsonc`)
|
||||
2. Enabled mods' `server/tuning/<name>.jsonc` in load order
|
||||
3. Player overrides (`<dataFolder>/tuning/<name>.jsonc`, highest priority)
|
||||
|
||||
## 2. All 12 Tuning Files
|
||||
|
||||
`battle.jsonc`, `battle-economy.jsonc`, `store.jsonc`, `marketplace.jsonc`, `trophies.jsonc`, `supply-chests.jsonc`, `recycling.jsonc`, `redeem-codes.jsonc`, `new-profile.jsonc`, `research.jsonc`, `clans.jsonc`, `limits.jsonc`.
|
||||
|
||||
## 3. Additive List Operations (`$listOps`)
|
||||
|
||||
Objects merge recursively by key; plain arrays replace the previous array. To stack items across multiple mods without clobbering, wrap list edits in `{ "$listOps": [...] }`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"multiVehiclePacks": {
|
||||
"$listOps": [
|
||||
{ "op": "append", "items": [{ "id": "mod_duo_pack", "priceGjn": 49.99, "vehicles": ["us_m2a4"] }] },
|
||||
{ "op": "upsertBy", "key": "id", "item": { "id": "wto_pack_two_fronts", "priceGjn": 19.99 } },
|
||||
{ "op": "removeBy", "key": "id", "value": "some_pack_id" }
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Supported ops: `append`, `prepend`, `upsertBy`, `removeBy`.
|
||||
@@ -0,0 +1,40 @@
|
||||
# 06 · Server JS/TS Scripting API Reference
|
||||
|
||||
> **Experimental Warning (API `0.1-experimental`)**: All server script contracts, internal catalogue classes, and hook shapes are unstable and may change across releases without backwards compatibility.
|
||||
|
||||
## 1. Runtime & TypeScript Rules
|
||||
|
||||
Server scripts run inside Electron 43's bundled **Node.js 24** with built-in TypeScript type stripping (`erasableSyntaxOnly` syntax: no `enum`, `namespace`, or parameter properties). Pre-bundled `.mjs` / `.js` files are also supported.
|
||||
|
||||
Default entry lookup order: `server/index.ts` → `server/index.mjs` → `server/index.js` (or explicit `server.entry` in `mod.jsonc`).
|
||||
|
||||
```ts
|
||||
export default {
|
||||
async setup(ctx) {
|
||||
ctx.logger.info('mod initialized');
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Full TypeScript definitions live in `packages/mods/src/server-api.ts`.
|
||||
|
||||
## 2. `WtoServerModContext`
|
||||
|
||||
- `apiVersion`, `manifest`, `modDir`, `gameFolder`, `dataFolder`, `port`
|
||||
- `logger`: `{ info(msg), warn(msg), error(msg) }` (prefixed with `[mod:<id>]`)
|
||||
- `storage`:
|
||||
- `storage.forPlayer(userId)` → atomic JSON file under `<dataFolder>/saves/<userId>/mods/<modId>.json` (never mutate stock `profile.blk` with custom keys)
|
||||
- `storage.shared()` → `<dataFolder>/mods-data/<modId>.json`
|
||||
- `hooks`:
|
||||
- `onDatasetsLoaded(datasets)` — inspect/mutate `vehicles`, `battleEconomy`, `battleSpawnRules`, `multiplayerMissions`, `uiLabels`, `unitNames`, or `get(id)` / `set(id, value)`
|
||||
- `onCataloguesReady(catalogues)` — access `tuning`, `gameModes`, `profiles`, `accounts`, `research`, `equipment`, `repair`, `store`, `inventory`, `trophies`, `items`, `crew`, `decor`, `unlocks`, `clans`, `battleMatchmaker`, `battleEconomy`, `battleStreaks`, `notifyInventoryChanged()`, `notifyUser(userId, eventName, payload)`
|
||||
- `onServerListening({ port })` / `onServerClosing()`
|
||||
- `profile.onRefresh(profile, userId)`
|
||||
- `battle.onBeforeMatchmake({ userId, eventName, request })`
|
||||
- `battle.onFilterMissions({ userId, modeId, modeName, economicName, minMrank, maxMrank, missions })` — return a filtered/reordered subset of candidate missions (empty results safely fall back to the prior pool)
|
||||
- `battle.onLiveFact({ userId, roomId, fact })`
|
||||
- `battle.onAfterSettle({ userId, roomId, summary })`
|
||||
- `routes`:
|
||||
- `routes.char.register(action, handler)` / `routes.char.wrap(action, wrapper)`
|
||||
- `routes.matching.register(method, handler)` / `routes.matching.wrap(method, wrapper)` (callable from client Quirrel via `matchingApiFunc`)
|
||||
- `routes.http.register(subPath, handler)` — automatically namespaced under `/mods/<modId>/...` (supports exact paths and `/*` wildcards)
|
||||
@@ -0,0 +1,21 @@
|
||||
# 07 · Troubleshooting & Best Practices
|
||||
|
||||
## 1. Where to Check Logs
|
||||
|
||||
Open **Settings › Diagnostics › Open logs folder** or **About › Export diagnostics**:
|
||||
- **`launcher.log`**: filter `[build]` for pack/GUI/exe patch reports, `[mods]` for Junction mount and native-file conflict warnings, and `[mod:<id>]` for server script logs and stack traces.
|
||||
- **`<copy>/.game_logs/*.clog`**: client Quirrel runtime errors and `[PACK]` / `pkg_user` asset loading logs.
|
||||
|
||||
## 2. Common Issues
|
||||
|
||||
- **Discovery error in Mods page**: check `mod.jsonc` JSON syntax, unknown keys, `id` format, and `server.entry` path.
|
||||
- **Blocking errors on Launch**: enable missing `requires` dependencies or disable one of two mutually conflicting mods.
|
||||
- **Node TS syntax error**: avoid `enum`/`namespace`/parameter properties in raw `.ts`, or bundle to `.mjs`.
|
||||
- **`overlaps protected core patch`**: mod `exe` patch collided with a locked core isolation patch; choose a non-overlapping site.
|
||||
- **Client hangs at "Loading"**: run full `sq.exe` `compilestring` bytecode checks on all modified/added `.nut` files.
|
||||
|
||||
## 3. Cross-Drive & Non-NTFS Behavior
|
||||
|
||||
- NTFS drives mount `client/addon/` and exclusive `UserSkins/`/`UserSights/`/`UserMissions/` folders via cross-drive **NTFS Directory Junctions** (no admin required, 0 extra space).
|
||||
- Flat shared files (`sound/mod/*.bank`) try file symlink → same-drive hardlink → size/mtime cached copy.
|
||||
- exFAT drives automatically fall back to incremental cached copies.
|
||||
Reference in new issue
Block a user