when FOLLOW_SLIME has no following to do, call patrol patches so that it at least patrols area

This commit is contained in:
2025-01-26 14:22:27 +00:00
parent bb0cf6bd33
commit 8f7bb3bb16
2 changed files with 7 additions and 18 deletions

View File

@@ -511,7 +511,8 @@ struct
| _ => | _ =>
getFallingPatches (enemy, newPlatformID, platforms, acc) getFallingPatches (enemy, newPlatformID, platforms, acc)
fun canJumpOnPlatform (player, platforms, enemy: enemy, platformTree, acc) = fun getFollowPatches
(player: player, enemy, wallTree, platformTree, platforms, acc) =
let let
(* todo: possibly get pID and eID of player/enemy in a different way *) (* todo: possibly get pID and eID of player/enemy in a different way *)
val pID = getPlatformBelowPlayer (player, platformTree, platforms) val pID = getPlatformBelowPlayer (player, platformTree, platforms)
@@ -533,7 +534,9 @@ struct
* (which means there is no platform below the enemy/player) * (which means there is no platform below the enemy/player)
* there is a subscript error because the PathFinding.start * there is a subscript error because the PathFinding.start
* function expects neither of these values to be ~1. *) * function expects neither of these values to be ~1. *)
acc getPatrollPatches (enemy, wallTree, platformTree, acc)
else if eID = pID then
getPatrollPatches (enemy, wallTree, platformTree, acc)
else else
let let
val bestPath = PathFinding.start (pID, eID, platforms, platformTree) val bestPath = PathFinding.start (pID, eID, platforms, platformTree)
@@ -546,24 +549,10 @@ struct
getPathToNextPlatform getPathToNextPlatform
(nextPlatformID, platforms, platformTree, enemy, eID, pID, acc) (nextPlatformID, platforms, platformTree, enemy, eID, pID, acc)
end end
| [] => acc | [] => getPatrollPatches (enemy, wallTree, platformTree, acc)
end end
end end
fun getFollowPatches
(player: player, enemy, wallTree, platformTree, platforms, acc) =
let
val {x = px, y = py, ...} = player
val {x = ex, y = ey, yAxis = eyAxis, ...} = enemy
val xAxis = if px < ex then MOVE_LEFT else MOVE_RIGHT
val acc = canJumpOnPlatform (player, platforms, enemy, platformTree, acc)
in
EnemyPatch.W_X_AXIS STAY_STILL :: acc
end
fun getVariantPatches fun getVariantPatches
(enemy, walls, wallTree, platforms, platformTree, player, acc) = (enemy, walls, wallTree, platforms, platformTree, player, acc) =
let let

View File

@@ -187,7 +187,7 @@ struct
, x = 251 , x = 251
, y = 855 , y = 855
, health = 1 , health = 1
, xAxis = MOVE_LEFT , xAxis = STAY_STILL
, yAxis = FALLING , yAxis = FALLING
, variant = EnemyVariants.FOLLOW_SLIME , variant = EnemyVariants.FOLLOW_SLIME
, platID = ~1 , platID = ~1