Proper death

This commit is contained in:
Rendo 2025-12-12 01:55:10 +05:00
commit d918533ebe
4 changed files with 20 additions and 4 deletions

View file

@ -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"]

View file

@ -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():

View file

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

View file

@ -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()