add hud to joiners...
sync alittle better, so double damage isn't done.
This commit is contained in:
@@ -1878,6 +1878,11 @@ func _sync_release(obj_path: NodePath):
|
||||
obj.set_collision_mask_value(2, true)
|
||||
if "is_frozen" in obj:
|
||||
obj.is_frozen = false
|
||||
# CRITICAL: Clear is_being_held so object can be grabbed again and switches can detect it
|
||||
if "is_being_held" in obj:
|
||||
obj.is_being_held = false
|
||||
if "held_by_player" in obj:
|
||||
obj.held_by_player = null
|
||||
elif _is_player(obj):
|
||||
obj.set_collision_layer_value(1, true)
|
||||
obj.set_collision_mask_value(1, true)
|
||||
@@ -2384,12 +2389,27 @@ func add_coins(amount: int):
|
||||
if character_stats:
|
||||
character_stats.add_coin(amount)
|
||||
print(name, " picked up ", amount, " coin(s)! Total coins: ", character_stats.coin)
|
||||
|
||||
# Sync coins to client if this is server-side coin collection
|
||||
# (e.g., when loot is collected on server, sync to client)
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.is_server() and not is_multiplayer_authority() and can_send_rpcs and is_inside_tree():
|
||||
# Server is adding coins to a client's player - sync to the client
|
||||
var peer_id = get_multiplayer_authority()
|
||||
if peer_id != 0:
|
||||
_sync_stats_update.rpc_id(peer_id, character_stats.kills, character_stats.coin)
|
||||
else:
|
||||
coins += amount
|
||||
print(name, " picked up ", amount, " coin(s)! Total coins: ", coins)
|
||||
|
||||
# Sync coins to other players if needed (for UI display)
|
||||
# This can be expanded later if coins need to be synced across network
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func _sync_stats_update(kills_count: int, coins_count: int):
|
||||
# Client receives stats update from server (for kills and coins)
|
||||
# Update local stats to match server
|
||||
if character_stats:
|
||||
character_stats.kills = kills_count
|
||||
character_stats.coin = coins_count
|
||||
print(name, " stats synced from server: kills=", kills_count, " coins=", coins_count)
|
||||
|
||||
func heal(amount: float):
|
||||
if is_dead:
|
||||
|
||||
Reference in New Issue
Block a user