Move equipment effects into "zipper" item update

This commit is contained in:
2024-12-19 10:00:39 +00:00
parent 19e5927934
commit 3ffe61e6db
5 changed files with 15 additions and 8 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -48,4 +48,4 @@ armourChaseCrit =
, _crMvType = defaultChaseMvType{_mvTurnRad = FloatConst 0.05} , _crMvType = defaultChaseMvType{_mvTurnRad = FloatConst 0.05}
} }
& crEquipment . at OnChest ?~ 0 & crEquipment . at OnChest ?~ 0
& crInvEquipped . at 0 ?~ OnChest -- & crInvEquipped . at 0 ?~ OnChest
+1 -1
View File
@@ -28,7 +28,7 @@ invisibleChaseCrit =
& crCamouflage .~ Invisible & crCamouflage .~ Invisible
& crInv . at 0 ?~ wristInvisibility & crInv . at 0 ?~ wristInvisibility
& crEquipment . at OnLeftWrist ?~ 0 & crEquipment . at OnLeftWrist ?~ 0
& crInvEquipped . at 0 ?~ OnLeftWrist -- & crInvEquipped . at 0 ?~ OnLeftWrist
chaseCrit :: Creature chaseCrit :: Creature
chaseCrit = chaseCrit =
+11 -4
View File
@@ -70,7 +70,7 @@ crUpdate f =
, updateInv -- upInv must be called before invSideEff 22.05.23 , updateInv -- upInv must be called before invSideEff 22.05.23
, invRootItemEffs , invRootItemEffs
, invSideEff , invSideEff
, equipmentEffects -- , equipmentEffects
] ]
checkDeath :: Creature -> World -> World checkDeath :: Creature -> World -> World
@@ -172,11 +172,11 @@ invRootItemEffs :: Creature -> World -> World
invRootItemEffs cr = invRootItemEffs cr =
appEndo $ appEndo $
foldMap foldMap
(reduceLocLDT (Endo . invItemLocUpdate) . LocLDT TopLDT) (reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
(invLDT (_crInv cr)) (invLDT (_crInv cr))
invItemLocUpdate :: LocationLDT ItemLink ComposedItem -> World -> World invItemLocUpdate :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
invItemLocUpdate loc w = case itm ^. itType of invItemLocUpdate cr loc w = doAnyEquipmentEffect cr loc $ case itm ^. itType of
ATTACH BULLETSYNTH -> trySynthBullet loc w ATTACH BULLETSYNTH -> trySynthBullet loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
_ -> w _ -> w
@@ -186,6 +186,13 @@ invItemLocUpdate loc w = case itm ^. itType of
== Just 0 == Just 0
itm = loc ^. locLDT . ldtValue . _1 itm = loc ^. locLDT . ldtValue . _1
doAnyEquipmentEffect :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
doAnyEquipmentEffect cr loc = case itm ^? itLocation . ilEquipPosition . _Just of
Just _ -> useE (_eeUse (_uequipEffect $ _itUse itm)) itm cr
_ -> id
where
itm = loc ^. locLDT . ldtValue . _1
tryUseParent :: LocationLDT ItemLink ComposedItem -> World -> World tryUseParent :: LocationLDT ItemLink ComposedItem -> World -> World
tryUseParent loc w = fromMaybe w $ do tryUseParent loc w = fromMaybe w $ do
t <- locUp loc t <- locUp loc
+1 -1
View File
@@ -24,7 +24,7 @@ equipmentStrValue itm = case _itType itm of
_ -> 0 _ -> 0
crCurrentEquipment :: Creature -> IM.IntMap Item crCurrentEquipment :: Creature -> IM.IntMap Item
crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipPosition)) . _crInv crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipPosition . _Just)) . _crInv
-- merge -- merge
-- dropMissing -- dropMissing
-- dropMissing -- dropMissing