Work on creature destruction/damage update
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
--import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Creature.Damage
|
||||
import Color
|
||||
import Control.Monad
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -39,12 +40,17 @@ import ShapePicture.Data
|
||||
updateCreature :: Creature -> World -> World
|
||||
updateCreature cr
|
||||
| cr ^. crPos . _z < negate 300 = (tocr . crHP .~ CrDestroyed Pitted) . destroyAllInvItems cr
|
||||
| CrIsCorpse _ <- cr ^. crHP = updateCarriage (_crID cr)
|
||||
| null (cr ^? crHP . _HP) = id
|
||||
| otherwise = updateLivingCreature cr
|
||||
| otherwise = case cr ^. crHP of
|
||||
CrIsCorpse{} -> cleardamage . updateCarriage (_crID cr) . damageCorpse (_crID cr) cr
|
||||
CrDestroyed{} -> id
|
||||
HP{} -> cleardamage . updateLivingCreature cr
|
||||
where
|
||||
cleardamage = tocr . crDamage .~ mempty
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
|
||||
damageCorpse :: Int -> Creature -> World -> World
|
||||
damageCorpse _ cr w = w & applyCreatureDamage (cr ^. crDamage) cr
|
||||
|
||||
updateLivingCreature :: Creature -> World -> World
|
||||
updateLivingCreature cr = case _crType cr of
|
||||
Avatar{} ->
|
||||
@@ -226,31 +232,20 @@ checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix c
|
||||
|
||||
checkDeath' :: Creature -> World -> World
|
||||
checkDeath' cr w = case cr ^. crHP of
|
||||
HP x | x > 0 -> w & tocr . crDamage .~ []
|
||||
HP x | x > 0 -> w
|
||||
HP x
|
||||
| x > -200 && null (cr ^. crDeathTimer) ->
|
||||
w & tocr %~ startDeathTimer
|
||||
HP x
|
||||
| x > -200
|
||||
, Just y <- cr ^. crDeathTimer
|
||||
, y > 0 ->
|
||||
w
|
||||
& tocr
|
||||
. crDamage
|
||||
.~ []
|
||||
& tocr
|
||||
. crDeathTimer
|
||||
. _Just
|
||||
-~ 1
|
||||
, y > 0 -> w & tocr . crDeathTimer . _Just -~ 1
|
||||
HP _ ->
|
||||
w
|
||||
& dropAll cr -- the order of these is possibly important
|
||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
& corpseOrGib cr
|
||||
& tocr
|
||||
. crStance
|
||||
. carriage
|
||||
%~ toDeathCarriage
|
||||
& tocr . crStance . carriage %~ toDeathCarriage
|
||||
_ -> w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
|
||||
Reference in New Issue
Block a user