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