feat: implement core movement, combat, weapon management, and networking systems

This commit is contained in:
DottsGit
2026-06-07 00:22:21 -04:00
parent 064bc90f53
commit 7f54792ad9
12 changed files with 191 additions and 42 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ func _on_hit(result: Dictionary) -> void:
if not result.collider.has_method("take_damage"):
if result.collider is StaticBody3D or result.collider is CSGShape3D:
ImpactSpawner.spawn(get_tree(), "crater", result.position, result.normal, explosion_radius * 1.5)
elif owner_player and owner_player.multiplayer.is_server():
elif owner_player and owner_player.is_multiplayer_authority():
result.collider.take_damage(damage, result.position, owner_player)
_explode(result.position)
destroy()
+1 -1
View File
@@ -58,7 +58,7 @@ func _on_hit(result: Dictionary) -> void:
final_damage = lerpf(damage, min_damage, falloff_factor)
if result.collider.has_method("take_damage"):
if owner_player and owner_player.multiplayer.is_server():
if owner_player and owner_player.is_multiplayer_authority():
result.collider.take_damage(final_damage, result.position, owner_player)
elif result.collider is StaticBody3D or result.collider is CSGShape3D:
var size = 0.4 if impact_type == "plasma" else 0.15
+4 -4
View File
@@ -10,8 +10,8 @@ func _init() -> void:
fire_rate = 1.0 # 1 click fires all 8
max_ammo = 4 # 4 swarms
reload_time = 3.0
base_damage = 35.0 # Per mini rocket
min_damage = 20.0
base_damage = 50.0 # Per mini rocket
min_damage = 35.0
falloff_start = 0.0
max_range = 300.0
automatic = false
@@ -145,7 +145,7 @@ func _fire() -> void:
# They shoot mostly forward, but fan out horizontally, and slightly arch upwards radially
var angle = lerpf(-PI/3.0, PI/3.0, fraction) # -60 deg to +60 deg fan
var x_dir = sin(angle) * 0.6
var y_dir = cos(angle) * 0.8 # Reduced upward angle so it's not mostly straight up
var y_dir = cos(angle) * 1.5 # Adjusted upward angle so it launches a little more "up"
var fire_dir = (base_dir + right * x_dir + up * y_dir).normalized()
_spawn_custom_projectile(proj_origin, fire_dir)
@@ -179,7 +179,7 @@ func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
# Logic
proj.weapon_source = self
proj.turn_speed = 6.5 # Slower turn radius so they sweep nicely
proj.turn_speed = 12.0 # Faster turn radius so they can hit moving targets better
proj.position = origin # Start at origin to spread outward around camera
proj.logical_source = origin
+14 -1
View File
@@ -75,6 +75,8 @@ func _build_loadout() -> void:
# Clear existing weapons
for w in weapons.values():
if is_instance_valid(w):
if w.has_method("unequip"):
w.unequip()
w.queue_free()
weapons.clear()
@@ -102,6 +104,8 @@ func _build_loadout() -> void:
func _build_remote_loadout(p1: String, p2: String, sp: String, melee: String) -> void:
for w in weapons.values():
if is_instance_valid(w):
if w.has_method("unequip"):
w.unequip()
w.queue_free()
weapons.clear()
@@ -161,7 +165,16 @@ func _add_procedural_arms(weapon: Node3D) -> void:
# Attach to weapon instead of model_root to avoid arms spinning on reload
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(0.2, 0.4, 0.8) # Player color
var pcolor = Color(0.2, 0.4, 0.8)
var nm = get_node_or_null("/root/NetworkManager")
if nm and nm.multiplayer.has_multiplayer_peer() and not nm.multiplayer.multiplayer_peer is OfflineMultiplayerPeer:
var my_id = nm.multiplayer.get_unique_id()
if nm.player_stats.has(my_id):
pcolor = Color(nm.player_stats[my_id].get("color", "3366cc"))
elif nm and nm.player_stats.has(1):
pcolor = Color(nm.player_stats[1].get("color", "3366cc"))
mat.albedo_color = pcolor
mat.roughness = 0.8
# Right Arm (Main Grip)