Allow for more variation in death timers
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user