Fold together useDelay and itemTriggerType

This commit is contained in:
2025-07-03 22:25:32 +01:00
parent 8a00450e3f
commit a207073846
12 changed files with 404 additions and 365 deletions
+8 -7
View File
@@ -3,9 +3,10 @@ module Dodge.Creature.State (
doDamage,
) where
import Dodge.HeldUse
import Dodge.BaseTriggerType
import Dodge.Data.DoubleTree
import Dodge.Item.Orientation
import Dodge.Item.UseDelay
import Control.Applicative
import Control.Monad
import qualified Data.Map.Strict as M
@@ -166,26 +167,26 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
w & pointerToItem itm . itParams . wTime
%~ (max 0 . subtract 1)
HELD MACHINEPISTOL{}
| fromMaybe 0 (itm ^? itParams . wTime) >= _coolEnd (useDelay itm) ->
| fromMaybe 0 (itm ^? itParams . wTime) >= _coolEnd (itemTriggerType itm) ->
w & pointerToItem itm . itParams . wTime
.~ 0
& pointerToItem itm . itParams . coolSound .~ Nothing
| fromMaybe 0 (itm ^? itParams . wTime) == _coolStart (useDelay itm) ->
| fromMaybe 0 (itm ^? itParams . wTime) == _coolStart (itemTriggerType itm) ->
w
& randGen .~ g
& pointerToItem itm . itParams . wTime +~ 1
& pointerToItem itm . itParams . coolSound ?~ sid
& soundContinue (CrWeaponSound (_crID cr) (fromIntegral $ _itID itm)) (_crPos cr) sid (Just 1)
| fromMaybe 0 (itm ^? itParams . wTime) > _coolStart (useDelay itm) ->
| fromMaybe 0 (itm ^? itParams . wTime) > _coolStart (itemTriggerType itm) ->
w
& pointerToItem itm . itParams . wTime +~ 1
& soundContinue (CrWeaponSound (_crID cr) (fromIntegral $ _itID itm)) (_crPos cr) (fromMaybe undefined (itm ^? itParams . coolSound . _Just)) (Just 1)
| itm ^? itParams . isWarming == Just True ->
w
& pointerToItem itm . itParams . isWarming .~ False
| fromMaybe 0 (itm ^? itParams . wTime) >= _warmStart (useDelay itm) ->
| fromMaybe 0 (itm ^? itParams . wTime) >= _warmStart (itemTriggerType itm) ->
w & pointerToItem itm . itParams . wTime
.~ _coolStart (useDelay itm)
.~ _coolStart (itemTriggerType itm)
| otherwise ->
w & pointerToItem itm . itParams . wTime
.~ 0
@@ -219,7 +220,7 @@ tryUseParent loc w = fromMaybe w $ do
t <- locUp loc
let t' = t ^. locLDT
cr <- w ^? cWorld . lWorld . creatures . ix 0
return $ heldEffectNoHammerCheck t' cr w
return $ heldEffect InitialPress t' cr w
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
trySynthBullet loc w = fromMaybe w $ do