# Project Cold Water & Sculpt Engine — Modding Guide
This guide covers creating, editing, scripting, packaging, and hosting custom **Weapons**, **Vehicles**, **Reusable Map Stamps**, **Maps & Missions**, **Custom Grid Maps (`.cwgrid.json`)**, **MapGen Asset Palettes**, **ColdFlux / Luau Scripts**, and **Asset Packs (`.cwassetopack.json`)** in **Project Cold Water** and **Sculpt Engine**.
You can author almost everything visually inside the in-engine **Asset Studio** and **Grid & Palette Studio**, or write/tweak the JSON and Luau files directly.
See [`README.md`](README.md) for general controls and CLI flags, and [`ARCHITECTURE.md`](ARCHITECTURE.md) for internal engine details.
---
## Table of Contents
1. [Modding Folder Layout & Reloading](#1-modding-folder-layout--reloading)
2. [CSG Sculpting, Materials & Procedural Modifiers](#2-csg-sculpting-materials--procedural-modifiers)
3. [Custom Weapons (`mods/weapons/`)](#3-custom-weapons-modsweapons)
4. [Custom Vehicles & Turrets (`mods/vehicles/`)](#4-custom-vehicles--turrets-modsvehicles)
5. [Reusable Map Stamps (`mods/stamps/`)](#5-reusable-map-stamps-modsstamps)
6. [Maps, Missions & Default AI Behavior (`mods/maps/`)](#6-maps-missions--default-ai-behavior-modsmaps)
7. [Custom Grids (`.cwgrid.json`) & Asset Palettes (`mods/mapgen_palettes/`)](#7-custom-grids-cwgridjson--asset-palettes-modsmapgen_palettes)
8. [ColdFlux & Luau Scripting (`mods/scripts/`, `F9`)](#8-coldflux--luau-scripting-modsscripts-f9)
9. [Packaging Mods with `.cwassetopack.json` (`📦 Pack Builder`)](#9-packaging-mods-with-cwassetopackjson--pack-builder)
10. [Multiplayer Hosting, Live Map Switching & Temp Mod Sync](#10-multiplayer-hosting-live-map-switching--temp-mod-sync)
---
## 1. Modding Folder Layout & Reloading
### Cold Water vs Isolated Sculpt Projects
- **`project_cold_water`** reads mods from **`./mods/`** by default (or the path passed to `--project
`).
- **`sculpt`** (the engine-only binary built with `--no-default-features --features client`) uses isolated workspaces under **`./sculpt_projects//`** (`--project sculpt_projects/default` by default) with zero Cold Water starter assets preloaded.
Both project roots share the exact same subfolder structure:
```text
mods/ (or sculpt_projects//)
├── weapons/*.json # Custom CSG weapons + ballistics/audio stats
├── vehicles/*.json # Custom CSG vehicles + locomotion/turret/armor specs
├── maps/*.json # Custom CSG maps, missions & terrain/generator configs
├── stamps/*.json # Reusable CSG building/cover stamps
├── mapgen_palettes/*.json # Weighted asset tables per biome & slot for MapGen
├── grids/*.cwgrid.json # Painted 3x3..128x128 custom grid maps
├── scripts/
│ ├── *.luau # Persistent Luau gameplay / UI / modifier scripts
│ └── *.coldflux.json # Saved ColdFlux visual node-graph scripts
├── packs/*.cwassetopack.json # Multi-mod bundles (excludes heightmaps)
└── heightmaps/*.png # 8-bit / 16-bit grayscale terrain heightmaps
```
### Envelope Format (`AssetBlueprint`)
Weapons, vehicles, maps, and map stamps share the top-level JSON wrapper `AssetBlueprint` (`schema_version: 1`):
```json
{
"schema_version": 1,
"id": "my_custom_id",
"name": "Display Name",
"author": "Your Name",
"payload": {
"Weapon": { }
}
}
```
Valid `payload` tags are `"Weapon"`, `"Vehicle"`, `"Map"`, and `"MapStamp"`. IDs are normalized with lowercase alphanumeric + underscores (`a-z`, `0-9`, `_`).
### Hot Reloading & Precedence
- Click **`📁 Open Mod Folder`** in the Main Menu or Asset Studio toolbar to open your active mods root in Explorer.
- Click **`↻ Reload`** (Main Menu / Asset Studio) after hand-editing JSON or dropping packs/scripts on disk.
- **Override Precedence:** Loose files in `weapons/`, `vehicles/`, `maps/`, `stamps/`, `mapgen_palettes/`, `grids/`, and `scripts/` take priority over assets of the same ID inside `.cwassetopack.json` packs.
---
## 2. CSG Sculpting, Materials & Procedural Modifiers
### CSG Tree (`CsgNode`)
Every weapon, vehicle hull, vehicle turret, map stamp, and map structure is a sequence of CSG nodes:
- **Operations (`op`)**: `"Union"` (`+`), `"Subtract"` (`-`), `"Intersect"` (`∩`). Keep at least one solid `"Union"` base before `"Subtract"` cutters so negative space carves cleanly.
- **Shapes (`shape`)**:
- `{"Primitive": "Box"}`
- `{"Primitive": {"Cylinder": {"segments": 12}}}`
- `{"Primitive": {"Sphere": {"rings": 8, "sectors": 12}}}`
- `{"Primitive": {"Cone": {"segments": 12}}}`
- `{"Primitive": "Wedge"}`
- `{"Primitive": {"Torus": {"major_segs": 12, "minor_segs": 8}}}`
- `{"Primitive": {"AssetStamp": "Ak74m"}}` — clones built-in geometry (`Ak74m`, `Akm`, `Aks74u`, `Pkm`, `Svd`, `Rpg7v`, `Uaz469Body`, `Ural4320Body`, `Btr80Hull`, `Btr80Turret`, `VehicleWheel`, `SandbagWall`, `ConcreteBarrier`, `BunkerShell`, `PineTree`)
- `{"Group": [ ...CsgNode... ]}` — reusable nested group (used by **Map Stamps**).
- **Transforms**: `pos: [x, y, z]`, `rot_deg: [rx, ry, rz]`, `scale: [sx, sy, sz]`.
### Asset Studio Viewport Controls
| Input | Action |
| :--- | :--- |
| `LMB` | Pick CSG node, `TURRET` / `MUZZLE` / `AXLE` anchor, or `SPAWN` / `OBJ` / `VEH` marker and drag gizmo |
| `W` / `R` / `E` | Switch Gizmo: Move / Scale (or Objective Radius) / Rotate (or Vehicle Yaw) |
| Hold `Ctrl` | Grid / angle snapping during drag |
| `F` | Focus camera on selected part/marker |
| `RMB` drag | Orbit camera |
| `MMB` drag or `Shift + RMB` | Pan camera target |
| `Scroll` | Zoom (scales dynamically to map extent up to 2.6 km in Map mode) |
| `Ctrl+Z` / `Ctrl+Y` | Undo / Redo CSG & property edits |
### Materials (`MaterialId`)
Textures, PBR roughness/wetness, 3-band acoustic absorption/scattering, and ballistic resistance/ricochet are all driven by `MaterialId`:
| `MaterialId` | Surface Description | Typical Use |
| :--- | :--- | :--- |
| `"Concrete"` | Poured Soviet concrete | Bunkers, panelkas, barriers |
| `"BrickRubble"` | Cracked masonry brick | Old compounds, warehouses |
| `"WinterMud"` | Wet frozen dirt | Ground, berms, earthworks |
| `"WetAsphalt"` | Slick dark road tarmac | Highways, airstrips, intersections |
| `"MountainRock"` | Sharp Caucasus cliff granite | Cliffs, outcrops, boulders |
| `"WinterSnow"` | Packed snowdrift | Alpine peaks, drifts |
| `"SteelHulk"` | Painted heavy armor steel | Tanks, APC hulls, turrets, girders |
| `"Sandbag"` | Heavy woven canvas | Sandbag walls, revetments |
| `"WinterPine"` | Dark evergreen bark & needles | Conifers, timber logs |
| `"FloraCamo"` | VSR-98 green camouflage fabric | Gear, tarps |
| `"MilitiaCloth"` | Muted wool/cotton uniform cloth | Fabric wraps |
| `"Gunmetal"` | Blued machined receiver steel | Rifle receivers, barrels, rails |
| `"Vsr93Barvikha"` | Vertical-stripe camo fabric | Tarps, webbing |
| `"GorkaKhaki"` | Mountain suit khaki canvas | Canvas covers, pouches |
| `"M81Woodland"` | Four-color woodland camo | Pouches, gear |
| `"AfghankaOlive"` | Olive drab field canvas | Field packs, seat fabric |
| `"WinterOverwhite"` | Winter camo white cloth | Arctic wraps |
| `"WoolFleece"` | Dark knit fleece | Trim, grips |
| `"WoodFurniture"` | Laminated birch stock wood | AK stocks, crates, doors |
| `"BakelitePlum"` | Dark plum/orange phenolic polymer | Magazines, pistol grips |
| `"TireRubber"` | Molded off-road lugged rubber | Vehicle tires, mudflaps |
| `"ColdWater"` | Acoustic water surface *(non-GPU solid)* | River water reference only |
### Procedural Modifier Stack
Each `CsgNode` can hold non-destructive `modifiers: [...]`:
- **`Array`**:
- `mode`: `"Linear"`, `"Radial"`, or `"Grid"`.
- Linear/Grid repeat by `offset` (world meters) and/or `relative_offset`, plus per-step `step_rot_deg` and `step_scale`.
- Radial sweeps around `radial_radius` across `radial_arc_deg` with optional `radial_align`.
- Set `snap_to_terrain: true` in Map mode to drape fence posts, dragon's teeth, or streetlights onto terrain height.
- **`RandomizeTransform`**:
- Deterministic seeded variation (`seed`) within `pos_min..pos_max`, `rot_min_deg..rot_max_deg`, `scale_min..scale_max`, optional `uniform_scale`, random `skip_chance`, and `snap_to_terrain`.
- **`Curve`**:
- Distributes clones along local control `points` OR references a shared `MapNamedCurve` via `shared_curve_id`.
- Supports `"CatmullRom"` or `"Polyline"`, `"FitCount"` or `"FixedSpacing"`, `spacing_m`, `follow_tangent`, `forward_axis` (`"PosZ"`, `"PosX"`, `"NegZ"`, `"NegX"`), `bank_pitch`, `lateral_offset`, `vertical_offset`, `snap_to_terrain`, and `align_to_slope`.
- **`LuauScript` / `ColdFlux`**:
- Scripted transform/modifier evaluation with live numeric sliders (`params`).
> **Engine Caps:** `MAX_MODIFIER_INSTANCES = 128` instances per node, `MAX_BLUEPRINT_MODIFIER_INSTANCES = 512` destructible expanded structures per map, `MAX_CURVE_CONTROL_POINTS = 64`.
---
## 3. Custom Weapons (`mods/weapons/`)
### Authoring Workflow in Asset Studio
1. Open **Asset Studio** -> select **`🔫 Weapon`**.
2. Pick a `base_archetype` (`"Ak74m"`, `"Akm"`, `"Aks74u"`, `"Pkm"`, `"Svd"`, `"Rpg7v"`) or click **Starter** for the suppressed carbine template.
3. Add or subtract CSG parts around the origin (`+Z` points forward toward the muzzle; `+Y` is up).
4. Toggle **`MUZZLE`** anchor selection (or click the 3D `MUZZLE` gizmo) to align tracer/flash spawn (`muzzle_local`).
5. Adjust `sight_height_y` (ADS iron-sight alignment height in meters) and `ads_fov_deg` (zoomed FOV; enable `has_pso1_scope: true` for the 4× PSO-1 optic overlay).
6. Click **`💾 Save JSON`** (writes `mods/weapons/.json`) or **`🚀 Save & Test in Valley`** to spawn immediately holding your weapon.
### `WeaponBlueprint` Field Reference
- `base_archetype`: `"Ak74m" | "Akm" | "Aks74u" | "Pkm" | "Svd" | "Rpg7v"`
- `damage`: base torso damage (`f32`; Headshots deal `2.2×`, Legs deal `0.75×`)
- `rpm`: cyclic fire rate (`60.0 / fire_interval`)
- `muzzle_velocity`: projectile speed (`m/s`)
- `drag_coeff`: air resistance decay (`~0.0008`–`0.0020`)
- `suppression_power`: suppression spike inflicted on nearby targets per bullet
- `mag_capacity` / `reserve_default` / `reload_secs`: magazine size, starting spare rounds, and base reload time
- `spread_rad`: base angular dispersion in radians
- `recoil_pitch` / `recoil_yaw` / `recoil_kick_z`: per-shot climb, horizontal kick, and camera/viewmodel pushback
- `auto_capable`: `true` enables `[B]` Full-Auto / Semi toggle
- `is_rocket` / `blast_radius`: enable explosive warheads + CSG cratering on impact
- `tracer_every`: `1` = every round has a visible tracer; `4` = every 4th round
- `sound`: `"Ak74mShot" | "AkmShot" | "SvdShot" | "PkmShot" | "RpgLaunch" | ...`
Minimal Example: mods/weapons/vintorez_9x39.json
```json
{
"schema_version": 1,
"id": "vintorez_9x39",
"name": "VSS Vintorez 9x39",
"author": "Modder",
"payload": {
"Weapon": {
"nodes": [
{
"id": 1,
"name": "Receiver Stamp",
"op": "Union",
"shape": { "Primitive": { "AssetStamp": "Aks74u" } },
"pos": [0.0, 0.0, 0.0],
"rot_deg": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0],
"material": "Gunmetal"
},
{
"id": 2,
"name": "Integral Suppressor",
"op": "Union",
"shape": { "Primitive": { "Cylinder": { "segments": 12 } } },
"pos": [0.0, 0.016, 0.48],
"rot_deg": [90.0, 0.0, 0.0],
"scale": [0.022, 0.28, 0.022],
"material": "Gunmetal"
}
],
"base_archetype": "Svd",
"damage": 58.0,
"rpm": 700.0,
"muzzle_velocity": 295.0,
"drag_coeff": 0.0014,
"suppression_power": 0.16,
"mag_capacity": 20,
"reserve_default": 120,
"reload_secs": 2.1,
"spread_rad": 0.012,
"recoil_pitch": 0.014,
"recoil_yaw": 0.005,
"recoil_kick_z": 0.032,
"auto_capable": true,
"is_rocket": false,
"blast_radius": 0.0,
"tracer_every": 5,
"sound": "Aks74uShot",
"sight_height_y": 0.095,
"muzzle_local": [0.0, 0.016, 0.64],
"ads_fov_deg": 24.0,
"has_pso1_scope": true,
"script_hooks": []
}
}
}
```
---
## 4. Custom Vehicles & Turrets (`mods/vehicles/`)
### Authoring Workflow in Asset Studio
1. Open **Asset Studio** -> select **`🚚 Vehicle`**.
2. Switch **Edit Layer** between **`Hull`** (`hull_nodes`) and **`Turret`** (`turret_nodes`, rotated at `turret_mount_local`).
3. Choose **Locomotion** (`locomotion`):
- `"Wheeled"`: configure `wheel_offsets` (`[x, z, can_steer]` with `AXLE 1..N` 3D markers), `wheel_radius`, `wheel_width`, `is_amphibious`. Engine auto-generates 16-sided off-road `TireRubber` lugged wheels at runtime.
- `"Tracked"`: configure `track_half_width`, `track_length`, `track_height`, `roadwheel_count`, `pivot_turn_rate` (differential steering & neutral pivot turns).
- `"Helicopter"`: configure `rotor_mount_local`, `tail_rotor_mount_local`, `rotor_radius`, `lift_power`, `max_climb_rate`.
- `"EmplacedTurret"`: stationary AA/AT tripod or gun emplacement (`has_turret` enabled).
4. Set **3D Anchors**: drag `TURRET` (`turret_mount_local`) and `MUZZLE` (`turret_muzzle_local`) visually in the viewport.
5. Configure **Turret Weapons** (`turret_primary` and optional `turret_secondary`):
- **Presets (`kind`)**: `"HeavyMg14_5mm"`, `"Autocannon30mm"`, `"TwinAutocannon23mm"`, `"TwinAutocannon30mm"`, `"TankCannon125mm"`, `"TowAtgmLauncher"`, `"AtakaQuadAtgm"`, `"RocketPodS8"`.
- **Multi-Barrel & Guidance**: `barrel_count` (`1..6`), `barrel_fire_mode` (`"Alternating"` | `"Salvo"`), `barrel_layout` (`"Horizontal"` | `"QuadGrid"` | `"Rotary"`), `barrel_spacing`, and `guidance` (`"Unguided"` | `"SaclosWireGuided"`).
6. Set **Crew Seats** (`seat_roles`): mix of `"Driver"`, `"Gunner"`, and `"Passenger"` entries.
7. Click **`💾 Save JSON`** to save to `mods/vehicles/.json`. Your custom vehicle immediately appears in:
- **Game Director (`F7`)** -> *Vehicles* palette (with the **`Spawn with AI Crew`** toggle).
- **Map Editor (`🏔 Map / Heightmap`)** -> *Vehicles* panel dropdown (`Mod`).
---
## 5. Reusable Map Stamps (`mods/stamps/`)
Use **Map Stamps** to build a building, guard tower, checkpoint, or barricade once and stamp it cleanly across any Map or MapGen Asset Palette.
1. Switch Asset Studio to **`🧱 Map Stamp`**.
2. Sculpt solid walls/pillars with **`+ Union`** and carve enterable doorways & firing windows with **`- Subtract`**.
- **Important for AI & Player entry:** Carve doors all the way down to `Y = 0` (at least `1.2 m` wide and `2.1 m` tall) so `NavGrid` carves walkable transitions cleanly through openings while solid walls block movement.
3. Use **`Sit Base on Ground`** and **`Center XZ Pivot`** so the building rests cleanly at `Y = 0`.
4. Click **`💾 Save JSON`** (or **`Save & Open in Map Editor`**) to save to `mods/stamps/.json`.
5. When placed in a `MapBlueprint` (or spawned by a `MapGenPalette`), each `MapStamp` compiles automatically as an independent **destructible structure** supporting **CSG craters** and **structural collapse** (`Pancaking`, `Cantilever V-Frame`, `A-Frame`).
---
## 6. Maps, Missions & Default AI Behavior (`mods/maps/`)
Switch Asset Studio to **`🏔 Map / Heightmap`** to author playable maps and mission templates saved to `mods/maps/.json`.
### Choosing Base Terrain (`base_terrain`)
Four terrain modes are available directly inside the **Terrain** selector:
1. **`FlatSandbox`**: customizable `half_extent` (`120..450 m`) and GPU ground `material`.
2. **`ClassicFoothills`**: builds on the built-in Foothill River Town valley terrain.
3. **`HeightmapPng`**: loads 8-bit or 16-bit grayscale PNGs from `mods/heightmaps/` (or `/heightmaps/`), with `half_extent`, `min_height`, `max_height`, `enable_water`, and `water_level`. Click **`🏔 Generate Demo Heightmap PNG`** to create a sample valley PNG immediately.
4. **`Dynamic(MapGenConfig)`**: exposes **every procedural world generator** directly in the Map Editor:
- **Single Zone**: `"RiverValleyTown"`, `"SmallCity"`, `"TwinBridgeCrossing"`, `"DryCityOutskirts"`.
- **3-Zone Corridor**: customizable W / C / E biome strip (`Transition Blend`).
- **2×2 Quad**: 4-corner NW / NE / SW / SE stitched biomes.
- **3 km Theater**: `3072 m × 3072 m` chunked combined-arms map.
- **Custom Grid**: embeds any `CustomGridSpec` directly in the map! Pick any saved `.cwgrid.json`, adjust `Cell Scale` (`32m` / `64m` / `128m`), `Auto Roads`, `Auto Bridges`, `Seed`, `Asset Palette`, `Urban Density`, and `Rubble Density`, or click **`🎨 Open Grid & Palette Designer`** to paint cells live and click **`🗺 Apply Grid to Map Editor`** to push the painted grid right back into your map.
### Placing Spawns, Objectives, Vehicles & Shared Curves
- Click **`+ Fed Spawn` / `+ Mil Spawn`**, **`+ Add Objective`**, or **`+ Fed Vehicle` / `+ Mil Vehicle`**.
- Drag any 3D marker directly with `LMB` (`W` Move, `R` scales Objective radius, `E` rotates Vehicle yaw), or use **`🔍`** to focus the camera.
- Use **Shared Curves** (`named_curves`) to draw Catmull-Rom/Polyline roads or ridgelines and bind multiple `Curve` modifiers to follow the same path.
### Configuring Mission Default Behavior (`mission_defaults`) & Per-Unit Overrides
Inside the **`⚙ Mission Default Behavior`** panel in the Map Editor, you can define how missions and AI behave by default whenever the map loads, switches in multiplayer, or resets (`Reset`):
- **Player / Mission Side (`friendly_faction`)**: `"Federal"` or `"Militia"`.
- **Federal AI Defaults** & **Militia AI Defaults**:
- **Starting Order (`federal_behavior` / `militia_behavior`)**:
- `"MoveToObjective"` — march/advance tactically to objective
- `"AssaultObjective"` — aggressive assault on objective
- `"HoldCover"` — hold fortified cover at spawn point
- `"SuppressObjective"` — deliver suppressive fire onto objective sector
- **Formation (`federal_formation` / `militia_formation`)**: `"Wedge"`, `"Line"`, `"Column"`, `"Spread"`
- **ROE (`federal_roe` / `militia_roe`)**: `"WeaponsFree"`, `"ReturnFireOnly"`, `"HoldFire"`
- **Vehicle AI Defaults**:
- `default_vehicle_tactic`: `"Auto"`, `{"Ground": "Move" | "AssistInfantry" | "ArmoredPush" | "SuppressPosition"}`, or `{"Heli": "Cas" | "Transport" | "Move"}`
- `vehicles_engage_objective`: when `true`, crewed vehicles automatically receive an `ai_target` on the primary (or selected) objective at match start
- **Match Rules**:
- `default_ai_skill`: `null` (use user/server setting) or `"Conscript" | "Regular" | "Spetsnaz"`
- `respawn_delay_secs`: player respawn timer (`0..30 s`)
- `auto_director_waves`: automatically spawn reinforcement waves
- `sandbox_all_weapons`: allow all 6 weapons regardless of kit role
Every individual **Squad Spawn** (`mb.spawns[i]`) and **Vehicle** (`mb.vehicles[i]`) can leave its behavior on **`Mission Default`** (inheriting faction/map defaults) or override its starting behavior, formation, ROE, objective engagement, and target objective index (`target_objective_idx`, `0`-based).
Example JSON snippet: mission_defaults + per-spawn / per-vehicle overrides inside MapBlueprint
```json
"mission_defaults": {
"friendly_faction": "Federal",
"federal_behavior": "AssaultObjective",
"federal_formation": "Line",
"federal_roe": "WeaponsFree",
"militia_behavior": "HoldCover",
"militia_formation": "Wedge",
"militia_roe": "ReturnFireOnly",
"default_vehicle_tactic": { "Ground": "AssistInfantry" },
"vehicles_engage_objective": true,
"auto_director_waves": false,
"default_ai_skill": "Regular",
"respawn_delay_secs": 8.0,
"sandbox_all_weapons": false
},
"spawns": [
{
"name": "Federal Assault",
"faction": "Federal",
"pos": [-60.0, 0.0, -25.0],
"behavior": "MissionDefault",
"formation": null,
"roe": null,
"target_objective_idx": null
},
{
"name": "Overwatch PKM",
"faction": "Federal",
"pos": [-75.0, 0.0, 40.0],
"behavior": "SuppressObjective",
"formation": "Spread",
"roe": "WeaponsFree",
"target_objective_idx": 1
}
],
"vehicles": [
{
"name": "Mi-24V Gunship",
"stock_kind": "Mi24Gunship",
"custom_vehicle_id": null,
"faction": "Federal",
"pos": [-110.0, 0.0, 0.0],
"yaw_deg": 90.0,
"crewed": true,
"tactic_mode": { "Heli": "Cas" },
"engage_objective": true,
"target_objective_idx": 0
}
]
```
---
## 7. Custom Grids (`.cwgrid.json`) & Asset Palettes (`mods/mapgen_palettes/`)
Open **Grid & Palette Studio** via **`F6` -> `🗺 Grid & Palette Studio`**, **`F8`** in tactical view, **Sculpt Engine Hub**, or **`🗺 Grid & Palette Designer`** inside the Map Editor.
### Painting `.cwgrid.json` Maps
- **Dimensions**: `3×3` up to `128×128` tiles.
- **Cell Scopes (`GridCellScope`)**:
- `"Block32m"` (`32 m` per cell — tight CQB towns)
- `"District64m"` (`64 m` per cell — standard districts & valleys)
- `"Sector128m"` (`128 m` per cell — up to `16.4 km × 16.4 km` theater scale)
- **9 Biomes (`ZoneType`)**: `"SovietCityCore"`, `"SuburbanTown"`, `"IndustrialOutskirts"`, `"MilitaryOutpost"`, `"RiverCrossing"`, `"Forest"`, `"OpenField"`, `"FoothillRidge"`, `"WaterLake"`.
- **Tools**: `Brush` (radius `1/2/4/8/16`), `Line / River` (clean continuous river channels with auto bank-to-bank bridges), `Flood Fill`, and `Eyedropper`, plus 6 quick templates (`Valley River`, `Twin Cities`, `Archipelago`, `Military Corridor`, `Random Biomes`, `Clear Field`).
- Saved files live in `/grids/.cwgrid.json` and can be launched from **Grid Studio**, **Multiplayer Host**, `server_config.json` (`"grid:"`), or embedded inside a **Map Editor** map.
### Customizing `MapGenPalette` (`mapgen_palettes/*.json`)
Each `MapGenPalette` maps `(ZoneType, MapGenSlot)` -> weighted asset entries:
- **Slots (`MapGenSlot`)**: `"LargeBuilding"`, `"MediumBuilding"`, `"SmallBuilding"`, `"Landmark"`, `"CoverProp"`, `"Bridge"`, `"Vegetation"`.
- **Entry Types (`MapGenAssetRef`)**:
- `{"MapStamp": "your_stamp_id"}` — spawns one of your custom CSG stamps (`mods/stamps/*.json`)
- `{"BuiltIn": ""}` — procedural built-in preset (`khrushchyovka`, `panelka`, `warehouse`, `brick_house`, `bunker`, `guard_tower`, `pine`, `sandbag`, etc.)
- Each entry controls `weight`, `footprint_radius`, `min_scale`, `max_scale`, `random_yaw`, and `destructible`.
- Inside the **MapGen Asset Palette Editor** tab, click **`Edit in Studio`** on any stamp or **`Convert -> CSG Stamp`** on any built-in preset to inspect/re-sculpt it in CSG Asset Studio.
---
## 8. ColdFlux & Luau Scripting (`mods/scripts/`, `F9`)
Open the **ColdFlux / Luau Scripting Studio** with **`F9`** (or **`⚡ ColdFlux (F9)`** in Asset Studio).
- **ColdFlux (`.coldflux.json`)**: Visual node graph compiled straight into sandboxed Luau source. Great for timers, triggers, variable checks, HUD buttons, explosions, lighting, and scenario scripting.
- **Luau (`.luau`)**: Write sandboxed Luau scripts directly. Set `auto_load: true` in saved `.coldflux.json`/`.luau` headers to load scripts automatically with the world, or attach scripts directly onto a blueprint's `script_hooks` array.
- Scripts run with `on_tick(dt)` every simulation tick inside strict VM caps (by role via `ScriptBudget`: e.g. `max_instructions`, `max_memory_bytes`, default `512 KB`).
### Core `cw.*` API Quick Reference
| Category | Functions |
| :--- | :--- |
| **World & Queries** | `cw.time()`, `cw.ground_height(x, z)` / `cw.ground_height(vec3)`, `cw.is_walkable(x, z)`, `cw.raycast(origin, dir, max_dist)`, `cw.find_entities_in_radius(center, radius)`, `cw.get_soldier(id)`, `cw.get_vehicle(id)` |
| **Variables** | `cw.get_var(key)`, `cw.set_var(key, val)` |
| **Combat & FX** | `cw.play_sound(kind, pos, gain)`, `cw.spawn_light(pos, r, g, b, intensity, radius)`, `cw.spawn_explosion(pos, radius, damage, crater_radius)`, `cw.spawn_vehicle(kind, faction, pos)`, `cw.damage_entity(kind, id, amount)`, `cw.call_artillery(pos)`, `cw.broadcast_banner(text)` |
| **UI Extensions (`cw.ui.*`)** | `cw.ui.panel(id, title, surface, opts)`, `cw.ui.window(id, title, w, h, screens)`, `cw.ui.heading(panel, id, text)`, `cw.ui.label(...)`, `cw.ui.button(panel, id, label)` *(returns `true` on click)*, `cw.ui.checkbox(...)`, `cw.ui.slider(...)`, `cw.ui.set_open(panel, bool)`, `cw.ui.is_open(panel)`, `cw.ui.clear(panel)`, `cw.ui.remove(panel)`, `cw.ui.toast(text, secs)`, `cw.ui.context()` |
| **Game Director (`cw.gm.*`)** | `cw.gm.set_time_scale(scale)`, `cw.gm.set_paused(bool)`, `cw.gm.set_weather(sun_elev, clouds, wetness)`, `cw.gm.heal_all(faction_or_nil)` |
| **Asset Studio (`cw.editor.*`)** | `cw.editor.add_primitive(kind, name, pos, size)`, `cw.editor.set_selected_pos/rot/scale(vec3)`, `cw.editor.duplicate_selected()`, `cw.editor.focus_selection()`, `cw.editor.set_status(text)`, `cw.editor.add_map_spawn(name, faction, pos)`, `cw.editor.add_map_objective(name, pos)` |
Example: Simple Luau Script Adding a Live Artillery Call HUD Window (mods/scripts/arty_button.luau)
```lua
function on_tick(dt)
cw.ui.window("mod_support_win", "Custom Support", 240, 120, "LiveGame")
cw.ui.label("mod_support_win", "info", "Click to call danger-close smoke/HE:")
if cw.ui.button("mod_support_win", "fire_btn", "Fire Mission (0, 0, 0)") then
cw.call_artillery({ x = 0, y = 0, z = 0 })
cw.broadcast_banner("Custom Luau Fire Mission Inbound!")
end
end
```
---
## 9. Packaging Mods with `.cwassetopack.json` (`📦 Pack Builder`)
Instead of sharing dozens of separate JSON files, open **`📦 Pack Builder`** inside Asset Studio to bundle a full mod collection into a single `./mods/packs/.cwassetopack.json`:
- Select any combination of **Weapons**, **Vehicles**, **Maps**, **Map Stamps**, **MapGen Palettes**, **Custom Grids**, and **ColdFlux/Luau Scripts**.
- **Important:** Heightmap `.png` files are intentionally excluded from packs (`heightmaps/*.png` must still be distributed separately if a map uses `HeightmapPng`).
- **Pack Builder Actions**:
- **`Export Pack`**: saves `./mods/packs/.cwassetopack.json`.
- **`Edit in Builder`**: opens an existing pack to add/remove items or change version/author metadata.
- **`Unpack to Loose`**: extracts every bundled asset, palette, `.cwgrid.json`, and script back into loose folders so they can be edited individually or override the pack.
---
## 10. Multiplayer Hosting, Live Map Switching & Temp Mod Sync
### Hosting Custom Maps & Grids
1. **In-App Host UI (`🌐 Multiplayer -> Host`)**:
- Select any built-in map, any saved **Custom Grid (`.cwgrid.json`)**, or any **Custom CSG Map (`mods/maps/*.json`)**.
- Configure `GM Password (PIN)` (lets trusted players claim `GameMaster` live in `F10`) and `Allow All GM` (open sandbox, off by default).
- While in-game, `Owner` / `Admin` players can switch maps live via **`F6` Map Gen** or **Grid & Palette Studio** (`ChangeMap` reloads the world across all connected clients without dropping their session).
2. **Dedicated Server (`server_config.json`)**:
- Set `"map"` to `"foothills"`, `"small_city"`, `"twin_bridges"`, `"dry_city"`, `"theater_3km"`, `"custom:"`, or `"grid:"`.
- Set `"mods_dir"`, `"admin_callsigns"`, `"gm_password"`, and `"allow_all_gm"`.
### Automatic Temporary Mod Sync Limits
When clients join a modded server (or when the host switches to a custom map live), the server compares FNV-1a manifests and transfers missing blueprints, palettes/grids embedded in `MapBlueprint`, and heightmap PNGs automatically into an **in-memory session overlay** (never overwriting the client's local `./mods/` folder):
- `MAX_TEMP_MOD_COUNT`: `64` entries
- `MAX_TEMP_MOD_JSON_BYTES`: `512 KB` per blueprint
- `MAX_TEMP_CSG_NODES`: `512` CSG nodes per blueprint
- `MAX_TEMP_HEIGHTMAP_BYTES`: `2 MB` per heightmap PNG
- `NET_PROTOCOL_VERSION`: `2`
If a blueprint fails validation or exceeds these limits during multiplayer sync, trim complex CSG node counts using **Instanced Modifiers** (`Array` / `Curve` instead of hundreds of raw manual `CsgNode`s) so the blueprint JSON stays compact and fast to transfer.