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
+5 -5
View File
@@ -25,7 +25,7 @@ useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
useItemLoc cr usedloc pt w
useItemLoc :: Creature ->
LocationLDT ItemLink CItem ->
LocationLDT ItemLink OItem ->
PressType ->
World ->
Maybe World
@@ -33,13 +33,13 @@ useItemLoc cr loc pt w
| HeldPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot
, Aiming {} <- cr ^. crStance . posture =
return $ heldEffect pt (bimap id (^. _1) ldt) cr w
return $ heldEffect pt (bimap id id ldt) cr w
| GadgetPlatformSF <- sf =
return $ gadgetEffect pt loc cr w
| UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, Aiming {} <- cr ^. crStance . posture =
return $ heldEffect pt (bimap id (^. _1) ldt) cr w
return $ heldEffect pt (bimap id id ldt) cr w
| RemoteDetonatorSF <- sf
, pt == InitialPress =
return $ activateDetonator ldt w
@@ -62,7 +62,7 @@ useItemLoc cr loc pt w
ldt = loc ^. locLDT
itm = ldt ^. ldtValue . _1
useLocation :: LocationLDT ItemLink CItem -> LocationLDT ItemLink CItem
useLocation :: LocationLDT ItemLink OItem -> LocationLDT ItemLink OItem
useLocation loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itType . ibtEquip = loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0 =
@@ -80,7 +80,7 @@ structureUseAtLoc = \case
MapperSF -> True
_ -> False
activateDetonator :: LDTree ItemLink CItem -> World -> World
activateDetonator :: LDTree ItemLink OItem -> World -> World
activateDetonator det = fromMaybe id $ do
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0