From 34192777a636e6dd2cbc6a5b5db4a82b00bddf28 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 8 Apr 2026 23:11:36 +0100 Subject: [PATCH] Add randomness to chase crit corpses --- src/Dodge/Corpse/Make.hs | 17 ++++++++++------- src/Dodge/Creature/Picture.hs | 2 +- src/Dodge/Creature/Update.hs | 10 +++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Dodge/Corpse/Make.hs b/src/Dodge/Corpse/Make.hs index bd28c0647..00477b97b 100644 --- a/src/Dodge/Corpse/Make.hs +++ b/src/Dodge/Corpse/Make.hs @@ -11,11 +11,12 @@ import Dodge.Data.Creature import Geometry import Shape import ShapePicture +import RandomHelp -makeCorpse :: Creature -> SPic -makeCorpse cr = case cr ^. crType of +makeCorpse :: StdGen -> Creature -> SPic +makeCorpse g cr = case cr ^. crType of HoverCrit{} -> noPic $ drawHoverCrit cr - ChaseCrit{} -> noPic $ chaseCorpse cr + ChaseCrit{} -> noPic $ chaseCorpse g cr _ -> noPic . scaleSH (V3 crsize crsize crsize) @@ -29,8 +30,8 @@ makeCorpse cr = case cr ^. crType of crsize = 0.1 * crRad (cr ^. crType) rotmdir = rotateSH (_crMvDir cr - _crDir cr) -chaseCorpse :: Creature -> Shape -chaseCorpse cr = mconcat +chaseCorpse :: StdGen -> Creature -> Shape +chaseCorpse g cr = mconcat [colorSH (_skinUpper cskin) . upperPrismPolyHalfMI 0 $ polyCirc 3 12 & each %~ vNormal & each . _y *~ 0.6 @@ -41,7 +42,9 @@ chaseCorpse cr = mconcat , rotmdir $ colorSH (_skinLower cskin) $ deadFeet cr ] where - neckq = (V3 6 0 0, Q.qid) + neckq = (V3 6 0 0, Q.qz a) + a = fst $ randomR (-2,2) $ g + b = fst $ randomR (-2,2) $ g cskin = crShape $ _crType cr -- this should be fixed rotmdir = rotateSH (_crMvDir cr - _crDir cr) - headq = neckq `Q.comp` (V3 16 0 0, Q.qid ) + headq = neckq `Q.comp` (V3 16 0 0, Q.qz b ) diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index 416a9d73f..4e00341be 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -84,7 +84,7 @@ drawChaseCrit w cr = mconcat rotmdir = rotateSH (_crMvDir cr - _crDir cr) crabUpperBody :: World -> Creature -> Shape -crabUpperBody w cr = colorSH (_skinUpper cskin) +crabUpperBody _ cr = colorSH (_skinUpper cskin) $ (overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI 5 $ polyCirc 4 12 & each . _x *~ 0.6) diff --git a/src/Dodge/Creature/Update.hs b/src/Dodge/Creature/Update.hs index 629c2b44f..a4e98539a 100644 --- a/src/Dodge/Creature/Update.hs +++ b/src/Dodge/Creature/Update.hs @@ -133,7 +133,7 @@ toDeathCarriage = \case -- could look at the amount of damage here (given by maxDamage) too corpseOrGib :: Creature -> World -> World -corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of +corpseOrGib cr w = w & case cr ^? crDamage . to maxDamageType . _Just . _1 of Just CookingDamage -> sethp (CrIsCorpse $ scorchSPic thecorpse) . dodeathsound CookDeath @@ -150,16 +150,16 @@ corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of . dodeathsound PlainDeath where dodeathsound dt = f dt . stopSoundFrom (CrMouth cid) - f dt w = fromMaybe w $ do - let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w) + f dt w' = fromMaybe w' $ do + let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w') sid <- msid return $ - w + w' & soundStart (CrMouth cid) (cr ^. crPos . _xy) sid Nothing & randGen .~ g cid = cr ^. crID sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x - thecorpse = makeCorpse cr + thecorpse = makeCorpse (w ^. randGen) cr scorchSPic :: SPic -> SPic scorchSPic = _1 %~ overColSH (mixColors 0.9 0.1 black . normalizeColor)