Remove external corpses, handle them as creatures

This commit is contained in:
2025-09-25 09:31:58 +01:00
parent fcb02850d0
commit 23f61081cf
33 changed files with 184 additions and 159 deletions
+39 -26
View File
@@ -5,7 +5,7 @@ import Color
import qualified Data.IntMap.Strict as IM
import qualified Data.List as List
import Dodge.Barreloid
import Dodge.Base.NewID
--import Dodge.Base.NewID
import Dodge.Corpse.Make
import Dodge.Creature.Action
import Dodge.Creature.Radius
@@ -30,7 +30,8 @@ import ShapePicture.Data
-- allow for knockbacks etc to be determined as well as intended movements
updateCreature :: Creature -> World -> World
updateCreature cr
| _crZ cr < negate 100 = (tocr . crHP .~ negate 1) . destroyAllInvItems cr
| null (cr ^? crHP . _HP) = id
| _crZ cr < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
| _crZ cr < 0 = (tocr . crZVel -~ 0.5) . (tocr . crZ +~ _crZVel cr)
| otherwise = updateCreature' cr
where
@@ -69,44 +70,56 @@ checkDeath :: Int -> World -> World
checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w
checkDeath' :: Creature -> World -> World
checkDeath' cr w
| _crHP cr > 0 = w & tocr . crDamage .~ []
| _crHP cr <= -200 = w
& dropAll cr -- the order of
& destroyCreature cr -- these is important
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
& addCrGibs cr
| _crHP cr > -200 && _crDeathTimer cr < 5 = w
checkDeath' cr w = case cr ^. crHP of
HP x | x > 0 -> w & tocr . crDamage .~ []
HP x | x > -200 && _crDeathTimer cr < 5 -> w
& tocr . crDamage .~ []
& tocr . crDeathTimer +~ 1
| otherwise = w
HP x | x > -200 -> w
& dropAll cr -- the order of
& removecr -- these is important
-- & removecr -- these is important
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
& corpseOrGib cr
HP _ -> w
& dropAll cr -- the order of
& tocr . crHP .~ CrIsGibs
-- & destroyCreature cr -- these is important
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
& addCrGibs cr
_ -> w
-- | otherwise = w
-- & dropAll cr -- the order of
-- & removecr -- these is important
-- & stopSoundFrom (CrWeaponSound (_crID cr) 0)
-- & corpseOrGib cr
where
tocr = cWorld . lWorld . creatures . ix (_crID cr)
removecr
| _crID cr == 0 = id
-- hack to get around player creature being killed but left with more than 0 hp
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
-- removecr
-- | _crID cr == 0 = id
-- -- hack to get around player creature being killed but left with more than 0 hp
-- | otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
destroyCreature :: Creature -> World -> World
destroyCreature cr
| _crID cr == 0 = id
-- cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ 0
-- hack to get around player creature being killed but left with more than 0 hp
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
--destroyCreature :: Creature -> World -> World
--destroyCreature cr
-- | _crID cr == 0 = id
-- -- cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ 0
-- -- hack to get around player creature being killed but left with more than 0 hp
-- | otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
-- could look at the amount of damage here (given by maxDamage) too
corpseOrGib :: Creature -> World -> World
corpseOrGib cr w = w & case cr ^? crDamage . to maxDamageType . _Just . _1 of
Just CookingDamage -> addcorpse (thecorpse & cpSPic %~ scorchSPic)
Just PoisonDamage -> addcorpse (thecorpse & cpSPic %~ poisonSPic)
Just CookingDamage -> -- addcorpse (thecorpse & cpSPic %~ scorchSPic)
sethp (CrIsCorpse $ scorchSPic thecorpse)
Just PoisonDamage -> --addcorpse (thecorpse & cpSPic %~ poisonSPic)
sethp (CrIsCorpse $ poisonSPic thecorpse)
Just PhysicalDamage | _crPain cr > 200 -> addCrGibs cr
_ -> addcorpse thecorpse
. sethp CrIsGibs
_ -> -- addcorpse thecorpse
sethp (CrIsCorpse thecorpse)
where
addcorpse ctype = plNew (cWorld . lWorld . corpses) cpID ctype
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
-- addcorpse ctype = plNew (cWorld . lWorld . corpses) cpID ctype
thecorpse = makeCorpse cr
scorchSPic :: SPic -> SPic