Add randomness to multiple crab evasions

This commit is contained in:
2026-04-09 13:28:39 +01:00
parent 0a8a2210c0
commit c8a06bc084
14 changed files with 194 additions and 179 deletions
+13 -9
View File
@@ -371,20 +371,24 @@ muzzleWallCheck w cr = fromMaybe cr $ do
_ -> Nothing
updateCreatureStrides :: World -> World
updateCreatureStrides = cWorld . lWorld . creatures . each %~ updateCreatureStride
updateCreatureStrides w = foldl' updateCreatureStride w (w ^. cWorld . lWorld . creatures)
updateCreatureStride :: Creature -> Creature
updateCreatureStride cr
updateCreatureStride :: World -> Creature -> World
updateCreatureStride w cr
| Walking <- cr ^. crStance . carriage
, CrabCrit {} <- cr ^. crType
= cr & crType . lFootPos %~ f (g 10)
& crType . rFootPos %~ f (g (-10))
= w & f (g 10) (cr ^?! crType . lFootPos) lFootPos
& f (g (-10)) (cr ^?! crType . rFootPos) rFootPos
| Walking <- cr ^. crStance . carriage
, isJust $ cr ^? crType . strideAmount = cr & crType . strideAmount +~ d
| otherwise = cr
, isJust $ cr ^? crType . strideAmount = w & tocr . crType . strideAmount +~ d
| otherwise = w
where
f p q | distance p q > 10 = p - 9 *^ signorm (q - p)
| otherwise = q
tocr = cWorld . lWorld . creatures . ix cid
cid = cr ^. crID
f p q fp
| distance p q > 10 = (tocr . crType . fp .~ (p - 9 *^ signorm (q - p)))
. soundStart (CrFootSound cid 0) (p - 9 *^ signorm (q - p)) foot1S Nothing
| otherwise = id
g x = cr ^. crPos . _xy + x *^ vNormal (unitVectorAtAngle (cr ^. crDir))
s = 2 * fromMaybe 1 (crMvType cr ^? mvSpeed)
-- d = min s . norm $ cr ^. crPos - cr ^. crOldPos