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
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Creature.Vocalization (
|
||||
crWarningSounds,
|
||||
crDeathSounds,
|
||||
vocalizationTest,
|
||||
resetCrVocCoolDown,
|
||||
) where
|
||||
@@ -39,6 +41,23 @@ crWarningSounds cr = case cr ^. crType of
|
||||
BarrelCrit{} -> mempty
|
||||
LampCrit{} -> mempty
|
||||
|
||||
crDeathSounds :: Creature -> DeathType -> [SoundID]
|
||||
crDeathSounds cr dt = case cr ^. crType of
|
||||
Avatar{} -> mempty
|
||||
AvatarDead -> mempty
|
||||
ChaseCrit{} -> defaultDeathSounds dt
|
||||
SwarmCrit -> mempty
|
||||
AutoCrit -> mempty
|
||||
BarrelCrit{} -> mempty
|
||||
LampCrit{} -> mempty
|
||||
|
||||
defaultDeathSounds :: DeathType -> [SoundID]
|
||||
defaultDeathSounds = \case
|
||||
CookDeath -> mempty
|
||||
PoisonDeath -> mempty
|
||||
PlainDeath -> mempty
|
||||
GibsDeath -> mempty
|
||||
|
||||
vocalizationTest :: Creature -> Maybe SoundID
|
||||
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
|
||||
Just 0 -> crVocalizationSound cr
|
||||
|
||||
Reference in New Issue
Block a user