Allow for more variation in death timers

This commit is contained in:
2026-04-03 21:06:53 +01:00
parent 789b94b514
commit 30b0bb55c0
3 changed files with 14 additions and 8 deletions
+12 -3
View File
@@ -42,7 +42,6 @@ updateCreature cr
| cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr | cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
| CrIsCorpse _ <- cr ^. crHP = updateCarriage (_crID cr) . chasmTestCorpse cr | CrIsCorpse _ <- cr ^. crHP = updateCarriage (_crID cr) . chasmTestCorpse cr
| null (cr ^? crHP . _HP) = id | null (cr ^? crHP . _HP) = id
-- | cr ^. crPos . _z < 0 = (tocr . crZVel -~ 0.5) . (tocr . crPos . _z +~ _crZVel cr)
| otherwise = updateLivingCreature cr | otherwise = updateLivingCreature cr
where where
tocr = cWorld . lWorld . creatures . ix (_crID cr) 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' :: Creature -> World -> World
checkDeath' cr w = case cr ^. crHP of checkDeath' cr w = case cr ^. crHP of
HP x | x > 0 -> w & tocr . crDamage .~ [] 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 w
& tocr . crDamage .~ [] & tocr . crDamage .~ []
& tocr . crDeathTimer -~ 1 & tocr . crDeathTimer . _Just -~ 1
HP _ -> HP _ ->
w w
& dropAll cr -- the order of these is possibly important & dropAll cr -- the order of these is possibly important
@@ -117,6 +120,12 @@ checkDeath' cr w = case cr ^. crHP of
where where
tocr = cWorld . lWorld . creatures . ix (_crID cr) 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 :: Carriage -> Carriage
toDeathCarriage = \case toDeathCarriage = \case
Flying {} -> Falling Flying {} -> Falling
+1 -3
View File
@@ -36,10 +36,8 @@ data Creature = Creature
{ _crPos :: Point3 { _crPos :: Point3
, _crOldPos :: Point3 , _crOldPos :: Point3
, _crOldOldPos :: Point3 , _crOldOldPos :: Point3
-- , _crZVel :: Float
, _crDir :: Float , _crDir :: Float
, _crMvDir :: Float , _crMvDir :: Float
-- , _crMvAim :: Float
, _crType :: CreatureType , _crType :: CreatureType
, _crID :: Int , _crID :: Int
, _crHP :: CrHP , _crHP :: CrHP
@@ -57,7 +55,7 @@ data Creature = Creature
, _crGroup :: CrGroup , _crGroup :: CrGroup
, _crIntention :: Intention , _crIntention :: Intention
, _crName :: String , _crName :: String
, _crDeathTimer :: Int , _crDeathTimer :: Maybe Int
, _crWallTouch :: IM.IntMap Point2 , _crWallTouch :: IM.IntMap Point2
} }
+1 -2
View File
@@ -53,8 +53,7 @@ defaultCreature =
-- , _crHammerPosition = HammerUp -- , _crHammerPosition = HammerUp
, _crName = "DEFAULTCRNAME" , _crName = "DEFAULTCRNAME"
-- , _crStatistics = CreatureStatistics 50 50 50 -- , _crStatistics = CreatureStatistics 50 50 50
, _crDeathTimer = 5 -- how long a creature remains standing , _crDeathTimer = Nothing
-- after a killing blow has been dealt
, _crWallTouch = mempty , _crWallTouch = mempty
} }