Fix bug in creature death drop/destruction ordering
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (602 modules, at 10:34:04)
|
All good (602 modules, at 11:19:44)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -179,10 +179,6 @@ dropItem cr invid = rmInvItem (_crID cr) invid .
|
|||||||
copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
|
copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
|
||||||
where
|
where
|
||||||
itm = fromMaybe (error "dropItem cannot find item") $ cr ^? crInv . ix invid
|
itm = fromMaybe (error "dropItem cannot find item") $ cr ^? crInv . ix invid
|
||||||
-- the following should be done in rmInvItem
|
|
||||||
-- mayberemoveequip = case _crLeftInvSel cr of
|
|
||||||
-- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
|
|
||||||
-- _ -> id
|
|
||||||
|
|
||||||
-- | Get your creature to drop the item under the cursor.
|
-- | Get your creature to drop the item under the cursor.
|
||||||
youDropItem :: World -> World
|
youDropItem :: World -> World
|
||||||
|
|||||||
@@ -71,14 +71,14 @@ stateUpdate f =
|
|||||||
]
|
]
|
||||||
|
|
||||||
checkDeath :: Creature -> World -> World
|
checkDeath :: Creature -> World -> World
|
||||||
checkDeath cr
|
checkDeath cr w
|
||||||
| _crHP cr > 0 =
|
| _crHP cr > 0 = w
|
||||||
cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
& cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
||||||
| otherwise =
|
| otherwise = w
|
||||||
dropByState cr
|
& dropByState cr -- the order of
|
||||||
. removecr
|
& removecr -- these is important
|
||||||
. stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||||
. corpseOrGib cr
|
& corpseOrGib cr
|
||||||
where
|
where
|
||||||
removecr
|
removecr
|
||||||
| _crID cr == 0 =
|
| _crID cr == 0 =
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
--{-# LANGUAGE TupleSections #-}
|
--{-# LANGUAGE TupleSections #-}
|
||||||
module Dodge.Inventory (
|
module Dodge.Inventory (
|
||||||
checkInvSlotsYou,
|
checkInvSlotsYou,
|
||||||
rmSelectedInvItem,
|
|
||||||
rmInvItem,
|
rmInvItem,
|
||||||
destroyInvItem,
|
destroyInvItem,
|
||||||
updateCloseObjects,
|
updateCloseObjects,
|
||||||
@@ -59,7 +58,6 @@ rmInvItem ::
|
|||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
rmInvItem cid invid w = w
|
rmInvItem cid invid w = w
|
||||||
-- & pointcid %~ crCancelReloading
|
|
||||||
& doanyitemeffect
|
& doanyitemeffect
|
||||||
& dounequipfunction --the ordering of these is
|
& dounequipfunction --the ordering of these is
|
||||||
& pointcid . crInv %~ f -- important
|
& pointcid . crInv %~ f -- important
|
||||||
@@ -110,85 +108,6 @@ rmInvItem cid invid w = w
|
|||||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||||
| otherwise = x
|
| otherwise = x
|
||||||
|
|
||||||
--updateCreatureItemLocations :: Int -> World -> World
|
|
||||||
--updateCreatureItemLocations crid w = fromMaybe w $ do
|
|
||||||
-- inv <- w ^? cWorld . lWorld . creatures . ix crid . crInv
|
|
||||||
-- return $ foldl' updateItemLocation w inv
|
|
||||||
--
|
|
||||||
--updateItemLocation :: World -> Item -> World
|
|
||||||
--updateItemLocation w itm = w
|
|
||||||
-- & cWorld . lWorld . itemLocations . ix (itm ^. itID) .~ itm ^. itLocation
|
|
||||||
|
|
||||||
---- | after this the item at the inventory position will no longer exist
|
|
||||||
--rmInvItem ::
|
|
||||||
-- -- | Creature id
|
|
||||||
-- Int ->
|
|
||||||
-- -- | Inventory position
|
|
||||||
-- Int ->
|
|
||||||
-- World ->
|
|
||||||
-- World
|
|
||||||
--rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of
|
|
||||||
-- Just x
|
|
||||||
-- | x > 1 ->
|
|
||||||
-- w & pointcid . crInv . ix invid . itUse . useAmount -~ 1
|
|
||||||
-- & worldEventFlags . at InventoryChange ?~ ()
|
|
||||||
-- _ ->
|
|
||||||
-- w
|
|
||||||
---- & pointcid %~ crCancelReloading
|
|
||||||
-- & doanyitemeffect
|
|
||||||
-- & dounequipfunction --the ordering of these is
|
|
||||||
-- & pointcid . crInv %~ f -- important
|
|
||||||
--
|
|
||||||
-- & removeAnySlotEquipment
|
|
||||||
-- & pointcid . crEquipment . each %~ g
|
|
||||||
-- & pointcid . crInvEquipped %~ IM.delete invid
|
|
||||||
-- & pointcid . crInvEquipped %~ IM.mapKeys g
|
|
||||||
--
|
|
||||||
-- & removeanyactivation
|
|
||||||
-- & pointcid . crHotkeys . each %~ g
|
|
||||||
-- & pointcid . crInvHotkeys %~ IM.delete invid
|
|
||||||
-- & pointcid . crInvHotkeys %~ IM.mapKeys g
|
|
||||||
--
|
|
||||||
-- & updateselection
|
|
||||||
-- & worldEventFlags . at InventoryChange ?~ ()
|
|
||||||
-- where
|
|
||||||
-- getcid = cWorld . lWorld . creatures . ix cid
|
|
||||||
-- pointcid = cWorld . lWorld . creatures . ix cid
|
|
||||||
--
|
|
||||||
-- updateselection
|
|
||||||
-- | cid == 0 && cr ^? crManipulation . manObject . inInventory . ispItem == Just invid =
|
|
||||||
-- scrollAugInvSel (-1) . scrollAugInvSel 1 . updateInventorySectionItems
|
|
||||||
-- | otherwise =
|
|
||||||
-- pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
|
||||||
--
|
|
||||||
-- cr = w ^?! cWorld . lWorld . creatures . ix cid
|
|
||||||
-- itm = _crInv cr IM.! invid
|
|
||||||
-- dounequipfunction = fromMaybe id $ do
|
|
||||||
-- rmf <- itm ^? itUse . equipEffect . eeOnRemove
|
|
||||||
-- return $ useE rmf itm cr
|
|
||||||
-- doanyitemeffect = fromMaybe id $ do
|
|
||||||
-- rmf <- itm ^? itEffect . ieOnDrop
|
|
||||||
-- return $ doInvEffect rmf itm cr
|
|
||||||
-- removeAnySlotEquipment = fromMaybe id $ do
|
|
||||||
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
|
|
||||||
-- return $ pointcid . crEquipment . at epos .~ Nothing
|
|
||||||
-- removeanyactivation = fromMaybe id $ do
|
|
||||||
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
|
|
||||||
-- return $ pointcid . crHotkeys . at epos .~ Nothing
|
|
||||||
-- maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
|
||||||
-- f inv =
|
|
||||||
-- let (xs, ys) = IM.split invid inv
|
|
||||||
-- in xs `IM.union` IM.mapKeysMonotonic (subtract 1) ys
|
|
||||||
-- -- the following might not work if a non-player creature drops their last item
|
|
||||||
-- g x
|
|
||||||
-- | x > invid || Just x == maxk = max 0 $ x - 1
|
|
||||||
-- | otherwise = x
|
|
||||||
|
|
||||||
rmSelectedInvItem :: Int -> World -> World
|
|
||||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . imSelectedItem of
|
|
||||||
Just i -> rmInvItem cid i w
|
|
||||||
Nothing -> w
|
|
||||||
|
|
||||||
-- this looks ugly...
|
-- this looks ugly...
|
||||||
updateCloseObjects :: World -> World
|
updateCloseObjects :: World -> World
|
||||||
updateCloseObjects w =
|
updateCloseObjects w =
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import SDL
|
|||||||
updateWheelEvent :: Int -> World -> World
|
updateWheelEvent :: Int -> World -> World
|
||||||
updateWheelEvent yi w = case w ^. hud . hudElement of
|
updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||||
DisplayCarte
|
DisplayCarte
|
||||||
| rbDown -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
|
| bdown ButtonRight -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
|
||||||
| otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
|
| otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
|
||||||
DisplayInventory{_subInventory = NoSubInventory}
|
DisplayInventory{_subInventory = NoSubInventory}
|
||||||
-- functions that modify the inventory should be centralised so that
|
-- functions that modify the inventory should be centralised so that
|
||||||
@@ -30,14 +30,15 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
|||||||
-- (_,EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
-- (_,EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||||
-- (Nothing, _) -> w
|
-- (Nothing, _) -> w
|
||||||
-- (Just (invid,hs), _) -> doHeldScroll invid hs y w
|
-- (Just (invid,hs), _) -> doHeldScroll invid hs y w
|
||||||
| rbDown -> case _rbOptions w of
|
| bdown ButtonRight -> case _rbOptions w of
|
||||||
EquipOptions{} -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
EquipOptions{} -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||||
NoRightButtonOptions -> w
|
NoRightButtonOptions -> w
|
||||||
| lbDown -> w & wCam . camZoom +~ y
|
| bdown ButtonLeft -> w & wCam . camZoom +~ y
|
||||||
| invKeyDown -> changeSwapSel yi w
|
| invKeyDown -> changeSwapSel yi w
|
||||||
| otherwise -> scrollAugInvSel yi w
|
| otherwise -> scrollAugInvSel yi w
|
||||||
--DisplayInventory{_subInventory = ExamineInventory mi} -> w
|
DisplayInventory{_subInventory = ExamineInventory}
|
||||||
DisplayInventory{_subInventory = ExamineInventory} -> w
|
| invKeyDown -> scrollAugInvSel yi w
|
||||||
|
| otherwise -> w
|
||||||
-- | invKeyDown && rbDown -> w & moveTweakSel yi
|
-- | invKeyDown && rbDown -> w & moveTweakSel yi
|
||||||
-- | invKeyDown -> scrollAugInvSel yi w
|
-- | invKeyDown -> scrollAugInvSel yi w
|
||||||
-- | rbDown -> w & changeTweakParam mi yi
|
-- | rbDown -> w & changeTweakParam mi yi
|
||||||
@@ -52,8 +53,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
|||||||
return $ length $ equipSiteToPositions esite
|
return $ length $ equipSiteToPositions esite
|
||||||
y = fromIntegral yi
|
y = fromIntegral yi
|
||||||
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
||||||
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
|
bdown b = b `M.member` _mouseButtons (_input w)
|
||||||
lbDown = ButtonLeft `M.member` _mouseButtons (_input w)
|
|
||||||
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
|
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
|
||||||
|
|
||||||
moveCombineSel :: Int -> World -> World
|
moveCombineSel :: Int -> World -> World
|
||||||
|
|||||||
Reference in New Issue
Block a user