From 3119f10c2c4dc2fee26db56e3cf9b8f1ddb4fa2d Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 18 May 2026 15:49:03 +0100 Subject: [PATCH] Use getInventoryPath in useInventoryPath --- src/Dodge/HeldUse.hs | 28 ++++++++++++++++------------ src/Dodge/Inventory/Path.hs | 4 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs index da6cd56de..8feac27ee 100644 --- a/src/Dodge/HeldUse.hs +++ b/src/Dodge/HeldUse.hs @@ -1416,18 +1416,22 @@ useInventoryPath :: Creature -> World -> World -useInventoryPath pt i ip loc cr w = case ip of - ABSOLUTE -> fromMaybe w $ useat i - RELCURS -> fromMaybe w $ do - Sel 0 j <- w ^? hud .diSelection._Just - useat $ i + j - RELITEM -> fromMaybe w $ do - j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt - useat $ i + j - where - useat k = do - guard $ k `IM.member` (cr ^. crInv . unNIntMap) - return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem k pt) +useInventoryPath pt i ip loc cr w = fromMaybe w $ do + invid <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt + j <- getInventoryPath w i ip invid cr + return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem j pt) +-- = case ip of +-- ABSOLUTE -> fromMaybe w $ useat i +-- RELCURS -> fromMaybe w $ do +-- Sel 0 j <- w ^? hud .diSelection._Just +-- useat $ i + j +-- RELITEM -> fromMaybe w $ do +-- j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt +-- useat $ i + j +-- where +-- useat k = do +-- guard $ k `IM.member` (cr ^. crInv . unNIntMap) +-- return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem k pt) --useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of diff --git a/src/Dodge/Inventory/Path.hs b/src/Dodge/Inventory/Path.hs index 2fe393534..f818ad831 100644 --- a/src/Dodge/Inventory/Path.hs +++ b/src/Dodge/Inventory/Path.hs @@ -7,12 +7,12 @@ import Control.Lens import Control.Monad getInventoryPath :: World -> Int -> InventoryPathing -> Int -> Creature -> Maybe Int -getInventoryPath w x ip itid cr = case ip of +getInventoryPath w x ip invid cr = case ip of ABSOLUTE -> checkinvid x RELCURS -> do Sel 0 selid <- w ^? hud .diSelection._Just checkinvid (x + selid) - RELITEM -> checkinvid (itid + x) + RELITEM -> checkinvid (invid + x) where checkinvid y = do guard $ y `IM.member` (cr ^. crInv . unNIntMap)