This commit is contained in:
2025-06-26 12:17:08 +01:00
parent d0f20da9f1
commit ab82bcbe20
9 changed files with 103 additions and 117 deletions
+25 -17
View File
@@ -82,13 +82,15 @@ hammerCheck ::
World
hammerCheck f pt it cr w
| BurstTrigger is <- itemTriggerType (it ^. ldtValue)
, pt == InitialPress = w & f it cr & cWorld . lWorld . delayedEvents .++~ map g is
, pt == InitialPress =
w & f it cr & cWorld . lWorld . delayedEvents .++~ map g is
| BurstTrigger{} <- itemTriggerType (it ^. ldtValue) = w
| VolleyGunTrigger i <- itemTriggerType (it ^. ldtValue)
, pt == InitialPress = let (is,gen) = getVolleyBurst i (w ^. randGen)
in w & f it cr
& cWorld . lWorld . delayedEvents .++~ map g is
& randGen .~ gen
, pt == InitialPress =
let (is, gen) = getVolleyBurst i (w ^. randGen)
in w & f it cr
& cWorld . lWorld . delayedEvents .++~ map g is
& randGen .~ gen
| VolleyGunTrigger{} <- itemTriggerType (it ^. ldtValue) = w
| t <- itemTriggerType (it ^. ldtValue)
, t == HammerTrigger || t == AlwaysSingleTrigger
@@ -99,10 +101,10 @@ hammerCheck f pt it cr w
where
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
getVolleyBurst :: (Random a, RandomGen b, Num a) => Int -> b -> ([a], b)
getVolleyBurst i g = let (is,g') = runState (replicateM (i-1) (state $ randomR (0,6))) g
in (scanl1 (+) is, g')
getVolleyBurst i g =
let (is, g') = runState (replicateM (i -1) (state $ randomR (0, 6))) g
in (scanl1 (+) is, g')
{- | Applies a world effect after an item use cooldown check.
input buffering?
@@ -224,7 +226,7 @@ heldItemMuzzles = \case
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
GRAPECANNON _ -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
TORCH -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
VOLLEYGUN {} -> error "should get volleygun muzzles earlier"
VOLLEYGUN{} -> error "should get volleygun muzzles earlier"
FLAMETHROWER -> flameMuzzles
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
RLAUNCHER ->
@@ -340,15 +342,21 @@ doHeldUseEffect t cr w = case t ^. ldtValue . itType of
Just [_] -> fromMaybe w $ do
let (is, g) = runState (shuffle [0 .. j -1]) $ w ^. randGen
i <- itm ^? itLocation . ilInvID
return $ w
& randGen .~ g
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams . unfiredBarrels %~ const is
Just (_:_:_) -> fromMaybe w $ do
return $
w
& randGen .~ g
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams
. unfiredBarrels
%~ const is
Just (_ : _ : _) -> fromMaybe w $ do
i <- itm ^? itLocation . ilInvID
return $ w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams . unfiredBarrels %~ tail
return $
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams
. unfiredBarrels
%~ tail
_ -> w
HELD ALTERIFLE -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID