Simplify and correct hammer check for held weapons

This commit is contained in:
2023-05-19 20:00:11 +01:00
parent 17c79e7cee
commit 297b4e0b3c
3 changed files with 29 additions and 32 deletions
+23 -13
View File
@@ -62,7 +62,7 @@ useMod hm = case hm of
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
, hammerCheckI
, blCheck
]
TeslaMod ->
[ useAmmoAmount 1
@@ -109,20 +109,22 @@ useMod hm = case hm of
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
, hammerCheckI
, blCheck
]
ShatterMod ->
[ useAmmoAmount 1
-- , withSoundStart tap3S
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AmmoCheckMod -> [ammoCheckI]
AmmoUseCheckMod -> [useAmmoAmount 1,useTimeCheck, ammoCheckI]
AmmoHammerTimeUseOneMod ->
[ useAmmoAmount 1
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
BangCaneMod ->
[ withMuzFlareI
@@ -133,7 +135,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart tap3S
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
VolleyGunMod ->
[ withRecoil
@@ -144,7 +147,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundItemChoiceStart caneStickSoundChoice
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoRifleMod ->
-- note this is the same as BangCanemMod with the first changed
@@ -167,7 +171,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
ElephantGunMod ->
[ withRecoil
@@ -178,7 +183,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoAmrMod ->
[ withRecoil
@@ -209,7 +215,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
PistolMod ->
[ withMuzFlareI
@@ -220,7 +227,8 @@ useMod hm = case hm of
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoPistolMod ->
[ withMuzFlareI
@@ -254,7 +262,8 @@ useMod hm = case hm of
, lockInvFor 7
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
BurstRifleRepeatMod ->
[ withRecoil
@@ -305,7 +314,8 @@ useMod hm = case hm of
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
RevolverXRepeatMod ->
[ withRecoil
@@ -328,8 +338,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundStart bangEchoS
, useTimeCheck
, hammerCheckI
, ammoCheckI
, blCheck
]
where
f = do
+6 -18
View File
@@ -54,16 +54,16 @@ module Dodge.Item.Weapon.TriggerType (
duplicateOffsets,
duplicateOffsetsV2,
duplicateOffsetsFocus,
hammerCheckI,
hammerCheckL,
shootL,
useTimeCheck,
ammoCheckI,
applyInaccuracy,
modClock,
ammoHammerCheck,
blCheck,
) where
import qualified SDL
import Data.Foldable
import Data.Maybe
import Dodge.Base
@@ -146,17 +146,6 @@ ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
-> w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
-- combined ammo and hammer check: want to be able to auto-reload even if the
-- hammer is down?
ammoHammerCheck :: ChainEffect
ammoHammerCheck eff itm cr w
| _iaLoaded ic <= 0 || not (_iaPrimed ic) = w
-- fromMaybe w (startReloadingWeapon cr w)
| otherwise = case itm ^? itUse . heldHammer of
Just HammerUp -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
_ -> w
where
ic = itm ^?! itUse . heldConsumption . laSource . _InternalSource
itUseCharge :: Int -> Item -> Item
itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
@@ -388,12 +377,11 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
hammerCheckI :: ChainEffect
hammerCheckI f it cr w = case it ^? itUse . heldHammer of
Just HammerUp
| it ^?! itUse . heldConsumption . laSource . _InternalSource . iaPrimed ->
f it cr w
blCheck :: ChainEffect
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
_ -> w
{- | Applies a world effect after a hammer position check.
-1
View File
@@ -86,7 +86,6 @@ stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture
selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
--yint <- sss ^? sssSections . ix i . ssCursor . _Just . scurPos
yint <- selSecYint i j sss
xint <- sss ^? sssSections . ix i . ssIndent
si <- sss ^? sssSections . ix i . ssItems . ix j