diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index e45385438..e1ed62953 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -7,6 +7,7 @@ module Dodge.Creature.Action , setMinInvSize , dropUnselected , dropExcept + , dropItem -- , startReloadingWeapon , blinkAction , unsafeBlinkAction diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 23e12eae2..89407dd9f 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -68,11 +68,15 @@ checkDeath :: Creature -> World -> World checkDeath cr w | _crHP cr > 0 = w | otherwise = w - & creatures . at (_crID cr) .~ Nothing +-- & creatures . at (_crID cr) .~ Nothing + & removecr & stopSoundFrom (CrWeaponSound (_crID cr) 0) & over decorations addCorpse & dropByState cr where + removecr + | _crID cr == 0 = creatures . ix (_crID cr) . crUpdate .~ const id + | otherwise = creatures . at (_crID cr) .~ Nothing addCorpse = IM.insertNewKey $ uncurryV translate (_crOldPos cr) $ rotate (_crDir cr) @@ -88,7 +92,7 @@ internalUpdate cr = creatures . ix (_crID cr) %~ -- | Drop items according to the creature state. -- TODO make sure this doesn't mess up any ItemPosition dropByState :: Creature -> World -> World -dropByState cr w = foldr (copyInvItemToFloor cr) w $ case cr ^. crState . crDropsOnDeath of +dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . crDropsOnDeath of DropAll -> IM.keys $ _crInv cr DropSpecific xs -> xs DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w) diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index d47695734..e09f21945 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -143,6 +143,7 @@ data World = World , _genParams :: GenParams , _genPlacements :: IM.IntMap [(Placement,Int)] , _genRooms :: IM.IntMap Room + , _deathDelay :: Maybe Int } newtype GenParams = GenParams diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 0dc07376e..41ec85f4e 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -101,6 +101,7 @@ defaultWorld = World , _genParams = GenParams M.empty , _genPlacements = IM.empty , _genRooms = IM.empty + , _deathDelay = Nothing } youLight :: TempLightSource youLight = TLS diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 174a0c63b..261fbc575 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -269,9 +269,12 @@ markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w } mw wl' = wl' {_wlSeen = True} checkEndGame :: World -> World -checkEndGame w - | _crHP (you w) < 1 = w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu])) - | otherwise = w +checkEndGame w = case _deathDelay w of + Just x | x < 0 -> w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu])) + & deathDelay .~ Nothing + Just _ -> w & deathDelay . _Just -~ 1 + _ | _crHP (you w) < 1 -> w & deathDelay ?~ 50 + _ -> w updateGusts :: World -> World updateGusts w = w