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
- 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