freeftf/entities/coffin.gd

23 lines
944 B
GDScript3
Raw Permalink Normal View History

2025-07-18 19:32:37 +01:00
class_name Coffin
extends StaticBody3D
var caught_player: Player = null
func _on_dropoff(body: Node3D) -> void:
if multiplayer.is_server() and body is Player:
var player: Player = body
if player.caught_player and !caught_player:
caught_player = player.caught_player
player.caught_player.get_imprisoned.rpc_id(player.caught_player.get_multiplayer_authority(), get_path())
player.released_player.rpc_id(player.get_multiplayer_authority())
(player.get_node("ReleaseTimer") as Timer).stop()
($DamageTimer as Timer).start()
elif !player.hunter and player.visible and caught_player and caught_player.health > 0:
caught_player.go_free.rpc_id(caught_player.get_multiplayer_authority())
caught_player = null
($DamageTimer as Timer).stop()
func _on_damage_timer_timeout() -> void:
if multiplayer.is_server() and caught_player.health > 0:
caught_player.damage_player.rpc_id(caught_player.get_multiplayer_authority())