Files
WT-Offline/mod-dev-docs/en/05-server-tuning.md
T
N0VAN0M4LY a2fdcc1f15 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/.
2026-12-03 11:25:54 +08:00

201 lines
11 KiB
Markdown

# 05 · Server Code-Free Tuning Overlays
The local server consolidates all offline-defined battle multipliers, session/bot capacities, web store bundles, marketplace prices, trophy chests, redeem codes, starter balances, and clan rules into **12 `.jsonc` configuration files**. Mod authors can overlay individual fields without writing a single line of code simply by placing matching `.jsonc` files inside `server/tuning/`.
> Browse all 12 default tuning files with full comments online:
> **[WT-Offline `apps/server/tuning/` Source Directory](https://git.wto-project.net/Sh3ll_in_Sh3ll/WT-Offline/src/branch/main/apps/server/tuning)**
---
## 1. Multi-Layer Merge Precedence (Watch Out for Launcher Player Overrides!)
Whenever the local server starts, each `tuning/<name>.jsonc` file is merged from lowest to highest priority (later layers override earlier ones):
```text
1. Shipped offline defaults (apps/server/tuning/<name>.jsonc)
2. Enabled Mod 1's server/tuning/<name>.jsonc
3. Enabled Mod 2's server/tuning/<name>.jsonc
... (applied top-to-bottom in Launcher "Mods" load order)
N. Player overrides saved in the Launcher "Tuning" tab (<dataFolder>/tuning/<name>.jsonc — HIGHEST PRIORITY!)
```
- **Crucial Debugging Tip**: Because **player overrides saved in the Launcher's "Tuning" tab take highest priority**, if a field in your mod's `battle.jsonc` or `new-profile.jsonc` appears to be ignored during testing, check whether your test client has a manual override saved in the Launcher **Tuning** tab (`<dataFolder>/tuning/*.jsonc`) and reset that field to default!
- Every merged configuration is validated strictly for types and numeric bounds at server startup; unknown keys or out-of-range numbers immediately report the exact file, key, and expected constraint.
---
## 2. All 12 Overlayable Tuning Files at a Glance
| File Name | Governs | Merge Structure | Typical Mod Use Cases |
| --- | --- | --- | --- |
| `battle.jsonc` | SL/RP multipliers, room size, AI bot count & respawns, `brSpreadMrank`, sub-mode chance, Strike UCAV spawn score | Flat key-value object | Custom reward rates, 16v16 capacity tweaks, tighter/wider BR spread, bot respawn counts |
| `battle-economy.jsonc` | Base action prices and battle settlement economy curves | Nested key-value object | Rebalance kills vs captures vs assists rewards |
| `store.jsonc` | GE packs, SL packs, Premium tiers, and `vehiclePacks` (`multiVehiclePacks` list, `byRank` list, `byVehicle` map) | Lists (`$listOps`) + map merge | Price custom `gift` vehicles, create custom multi-vehicle bundles |
| `marketplace.jsonc` | Marketplace vehicle/skin coupon reference prices, rarity tiers & fees | Nested object + map merge | Adjust market economy or price custom market coupons |
| `trophies.jsonc` | Classic `supplyTrophies` (SL chest, Veteran chest) & `directVehicles` GE buyout price | List (`$listOps`) + object | Add custom gacha chests, tweak rare vehicle drop weights |
| `supply-chests.jsonc` | External-inventory supply chests and drop pools | List (`$listOps`) + object | Add custom external-inventory chests |
| `recycling.jsonc` | Item recycling and crafting/re-roll recipes | Nested key-value object | Customize item recycling ratios and output weights |
| `redeem-codes.jsonc` | Dynamic Premium/GJN code prefixes and one-time `fixedCodes` | Object + map merge | Add custom promo redeem codes for your modpack |
| `new-profile.jsonc` | Starting Silver Lions, Golden Eagles, and GJN balances for new saves | Flat key-value object | High-resource sandbox presets or zero-balance hardcore presets |
| `research.jsonc` | Automatic default next-research target selection | Flat key-value object | Customize auto-selected research behavior |
| `clans.jsonc` | Squadron member caps, activity rules, and preset offline squadrons | Object + list (`$listOps`) | Add custom preset squadrons |
| `limits.jsonc` | Max items per purchase, battle report & log retention caps | Flat key-value object | Raise bulk-purchase limits or retained battle log history |
---
## 3. Recursive Key-Map Merge vs Additive List Operations (`$listOps`)
Understanding how the merger treats objects versus arrays prevents mods from clobbering one another:
1. **Plain Objects / Key-Value Maps (such as `vehiclePacks.byVehicle` and `redeem-codes.jsonc` `fixedCodes`) → Merge Recursively by Key Automatically**:
Just write the specific keys you want to add or override (e.g. `"my_new_tank": { ... }`). All other stock keys remain intact—**do not** wrap key-value maps in `$listOps`!
2. **JSON Array Properties (such as `vehiclePacks.multiVehiclePacks`, `goldenEaglePacks`, `supplyTrophies`) → Replace by Default; Use `{ "$listOps": [...] }` to Stack**:
Writing a raw array `"multiVehiclePacks": [ ... ]` replaces the entire stock and earlier-mod list! To stack items cleanly across multiple mods, set that array property to an envelope object whose **only key is `"$listOps"`** (note: if the object has any sibling keys alongside `"$listOps"`, it will NOT be recognized as a list-ops envelope!):
```jsonc
// Correct Example: server/tuning/store.jsonc
// Note: multiVehiclePacks, byRank, and byVehicle live INSIDE "vehiclePacks", and the GJN price key is "gjn"!
{
"vehiclePacks": {
// ① multiVehiclePacks is an array -> wrap in { "$listOps": [...] } to stack safely
"multiVehiclePacks": {
"$listOps": [
{
"op": "append",
"items": [
{
"id": "mod_modern_duo_pack",
"title": { "en": "Modern Duo Pack", "zh": "现代双车组合包" },
"gjn": 49.99,
"goldenEagles": 2000,
"premiumDays": 15,
"vehicles": ["us_m1a2_sep2_abrams", "germ_leopard_2a7v"]
}
]
},
{
"op": "upsertBy",
"key": "id",
"item": {
"id": "wto_pack_two_fronts",
"gjn": 19.99
}
},
{
"op": "removeBy",
"key": "id",
"value": "some_unwanted_pack_id"
}
]
},
// ② byVehicle is a key-value map (NOT an array) -> write vehicle IDs directly without $listOps!
"byVehicle": {
"us_mbt_demo": {
"gjn": 59.99,
"goldenEagles": 2000,
"premiumDays": 15
}
}
}
}
```
### All 4 Supported `$listOps` Operations
- `append`: `{ "op": "append", "items": [ ... ] }` — appends `items` to the end of the array;
- `prepend`: `{ "op": "prepend", "items": [ ... ] }` — inserts `items` at the start of the array;
- `upsertBy`: `{ "op": "upsertBy", "key": "<idField>", "item": { ... } }` — finds the first element where `entry[key] === item[key]` and recursively merges `item` into it, or appends `item` if absent;
- `removeBy`: `{ "op": "removeBy", "key": "<field>", "value": <matchValue> }` — removes every element where `entry[key] === value`.
---
## 4. Practical Field Quick-Reference & Verified Snippets
Every key name below is verified directly against `apps/server/tuning/*.jsonc` and the server's strict tuning readers:
### 4.1 `battle.jsonc` (Multipliers, Session Size, BR Spread & Bot Respawns)
```jsonc
{
"rewardMultiplierSilverLions": 2.0, // Global Silver Lions reward multiplier (default 1.0)
"rewardMultiplierResearchPoints": 2.0, // Global Research Points reward multiplier (default 1.0)
"maxPlayers": 32, // Total session slots (16v16 = 32: 1 local player + up to 31 bots)
"maxBots": 31, // Maximum AI bots (default 31)
"smallTeamsMaxPlayers": 16, // Total slots when Tactical Skies (small_teams_) rolls (default 16 = 8v8)
"subModeChance": 0.5, // Probability (0..1) of rolling an enabled sub-mode alongside classic
"brSpreadMrank": 3, // Matchmaking mrank spread (3 steps = +/- 1.0 BR; 0 = exact-BR matches)
"botPoolLimitPerType": 80, // Max vehicles per category emitted into customBots
"tankBotRespawns": 3, // Max respawns per AI bot in multi-slot Ground battles
"airBotRespawns": 2, // Max respawns per AI bot in multi-slot Air battles
"strikeUcavSpawnScore": 750, // Spawn points required for Strike UCAV in Ground RB (default 750)
"nuclearEscalationStrategicBombers": true // Enable stage-3 strategic bombers (B-52H / Tu-95M) in Air RB Nuclear Escalation
}
```
### 4.2 `store.jsonc` (Local Web Store & In-Game GE / SL / Vehicle Pack Pricing)
- Top-level keys: `goldenEaglePacks` (array), `silverLionPacks` (array), `premiumForGoldenEagles` (array), `premiumForGjn` (array), and **`vehiclePacks` (object)**;
- Inside `vehiclePacks`:
- `multiVehiclePacks` (array; use `$listOps`): each entry requires `id`, `vehicles` (non-empty unique vehicle ID array), `gjn` (min `0.01`), `goldenEagles` (int `≥0`), `premiumDays` (int `≥0`), optional `silverLions` (int `≥0`), and **exact one naming property**—either custom bilingual `"title": { "en": "...", "zh": "..." }`, tech-tree folder `"groupKey": "shop/group/..."`, or national starter pack `"starter": true`;
- `byRank` (array; fallback single-vehicle pack tiers sorted by `upToRank`): each entry has `upToRank`, `gjn`, `goldenEagles`, `premiumDays` (optional `silverLions`);
- `byVehicle` (key-value map): keyed by `gift` vehicle ID from `wpcost.blk`, with `{ "gjn"?, "goldenEagles"?, "premiumDays"?, "silverLions"? }` (omitted fields fall back to the matching `byRank` tier).
### 4.3 `new-profile.jsonc` (Starting Balances for Brand-New Saves)
```jsonc
{
"silverLions": 1000000, // Starting Silver Lions (default 150000)
"goldenEagles": 5000, // Starting Golden Eagles (default 500)
"gjn": 50 // Starting GJN balance, up to 2 decimal places (default 0)
}
```
### 4.4 `redeem-codes.jsonc` (Custom One-Time Promo Codes)
`fixedCodes` is a key-value map (redeemable once per save, case-insensitive; omitted currency fields default to `0`)—merge new codes directly by key:
```jsonc
{
"fixedCodes": {
"MYMOD-GIFT-2026": {
"silverLions": 500000,
"goldenEagles": 1000,
"premiumDays": 7,
"gjn": 25
}
}
}
```
### 4.5 `trophies.jsonc` (Adding Custom Silver Lion / Golden Eagle Trophy Chests)
`supplyTrophies` is an array—use `$listOps` to append a custom chest, and the client will automatically compute and display drop probabilities from your `weight` / `weightTotal` / `weightEach` entries:
```jsonc
{
"supplyTrophies": {
"$listOps": [
{
"op": "append",
"items": [
{
"id": "mod_lucky_trophy",
"iconStyle": "big_chest",
"silverLions": 100000,
"goldenEagles": 0,
"prizes": [
{ "silverLions": 50000, "weight": 50 },
{ "silverLions": 250000, "weight": 20 },
{ "goldenEagles": 200, "weight": 10 },
{ "item": "item_universal_spare", "count": 3, "weight": 15 },
{ "eventVehicles": { "minRank": 3, "maxRank": 7, "pick": 6 }, "weightTotal": 5 }
]
}
]
}
]
}
}
```