Allow for creature death sounds

This commit is contained in:
2026-01-02 15:06:02 +00:00
parent b414da7dab
commit 71f56c0638
10 changed files with 367 additions and 320 deletions
+14
View File
@@ -1,5 +1,8 @@
module Dodge.Creature.Update (updateCreature) where
import Dodge.Creature.Vocalization
import RandomHelp
import Data.Maybe
import Linear
import NewInt
import Color
@@ -88,11 +91,22 @@ checkDeath' cr w = case cr ^. crHP of
corpseOrGib :: Creature -> World -> World
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
Just CookingDamage -> sethp (CrIsCorpse $ scorchSPic thecorpse)
. dodeathsound CookDeath
Just PoisonDamage -> sethp (CrIsCorpse $ poisonSPic thecorpse)
. dodeathsound PoisonDeath
Just PhysicalDamage | _crPain cr > 200
-> addCrGibs cr . sethp CrIsGibs
. dodeathsound GibsDeath
_ -> sethp (CrIsCorpse thecorpse)
. dodeathsound PlainDeath
where
dodeathsound dt = f dt . stopSoundFrom (CrMouth cid)
f dt w = fromMaybe w $ do
let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w)
sid <- msid
return $ w & soundStart (CrMouth cid) (cr ^. crPos . _xy) sid Nothing
& randGen .~ g
cid = cr ^. crID
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
thecorpse = makeCorpse cr