fix bot issues : Prevent bot creation when enable_bots is false
This commit is contained in:
+55
-15
@@ -184,6 +184,8 @@ func _ready():
|
||||
if is_multiplayer_authority():
|
||||
rpc("sync_position", current_position)
|
||||
|
||||
|
||||
|
||||
# Add function to check if position is at finish line
|
||||
func is_at_finish_line() -> bool:
|
||||
return current_position in finish_locations
|
||||
@@ -246,12 +248,6 @@ func finish_race():
|
||||
var message = "Finish 2nd lap on " + get_ordinal_string(race_position)
|
||||
if is_multiplayer_authority():
|
||||
rpc("display_message", message)
|
||||
|
||||
# Notify game completion
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if main and is_multiplayer_authority():
|
||||
main.player_finished_race(self)
|
||||
|
||||
|
||||
# Add function to check 3x3 pattern matching anywhere in 5x5 playerboard
|
||||
func check_pattern_match() -> bool:
|
||||
@@ -319,7 +315,7 @@ func start_new_lap():
|
||||
goals = second_lap_goals.duplicate()
|
||||
|
||||
# Reset playerboard
|
||||
playerboard.fill(-1)
|
||||
#playerboard.fill(-1)
|
||||
|
||||
# Reset can_finish flag
|
||||
can_finish = false
|
||||
@@ -446,9 +442,13 @@ func ping_existence():
|
||||
# They can check if they have this node
|
||||
pass
|
||||
|
||||
func _physics_process(_delta):
|
||||
func _physics_process(delta):
|
||||
if is_multiplayer_authority():
|
||||
rpc("remote_set_position", global_position)
|
||||
|
||||
# Add continuous finish line check
|
||||
if current_position in finish_locations and can_finish and not is_player_moving:
|
||||
start_new_lap()
|
||||
|
||||
func _unhandled_input(event):
|
||||
# Early return if not authorized human player
|
||||
@@ -686,6 +686,13 @@ func move_player_to_clicked_position(grid_position: Vector2i):
|
||||
if not is_multiplayer_authority() or is_player_moving or action_points <= 0:
|
||||
return
|
||||
|
||||
# Check if trying to move to finish line
|
||||
if grid_position in finish_locations:
|
||||
if not can_finish:
|
||||
can_finish = check_pattern_match()
|
||||
if not can_finish:
|
||||
return # Cannot move to finish line if pattern doesn't match
|
||||
|
||||
var is_valid_finish = false
|
||||
# Make scenario for match checking laps, for handle lap count
|
||||
if current_lap == 0: # first lap
|
||||
@@ -693,15 +700,11 @@ func move_player_to_clicked_position(grid_position: Vector2i):
|
||||
else: # second lap
|
||||
is_valid_finish = grid_position in spawn_locations
|
||||
|
||||
if is_valid_finish:
|
||||
if not can_finish:
|
||||
can_finish = check_pattern_match()
|
||||
if not can_finish:
|
||||
return
|
||||
|
||||
if not is_within_movement_range(grid_position):
|
||||
return
|
||||
|
||||
|
||||
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if not main or main.current_action_state != main.ActionState.MOVING or not grid_position in highlighted_cells:
|
||||
return
|
||||
@@ -732,7 +735,7 @@ func move_player_to_clicked_position(grid_position: Vector2i):
|
||||
# Clear highlights after moving
|
||||
if not (is_bot or is_in_group("Bots")):
|
||||
clear_highlights()
|
||||
|
||||
|
||||
# Handle finish line crossing
|
||||
if is_valid_finish and can_finish:
|
||||
rpc("finish_race")
|
||||
@@ -751,6 +754,10 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
current_position = Vector2i(path[-1].x, path[-1].y)
|
||||
is_player_moving = false
|
||||
|
||||
# Check if we've reached the finish line
|
||||
if current_position in finish_locations and can_finish:
|
||||
finish_race()
|
||||
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
|
||||
# Only clear visuals if this is a human player
|
||||
@@ -773,6 +780,39 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
||||
_after_action_completed()
|
||||
)
|
||||
|
||||
#func trigger_finish_line():
|
||||
#if not is_multiplayer_authority():
|
||||
#return
|
||||
#
|
||||
#if current_lap == 0: # First lap
|
||||
#lap1_finishers += 1
|
||||
#race_position = lap1_finishers
|
||||
#
|
||||
## Display first lap completion message
|
||||
#var message = "Finish 1st lap on " + get_ordinal_string(race_position)
|
||||
#rpc("display_message", message)
|
||||
#print("DEBUG: Triggered first lap finish. Position: ", race_position)
|
||||
#
|
||||
## Start second lap
|
||||
#current_lap += 1
|
||||
#rpc("start_new_lap")
|
||||
#
|
||||
#elif current_lap == 1: # Second lap
|
||||
#lap2_finishers += 1
|
||||
#race_position = lap2_finishers
|
||||
#
|
||||
## Display second lap completion message
|
||||
#var message = "Finish 2nd lap on " + get_ordinal_string(race_position)
|
||||
#rpc("display_message", message)
|
||||
#print("DEBUG: Triggered second lap finish. Position: ", race_position)
|
||||
#
|
||||
##func debug_finish_state():
|
||||
##print("DEBUG: Current Position: ", current_position)
|
||||
##print("DEBUG: Can Finish: ", can_finish)
|
||||
##print("DEBUG: Current Lap: ", current_lap)
|
||||
##print("DEBUG: Pattern Match: ", check_pattern_match())
|
||||
##print("DEBUG: Is at finish: ", current_position in finish_locations)
|
||||
|
||||
func update_player_position(grid_position: Vector2i):
|
||||
position = grid_to_world(grid_position)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user