Partial refactor of bullet weapon effect chain

This commit is contained in:
2024-09-16 13:05:59 +01:00
parent 6f372109d9
commit abc0dd1106
23 changed files with 655 additions and 510 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ droneLauncher =
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandOver
& itUse . heldAmmoTypes .~ [DroneAmmo]
& itUse . heldAmmoTypes .~ singleAmmo DroneAmmo
& itType . iyBase .~ HELD DRONELAUNCHER
lasDronesPic :: Item -> SPic
+13 -3
View File
@@ -53,6 +53,7 @@ module Dodge.Item.Weapon.TriggerType (
duplicateOffsetsV2,
duplicateOffsetsFocus,
hammerCheckL,
hammerCheck,
shootL,
useTimeCheck,
ammoCheckI,
@@ -145,7 +146,7 @@ ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
leftitms <- itm ^? ldtLeft
mag <- lookup (AmmoInLink atype) leftitms
mag <- lookup (AmmoInLink 0 atype) leftitms
x <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
guard $ x > 0
return $ eff itm cr $ w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
@@ -363,7 +364,7 @@ useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr = fromMaybe id $ do
atype <- item ^? ldtValue . itUse . heldAmmoTypes . ix 0
leftitms <- item ^? ldtLeft
mag <- lookup (AmmoInLink atype) leftitms
mag <- lookup (AmmoInLink 0 atype) leftitms
magid <- mag ^? ldtValue . itLocation . ipInvID
-- invid <- ams ^? ix 0 . itLocation . ipInvID
return $ eff item cr
@@ -380,7 +381,8 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay . rateTime
_ -> w
where
cid = _crID cr
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
setUseTime = 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
@@ -390,6 +392,14 @@ blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
_ -> w
hammerCheck :: ChainEffect
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
Just HammerTrigger -> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
_ -> w
_ -> f it cr w
{- | Applies a world effect after a hammer position check.
Arbitrary inventory position.
-}