From b8278279514788868505171c2502988310203b11 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 2 May 2026 19:46:12 +0100 Subject: [PATCH] Tweak slime wall collisions, all creatures cliff collisions (min 10) --- src/Dodge/Creature/State/WalkCycle.hs | 9 +++++++-- src/Dodge/Data/Config.hs | 1 + src/Dodge/Debug.hs | 9 +++++++++ src/Dodge/Room/Tutorial.hs | 4 +++- src/Dodge/Update.hs | 8 +++++--- src/Dodge/WallCreatureCollisions.hs | 10 ++++------ 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Dodge/Creature/State/WalkCycle.hs b/src/Dodge/Creature/State/WalkCycle.hs index 55e0368d5..83844c75d 100644 --- a/src/Dodge/Creature/State/WalkCycle.hs +++ b/src/Dodge/Creature/State/WalkCycle.hs @@ -87,7 +87,7 @@ walkCliffPush :: Creature -> [(Point2,Point2)] -> Point2 walkCliffPush cr xs = pushAgainst (cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy) (-h xs) where cxy = cr ^. crPos . _xy - h = circSegsInside cxy (cr ^. crType . to crRad) + h = circSegsInside cxy (min 10 (cr ^. crType . to crRad)) groundCliffPush :: Creature -> [(Point2,Point2)] -> Point2 groundCliffPush cr xs = x *^ circSegsInside cxy r xs @@ -138,9 +138,14 @@ chasmTestCliffPush f' cr w where cxy = cr ^. crPos . _xy tocr = cWorld . lWorld . creatures . ix (_crID cr) - g = uncurry $ crOnSeg cr + --g = uncurry $ crOnSeg cr + g = uncurry $ crOnSeg' cr f = pointInPoly cxy +crOnSeg' :: Creature -> Point2 -> Point2 -> Bool +{-# INLINE crOnSeg' #-} +crOnSeg' cr = circOnSeg (cr ^. crPos . _xy) (min 10 (cr ^. crType . to crRad)) + chasmRotate :: Creature -> Point2 -> World -> World chasmRotate cr v w | t = rotateTo8 (argV v) w diff --git a/src/Dodge/Data/Config.hs b/src/Dodge/Data/Config.hs index f36f8a2c4..59371eed0 100644 --- a/src/Dodge/Data/Config.hs +++ b/src/Dodge/Data/Config.hs @@ -108,6 +108,7 @@ data DebugBool | Show_writable_values | Show_mouse_click_pos | Muzzle_positions + | Show_cr_hitboxes deriving (Eq, Ord, Bounded, Enum, Show) data ResFactor = DoubleRes | FullRes | HalfRes | QuarterRes | EighthRes | SixteenthRes diff --git a/src/Dodge/Debug.hs b/src/Dodge/Debug.hs index 4177bfa40..21b147671 100644 --- a/src/Dodge/Debug.hs +++ b/src/Dodge/Debug.hs @@ -2,6 +2,7 @@ module Dodge.Debug (debugEvents, drawDebug) where +import Dodge.Creature.Radius import Geometry.Data import Dodge.Render.Label import Dodge.HeldUse @@ -81,6 +82,7 @@ debugEvent' = \case Debug_get -> id Debug_put -> id Muzzle_positions -> id + Show_cr_hitboxes -> id debugItem :: DebugBool -> Universe -> Maybe [DebugItem] debugItem = \case @@ -117,6 +119,7 @@ debugItem = \case Debug_get -> doDebugGet Debug_put -> debugPutItems Muzzle_positions -> mempty + Show_cr_hitboxes -> mempty debugGet :: Universe -> [String] debugGet u = foldMap getPretty $ u ^. uvWorld . cWorld . lWorld . shockwaves @@ -287,7 +290,13 @@ drawDebug u = \case Show_writable_values -> mempty Show_mouse_click_pos -> mempty Muzzle_positions -> showMuzzlePositions u + Show_cr_hitboxes -> foldMap drawCreatureRad (u ^. uvWorld . cWorld . lWorld . creatures) +drawCreatureRad :: Creature -> Picture +drawCreatureRad cr = setLayer DebugLayer + . translate3 (cr ^. crPos) + . color orange + $ circle (crRad (cr ^. crType)) showMuzzlePositions :: Universe -> Picture showMuzzlePositions u = fold $ do diff --git a/src/Dodge/Room/Tutorial.hs b/src/Dodge/Room/Tutorial.hs index 413a57572..b48cac740 100644 --- a/src/Dodge/Room/Tutorial.hs +++ b/src/Dodge/Room/Tutorial.hs @@ -377,7 +377,9 @@ chasmSpitTerminal = do return $ tToBTree "chasmTerm" $ Node - (addDoorToggleTerminal' i1 (PS 150 0) y') + (addDoorToggleTerminal' i1 (PS 150 0) y' + & rmPmnts .:~ (sps0 (PutCrit slimeCrit) & plSpot . psPos .~ V2 150 100) + ) [ treePost [triggerDoorRoom i1, deadEndPSType cr] , treePost [triggerDoorRoom i1, deadEndPSType cr] , return $ cleatOnward $ triggerDoorRoom i1 diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 14e9e92f4..86d5d7db0 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -283,7 +283,7 @@ functionalUpdate = . over uvWorld updateDistortions . over uvWorld updateCreatureSoundPositions . over uvWorld updateCreatureStrides - . over uvWorld pushYouOutFromWalls + . pushYouOutFromWalls . colCrsWalls . over uvWorld simpleCrSprings . over uvWorld updateDoors @@ -342,8 +342,10 @@ functionalUpdate = . updateAimPos . over uvWorld updatePastWorlds -- it might be possible to do this without storing stuff such as the temporary lights/flares etc -pushYouOutFromWalls :: World -> World -pushYouOutFromWalls w = w & cWorld . lWorld . creatures . ix 0 %~ muzzleWallCheck w +pushYouOutFromWalls :: Universe -> Universe +pushYouOutFromWalls u + | debugOn Noclip (u ^. uvConfig) = u + | otherwise = u & uvWorld . cWorld . lWorld . creatures . ix 0 %~ muzzleWallCheck (u ^. uvWorld) -- rotate creature as well? behaviour on ledges? muzzleWallCheck :: World -> Creature -> Creature diff --git a/src/Dodge/WallCreatureCollisions.hs b/src/Dodge/WallCreatureCollisions.hs index 3c93bd3d1..ce06ec0f2 100644 --- a/src/Dodge/WallCreatureCollisions.hs +++ b/src/Dodge/WallCreatureCollisions.hs @@ -30,7 +30,8 @@ colCrWall w c = cornpush . wallpush $ pushthrough c cornpush = crPos . _xy %~ pushOutFromCorners r ls' wallpush = pushCr (w ^. cWorld . lWorld) wls pushthrough = crPos . _xy %~ fst . flip (collidePoint p1) wls -- check push throughs - r = crRad (c ^. crType) + wallBuffer + r | SlimeCrit {} <- c ^. crType = min 10 . crRad $ c ^. crType + | otherwise = crRad $ c ^. crType p1 = c ^. crOldPos . _xy p2 = c ^. crPos . _xy ls = _wlLine <$> IM.elems wls @@ -60,7 +61,8 @@ pushCr w wls cr ap = cr ^. crOldPos . _xy -- sp = cr ^. crPos . _xy ecr = foldl' f (cr & crWallTouch .~ mempty) wls - r = crRad (cr ^. crType) + r | SlimeCrit {} <- cr ^. crType = min 10 . crRad $ cr ^. crType + | otherwise = crRad $ cr ^. crType f acr wl = case pushOutFromWall' r (acr ^. crPos . _xy) (wl ^. wlLine) of Just (p,hitp) -> acr & crPos . _xy .~ p & crWallTouch . at (wl ^. wlID) ?~ hitp Nothing -> acr @@ -95,10 +97,6 @@ wlWlCrush' w p w1 w2 = (t w1 w2 || t w2 w1) -- test either wall is moving toward (wallMovement w p x - wallMovement w p y) > 0 f = normalizeV . uncurry (-) . (^. wlLine) --- the amount to push creatures out from walls, extra to their radius -wallBuffer :: Float -wallBuffer = 0 - ---- assumes that the wall is orientated ---- assumes wall points are different --pushOutFromWall :: Float -> Point2 -> (Point2, Point2) -> Maybe Point2