Work on machine pistol

This commit is contained in:
2025-06-26 01:09:09 +01:00
parent 5b35b4c6c8
commit 7830b0e2c1
14 changed files with 432 additions and 394 deletions
+27 -16
View File
@@ -98,38 +98,42 @@ hammerCheck f pt it cr
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
-- | Applies a world effect after an item use cooldown check.
-- input buffering?
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
FixedRate rate
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr w
-- note that the time last used must be updated later in the chain!
FixedRate{} -> w
WarmUpNoDelay wm ws
WarmUpNoDelay wm
| _wTime (_itParams $ _ldtValue item) < wm ->
w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 2
WarmUpNoDelay wm _ ->
f item cr w
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime .~ (wm + 1)
w & setwarming
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . itType) (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
WarmUpNoDelay {} -> f item cr w & setwarming
NoDelay -> f item cr w
where
lastused = item ^. ldtValue . itTimeLastUsed
cid = _crID cr
setUseRate =
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
setwarming =
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . isWarming
%~ const True
-- the following is unsafe, but if ilInvID isn't correctly set we probably
-- will have problems elsewhere also
itRef = item ^?! ldtValue . itLocation . ilInvID
heldEffectMuzzles :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w =
doHeldUseEffect t cr
setusetime . doHeldUseEffect t cr
. uncurry (applyCME (_ldtValue t) cr)
. foldl' (useLoadedAmmo t cr) (False, w)
$ loadedmuzzles
where
(_, loadedmuzzles) = mapAccumR loadMuzzle t . itemMuzzles $ t ^. ldtValue
setusetime =
cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itid . itTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
itid = t ^?! ldtValue . itLocation . ilInvID
itemMuzzles :: Item -> [Muzzle]
@@ -161,8 +165,9 @@ heldItemMuzzles = \case
& ix (i `div` 2) . mzFlareType .~ BasicFlare
& ix (i -1) . mzFlareType .~ NoLightFlare
PISTOL -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
AUTOPISTOL -> [Muzzle (V2 20 0) 0 0 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
SMG -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
MACHINEPISTOL -> [Muzzle (V2 10 0) 0 0.15 0 MiniGunFlare MuzzleShootBullet (UseExactly 1)]
AUTOPISTOL -> [Muzzle (V2 10 0) 0 0 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
SMG -> [Muzzle (V2 20 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
RIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0
BURSTRIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0 & ix 0 . mzInaccuracy .~ 0.05
MINIGUNX i ->
@@ -467,7 +472,7 @@ recoilAmount itm
TIMESTOPPER -> 0
TIMESCROLLER -> 0
PISTOL -> 10
MACHINEPISTOL -> 15
MACHINEPISTOL -> 5
AUTOPISTOL -> 10
SMG -> 10
BANGCONE -> 150
@@ -515,7 +520,7 @@ bgunSound itm
TIMESTOPPER -> Nothing
TIMESCROLLER -> Nothing
PISTOL -> Just (tap3S, 0)
MACHINEPISTOL -> Just (tap1S, 0)
MACHINEPISTOL -> Just (whirTapS, 2)
AUTOPISTOL -> Just (tap1S, 0)
SMG -> Just (tap1S, 0)
BANGCONE -> Just (bangEchoS, 0)
@@ -1370,6 +1375,12 @@ dropInventoryPath i ip loc cr = fromMaybe id $ do
-- guard $ (i + j) `IM.member` (cr ^. crInv)
-- return $ dropItem cr (i + j) w
warmupSound :: ItemType -> SoundID
warmupSound = \case
HELD MINIGUNX {} -> crankSlowS
HELD MACHINEPISTOL {} -> whirupS
_ -> crankSlowS
useInventoryPath ::
PressType ->
Int ->