b0c83af092
Complete replacement of the tactical-shooter project with the netfox-cs-sample (MIT) — a CS 1.6 inspired multiplayer FPS built with Godot 4 and netfox. ## What's new - Full CS-style gameplay: teams (T/CT), rounds, economy, buy menu - 6 weapons: Knife, Glock, USP, AK-47, M4A1, AWP - Bomb plant/defuse with 2 bombsites - Flashbang & smoke grenades - Proper netfox rollback netcode at 64 tick - Network popup UI for host/join - HUD, crosshair, round timer, scoreboard - All netfox singletons registered as autoloads (works in exported builds) ## Architecture - Listen-server (host from client, no dedicated server binary) - Multiplayer-fps game lives at examples/multiplayer-fps/ - Netfox addons registered as autoloads for exported build compat - Godot 4.7 with Forward+ renderer ## Removed - Old headless-server architecture (client_main, server_main, player.gd, etc.) - Custom netfox bootstrap with ENet fallback - Old ChaffGames FPS template (2,420 lines, 844 KB) - SimulationServer GDExtension stub - Godot-jolt physics (netfox sample uses default Godot physics) - Duplicate weapon_data.gd, anti_cheat.gd, round_manager.gd, etc. - Server browser API Python venv (87 MB) - test_range map and modular assets ## Preserved - Git history - Server config at config/default_server_config.cfg - Windows export preset - Build directory (gitignored) Co-authored-by: naxIO <naxIO@users.noreply.github.com>
73 lines
1.9 KiB
GDScript
73 lines
1.9 KiB
GDScript
extends Node3D
|
|
|
|
@export var fire_cooldown: float = 0.25
|
|
@export var damage: int = 35
|
|
|
|
@onready var input := $"../../Input" as ExampleRollbackFPS.PlayerInput
|
|
@onready var sound := $AudioStreamPlayer3D as AudioStreamPlayer3D
|
|
@onready var fire_action := $"Fire Action" as RewindableAction
|
|
@onready var rollback_synchronizer := %RollbackSynchronizer as RollbackSynchronizer
|
|
|
|
var last_fire: int = -1
|
|
|
|
func _ready():
|
|
fire_action.mutate(self) # Mutate self, so firing code can run
|
|
fire_action.mutate($"../../") # Mutate player
|
|
|
|
NetworkTime.after_tick_loop.connect(_after_loop)
|
|
|
|
func _rollback_tick(_dt, tick: int, _if):
|
|
if rollback_synchronizer.is_predicting():
|
|
return
|
|
|
|
fire_action.set_active(input.fire and _can_fire())
|
|
match fire_action.get_status():
|
|
RewindableAction.CONFIRMING, RewindableAction.ACTIVE:
|
|
# Fire if action has just activated or is active
|
|
_fire()
|
|
RewindableAction.CANCELLING:
|
|
# Whoops, turns out we couldn't have fired, undo
|
|
_unfire()
|
|
|
|
func _after_loop():
|
|
if fire_action.has_confirmed():
|
|
sound.play()
|
|
|
|
func _can_fire() -> bool:
|
|
return NetworkTime.seconds_between(last_fire, NetworkRollback.tick) >= fire_cooldown
|
|
|
|
func _fire():
|
|
last_fire = NetworkRollback.tick
|
|
|
|
# See what we've hit
|
|
var hit := _raycast()
|
|
if hit.is_empty():
|
|
# No hit, nothing to do
|
|
return
|
|
|
|
_on_hit(hit)
|
|
|
|
func _unfire():
|
|
fire_action.erase_context()
|
|
|
|
func _raycast() -> Dictionary:
|
|
# Detect hit
|
|
var space := get_world_3d().direct_space_state
|
|
var origin_xform := global_transform
|
|
var query := PhysicsRayQueryParameters3D.create(
|
|
origin_xform.origin,
|
|
origin_xform.origin + origin_xform.basis.z * 1024.
|
|
)
|
|
|
|
return space.intersect_ray(query)
|
|
|
|
func _on_hit(result: Dictionary):
|
|
var is_new_hit := false
|
|
if not fire_action.has_context():
|
|
fire_action.set_context(true)
|
|
is_new_hit = true
|
|
|
|
if result.collider.has_method("damage"):
|
|
result.collider.damage(damage, is_new_hit)
|
|
NetworkRollback.mutate(result.collider)
|