diff --git a/scenes/main.gd b/scenes/main.gd index 637afa5..22097eb 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -114,16 +114,16 @@ func set_action_state(new_state): return current_action_state = new_state - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.clear_highlights() local_player_character.clear_playerboard_highlights() match new_state: ActionState.MOVING: - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.highlight_movement_range() ActionState.GRABBING: - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.highlight_adjacent_cells() if local_player_character.has_item_at_current_position(): local_player_character.highlighted_cells.append(local_player_character.current_position) @@ -132,14 +132,14 @@ func set_action_state(new_state): local_player_character.enhanced_gridmap.hover_item ) ActionState.PUTTING: - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.highlight_occupied_playerboard_slots() ActionState.RANDOMIZING: - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.highlight_random_valid_cells() ActionState.ARRANGING: show_arrangement_ui() - if not local_player_character.is_bot: + if local_player_character.is_bot == false: local_player_character.highlight_occupied_playerboard_slots() func update_button_states(): diff --git a/scenes/player.gd b/scenes/player.gd index 981d29a..bf4b947 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -58,7 +58,7 @@ func _ready(): var behavior_tree = $BehaviorTree # Early setup for bots - if is_bot or is_in_group("Bots"): + if is_bot == true or is_in_group("Bots"): # Set Input process to false for bots immediately set_process_input(false) set_process_unhandled_input(false) @@ -119,7 +119,7 @@ func _physics_process(_delta): rpc("remote_set_position", global_position) func _unhandled_input(event): - if is_bot or is_in_group("Bots"): + if is_bot == true or is_in_group("Bots"): set_process_unhandled_input(false) set_process_input(false) return @@ -133,7 +133,7 @@ func _unhandled_input(event): return if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: - if is_bot or is_in_group("Bots"): + if is_bot == true or is_in_group("Bots"): set_process_unhandled_input(false) set_process_input(false) return @@ -166,7 +166,7 @@ func _on_slot_gui_input(event, slot_index, slot_ui) -> int: return -1 func handle_grid_click(grid_position: Vector2i): - if is_bot or is_in_group("Bots"): + if is_bot == true or is_in_group("Bots"): return var main = get_tree().get_root().get_node_or_null("Main") if not main: @@ -287,7 +287,7 @@ func move_player_to_clicked_position(grid_position: Vector2i): path.pop_front() rpc("start_movement_along_path", path) action_points -= 1 - if not is_bot: + if not is_bot == true: clear_highlights() else: @@ -307,7 +307,7 @@ func start_movement_along_path(path: Array, clear_visual: bool = true): current_position = Vector2i(path[-1].x, path[-1].y) is_player_moving = false - if clear_visual: + if clear_visual == true: enhanced_gridmap.clear_path_visualization() has_moved_this_turn = path.size() <= movement_range @@ -406,7 +406,7 @@ func grab_item(grid_position: Vector2i = current_position) -> bool: if item == -1: return false - if is_in_group("Bots") or is_bot: + if is_in_group("Bots") or is_bot == true: var empty_slot = playerboard.find(-1) if empty_slot == -1: return false @@ -465,7 +465,7 @@ func put_item(grid_position: Vector2i = current_position) -> bool: has_performed_action = true consume_action_points(1) - if not is_bot: + if not is_bot == true: clear_highlights() clear_playerboard_highlights() selected_playerboard_slot = -1 @@ -481,7 +481,7 @@ func handle_put_action(): if not main or action_points < 1: return - if not is_bot: + if not is_bot == true: clear_highlights() clear_playerboard_highlights() @@ -516,7 +516,7 @@ func handle_playerboard_slot_selected(slot_index: int): has_performed_action = true consume_action_points(1) - if not is_bot: + if not is_bot == true: clear_highlights() clear_playerboard_highlights() selected_gridmap_position = Vector2i(-1, -1) @@ -532,7 +532,7 @@ func handle_put_slot_selected(slot_index: int): if slot_index in highlighted_cells and playerboard[slot_index] in goals: selected_playerboard_slot = slot_index clear_highlights() - if not is_bot: + if not is_bot == true: highlight_empty_adjacent_cells() @@ -570,7 +570,7 @@ func arrange_playerboard_item(slot_index: int): slot.gui_input.connect(_on_slot_clicked.bind(i)) func _on_slot_clicked(event: InputEvent, slot_index: int): - if not event is InputEventMouseButton or is_bot or not event.pressed or event.button_index != MOUSE_BUTTON_LEFT: + if not event is InputEventMouseButton or is_bot == true or not event.pressed or event.button_index != MOUSE_BUTTON_LEFT: return var main = get_tree().get_root().get_node_or_null("Main") @@ -638,7 +638,7 @@ func playerboard_is_full() -> bool: return playerboard.find(-1) == -1 func highlight_movement_range(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return for x in range(enhanced_gridmap.columns): @@ -651,7 +651,7 @@ func highlight_movement_range(): enhanced_gridmap.set_cell_item(Vector3i(x, 0, z), enhanced_gridmap.hover_item) func highlight_adjacent_cells(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return var current_cell = Vector3i(current_position.x, 1, current_position.y) @@ -669,7 +669,7 @@ func highlight_adjacent_cells(): func highlight_empty_adjacent_cells(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return # Clear previous highlights @@ -694,7 +694,7 @@ func highlight_empty_adjacent_cells(): enhanced_gridmap.hover_item) func highlight_random_valid_cells(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return var valid_cells = [] @@ -715,7 +715,7 @@ func highlight_random_valid_cells(): valid_cells.remove_at(index) func highlight_occupied_playerboard_slots(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return var main = get_tree().get_root().get_node_or_null("Main") @@ -740,7 +740,7 @@ func highlight_occupied_playerboard_slots(): main.update_playerboard_ui() func clear_highlights(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return if not enhanced_gridmap: return @@ -759,7 +759,7 @@ func clear_highlights(): child.hide() func clear_playerboard_highlights(): - if is_bot or is_in_group("Bots") or not is_multiplayer_authority(): + if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority(): return var main = get_tree().get_root().get_node_or_null("Main") if main and main.playerboard_ui: @@ -904,7 +904,7 @@ func consume_action_points(points: int): return # Don't consume points for bots in non-turn-based mode - if is_bot and not main.turn_based_mode: + if is_bot == true and not main.turn_based_mode: _after_action_completed() return diff --git a/scripts/behaviors/actions/do_move.gd b/scripts/behaviors/actions/do_move.gd index 53aacfd..3ce0e38 100644 --- a/scripts/behaviors/actions/do_move.gd +++ b/scripts/behaviors/actions/do_move.gd @@ -9,12 +9,12 @@ func tick(actor: Node, blackboard: Blackboard) -> int: if actor.action_points <= 0: return FAILURE - if not actor.is_bot and not actor.is_in_group("Bots"): + if not actor.is_bot == true and not actor.is_in_group("Bots"): return FAILURE # Execute movement if actor.is_within_movement_range(target_pos): - if actor.is_bot: + if actor.is_bot == true: var path = actor.enhanced_gridmap.find_path( Vector2(actor.current_position), Vector2(target_pos), diff --git a/scripts/bot_blackboard.gd b/scripts/bot_blackboard.gd index df69e78..f85c011 100644 --- a/scripts/bot_blackboard.gd +++ b/scripts/bot_blackboard.gd @@ -1,27 +1,19 @@ @tool extends Blackboard -# Default values when initializing blackboard var default_data = { - "move_target": null, # Vector2i for movement target - "can_arrange": false, # Whether bot can arrange items - "can_grab": false, # Whether bot can grab items - "can_put": false, # Whether bot can put items - "should_move": false, # Whether bot should move - "action_points": 0, # Current action points - "current_action": "", # Current action being performed - "item_to_grab": null, # Item to grab - "grab_position": null, # Position to grab from - "put_position": null, # Position to put item - "arrange_from": -1, # Slot to arrange from - "arrange_to": -1 # Slot to arrange to + "move_target": null, + "current_action": "", + "action_points": 3, # Adjust this value based on your game design + "last_position": null, + "path": [], + "is_moving": false } func _ready(): if Engine.is_editor_hint(): return - # Initialize with default values for key in default_data: if not has_value(key): set_value(key, default_data[key])