From d918533ebeda0b4141b302971bf693d0e4b0e46f Mon Sep 17 00:00:00 2001 From: Rendo Date: Fri, 12 Dec 2025 01:55:10 +0500 Subject: [PATCH] Proper death --- players/molikman.tscn | 1 + players/player/player.gd | 1 + players/player/player_movement.gd | 1 + systems/weapon_system/weapon_system.gd | 21 +++++++++++++++++---- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/players/molikman.tscn b/players/molikman.tscn index 48d7058..da43395 100644 --- a/players/molikman.tscn +++ b/players/molikman.tscn @@ -8824,6 +8824,7 @@ script = ExtResource("38_2cl6u") [connection signal="died" from="." to="Camera3D/DeadSpectator" method="set_active"] [connection signal="died" from="." to="BodyStateMachine/Death" method="on_death"] [connection signal="died" from="." to="PlayerMovement" method="disable"] +[connection signal="died" from="." to="WeaponSystem" method="drop_death"] [connection signal="died" from="." to="WeaponSystem" method="disable"] [connection signal="died" from="." to="PickupRange" method="disable"] [connection signal="health_changed" from="." to="HUD/Healthbar" method="on_hp_changed"] diff --git a/players/player/player.gd b/players/player/player.gd index 6c8efb7..c2b29f9 100644 --- a/players/player/player.gd +++ b/players/player/player.gd @@ -49,6 +49,7 @@ func die() -> void: died.emit() die_on_peers.rpc() passived = true + collision_layer = 0 @rpc("authority","call_remote","reliable") func die_on_peers(): diff --git a/players/player/player_movement.gd b/players/player/player_movement.gd index b6a1cc6..b4a0216 100644 --- a/players/player/player_movement.gd +++ b/players/player/player_movement.gd @@ -17,6 +17,7 @@ var debuff_tween: Tween func disable() -> void: disabled = true + player.velocity = Vector3.ZERO func process_movement(max_speed: float,acceleration: float,deceleration: float,delta: float) -> void: if is_multiplayer_authority() == false: diff --git a/systems/weapon_system/weapon_system.gd b/systems/weapon_system/weapon_system.gd index ef2832e..8ccbd16 100644 --- a/systems/weapon_system/weapon_system.gd +++ b/systems/weapon_system/weapon_system.gd @@ -27,6 +27,8 @@ signal slots_updated(current_slot: StringName,slots: Dictionary[StringName,Strin signal ammo_updated(ammo: int, remaining_ammo: int) func _ready() -> void: + if not multiplayer.is_server(): + return player_input.drop.connect(drop_current) player_input.fire_begin.connect(use_begin) player_input.fire_end.connect(use_end) @@ -128,6 +130,13 @@ func drop_slot(slot: StringName): return drop(slots[slot]) +func drop_death(): + if slots["primary"] != null: + drop_slot("primary") + elif slots["secondary"] != null: + drop_slot("secondary") + drop_slot("bomb") + func check_for_empty() -> void: if is_multiplayer_authority() == false: return @@ -174,35 +183,39 @@ func disable() -> void: disabled = true func _process(delta: float) -> void: + if not multiplayer.is_server(): + return if current_state == null or disabled: return current_state.update(delta) func _physics_process(delta: float) -> void: + if not multiplayer.is_server(): + return if current_state == null or disabled: return current_state.physics_update(delta) func use_begin() -> void: - if Session.round_state == Session.ROUND_STATES.BUY: + if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled: return if current_state != null: current_state.use_begin() func use_end() -> void: - if Session.round_state == Session.ROUND_STATES.BUY: + if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled: return if current_state != null: current_state.use_end() func alternate_state() -> void: - if Session.round_state == Session.ROUND_STATES.BUY: + if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled: return if current_state != null: current_state.alternate_state() func switch_mode() -> void: - if Session.round_state == Session.ROUND_STATES.BUY: + if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled: return if current_state != null: current_state.switch_mode()