# Project Cold Water *(powered by Sculpt Engine)* **Project Cold Water** is a tactical skirmishing simulator, first-person shooter (FPS), combined-arms sandbox, and authoritative UDP multiplayer game set in the Second Chechen War (winter 1999–2000), built on **Sculpt Engine** — a custom, pure-Rust (`wgpu 24` + `winit 0.30` + `egui 0.31` + `cpal 0.15`) procedural and CSG-first 3D engine. Rather than relying on external model packs, texture packs, or audio libraries, **Sculpt Engine** generates or sculpts **every texture, mesh, sound effect, acoustic reflection, world theater, and JSON mod in-engine**. See [`ARCHITECTURE.md`](ARCHITECTURE.md) for the full **Sculpt Engine** architecture, threading model, GPU render graph, networking stack, and module breakdown, and [`MODDING_GUIDE.md`](MODDING_GUIDE.md) for creating custom weapons, vehicles, CSG stamps, maps, missions, grids, asset packs, and ColdFlux/Luau scripts. --- ## Key Features ### 1. First-Person Combat, Ballistics, Inventory & Ammo - **Tactical FPS Mode (`V`) & Kit-Based Deployment Menu (`M`)**: Entering any skirmish, map, or multiplayer match opens the interactive **Deployment & Spawn Select (`M`)** screen with clickable 3D map spawn pins (including deployed **Squad Rally Points**), faction choice, **7 Tactical Kit Roles** (`Rifleman`, `Combat Medic`, `Machine Gunner`, `Marksman`, `Anti-Tank`, `Squad Leader`, `Ammo Bearer`), kit-scoped weapon selection, and a **Sandbox All-Weapons** override toggle. Possess any living soldier with raw mouse aiming, carry-weight encumbrance speed scaling, sprint, crouch, jump, BVH-clamped leaning (`Q` / `E`), Full-Auto/Semi switching (`B`), aligned 3D iron sights (`RMB`), and a 4× **PSO-1** chevron optic overlay on the `SVD Dragunov`. - **Arma / Squad Magazine-Based Ammo System (`R`, `Ctrl+R`, `Shift+R`)**: Replaces pooled ammo with discrete tracked magazines (`MagazineWeaponState`), `+1` chambered round mechanics on closed-bolt rifles, partial magazine retention on tactical reloads (`0.85×` reload duration when chambered vs `1.15×` dry), per-round cartridge weight reduction, round-conserving spare magazine repacking (`Shift+R`), and a tactical HUD magazine fullness bar + `+1` chamber pip + spare mag pips (approximate descriptors `FULL`/`~3/4`/`~HALF`/`LOW`/`EMPTY` by default, exact round counts revealed on **Mag Check (`Ctrl+R`)** or optional HUD toggle). - **Non-Visual Inventory, Trauma & Throwables (`I`, `7`–`0`)**: Open the **Inventory, Kit & Magazines (`I`)** drawer or use quick keys for `Field Bandage` (`7`, stops bleeding & heals), `RGD-5 Frag Grenade` (`8`, bouncing ballistics & HE/fragmentation/destruction), `RDG-2 Smoke Grenade` (`9`, spawns `SmokePuff` screens that conceal soldiers from AI line-of-sight), and kit utility gear (`0`: `Medkit`, `Ammo Bag`, `Squad Rally Beacon`, or `Morphine`). - **6 Iconic Weapons**: `AK-74M` (5.45×39), `AKM` (7.62×39), `AKS-74U`, `PKM` (7.62×54mmR), `SVD Dragunov`, and `RPG-7V` (with visible `PG-7V` warhead) — plus custom CSG weapons loaded from `./mods/weapons/` or synced temporarily in multiplayer. - **Continuous Swept Capsule Ballistics & Visible Barrel-to-Target Tracers**: Posture-matched `Head` (2.2×), `Torso` (1.0×), and `Legs` (0.75×) hitboxes clamped behind world BVH walls, supersonic bullet cracks (closest point of approach), HE rocket/mortar blast radii, visible tracer/ballistic ribbons converging smoothly from weapon muzzle to crosshair impact across all trajectories (including terrain/wall hits), and distinct Body / Headshot / Kill hit markers. - **Snappy Suppression & Trauma Post-Processing**: Near-miss gunfire, close impacts, and explosions drive GPU radial block pixelation, peripheral chromatic aberration, adrenaline desaturation, and pulsed tunnel-vision vignette (`shaders/post.wgsl`), with fast recovery once you leave gunfire. - **Material-Aware 3D Bullet Hit Effects**: Flying debris chunks, dust/snow/water/smoke puffs, HDR ricochet spark streaks, brief dynamic impact lights, and persistent bullet-hole/scorch decals tailored per material (`Concrete`, `BrickRubble`, `SteelHulk`/`Gunmetal`, `WinterSnow`, `WinterMud`/`Sandbag`, `WoodFurniture`/`WinterPine`, `ColdWater`), plus armored vs unarmored vehicle hits, helmet vs torso soldier hits, and HE explosion bursts. ### 2. Squad AI, Squad Management, Combined-Arms Vehicles & Game Director - **Sensory Tactical AI (up to 192 Soldiers)**: Forward vision cones (blocked dynamically by `SmokePuff` screens), range/stance-scaled spotting delays, gunfire hearing, opening-burst spread + aim settling, suppression pinning, bleeding & self-bandaging, cover peek/crouch states, flanking fireteams, and live `Conscript` / `Regular` / `Spetsnaz` AI skill presets. - **Squad Management (`U`) & AI Bot Helpers (`Z`)**: Create, join, leave, or lock squads, set `SquadFormation` (`Wedge`, `Line`, `Column`, `Spread`) and `RulesOfEngagement` (`Weapons Free`, `Return Fire`, `Hold Fire`), sync squad net frequencies, recruit up to 4 nearby AI riflemen, and deploy active **Squad Rally Points** (`RallyKit`). Use the **AI Squad Helpers (`Z`)** quick bar or autonomous AI routines for **Combat Medic** auto-approach & bleeding patch/heal (including the player), **Ammo Bearer** spare magazine resupply, `Follow Me`, `Pop Smoke`, `Mount Vehicle`, `Dismount All`, and live AI radio contact callouts. - **12 Driveable & Multi-Crew Combined-Arms Vehicles**: - **Wheeled**: `UAZ-469` (4×4 scout jeep), `Ural-4320` (6×6 cargo/troop truck), `BTR-80` (8×8 amphibious APC with rotating **14.5 mm KPVT** turret and `1PZ-2` gunner optic), and `BTR-80A` (30 mm autocannon + TOW ATGM). - **Tracked Armor**: `T-72B` (125 mm 2A46 cannon with hull recoil & directional heavy armor `0.50×` front glacis / `1.50×` rear engine deck), `BMP-2` (amphibious IFV, 30 mm + ATGM), `MT-LB` (amphibious tracked APC), and `BMPT Terminator` (T-72B hull + twin 30 mm 2A42 alternating autocannons + quad 9M120 Ataka-T SACLOS ATGMs). Tracked vehicles feature dual-track differential kinematics, neutral pivot turns in place, and 56 animated 3D track shoes + 16 roadwheels/idlers/sprockets. - **Helicopters**: `Mi-8MTV-2` (transport) and `Mi-24V Hind` (gunship with chin 30 mm, SACLOS TOW, and S-8 rocket pods) with collective/cyclic/tail-rotor aerodynamics and Auto-Hover (`Space`). - **Emplaced Weapons**: `TOW Tripod` (SACLOS wire-guided anti-tank launcher) and `ZU-23-2` (twin 23 mm AA autocannon with `-10°..+85°` elevation and linked salvo fire). - **Multi-Barrel & Guided Systems**: Supports configurable 1–6 barrel turrets (`Alternating` / `Salvo` fire modes; horizontal, quad-grid, and rotary layouts), SACLOS wire-guided ATGMs (`MMB` / secondary fire), custom JSON/CSG vehicles with procedural 16-sided `TireRubber` off-road chevron wheels, terrain suspension tilt (`pitch` / `roll`), `[F]` enter/exit (evicting AI crew safely in both SP and MP), `[1..3]` Driver/Gunner/Passenger seat switching (including independent multi-player Driver + Gunner seats in MP), and `[V]` chase/cockpit camera toggling. - **Tactical Vehicle AI Behaviors & Wreck Physics**: - **Helicopters (`Auto` + GM override)**: Automatically selects between **`CAS`** (`Ingress` → nose-tracked `AttackRun` with chin gun + S-8 wing rocket salvos → `BreakawayOrbit`), **`Transport`** (`CruiseToLz` → controlled `-2.6 m/s` `DescendingToLz` → ground-only troop dismount (`agl <= 3.0 m`) → `LiftoffClear`), and **`Move`** transit with terrain-clearance lookahead. Shot-down helicopters obey gravity, spin out with trailing dark smoke, crash onto the terrain with an explosion fireball/crater burst, and settle as ground wrecks. - **Tracked & Ground Vehicles (`Auto` + GM override)**: Automatically chooses between **`Move`**, **`AssistInfantry`** (escorts nearby friendly dismounted squads at infantry speed), **`ArmoredPush`** (front-glacis-first breakthrough), and **`SuppressPosition`** (standoff fire support with sustained suppression bursts even into occupied zones without direct LOS). Includes neutral-pivot frontal armor angling (`0.50×` glacis), tactical reverse under heavy damage, friendly convoy spacing, and multi-domain AI gunnery (`ZU-23-2` / AA turrets prioritize helicopters with velocity lead; tanks & IFVs prioritize enemy armor with ATGMs/coax). - **Game Director Mode (`F7`) & Deployment (`M`)**: Arma-style live scenario sandbox with a 3D placement ghost for spawning/deleting/teleporting/ordering squads, vehicles (with a **`Spawn with AI Crew`** toggle across both stock and custom vehicles), live AI vehicle tactic badges/inspector overrides (plus safe airborne helicopter land-and-dismount), player spawns, mission objectives, and fire support (`120mm` mortar salvo, precision HE, tactical smoke). - **6-Stage Tactical Mission Loop**: Supports `MoveToPosition`, `SuppressPosition`, `CallArtillery`, `AssaultPosition`, `ClearBuilding`, and `DefendPosition` with 3D perimeter beacons, HUD waypoints, and counterattack waves. ### 3. Worlds, Real-Time CSG Destruction, Structural Collapse & Enterable Navigation - **Real-Time CSG Subtraction Destruction & Dynamic Building Collapse**: 23 mm/30 mm autocannons, 125 mm tank shells, RPG-7V rockets, ATGMs, frags, and mortars dynamically carve strictly convex craters through per-panel subdivided buildings (`Khrushchyovka`, `Panelka`, `AdminPalace`, brick compounds, industrial warehouses, Caucasus houses, sandbags, concrete fences, and checkpoint barricades) with leak-proof hole clipping so follow-up shots and soldiers pass cleanly through mid-air breaches, incremental `NavGrid` breach carving, sub-millisecond two-level `AcousticBvh` updates, zero-allocation GPU tail streaming, and multiplayer late-joiner sync. Reaching a structure's load-bearing damage threshold triggers full **Structural Collapse** (`Pancaking`, `Cantilever V-Frame`, or `A-Frame`), rebuilding collapsed rubble geometry and playing debris/collapse effects. - **Dynamic, Stitched & Custom Grid Maps (`F6`)**: Single-zone presets (`RiverValleyTown`, `SmallSovietCity`, `TwinBridgeCrossing`, `DryCityOutskirts`), 3-zone stitched corridors, 2×2 stitched quadrant theaters with organic domain-warped transitions, a **3 km × 3 km Combined-Arms Theater**, and **Custom-Size Grid Map Generation (`3×3` to `128×128`)** via an interactive viewport-culled **2D Grid Map Painter** (`Brush`, `Line / River`, `Flood Fill`, `Eyedropper`, radius `1/2/4/8/16`, zoom/pan, 6 layout templates, `.cwgrid.json` save/load). Choose from 9 biomes (`City Core`, `Town / Suburbs`, `Industrial`, `Military Outpost`, `River Crossing`, `Forest / Woods`, `Open Field`, `Foothill / Mountain`, `Water / Lake`) and 3 cell scopes (`32m Block`, `64m District`, `128m Sector`, up to `16.4 km × 16.4 km` playable) with adaptive `8×8` / `16×16` 3-LOD chunked terrain (`256×256` / `512×512` vertices), a biome-aware `+25%` (`>= 48 m`) scenic out-of-bounds terrain skirt (open water past `WaterLake` edges, rolling ridges past land edges), dynamic camera far-plane/fog/LOD scaling (up to `10 km`), and strict placement safety (rejecting out-of-bounds, underwater `< water_level + 0.4 m`, and `> ~35°` cliff placements). - **Editable MapGen Asset Palettes**: Customize `MapGenPalette` JSON files (`mapgen_palettes/*.json`) per biome and slot (`LargeBuilding`, `MediumBuilding`, `SmallBuilding`, `Landmark`, `CoverProp`, `Bridge`, `Vegetation`) with weighted CSG `MapStamp`s or built-in presets, plus 1-click **"Edit in Asset Studio"** and **"Convert -> CSG Stamp"** directly from the **MapGen Asset Palette Editor**. - **Hierarchical Navigation, Doorway Carving & BVH Collision**: `2m` fine A* grid on standard maps and bounded (`<= 256×256`) coarse regional grid paired with exact obstacle/bridge checks and playable-bounds clamping on large theaters, plus **CSG wall/doorway carving** and exact `AcousticBvh` swept wall & floor collision (`STEP_UP_HEIGHT = 0.55m`) so both FPS players and AI squads can walk cleanly through doorways and wall breaches while staying blocked by solid walls and rivers. - **Live Map Hot-Reload**: Rebuilds GPU terrain/water buffers, acoustic BVH, `NavGrid`, and simulation state without restarting. ### 4. Sculpt Engine Asset Studio, Procedural Modifiers & `./mods/` - **Live-3D Main Menu & `Open Mod Folder`**: Launch into a real-time orbiting valley backdrop with Quick Skirmish, 3 km Theater, Custom & Dynamic Maps, Game Director, Multiplayer, Direct Connect, Asset Studio, Audio Synthesizer Studio, Settings, mod counts (`Weapons • Vehicles • Maps • Stamps`), `↻ Reload`, and `📁 Open Mod Folder`. - **CSG Boolean Sculptor**: `+ Union`, `- Subtract`, and `∩ Intersect` over primitives (`Box`, `Cylinder`, `Sphere`, `Cone`, `Wedge`, `Torus`) and existing asset stamps (`weapons`, `vehicle parts`, `bunkers`, `cover`, `pines`) with undo/redo, Mirror X, Duplicate, and layer editing (`Hull` + rotating `Turret`), plus Vehicle Editor controls for `Wheeled`/`Tracked`/`Helicopter`/`EmplacedTurret` locomotion and configurable multi-barrel `TurretWeaponSpec` presets (`HeavyMg14_5mm`..`RocketPodS8`, barrel count/layout/fire mode). - **Procedural Modifier Stack (Array, Randomize Transforms, Curve & Scripted Modifiers)**: Attach non-destructive `Array` (Linear, Radial, Grid), `Randomize Transforms` (deterministic seeded position/rotation/scale randomization), `Curve` (Catmull-Rom spline placement integrated with arrays), and programmable **Luau & ColdFlux** modifiers with live parameter controls (including the starter **Vertical Spinning Staircase** Luau script). - **Map Stamp Asset Creator (`🧱 Map Stamp`)**: Sculpt reusable static buildings, watchtowers, checkpoints, and cover out of CSG primitives, align them flush to `Y=0` (**Sit Base on Ground** / **Center XZ Pivot**), save them to `./mods/stamps/*.json` (with the built-in `guard_watchtower` starter stamp), and stamp them into the Map Editor as self-contained, movable/rotatable/scalable `CsgShape::Group` objects (with **Override Group Material** and **Unpack Group**). - **Grabbable 3D Transform, Anchor & Map Entity Gizmos**: Interactive `Move [W]`, `Scale [R]`, and `Rotate [E]` handles with `Ctrl` snap, clickable 3D viewport markers (`TURRET`, `MUZZLE`, `AXLE 1..N`) to drag turret pivots, weapon/turret muzzles, and symmetrical wheel axles live, plus **Map Editor Entity Placement & Gizmos** (`SPAWN:`, `OBJ:`, `VEH:`) featuring ground diamonds, objective capture radius rings, oriented vehicle wireframes, `R` Objective Radius Scale, `E` Vehicle Yaw Rotate, `Undo`/`Redo`, camera focus, and collapsible Spawns / Objectives / Vehicles (stock & custom mod) inspector panels. - **PNG Heightmap Importer, JSON Pipeline & `.cwassetopack.json` Packs (`📦 Pack Builder`)**: Load 8-bit/16-bit PNG heightmaps alongside CSG outpost geometry (`./mods/heightmaps/`), export lightweight JSON blueprints (`./mods/{weapons,vehicles,maps,stamps}/`), bundle combinations of weapons, vehicles, maps, stamps, `MapGenPalette` presets, `.cwgrid.json` custom grids, and `.coldflux.json`/`.luau` scripts (excluding heightmaps) into portable **`./mods/packs/*.cwassetopack.json`** files via Asset Studio's **Pack Builder** window (`Edit in Builder`, `Unpack to Loose`, loose-override precedence), copy JSON to clipboard, or click **Save & Test in Valley**. ### 5. GPU Rendering, Randomized Clouds, Raytraced Acoustics & VoIP/Radio - **Custom `wgpu 24` Render Pipeline**: 21 procedural PBR material layers (including `TireRubber` off-road lugs) with Catmull-Rom bicubic filtering (`A/B` toggleable), snapped sun shadow maps + Vogel Disk PCF (`8`/`16`/`32` taps), Dual Paraboloid reflections (`DPR`), raymarched 3D volumetric clouds with domain-warped dual rotated weather octaves & synced 2D cloud shadows (plus **Randomize Clouds** in Weather and GM Environment panels), reflective cold river water, zero-clip foreground FPS viewmodel pass, `F4` debug render PIP, and `F3` 3D acoustic bounce ray overlay. - **Frequency-Based VoIP & Tactical VHF Radio (`CapsLock`, `X`, `N`)**: Real-time `cpal` microphone capture compressed with pure-Rust 8 kHz IMA ADPCM and streamed over UDP. Supports 3D proximity voice (`CapsLock`, `35–60 m` with BVH wall occlusion) and tunable `30.000–87.975 MHz` VHF tactical radio (`X` PTT, `N` Tuner), Squad Leader dual-watch (`Left`/`Both`/`Right` ear routing), terrain ridge static + Conflict relay range boost, unencrypted cross-faction eavesdropping vs per-channel encryption, radio bandpass/static/squelch DSP mixing, offline **Loopback Mic Test (DSP)**, and a live comms log. - **Raytraced Procedural Audio (`F5`)**: Asynchronous two-level BVH multi-bounce acoustic propagation + diffraction feeding a real-time `cpal` procedural synth & DSP engine (ITD/ILD binaural panning + Hadamard FDN late reverb), with live `Audio Synthesizer Studio` (`F5`) patch editing. - **Flexible Frame Pacing & Capture Modes**: Stream-Safe capture mode (`F8`), VSync toggle (`Fifo` vs `Mailbox`/`Immediate`), full FPS cap controls (`30`, `60`, `90`, `120`, `144`, `165`, `240`, `360`, custom up to `500`, `Max`), and CLI launch flags. ### 6. Multiplayer, Conflict Mode, UDP Hole Punching & Temp Mod Sync - **Authoritative 60 Hz UDP Server (Windows & Static Linux)**: Run listen servers from **`🌐 Multiplayer (Host / LAN)`** or deploy headless [`cold_water_server`](src/bin/cold_water_server.rs) on Windows or Linux (`x86_64-unknown-linux-musl` static ELF / Docker) configured via [`server_config.json`](server_config.json). - **Direct Connect & Built-In NAT Hole Punching (`🔗 Direct Connect`)**: Join directly by `IP:Port` (with recent server history), discover LAN hosts, or punch through home NAT routers with zero port forwarding via Room Code + Rendezvous Relay (`cold_water_server --rendezvous --port 27016`). - **Dynamic Conflict Mode**: Radio-signal BFS chain propagation from Main HQ bases to capture sectors, extend tactical VoIP relay coverage, push frontlines, and unlock forward respawn bases. - **Lag-Compensated Combat & Client Prediction**: 250 ms server hitbox history rewind, instant client cosmetic bullet/impact prediction merged with replicated remote tracers, combat FX, sounds, CSG destruction events (`NetDestructionEvent`), frequency/proximity VoIP packets, and `ActorPosture::Dead` corpse drops, plus full multi-crew vehicle driving, tracked offsets, helicopter rotor sync, and turret combat. - **Automatic Temporary Mod Sync (Zero `./mods/` Pollution)**: Joining a modded server automatically compares FNV-1a manifests, downloads only missing/mismatched `.json` blueprints and custom-map heightmap `.png`s reliably over UDP with hash/size validation, compiles them into a temporary in-memory session overlay so you can see and use every server weapon/vehicle/map, and restores your clean local `./mods/` on disconnect. ### 7. ColdFlux Visual Scripting, Extensible UI, Luau VM & Server Admin - **ColdFlux Visual Scripting, UI Extensions & Disk Persistence (`F9`)**: Build scenario triggers, custom procedural modifiers, and extended UI overlays/windows visually with node graphs (**ColdFlux** compiled straight to Luau) or write Luau scripts directly on an embedded pure-Rust sandboxed Luau VM with deterministic instruction/memory budgets and the `cw.*` simulation API (raycasts, scenario variables, explosions, vehicle spawning, sounds, dynamic lights, Live Game/GM/Asset Studio UI widgets & click/change callbacks). Save, load, export, and autoload scripts on disk under `./mods/scripts/`. - **Server Admin & Role Permissions (`F10`)**: Manage player roles (`Guest`..`Owner`), role-gated script capabilities and scopes, live script execution, and security audit logs across singleplayer and authoritative multiplayer (`NetScriptSync` & admin RPCs). ### 8. Engine-Only `sculpt` Binary & Sculpt Engine Hub - **Asset-Free Engine Binary (`sculpt`)**: Build with `--no-default-features --features client` (disabling `cold_water_assets`) to compile **only Sculpt Engine**—zero Cold Water maps, weapons, Soviet vehicles, urban buildings, or starter blueprints compiled in (replaced with clean neutral geometric fallbacks). - **Sculpt Engine Hub & Project Switcher**: Boots over a clean neutral sandbox viewport with selectable project workspaces defaulting to `./sculpt_projects/default/` (`--project