Hack together correct positioning of grenades from attached items

This commit is contained in:
2025-06-28 22:32:12 +01:00
parent 6af2a8cc36
commit d88aed10c7
12 changed files with 225 additions and 178 deletions
+7 -7
View File
@@ -151,9 +151,9 @@ invRootItemEffs cr =
appEndo $
foldMap
(reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
(invLDT (_crInv cr))
(invLDT' (_crInv cr))
invItemLocUpdate :: Creature -> LocationLDT ItemLink CItem -> World -> World
invItemLocUpdate :: Creature -> LocationLDT ItemLink OItem -> World -> World
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
ATTACH BULLETSYNTH -> trySynthBullet loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
@@ -208,21 +208,21 @@ copierItemUpdate itm cr w = fromMaybe w $ do
v <- getItemValue itm' w cr
return $ w & pointerToItem itm . itUse . uValue .~ v
doAnyEquipmentEffect :: LocationLDT ItemLink CItem -> Creature -> World -> World
doAnyEquipmentEffect :: LocationLDT ItemLink OItem -> Creature -> World -> World
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
Just _ -> equipBackgroundEffect loc cr
_ -> id
where
itm = loc ^. locLDT . ldtValue . _1
tryUseParent :: LocationLDT ItemLink CItem -> World -> World
tryUseParent :: LocationLDT ItemLink OItem -> World -> World
tryUseParent loc w = fromMaybe w $ do
t <- locUp loc
let t' = bimap id (^. _1) $ t ^. locLDT
let t' = bimap id id $ t ^. locLDT
cr <- w ^? cWorld . lWorld . creatures . ix 0
return $ heldEffectNoHammerCheck t' cr w
trySynthBullet :: LocationLDT ItemLink CItem -> World -> World
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
trySynthBullet loc w = fromMaybe w $ do
i <- itm ^? itLocation . ilInvID
x <- itm ^? itUse . uaParams . apInt
@@ -278,7 +278,7 @@ trySynthBullet loc w = fromMaybe w $ do
updateHeldRootItem :: Creature -> World -> World
updateHeldRootItem cr = fromMaybe id $ do
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
itmtree <- invRootTrees (_crInv cr) ^? ix invid
itmtree <- invRootTrees' (_crInv cr) ^? ix invid
return $ updateAttachedItems itmtree cr
updateAttachedItems :: LDTree ItemLink CItem -> Creature -> World -> World