From 2d1cf4b37132418bb027c1134eb8f1a2e016055b Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 3 Apr 2026 15:31:11 +0100 Subject: [PATCH] Improve chaseCrit shape --- src/Dodge/Creature/MoveType.hs | 1 + src/Dodge/Creature/Picture.hs | 9 +++++++-- src/Dodge/Creature/YourControl.hs | 15 +++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Dodge/Creature/MoveType.hs b/src/Dodge/Creature/MoveType.hs index 87d92a930..c7e736565 100644 --- a/src/Dodge/Creature/MoveType.hs +++ b/src/Dodge/Creature/MoveType.hs @@ -28,6 +28,7 @@ defaultChaseMvType = CrMvType { _mvSpeed = 2 , _mvTurnRad = FloatAbsCheckGreaterLess (pi / 4) 0.2 0.05 + --, _mvTurnJit = 0.3 , _mvTurnJit = 0.05 , _mvAimSpeed = FloatAbsCheckGreaterLess (pi / 8) 0.2 0.01 } diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index 2f60a8750..7e3564054 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -89,8 +89,8 @@ chaseUpperBody w cr = colorSH (_skinUpper cskin) cskin = crShape $ _crType cr torsoq = (V3 0 0 (10 + tz + tbob),Q.qid) mcool = 1 - min 10 (fromIntegral . _meleeCooldown $ _crType cr) / 10 - neckq = torsoq `Q.comp` (V3 6 0 0,Q.axisAngle (V3 0 1 0) (-1.8*mcool)) - headq = neckq `Q.comp` (V3 16 0 0, Q.axisAngle (V3 0 1 0) (2*mcool+vocaltilt) * Q.qz headrot ) + neckq = torsoq `Q.comp` (V3 6 0 0, Q.qz aimrot * Q.axisAngle (V3 0 1 0) (-1.8*mcool)) + headq = neckq `Q.comp` (V3 16 0 0, Q.axisAngle (V3 0 1 0) (2*mcool+vocaltilt) * Q.qz aimrot ) vocaltilt = case cr ^? crVocalization . vcTime of Just x | x < 20 -> -pi * 0.05 * (10 - abs (fromIntegral x - 10)) _ -> 0 @@ -103,6 +103,11 @@ chaseUpperBody w cr = colorSH (_skinUpper cskin) --tbob = 2 * oneSmooth ((sLen - 2*i) / sLen) f i = (sLen - 2*i) / sLen cxy = cr ^. crPos . _xy + aimrot = fromMaybe pi $ do + i <- cr ^. crIntention . targetCr + tcxy <- w ^? cWorld . lWorld . creatures . ix i . crPos . _xy + guard $ hasLOSIndirect cxy tcxy w + return . (0.5*) . nearZeroAngle $ argV (tcxy - cxy) - cr ^. crDir headrot = fromMaybe pi $ do i <- cr ^. crIntention . targetCr tcxy <- w ^? cWorld . lWorld . creatures . ix i . crPos . _xy diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index 6abb7c5c2..0fa887b0f 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -117,19 +117,14 @@ wasdWithAiming w cr = wasdAim inp w $ wasdMovement (w ^. cWorld . lWorld) inp ca wasdAim :: Input -> World -> Creature -> Creature wasdAim inp w cr | SDL.ButtonRight `M.member` _mouseButtons inp - , AtEase <- cr ^. crStance . posture = setposture Aiming (-twoHandTwistAmount) --- cr --- & crStance . posture .~ Aiming --- & doAimTwist (cr ^? crManipulation . manObject . imAimStance) (-twoHandTwistAmount) - | SDL.ButtonRight `M.member` _mouseButtons inp = - aimTurn (w ^. cWorld . lWorld) mousedir cr + , AtEase <- cr ^. crStance . posture = + setposture Aiming (-twoHandTwistAmount) + | SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn (w ^. cWorld . lWorld) mousedir cr | Aiming{} <- cr ^. crStance . posture = setposture AtEase twoHandTwistAmount --- cr --- & crStance . posture .~ AtEase --- & doAimTwist (cr ^? crManipulation . manObject . imAimStance) twoHandTwistAmount | otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr where - setposture x r = cr + setposture x r = + cr & crStance . posture .~ x & doAimTwist (cr ^? crManipulation . manObject . imAimStance) r mousedir = argV $ w ^. cWorld . lWorld . lAimPos - (cr ^. crPos . _xy)