Files
WT-Offline/mod-dev-docs/en/03-custom-3d-vehicles.md

98 lines
8.3 KiB
Markdown

# 03 · Adding Custom 3D Vehicle Models & Textures
This chapter explains how to build **brand-new 3D vehicle mods shipping custom geometry (`.grp`) and texture packs (`.dxp.bin`)** in WTOffline so multiple vehicle packs from different authors stack cleanly, mount across drives with zero copying, and roll back cleanly when disabled.
---
## 1. Plain-Language Asset Glossary & Zero-Copy Mounting
When working with 3D vehicle mods, you will encounter four core asset and filesystem terms:
| Term / Extension | Plain-Language Meaning |
| --- | --- |
| **`.grp`** | Dagor Engine **3D geometry & skeleton archive** (exported from the official War Thunder CDK `AssetViewer` / exporter), containing multi-LOD meshes, animation skeleton nodes (`animChar`), collision volumes, and internal damage-model (DM) parts. |
| **`.dxp.bin`** | Dagor Engine **compressed texture pack**, bundling multiple diffuse, normal, and metallic/roughness DDSx textures referenced by name inside `.grp` materials. |
| **`.ddsx`** | A **single** Dagor compressed texture file (DDSx), commonly used for UI stat-card vehicle portraits (`ui/images.vromfs.bin/units/<unit_id>.ddsx`) or standalone skin textures. |
| **NTFS Directory Junction** | Think of it as an **OS-level zero-copy folder shortcut** built into Windows NTFS: when the game engine opens `<copy>/content/pkg_user/<modId>`, Windows transparently serves the files straight from your `mods/` folder on any drive—**no administrator rights needed, works across drives, consumes 0 extra disk bytes, and mounts/unmounts in ~1 ms**! |
### How the Engine Discovers `client/addon/` Automatically
Verified directly against 2.61.0.x `aces.exe` (`dlContent.cpp`) and `aces.vromfs.bin/config/settings.blk`:
- The patcher automatically registers every enabled mod's addon mount path into `addons`, `addons_no_check`, and `addonsWithBasePath` inside `config/settings.blk`;
- Any addon path under `/pkg_user/` (mounted by default at `<copy>/content/pkg_user/<safeModId>`) **skips the mandatory `res/grp_hdr.vromfs.bin` header check and directly scans `<addon>/res/` for all `.grp` model and `.dxp.bin` texture archives**, registering them into the global asset manager;
- If your mod ships an official CDK-compiled `res/grp_hdr.vromfs.bin`, the patcher mounts it at `<copy>/content/pkg_wto_<safeModId>` so the native `grp_hdr` loader handles it;
- Disabling a mod removes only the directory junction itself and never deletes or modifies your source files inside `mods/`.
---
## 2. 6-Step Checklist for a Custom 3D Vehicle
Suppose your mod ID is `demo.new-mbt` and your new vehicle's internal ID is `us_mbt_demo`:
```text
mods/demo-new-mbt/
├─ mod.jsonc
└─ client/
├─ addon/
│ └─ res/
│ ├─ us_mbt_demo.grp # ① 3D meshes, skeleton & collision (CDK export)
│ └─ us_mbt_demo.dxp.bin # ① Compressed texture pack (DDSx)
└─ packs/
├─ aces.vromfs.bin/
│ └─ gamedata/units/tankmodels/
│ └─ us_mbt_demo.blk # ② Physics, armor, turret & weapons (text BLK compiles automatically)
├─ char.vromfs.bin/
│ └─ config/
│ ├─ wpcost.blk.patch.blk # ③ Price, RP, BR & modifications (fastest via @clone:; .patch.jsonc also supported)
│ ├─ shop.blk.patch.blk # ④ Tech-tree column & position
│ └─ unittags.blk.patch.blk # ④ Unit class, hangar slot, test-drive mission & tags
├─ lang.vromfs.bin/
│ └─ lang/
│ └─ units.csv.patch.csv # ⑤ Localized names (_shop, _0, _1, _2)
├─ ui/atlases.vromfs.bin/
│ └─ gameuiskin/
│ └─ us_mbt_demo_ico.svg # ⑥ Tech-tree & local web store silhouette icon (all lowercase!)
└─ ui/images.vromfs.bin/
└─ units/
└─ us_mbt_demo.ddsx # ⑥ Stat-card / crew-slot portrait (optional; falls back to placeholder)
```
### Key Verification Checks
1. **Keep the vehicle's internal ID identical everywhere**: the `tankmodels/us_mbt_demo.blk` filename (or `flightmodels/us_jet_demo.blk` for aircraft) and the block names in `wpcost.blk`, `shop.blk`, and `unittags.blk` must match character for character.
2. **`ui/atlases.vromfs.bin` icon paths must be all lowercase**: stock icon packs store paths in lowercase, so name your icon `gameuiskin/<lowercase_unit_id>_ico.svg` (the local web store also displays this exact SVG on pack cards!).
3. **Match `.blk` asset names to `.grp` exports**: `model:t="..."` inside `gamedata/units/tankmodels/us_mbt_demo.blk` must match the exact asset name exported into your `.grp` archive from the CDK.
---
## 3. Regular Tech-Tree Vehicles vs `gift` Store Packs (& AI Bot Pool Rules)
In `wpcost.blk.patch.blk` and `shop.blk.patch.blk` (or `.patch.jsonc`), you can wire your custom vehicle either as a **regular Silver Lions researchable vehicle** or as a **local web store pack vehicle**:
### Option A: Regular Silver Lions Tech-Tree Vehicle (Recommended If You Want AI Bots to Drive It)
- Set normal `value` (Silver Lions price) and `reqExp` (Research Points) in `wpcost.blk`, and **omit** `gift`, `premPackAir`, `costGold`, `event`, and `researchType` (squadron tag), as well as `showOnlyWhenBought:b=yes` in `shop.blk`;
- **Automatically joins the AI bot pool**: the local server's matchmaking bot selector (`battle-ranks.ts`) automatically includes tech-tree vehicles (`inTechTree` in `shop.blk`) that have **none** of `gift`, `premPackAir`, `event`, `researchType`, or `showOnlyWhenBought`! Both friendly and enemy AI bots at matching BRs and nations will spawn in your custom vehicle during offline battles.
### Option B: Local Web Store Pack Vehicle (`gift:t="msi_notebook"`)
Modders inspecting stock `wpcost.blk` / `shop.blk` often wonder: **why do dozens of pack vehicles say `gift:t="msi_notebook"`?**
- In stock War Thunder, any non-empty `gift:t="..."` string (Gaijin historically reused promo strings like `"msi_notebook"` across countless store vehicles) marks the vehicle as an external store pack/gift unit whose **Order** button opens the web store instead of spending Silver Lions or Golden Eagles;
- **WTOffline auto-generates a local web store bundle**: during copy building, WTOffline scans every vehicle carrying `gift` in `wpcost.blk` and automatically registers a deterministic local store product ID **`wto_pack_<unitId>`** (e.g. `wto_pack_us_mbt_demo`) and bundle GUID:
- Even with zero server config, the local web store automatically prices the pack using `vehiclePacks.byRank` for the vehicle's `rank` tier so players can buy and unlock it right away in the in-game store!
- To customize its GJN price, Golden Eagles bonus, or Premium days, simply add an entry under `vehiclePacks.byVehicle` in `server/tuning/store.jsonc` (see Chapter 05).
- **AI Bot Pool Note**: vehicles carrying `gift`, `premPackAir`, `event`, `researchType`, or `showOnlyWhenBought` are intentionally **excluded** from the automatic AI bot pool so rare pack prototypes do not flood standard bot lineups.
---
## 4. Companion Skins, Sights, Sounds & the Native Folder Boundary
- **Standalone skins, sights & single-player missions**: players should continue placing standalone files directly into the game's native `UserSkins/`, `UserSights/`, and `UserMissions/` folders—the launcher never touches or deletes player-managed native folders, and they **do not** need to be wrapped as mods;
- **Companion assets bundled inside a large vehicle overhaul mod**: if your custom vehicle mod includes dedicated camouflages, custom FCS gun sights, or custom cannon sound banks, place them under `client/files/` so they mount and unmount together with the mod:
- `client/files/UserSkins/mod_us_mbt_demo_camo/...` (mod-exclusive subfolder → mounts across drives via zero-copy NTFS Junction)
- `client/files/UserSights/us_mbt_demo/...` (mod-exclusive subfolder → mounts across drives via zero-copy NTFS Junction)
- `client/files/sound/mod/my_cannon.bank` (shared flat directory file → tries file symlink → same-drive hardlink → size/mtime incremental cached copy)
- **Native Player File Protection**: if any target path under `client/files/` already exists in the game folder as a player-created native file or folder, the launcher skips that item with a log warning and **never overwrites or deletes player content**.