Add action to perform on pathing failure

This commit is contained in:
2026-04-03 15:45:16 +01:00
parent 2d1cf4b371
commit d15fbc902c
4 changed files with 16 additions and 15 deletions
+5 -5
View File
@@ -83,7 +83,7 @@ performAction cr w ac = case ac of
let (imps, newAcs) = foldMap (performAction cr w) acs
in (imps, newAcs)
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], mempty)
PathTo p -> performPathTo cr w p
PathTo p a -> performPathTo a cr w p
TurnToPoint p -> performTurnToA cr p
LeadTarget p -> fromMaybe ([], mempty) $ do
i <- cr ^? crIntention . targetCr . _Just
@@ -119,15 +119,15 @@ crPathing cr = case cr ^. crStance . carriage of
Flying {} -> (isFlyable, not . S.member (WallObstacle WallNotAutoOpen))
_ -> (isWalkable, not . pathEdgeObstructed)
performPathTo :: Creature -> World -> Point2 -> ActionUpdate
performPathTo cr w p
performPathTo :: Action -> Creature -> World -> Point2 -> ActionUpdate
performPathTo a cr w p
| dist cpos p <= crRad (cr ^. crType) = mempty
| fst (crPathing cr) cpos p w = gotowards p
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
Just q -> gotowards q
_ -> ([ChangeStrategy Flee], [])
_ -> ([], [a])
where
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , [PathTo p])
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , [PathTo p a])
cpos = cr ^. crPos . _xy
jit = _mvTurnJit $ crMvType cr