Pass ammo magazine items to held item use chain
This commit is contained in:
@@ -32,10 +32,23 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
|
||||
where
|
||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
getAmmoMags :: Item -> Creature -> [Item]
|
||||
getAmmoMags itm cr = fromMaybe [] $ do
|
||||
atypes <- itm ^? itUse . heldConsumption
|
||||
i <- itm ^? itLocation . ipInvID
|
||||
let amags = cr ^.. crInv . dropping (i + 1) traverse
|
||||
mmags = zipWith f atypes amags
|
||||
return $ catMaybes mmags
|
||||
where
|
||||
f atype itm' = do
|
||||
itype <- itm' ^? itUse . amagType
|
||||
guard $ itype == atype
|
||||
return $ itm'
|
||||
|
||||
itemEffect :: Creature -> Item -> World -> World
|
||||
itemEffect cr it w = case it ^. itUse of
|
||||
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
||||
foldl' (&) (useHeld eff) (useMod usemods) it cr w
|
||||
foldl' (&) (useHeld eff) (useMod usemods) (getAmmoMags it cr) it cr w
|
||||
& pointerToItem it . itUse . heldHammer .~ HammerDown
|
||||
LeftUse{} -> doequipmentchange
|
||||
EquipUse{} -> doequipmentchange
|
||||
|
||||
Reference in New Issue
Block a user