Skip to content

Commit

Permalink
Desert: Fix a bug that prevents a sandworm from moving.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozar committed Aug 17, 2022
1 parent d19a5cf commit 3d52d14
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions library/npc_ai/DesertAI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func _try_random_walk(id: int) -> bool:
var neck: Game_IntCoord
var forward: Game_IntCoord
var side := []
var has_forward: bool
var has_side: bool
var move_to: Game_IntCoord
var pc := _ref_DungeonBoard.get_pc()

Expand All @@ -107,10 +109,11 @@ func _try_random_walk(id: int) -> bool:
else:
side.push_back(i)

if (forward != null) and _ref_RandomNumber.get_percent_chance(
Game_DesertData.MOVE_STRAIGHT):
has_forward = (forward != null)
has_side = (side.size() > 0)
if _can_move_forward(has_forward, has_side):
move_to = forward
elif side.size() > 0:
elif has_side:
Game_ArrayHelper.shuffle(side, _ref_RandomNumber)
move_to = side[0]
else:
Expand All @@ -131,6 +134,12 @@ func _try_random_walk(id: int) -> bool:
return true


func _can_move_forward(has_forward: bool, has_side: bool) -> bool:
return has_forward and (not has_side \
or _ref_RandomNumber.get_percent_chance(
Game_DesertData.MOVE_STRAIGHT))


func _is_pc_pos(coord: Game_IntCoord) -> bool:
return (coord.x == _pc_pos.x) and (coord.y == _pc_pos.y)

Expand Down

0 comments on commit 3d52d14

Please sign in to comment.