From 18dc4694082e1553542eb017f29c505b2421f3fd Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 3 Apr 2026 09:14:18 +0100 Subject: [PATCH] Tweak corpse/chasm interaction --- src/Dodge/Creature/HandPos.hs | 1 + src/Dodge/Creature/Update.hs | 22 ++++++++++++++++++---- src/Dodge/Data/Creature/Stance.hs | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Dodge/Creature/HandPos.hs b/src/Dodge/Creature/HandPos.hs index 36a66c4b9..ed67b3e54 100644 --- a/src/Dodge/Creature/HandPos.hs +++ b/src/Dodge/Creature/HandPos.hs @@ -65,6 +65,7 @@ handWalkingPos b off cr = case cr ^. crStance . carriage of Floating -> V3 0 off 12 Flying {} -> V3 0 off 12 Boosting _ -> V3 0 off 12 + OnGround -> V3 0 off 12 zeroOneSmooth :: Float -> Float zeroOneSmooth x = (1 - cos (pi * x)) / 2 diff --git a/src/Dodge/Creature/Update.hs b/src/Dodge/Creature/Update.hs index f6d3f4834..0c6ce2679 100644 --- a/src/Dodge/Creature/Update.hs +++ b/src/Dodge/Creature/Update.hs @@ -168,16 +168,30 @@ chasmTestCorpse cr w w & tocr . crZVel -~ 0.5 & tocr . crPos . _z +~ _crZVel cr - | Just (x, y) <- List.find g (w ^. cWorld . cliffs) = + -- only look for TWO cliffs to push along + | (xy:xys) <- filter g (w ^. cWorld . cliffs) = w & soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100) - & tocr . crPos . _xy +~ normalizeV (vNormal (x - y)) + & tocr . crPos . _xy +~ h xy xys | any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5 | otherwise = w where + + h :: (Point2,Point2) -> [(Point2,Point2)] -> Point2 + h (x,y) [] = normalizeV (vNormal (x-y)) + h x (y:_) = unitVectorAtAngle $ tweenAngles (d1/(d1+d2)) (h' x) (h' y) + where + h' :: (Point2,Point2) -> Float + h' = argV . vNormal . uncurry (-) + d a = uncurry closestPointOnLine a (cr ^. crPos . _xy) + d1 :: Float + d1 = norm (cxy - d x) + d2 :: Float + d2 = norm (cxy - d y) + cxy = cr ^. crPos . _xy tocr = cWorld . lWorld . creatures . ix (_crID cr) - g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType) - f = pointInPoly (cr ^. crPos . _xy) + g = uncurry $ circOnSeg cxy (crRad $ cr ^. crType) + f = pointInPoly cxy chasmRotate :: Creature -> Point2 -> World -> World chasmRotate cr v w diff --git a/src/Dodge/Data/Creature/Stance.hs b/src/Dodge/Data/Creature/Stance.hs index 93b94dbef..29bba55d2 100644 --- a/src/Dodge/Data/Creature/Stance.hs +++ b/src/Dodge/Data/Creature/Stance.hs @@ -24,6 +24,7 @@ data Carriage | Flying {_zSpeed :: Float, _flyInertia :: Float, _oldOldPos :: Point2} | Boosting Point2 | Falling {_fallFlail :: Float, _fallFoot :: FootForward} + | OnGround deriving (Eq, Ord, Show, Read) --Generic, Flat) data FootForward = LeftForward | RightForward