Randomise volleygun muzzle order

This commit is contained in:
2024-12-21 19:10:34 +00:00
parent 17cb1d8ff8
commit 84821a1531
9 changed files with 326 additions and 297 deletions
+12
View File
@@ -82,6 +82,7 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
@@ -90,6 +91,17 @@ heldEffectMuzzles t cr w =
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
cmew = foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
doHeldUseEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
Just (RandomiseMuzzleFrames x) -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
let g = w ^. randGen
(is,g') = runState (shuffle [0..x-1]) g
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
& randGen .~ g'
Just NoHeldUseEffect -> w
Nothing -> w
-- need to be careful about inventory lock or item ids here
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of