diff --git a/fcore/enemy-behaviour.sml b/fcore/enemy-behaviour.sml index 86184b4..e1eff96 100644 --- a/fcore/enemy-behaviour.sml +++ b/fcore/enemy-behaviour.sml @@ -355,17 +355,25 @@ struct (* todo: possibly get pID and eID of player/enemy in a different way *) val pID = getPlatformBelowPlayer (player, platformTree, platforms) val eID = getPlatformBelowEnemy (enemy, platformTree, platforms) - - val bestPath = PathFinding.start (pID, eID, platforms, platformTree) in if eID = pID then EnemyPatch.W_Y_AXIS FALLING :: acc + else if eID = ~1 orelse pID = ~1 then + (* without checking that neither of these are ~1 + * (which means there is no platform below the enemy/player) + * there is a subscript error because the PathFinding.start + * function expects neither of these values to be ~1. *) + acc else - case bestPath of - nextPlatformID :: _ => - getPathToNextPlatform - (nextPlatformID, platforms, platformTree, enemy, eID, pID, acc) - | [] => acc + let + val bestPath = PathFinding.start (pID, eID, platforms, platformTree) + in + case bestPath of + nextPlatformID :: _ => + getPathToNextPlatform + (nextPlatformID, platforms, platformTree, enemy, eID, pID, acc) + | [] => acc + end end fun getFollowPatches diff --git a/fcore/game-type.sml b/fcore/game-type.sml index 753a0f2..afe16b1 100644 --- a/fcore/game-type.sml +++ b/fcore/game-type.sml @@ -168,8 +168,9 @@ struct val plat5 = {id = 5, x = 155, y = 811, width = 199} val plat6 = {id = 6, x = 155, y = 710, width = 199} val plat7 = {id = 7, x = 301, y = 855, width = 99} + val plat8 = {id = 8, x = 950, y = 710, width = 300} val platforms = Vector.fromList - [plat1, plat2, plat3, plat4, plat5, plat6, plat7] + [plat1, plat2, plat3, plat4, plat5, plat6, plat7, plat8] val platformTree = Platform.generateTree platforms val enemy1 =