Remove destroyed creatures rather than setting flag

Sill only set flag for avatar
This commit is contained in:
2026-05-08 10:45:05 +01:00
parent 84e95da2b5
commit ad998fb622
7 changed files with 26 additions and 18 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ updateExpBarrel ps cr w = case cr ^. crHP of
HP _ ->
w
& makeExplosionAt (CrIndirectO (cr ^. crID)) ((cr ^. crPos) & _z +~ 20) 0
& cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ CrDestroyed Gibbed
& cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
_ -> w
where
f w' p = makeSpark NormalSpark (p + normalizeV p + cr ^. crPos . _xy) (argV p) w'
@@ -43,7 +43,7 @@ updateExpBarrel ps cr w = case cr ^. crHP of
updateBarrel :: Creature -> World -> World
updateBarrel cr = case cr ^. crHP of
HP x | x > 0 -> doDamage (cr ^. crID)
HP _ -> cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ CrDestroyed Gibbed
HP _ -> cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
_ -> id
damsToExpBarrel :: [Damage] -> Creature -> Creature
+1 -1
View File
@@ -199,7 +199,7 @@ crHeight cr = case cr ^. crHP of
BarrelCrit{} -> 20
_ -> error $ "Need to define crHeight for this crType:\n" <> unlines (prettyShort (cr ^. crType))
CrIsCorpse{} -> Just 5
CrDestroyed{} -> Nothing
AvatarDestroyed{} -> Nothing
wallToSurface :: Wall -> (Point3, Point3, [(Point3, Point3)])
wallToSurface wl = (g x, g $ vNormal (x - y), [(g x, g (y - x)), (g y, g (x - y))])
+1 -1
View File
@@ -138,7 +138,7 @@ hasAutoDoorBody cr = crittype && notdestroyed
notdestroyed = case cr ^. crHP of
HP {} -> True
CrIsCorpse {} -> True
CrDestroyed {} -> False
AvatarDestroyed {} -> False
crittype = case cr ^. crType of
SlimeCrit {} -> False
BeeCrit {} -> False
+5 -4
View File
@@ -46,10 +46,11 @@ import qualified Data.IntSet as IS
-- allow for knockbacks etc to be determined as well as intended movements
updateCreature :: Creature -> World -> World
updateCreature cr
| cr ^. crPos . _z < negate 300 = (tocr . crHP .~ CrDestroyed Pitted) . destroyAllInvItems cr
| cr ^. crPos . _z < negate 300 = (cWorld . lWorld . creatures . at (cr ^. crID) %~ destroyCreature)
. destroyAllInvItems cr
| otherwise = case cr ^. crHP of
CrIsCorpse{} -> cleardamage . updateCarriage (_crID cr) . damageCorpse (_crID cr) cr
CrDestroyed{} -> id
AvatarDestroyed{} -> id
HP{} -> cleardamage . updateLivingCreature cr
where
cleardamage = tocr . crDamage .~ mempty
@@ -251,7 +252,7 @@ updateCalmBee cr cid w
slimeCritUpdate :: Int -> World -> World
slimeCritUpdate cid w
| r < 5 = w & cWorld . lWorld . creatures . ix cid . crHP .~ CrDestroyed Gibbed
| r < 5 = w & cWorld . lWorld . creatures . at cid .~ Nothing
| Just hitp <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmPos
, Just hitv <- w ^? cWorld . lWorld . creatures . ix cid . crDamage . ix 0 . dmVector
, Just w' <- splitSlimeCrit' hitp hitv cid cr w = w'
@@ -459,7 +460,7 @@ corpseOrGib cr w =
Just PhysicalDamage
| _crPain cr > 300 ->
makeCrGibs cr
. sethp (CrDestroyed Gibbed)
. (cWorld . lWorld . creatures . at (cr ^. crID) %~ destroyCreature)
. dodeathsound GibsDeath
_ ->
sethp (CrIsCorpse thecorpse)
+8 -1
View File
@@ -63,7 +63,14 @@ data Creature = Creature
data CrHP
= HP Int
| CrIsCorpse SPic
| CrDestroyed CrDestructionType
| AvatarDestroyed
-- | CrDestroyed CrDestructionType
destroyCreature :: Maybe Creature -> Maybe Creature
destroyCreature mcr
| Just cr <- mcr
, _crID cr == 0 = Just cr{_crHP = AvatarDestroyed}
| otherwise = Nothing
data CrDestructionType = Gibbed | Pitted | Swallowed
-1
View File
@@ -51,7 +51,6 @@ crslime :: Creature -> Int
crslime cr = case cr ^. crType of
SlimeCrit {_slimeSlime=r} | HP{} <- cr ^. crHP -> r -- r ^ (2::Int)
HiveCrit {_hiveSlime=x} -> x
BeeCrit {} | CrDestroyed{} <- cr ^. crHP -> 0
BeeCrit {_beeSlime=x} -> 400 + x
_ -> 0
+9 -8
View File
@@ -611,13 +611,14 @@ setOldPos cr = cr & crOldPos .~ _crPos cr
zoneCreatures :: World -> World
zoneCreatures w =
w & crZoning .~ foldl' zoneCreature mempty (IM.filter zonableCreature $ w ^. cWorld . lWorld . creatures)
-- w & crZoning .~ foldl' zoneCreature mempty (IM.filter zonableCreature $ w ^. cWorld . lWorld . creatures)
w & crZoning .~ foldl' zoneCreature mempty (w ^. cWorld . lWorld . creatures)
zonableCreature :: Creature -> Bool
zonableCreature cr = case cr ^. crHP of
HP{} -> True
CrIsCorpse{} -> True
CrDestroyed{} -> False
--zonableCreature :: Creature -> Bool
--zonableCreature cr = case cr ^. crHP of
-- HP{} -> True
-- CrIsCorpse{} -> True
-- AvatarDestroyed{} -> False
updateCreatureSoundPositions :: World -> World
updateCreatureSoundPositions w =
@@ -1005,7 +1006,7 @@ canSpring cr =
cr ^. crPos . _z >= 0 && case cr ^. crHP of
HP{} -> True
CrIsCorpse{} -> True
CrDestroyed{} -> False
AvatarDestroyed{} -> False
crCrSpring :: Creature -> Creature -> World -> World
crCrSpring c1 c2
@@ -1087,7 +1088,7 @@ feedSlime s c w = fromMaybe w $ do
& slimeSuck s c
else
w
& cWorld . lWorld . creatures . ix (c ^. crID) . crHP .~ CrDestroyed Swallowed
& cWorld . lWorld . creatures . at (c ^. crID) %~ destroyCreature
& cWorld . lWorld . creatures . ix (s ^. crID) %~ f
& slimeEatSound (s ^. crID) (s ^. crPos . _xy)
where