Simplify and correct hammer check for held weapons
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user