Move weapon repetitions into trigger type

This commit is contained in:
2025-06-04 13:23:40 +01:00
parent e77721fe7d
commit 0cb7b54180
9 changed files with 146 additions and 143 deletions
+24 -16
View File
@@ -80,19 +80,28 @@ type ChainEffect =
World
hammerCheck ::
(LabelDoubleTree ComposeLinkType Item -> t1 -> t2 -> t2) ->
(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World) ->
PressType ->
LabelDoubleTree ComposeLinkType Item ->
t1 ->
t2 ->
t2
Creature ->
World ->
World
hammerCheck f pt it cr
| BurstTrigger is <- baseTriggerType (it ^. ldtValue)
, pt == InitialPress = f it cr
. (cWorld . lWorld . delayedEvents .++~ map g is)
| t <- baseTriggerType (it ^. ldtValue)
, t == HammerTrigger || t == AlwaysSingleTrigger
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
, pt /= InitialPress =
id
| otherwise = f it cr
where
g x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffectNoHammer)
upitm x =
it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
& ldtValue . itUse . heldFrame .~ x
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
@@ -123,7 +132,7 @@ heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -
heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew
& doWeaponRepetitions upitm cr
-- & doWeaponRepetitions upitm cr
where
muzzles = t ^. ldtValue . itUse . heldMuzzles
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
@@ -151,17 +160,16 @@ doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
Just NoHeldUseEffect -> w
Nothing -> w
-- need to be careful about inventory lock or item ids here
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
_ -> id
where
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
upitm x =
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
& ldtValue . itUse . heldFrame .~ x
---- need to be careful about inventory lock or item ids here
--doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
--doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
-- Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
-- _ -> id
-- where
-- f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
-- upitm x =
-- itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
-- & ldtValue . itUse . heldFrame .~ x
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
applyCME itm cr cme