Commit before partial cleanup, continue weapon effect refactor

This commit is contained in:
2024-09-21 16:04:23 +01:00
parent bb18831393
commit 9dff2fcd7a
37 changed files with 817 additions and 856 deletions
+43 -42
View File
@@ -18,7 +18,7 @@ module Dodge.Item.Weapon.TriggerType (
withItem,
withItemUpdate,
withItemUpdateFirst,
rateIncAB,
-- rateIncAB,
torqueBefore,
torqueBeforeAtLeast,
withTorqueAfter,
@@ -161,44 +161,44 @@ itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
--itUseAmmo :: Int -> Item -> Item
--itUseAmmo x = itUse . heldConsumption . laSource . _InternalSource . iaLoaded %~ (max 0 . subtract x)
{- | Fires at an increasing rate.
Has different effect after first fire.
Applies ammo check and use cooldown check.
-}
rateIncAB ::
-- | Extra effect on first fire
ChainEffect ->
-- | Extra effect on continued fire
ChainEffect ->
ChainEffect
rateIncAB exeffFirst exeffCont eff item cr w
| repeatFire =
w
& pointItem
%~ ( (itUse . heldDelay . rateMax .~ max fastRate (currentRate - 1))
-- . itUseAmmo 1
. (itUse . heldDelay . rateTime .~ currentRate)
)
& exeffCont eff item cr
| firstFire =
w
& pointItem
%~ ( (itUse . heldDelay . rateMax .~ startRate - 1)
-- . itUseAmmo 1
. (itUse . heldDelay . rateTime .~ startRate)
)
& exeffFirst eff item cr
| otherwise = w
where
item' = _ldtValue item
fastRate = _rateMinMax . _heldDelay $ _itUse item'
startRate = _rateMaxMax . _heldDelay $ _itUse item'
cid = _crID cr
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_heldDelay (_itUse item'))
repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 1
firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 0
--{- | Fires at an increasing rate.
--Has different effect after first fire.
--Applies ammo check and use cooldown check.
---}
--rateIncAB ::
-- -- | Extra effect on first fire
-- ChainEffect ->
-- -- | Extra effect on continued fire
-- ChainEffect ->
-- ChainEffect
--rateIncAB exeffFirst exeffCont eff item cr w
-- | repeatFire =
-- w
-- & pointItem
-- %~ ( (itUse . heldDelay . rateMax .~ max fastRate (currentRate - 1))
---- . itUseAmmo 1
-- . (itUse . heldDelay . rateTime .~ currentRate)
-- )
-- & exeffCont eff item cr
-- | firstFire =
-- w
-- & pointItem
-- %~ ( (itUse . heldDelay . rateMax .~ startRate - 1)
---- . itUseAmmo 1
-- . (itUse . heldDelay . rateTime .~ startRate)
-- )
-- & exeffFirst eff item cr
-- | otherwise = w
-- where
-- item' = _ldtValue item
-- fastRate = _rateMinMax . _heldDelay $ _itUse item'
-- startRate = _rateMaxMax . _heldDelay $ _itUse item'
-- cid = _crID cr
-- itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
-- pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
-- currentRate = _rateMax (_heldDelay (_itUse item'))
-- repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 1
-- firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 0
-- | Apply effect after a warm up.
@@ -377,7 +377,7 @@ Applies a world effect after an item use cooldown check.
-}
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
Just (FixedRate _ 0) -> f item cr $ setUseTime w
Just (FixedRate _ 0) -> f item cr $ setUseRate w
Just (FixedRate _ _) -> w
Just (WarmUpNoDelay wt wm ws) | wt < wm -> w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
@@ -385,10 +385,11 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
Just (WarmUpNoDelay _ wm _) -> f item cr w
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm+1)
Just NoDelay -> f item cr w
_ -> w
-- Just (VariableRate rmax rtime rmaxmax rminmax) -> undefined
Nothing -> w
where
cid = _crID cr
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime
setUseRate = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime
+~ userate
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax