Allow more general detection of item use focus

This commit is contained in:
2024-12-25 21:26:25 +00:00
parent aec56f4977
commit c788af47bd
12 changed files with 28 additions and 32 deletions
+8 -1
View File
@@ -24,7 +24,7 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
invid <- cr ^? crManipulation . manObject . imSelectedItem
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
let usedloc = case itmloc ^. locLDT . ldtValue . _1 . itUseFocus of
let usedloc = case useLocation itmloc of
UseFromLocation -> itmloc ^. locLDT
UseFromRoot -> locToTop itmloc ^. locLDT
let itm = usedloc ^. ldtValue . _1
@@ -46,6 +46,13 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
where
fst3 (x,_,_) = x
useLocation :: LocationLDT ItemLink ComposedItem -> UseFocus
useLocation loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = UseFromLocation
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile
= UseFromLocation
| otherwise = UseFromRoot
toggleEquipmentAt :: Int -> Creature -> World -> World
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
DoNotMoveEquipment -> w