Creates the full buy/economy subsystem for a tactical FPS:
- EconomyManager (server/scripts/economy/economy_manager.gd): per-player
money tracking with starting 00, kill/round/objective rewards, spending
validation, escalating loss bonuses, and money_changed signal.
- BuyMenuHandler (server/scripts/economy/buy_menu_handler.gd): server-side
RPC validation of purchase requests — checks weapon validity, buy-zone
membership (scans BuyZone nodes in scene tree), affordability, then
deducts money and grants weapon via WeaponServer.give_weapon().
- BuyMenu (client/characters/weapon/buy_menu.gd): client-side Control UI
with styled panel, money display, weapon grid (name/cost/stats), numeric
key (1-4) and mouse-click purchase, server-driven affordability, and
auto-close after purchase.
- GameServer integration: creates EconomyManager + BuyMenuHandler in
_ready(), registers players for economy on spawn, awards kill rewards
via DamageProcessor.player_killed signal, and unregisters on despawn.
Economy rules: win=+,250, loss=,900 (+00/streak, cap ,900),
kill=+00, bomb_plant/defuse=+00. Weapon costs: pistol=00,
smg=,200, rifle=,700, shotgun=,900.
NEW: server/scripts/combat/lag_compensation.gd
- 128-entry ring buffer of player positions per server tick
- rewind_and_raycast(tick, origin, direction, range, exclude):
saves current positions, rewinds to tick-time positions,
performs PhysicsDirectSpaceState3D.intersect_ray(), restores
- Falls back to normal raycast if history missing for tick
- shot_processed signal
NEW: scripts/combat/damage_processor.gd
- Processes WeaponServer hit results: applies damage, tracks kills
- Optional distance-based damage falloff
- player_damaged / player_killed signals
- Health and kill-count queries
MODIFY: server/scripts/weapons/weapon_server.gd
- fire() now takes tick parameter: fire(tick, player_id, ...)
- _perform_hitscan() uses LagCompensation.rewind_and_raycast()
when lag_compensation reference is set and tick >= 0
- Non-compensated fallback path preserved
MODIFY: server/scripts/game_server.gd
- Adds _current_tick counter, incremented each simulation tick
- Creates WeaponServer + LagCompensation + DamageProcessor as children
- record_tick() called before each tick's simulation
- register/unregister_player_node() for player lifecycle
- _on_player_killed() relays kill events via player_damaged signal
MODIFY: scripts/network/server_main.gd
- _spawn_player() registers node with GameServer.register_player_node()
- _despawn_player() unregisters via unregister_player_node()
- team_data.gd: Team enum (SPECTATOR/CT/Terrorist), constants for names,
colors, starting money, and spawn groups; TeamData resource class
- team_manager.gd: Player-to-team assignment, auto-balancing, score
tracking; round-independent (persists across rounds)
- spawn_manager.gd: Scans scene for Marker3D nodes in spawn_points_ct
and spawn_points_t groups; selects valid spawns (farthest from enemies
with proximity check, fallback to first available)
- buy_zone.gd: Area3D-based trigger zone with team filtering, player
enter/exit tracking and signals
- test_range.tscn: Added 2 CT spawn markers and 2 T spawn markers with
appropriate groups
Add client-side prediction (t_p1_pred) with:
- scripts/network/snapshot.gd — lightweight snapshot resource with
to_dict/from_dict serialization for RPC. Stores position (Vector3),
rotation (Quaternion), velocity (Vector3), grounded (bool).
- scripts/network/client_prediction.gd — prediction/reconciliation
controller. 64-entry ring buffer of local snapshots, sends inputs to
server each physics tick (128Hz, ENet channel 0), detects misprediction
on server state arrival, rewinds and re-applies unconfirmed inputs.
Also supports remote player interpolation.
- scripts/network/network_manager.gd — new RPC endpoints for client
prediction: send_client_input (client->server, ch 0) and
send_server_state (server->client, ch 1). New signals for routing.
- client/characters/character/fps_character_controller.gd — prediction
hooks in _physics_process: on_before_tick() captures pre-input
snapshot, on_after_tick() sends input to server. Client prediction
path uses local movement (instant feedback) instead of reading from
SimulationServer entity.
Architecture:
Each tick: client applies input → predicts new state locally
→ sends input to server → server returns authoritative state
→ client compares and reconciles if mismatch.
- WeaponData resource class with configurable weapon properties and
pre-configured constants for rifle, pistol, shotgun, and SMG
- WeaponDefinitions singleton/static registry with WEAPONS dictionary
- WeaponServer node for server-authoritative weapon logic including
fire rate cooldowns, ammo tracking, reload state machine, and
multi-pellet hit-scan raycasting
- Extended WeaponManager with weapon inventory array, weapon switching,
per-weapon state persistence, fire_animation_triggered signal
Creates test_range.tscn under client/assets/maps/test_range/ as a simple
open-area test map for validating movement, shooting, and networking.
Layout:
- 80×80 open area with grey floor (CSGBox3D, 12 tris)
- Low platform (center, 1 unit high, gold)
- Medium platform (east, 2 units high, gold)
- High platform (north-west, 3 units high, red)
- Ramp (south, tilted ~20°, leads ground to low platform top)
- Enclosure/room (east, 12×12 interior, 4-unit walls, south doorway)
- SpawnPoint (Marker3D) with group 'spawn_points'
- DirectionalLight3D (sun) + WorldEnvironment
- All geometry uses Solid-color StandardMaterial3D placeholders
- Collision enabled on all CSGBox3D shapes
- ~132 tris total (well under 500 budget)
- Restructured kit_demo.tscn from linear demo to enclosed 5.12x5.12 room
with walls, floor tiles, pillar, beam, doorway, window
- Added WorldEnvironment with ProceduralSky for ambient lighting
- Added DirectionalLight3D (sun key light, 45° angle, shadows enabled)
- Added OmniLight3D (warm interior fill light)
- Added ReflectionProbe for interior specular reflections
(box projection, room-sized extents)
- Added LightmapGI with balanced quality settings
(bounces=3, texel_scale=1.0, max_texture_size=2048, denoiser=true)
- Added tool script (kit_demo.gd) that prints bake status in editor
- Added bake_lighting.gd CLI bake script (requires GPU-enabled instance)
- Updated project.godot with reflection atlas and shadow map quality settings
Headless baking note: Godot's standard editor build requires a GPU/display
for LightmapGI.bake(). Open the scene in the Godot editor and click 'Bake
Lightmap' on the LightmapGI node to generate the baked lightmap data.