From 1c8a6aab9f86a8e3a4ab5c54a0b738951dd016d5 Mon Sep 17 00:00:00 2001 From: adtpdn Date: Tue, 18 Feb 2025 11:34:36 +0800 Subject: [PATCH] fix the occuring that client doesn't get goals on joined --- scenes/main.gd | 3 +++ scenes/player.gd | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scenes/main.gd b/scenes/main.gd index 35c4a1e..982ff47 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -354,6 +354,9 @@ func add_player_character(peer_id): var bot_to_replace = get_node_or_null(str(bots[0])) if bots.size() > 0 else null if bot_to_replace: player_character.goals = bot_to_replace.goals.duplicate() + else: + # Only generate new goals if not inheriting from a bot + player_character.append_random_goals() func add_bot(bot_id): rpc("create_bot", bot_id) diff --git a/scenes/player.gd b/scenes/player.gd index d116baf..529691b 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -400,10 +400,11 @@ func initialize_random_goals(_size:int, min_value:int, max_value:int, null_count return result # Remove this since goals are now set by main.gd -#func append_random_goals(): -# goals.append_array(initialize_random_goals(9, 7, 10, 1.0)) -# if is_multiplayer_authority(): -# rpc("sync_goals", goals) +func append_random_goals(): + goals.append_array(initialize_random_goals(9, 7, 10, 1.0)) + + if is_multiplayer_authority(): + rpc("sync_goals", goals) func bot_try_grab_item() -> bool: if not enhanced_gridmap or action_points <= 0: