From 30b0bb55c0c5ca85b3a1ccfdc255fc32c305378d Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 3 Apr 2026 21:06:53 +0100 Subject: [PATCH] Allow for more variation in death timers --- src/Dodge/Creature/Update.hs | 15 ++++++++++++--- src/Dodge/Data/Creature.hs | 4 +--- src/Dodge/Default/Creature.hs | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Dodge/Creature/Update.hs b/src/Dodge/Creature/Update.hs index 04ca068d3..f091ba18e 100644 --- a/src/Dodge/Creature/Update.hs +++ b/src/Dodge/Creature/Update.hs @@ -42,7 +42,6 @@ updateCreature cr | cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr | CrIsCorpse _ <- cr ^. crHP = updateCarriage (_crID cr) . chasmTestCorpse cr | null (cr ^? crHP . _HP) = id --- | cr ^. crPos . _z < 0 = (tocr . crZVel -~ 0.5) . (tocr . crPos . _z +~ _crZVel cr) | otherwise = updateLivingCreature cr where tocr = cWorld . lWorld . creatures . ix (_crID cr) @@ -103,10 +102,14 @@ checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix c checkDeath' :: Creature -> World -> World checkDeath' cr w = case cr ^. crHP of HP x | x > 0 -> w & tocr . crDamage .~ [] - HP x | x > -200 && _crDeathTimer cr > 0 -> + HP x | x > -200 && null (cr ^. crDeathTimer) + -> w & tocr %~ startDeathTimer + HP x | x > -200 + ,Just y <- cr ^. crDeathTimer + , y > 0 -> w & tocr . crDamage .~ [] - & tocr . crDeathTimer -~ 1 + & tocr . crDeathTimer . _Just -~ 1 HP _ -> w & dropAll cr -- the order of these is possibly important @@ -117,6 +120,12 @@ checkDeath' cr w = case cr ^. crHP of where tocr = cWorld . lWorld . creatures . ix (_crID cr) +startDeathTimer :: Creature -> Creature +startDeathTimer cr = cr + & crDeathTimer ?~ case cr ^. crType of + HoverCrit {} -> 0 + _ -> 5 + toDeathCarriage :: Carriage -> Carriage toDeathCarriage = \case Flying {} -> Falling diff --git a/src/Dodge/Data/Creature.hs b/src/Dodge/Data/Creature.hs index fcbad6856..b4e1e9fdf 100644 --- a/src/Dodge/Data/Creature.hs +++ b/src/Dodge/Data/Creature.hs @@ -36,10 +36,8 @@ data Creature = Creature { _crPos :: Point3 , _crOldPos :: Point3 , _crOldOldPos :: Point3 --- , _crZVel :: Float , _crDir :: Float , _crMvDir :: Float --- , _crMvAim :: Float , _crType :: CreatureType , _crID :: Int , _crHP :: CrHP @@ -57,7 +55,7 @@ data Creature = Creature , _crGroup :: CrGroup , _crIntention :: Intention , _crName :: String - , _crDeathTimer :: Int + , _crDeathTimer :: Maybe Int , _crWallTouch :: IM.IntMap Point2 } diff --git a/src/Dodge/Default/Creature.hs b/src/Dodge/Default/Creature.hs index 86652aeed..f970034a5 100644 --- a/src/Dodge/Default/Creature.hs +++ b/src/Dodge/Default/Creature.hs @@ -53,8 +53,7 @@ defaultCreature = -- , _crHammerPosition = HammerUp , _crName = "DEFAULTCRNAME" -- , _crStatistics = CreatureStatistics 50 50 50 - , _crDeathTimer = 5 -- how long a creature remains standing - -- after a killing blow has been dealt + , _crDeathTimer = Nothing , _crWallTouch = mempty }