Pass ammo magazine items to held item use chain

This commit is contained in:
2024-06-25 15:50:22 +01:00
parent c723d1b1e1
commit 009a6cd30f
7 changed files with 289 additions and 238 deletions
+2 -2
View File
@@ -124,8 +124,8 @@ import Picture
-- y = 15 * sin (pi * fromIntegral x' * 0.01)
-- x' = _lasCycle $ _itParams it
shootLaser :: Item -> Creature -> World -> World
shootLaser it cr =
shootLaser :: [Item] -> Item -> Creature -> World -> World
shootLaser ams it cr =
cWorld . lWorld . lasers
.:~ lasRayAt
(_lasColor $ _itParams it)
+108 -110
View File
@@ -80,30 +80,31 @@ import qualified SDL
import Sound.Data
type ChainEffect =
(Item -> Creature -> World -> World) ->
([Item] -> Item -> Creature -> World -> World) ->
[Item] ->
Item ->
Creature ->
World ->
World
lockInvFor :: Int -> ChainEffect
lockInvFor i f it cr =
f it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
lockInvFor i f ams it cr =
f ams it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
. lockInv (_crID cr)
repeatTransformed ::
[(Item -> Item,Creature -> Creature)] ->
ChainEffect
repeatTransformed xs f itm cr w = foldr g w xs
repeatTransformed xs f ams itm cr w = foldr g w xs
where
g (fit,fcr) = f (fit itm) (fcr cr)
g (fit,fcr) = f ams (fit itm) (fcr cr)
trigDoAlso ::
(Item -> Item) ->
(Creature -> Creature) ->
(Item -> Creature -> World -> World) ->
ChainEffect
trigDoAlso fit fcr f g itm cr = g itm cr . f (fit itm) (fcr cr)
trigDoAlso fit fcr f g ams itm cr = g ams itm cr . f (fit itm) (fcr cr)
-- Note that this uses the "base" creature and item values
--trigDoAlso ::
@@ -112,8 +113,8 @@ trigDoAlso fit fcr f g itm cr = g itm cr . f (fit itm) (fcr cr)
--trigDoAlso afterEff eff item cr = afterEff item cr . eff item cr
withSmoke :: Int -> Point4 -> Float -> Int -> Float -> ChainEffect
withSmoke num col rad t alt eff item cr w =
eff item cr $
withSmoke num col rad t alt eff ams item cr w =
eff ams item cr $
foldl' (flip $ smokeCloudAt col rad t alt . (+.+.+ pos) . (* 8)) w ps
where
dir = _crDir cr
@@ -121,8 +122,8 @@ withSmoke num col rad t alt eff item cr w =
ps = replicateM num randOnUnitSphere & evalState $ _randGen w
withThinSmokeI :: ChainEffect
withThinSmokeI eff item cr w =
eff item cr $
withThinSmokeI eff ams item cr w =
eff ams item cr $
foldl' (flip $ makeThinSmokeAt . (+.+.+ pos) . (* 8)) w ps
where
dir = _crDir cr
@@ -130,8 +131,8 @@ withThinSmokeI eff item cr w =
ps = replicateM 5 randOnUnitSphere & evalState $ _randGen w
withThickSmokeI :: ChainEffect
withThickSmokeI eff item cr w =
eff item cr $
withThickSmokeI eff ams item cr w =
eff ams item cr $
foldl' (flip $ makeThickSmokeAt . (+.+.+ pos) . (* 8)) w ps
where
dir = _crDir cr
@@ -141,11 +142,10 @@ withThickSmokeI eff item cr w =
-- TODO create a trigger that does different things on first and continued
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
invid <- itm ^? itLocation . ipInvID
x <- cr ^? crInv . ix (invid + 1) . itUse . amagLoadStatus . iaLoaded
ammoCheckI eff ams itm cr w = fromMaybe (failsound w) $ do
x <- ams ^? ix 0 . itUse . amagLoadStatus . iaLoaded
guard $ x > 0
return $ eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
return $ eff ams itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
@@ -167,7 +167,7 @@ rateIncAB ::
-- | Extra effect on continued fire
ChainEffect ->
ChainEffect
rateIncAB exeffFirst exeffCont eff item cr w
rateIncAB exeffFirst exeffCont eff ams item cr w
| repeatFire =
w
& pointItem
@@ -175,7 +175,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
-- . itUseAmmo 1
. (itUse . heldDelay . rateTime .~ currentRate)
)
& exeffCont eff item cr
& exeffCont eff ams item cr
| firstFire =
w
& pointItem
@@ -183,7 +183,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
-- . itUseAmmo 1
. (itUse . heldDelay . rateTime .~ startRate)
)
& exeffFirst eff item cr
& exeffFirst eff ams item cr
| otherwise = w
where
fastRate = _rateMinMax . _heldDelay $ _itUse item
@@ -202,7 +202,7 @@ withWarmUp ::
-- | warm up sound id
SoundID ->
ChainEffect
withWarmUp soundID f item cr w
withWarmUp soundID f ams item cr w
| curWarmUp < maxWarmUp && crWeaponReady cr =
w
& pointertoitem . itUse . heldDelay . warmTime +~ 2
@@ -210,7 +210,7 @@ withWarmUp soundID f item cr w
| otherwise =
w
& pointertoitem . itUse . heldDelay . warmTime .~ maxWarmUp
& f item cr
& f ams item cr
where
cid = _crID cr
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
@@ -221,13 +221,13 @@ withWarmUp soundID f item cr w
withSoundItemChoiceStart ::
(Item -> SoundID) ->
ChainEffect
withSoundItemChoiceStart soundf f it cr =
withSoundItemChoiceStart soundf f ams it cr =
soundMultiFrom
[CrWeaponSound cid 0, CrWeaponSound cid 1, CrWeaponSound cid 2]
(_crPos cr)
(soundf it)
Nothing
. f it cr
. f ams it cr
where
cid = _crID cr
@@ -238,9 +238,9 @@ withSoundStart ::
-- | Sound id
SoundID ->
ChainEffect
withSoundStart soundid f item cr =
withSoundStart soundid f ams item cr =
soundMultiFrom [CrWeaponSound cid 0, CrWeaponSound cid 1, CrWeaponSound cid 2] (_crPos cr) soundid Nothing
. f item cr
. f ams item cr
where
cid = _crID cr
@@ -251,9 +251,9 @@ withSoundContinue ::
-- | Sound id
SoundID ->
ChainEffect
withSoundContinue soundid f item cr =
withSoundContinue soundid f ams item cr =
soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid Nothing
. f item cr
. f ams item cr
where
cid = _crID cr
@@ -266,9 +266,9 @@ withSoundForI ::
-- | Frames to play
Int ->
ChainEffect
withSoundForI soundid playTime f item cr =
withSoundForI soundid playTime f ams item cr =
soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) soundid (Just playTime)
. f item cr
. f ams item cr
{- | Adds a sound to a creature based world effect.
The sound is emitted from the creature's position.
@@ -281,21 +281,21 @@ withSoundForVol ::
-- | Frames to play
Int ->
ChainEffect
withSoundForVol vol soundid playTime f item cr =
withSoundForVol vol soundid playTime f ams item cr =
soundContinueVol vol (CrWeaponSound (_crID cr) 0) (_crPos cr) soundid (Just playTime)
. f item cr
. f ams item cr
afterRecoil ::
-- | Recoil amount
Float ->
ChainEffect
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (cWorld . lWorld . creatures . ix cid) pushback
afterRecoil recoilAmount eff ams item cr = eff ams item (pushback cr) . over (cWorld . lWorld . creatures . ix cid) pushback
where
cid = _crID cr
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount) / _crMass cr) 0))
withRecoil :: ChainEffect
withRecoil eff it cr = eff it cr . over (cWorld . lWorld . creatures . ix cid) pushback
withRecoil eff ams it cr = eff ams it cr . over (cWorld . lWorld . creatures . ix cid) pushback
where
cid = _crID cr
recoilAmount = fromMaybe 0 $ it ^? itUse . heldParams . recoil
@@ -308,8 +308,8 @@ withSidePushI ::
-- | Maximal possible side push amount
Float ->
ChainEffect
withSidePushI maxSide eff item cr w =
eff item (push cr) $
withSidePushI maxSide eff ams item cr w =
eff ams item (push cr) $
w
& cWorld . lWorld . creatures . ix cid %~ push
& randGen .~ g
@@ -327,8 +327,8 @@ withSidePushAfterI ::
-- | Maximal possible side push amount
Float ->
ChainEffect
withSidePushAfterI maxSide eff item cr w =
over (cWorld . lWorld . creatures . ix cid) push . eff item cr $
withSidePushAfterI maxSide eff ams item cr w =
over (cWorld . lWorld . creatures . ix cid) push . eff ams item cr $
w
& randGen .~ g
where
@@ -337,29 +337,27 @@ withSidePushAfterI maxSide eff item cr w =
(pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w
useAllAmmo :: ChainEffect
useAllAmmo eff item cr = fromMaybe id $ do
invid <- item ^? itLocation . ipInvID
return $ eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (invid + 1)
. itUse . amagLoadStatus . iaLoaded .~ 0)
useAllAmmo eff ams item cr w = fromMaybe w $ do
let invids = ams ^.. traverse . itLocation . ipInvID
return . eff ams item cr $ foldl' f w invids
where
f w' invid = w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid
. itUse . amagLoadStatus . iaLoaded .~ 0
useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff itm cr = fromMaybe id $ do
invid <- itm ^? itLocation . ipInvID
return $ eff itm cr
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (invid + 1) . itUse . amagLoadStatus . iaLoaded
useAmmoUpTo amAmount eff ams itm cr = fromMaybe id $ do
x <- ams ^? ix 0 . itUse . amagLoadStatus . iaLoaded
invid <- ams ^? ix 0 . itLocation . ipInvID
return $ eff ams itm cr
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . amagLoadStatus . iaLoaded
%~ (max 0 . subtract amAmount)
)
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ useAmmoAmount' itref amAmount)
where
itref = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
useAmmoAmount' itref x inv = inv & ix (itref + 1) . itUse . amagLoadStatus . iaLoaded -~ x
useAmmoAmount amAmount eff ams item cr = fromMaybe id $ do
invid <- ams ^? ix 0 . itLocation . ipInvID
return $ eff ams item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . amagLoadStatus . iaLoaded -~ amAmount)
-- . crInv . ix itRef . itUse . heldConsumption . laSource
@@ -367,8 +365,8 @@ useAmmoAmount' itref x inv = inv & ix (itref + 1) . itUse . amagLoadStatus . iaL
Applies a world effect after an item use cooldown check.
-}
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
Just 0 -> f item cr $ setUseTime w
useTimeCheck f ams item cr w = case item ^? itUse . heldDelay . rateTime of
Just 0 -> f ams item cr $ setUseTime w
_ -> w
where
cid = _crID cr
@@ -378,8 +376,8 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
-- | Applies a world effect after a hammer position check.
blCheck :: ChainEffect
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
blCheck f ams it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f ams it cr w
_ -> w
{- | Applies a world effect after a hammer position check.
@@ -423,52 +421,52 @@ shootL f item cr w
-- reloadCondition = _laLoaded (_itConsumption item) == 0
withItem :: (Item -> ChainEffect) -> ChainEffect
withItem g f it = g it f it
withItem g f ams it = g it f ams it
-- not ideal
withItemUpdateFirst :: (Item -> Item) -> ChainEffect
withItemUpdateFirst up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
withItemUpdateFirst up f ams it cr = f ams (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
withItemUpdate up g f ams it cr = g it f ams it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr =
eff item cr
withTempLight time rad col eff ams item cr =
eff ams item cr
. over (cWorld . lWorld . tempLightSources) (theTLS :)
where
theTLS = tlsTimeRadColPos time rad col (V3 x y 10)
V2 x y = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
modClock :: Int -> ChainEffect -> ChainEffect
modClock n chainEff eff it cr w
| (w ^. cWorld . lWorld . lClock) `mod` n == 0 = chainEff eff it cr w
| otherwise = eff it cr w
modClock n chainEff eff ams it cr w
| (w ^. cWorld . lWorld . lClock) `mod` n == 0 = chainEff eff ams it cr w
| otherwise = eff ams it cr w
withFlare :: ChainEffect
withFlare f it cr =
withFlare f ams it cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. f it cr
. f ams it cr
where
cdir = _crDir cr
cpos = _crPos cr
withMuzFlare :: ChainEffect
withMuzFlare f itm cr =
withMuzFlare f ams itm cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. f itm cr
. f ams itm cr
where
cdir = _crDir cr
cpos = _crPos cr + rotateV (_crDir cr) (_mzPos brl + aimingWeaponZeroPos cr itm)
@@ -486,7 +484,7 @@ withCrPos :: (Point3 -> World -> World) -> ChainEffect
withCrPos = withCrPosShift (V2 0 0)
withCrPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
withCrPosShift p g f it cr = g thepos . f it cr
withCrPosShift p g f ams it cr = g thepos . f ams it cr
where
thepos = (_crPos cr +.+ rotateV (_crDir cr) p) `v2z` 20
@@ -495,7 +493,7 @@ withRandomDirI ::
-- | Max possible rotation
Float ->
ChainEffect
withRandomDirI acc f it cr w = f it (cr & crDir +~ a) $ set randGen g w
withRandomDirI acc f ams it cr w = f ams it (cr & crDir +~ a) $ set randGen g w
where
(a, g) = randomR (- acc, acc) $ _randGen w
@@ -503,38 +501,38 @@ withOldDir ::
-- | The fraction of the old direction
Float ->
ChainEffect
withOldDir aFrac eff item cr =
eff item (cr & crDir %~ tweenAngles aFrac (_crOldDir cr))
withOldDir aFrac eff ams item cr =
eff ams item (cr & crDir %~ tweenAngles aFrac (_crOldDir cr))
withRandomItemUpdate ::
State StdGen (Item -> Item) ->
ChainEffect
withRandomItemUpdate randItUp eff it cr w = eff (f it) cr $ w & randGen .~ g
withRandomItemUpdate randItUp eff ams it cr w = eff ams (f it) cr $ w & randGen .~ g
where
(f, g) = runState randItUp (_randGen w)
withRandomItemParams :: State StdGen (ItemParams -> ItemParams) -> ChainEffect
withRandomItemParams rip eff it cr w = eff (it & itParams %~ f) cr $ w & randGen .~ g
withRandomItemParams rip eff ams it cr w = eff ams (it & itParams %~ f) cr $ w & randGen .~ g
where
(f, g) = runState rip (_randGen w)
withRandomItem :: State StdGen (Item -> Item) -> ChainEffect
withRandomItem rip eff it cr w = eff (f it) cr $ w & randGen .~ g
withRandomItem rip eff ams it cr w = eff ams (f it) cr $ w & randGen .~ g
where
(f, g) = runState rip (_randGen w)
withPositionOffset ::
(Item -> Creature -> World -> (Point2, Float)) ->
ChainEffect
withPositionOffset h f it cr w = f it (cr & crPos .+.+~ p & crDir +~ a) w
withPositionOffset h f ams it cr w = f ams it (cr & crPos .+.+~ p & crDir +~ a) w
where
(p, a) = h it cr w
withPositionWallCheck ::
(Item -> Creature -> World -> Point2) ->
ChainEffect
withPositionWallCheck h f it cr w
| hasLOS p (_crPos cr) w = f it (cr & crPos .~ p) w
withPositionWallCheck h f ams it cr w
| hasLOS p (_crPos cr) w = f ams it (cr & crPos .~ p) w
| otherwise = w
where
p = h it cr w
@@ -542,15 +540,15 @@ withPositionWallCheck h f it cr w
withPosDirWallCheck ::
(Item -> Creature -> World -> (Point2, Float)) ->
ChainEffect
withPosDirWallCheck h f it cr w
| hasLOS p (_crPos cr) w = f it (cr & crPos .~ p & crDir .~ a) w
withPosDirWallCheck h f ams it cr w
| hasLOS p (_crPos cr) w = f ams it (cr & crPos .~ p & crDir .~ a) w
| otherwise = w
where
(p, a) = h it cr w
-- | Apply the effect to a translated creature.
withRandomOffset :: ChainEffect
withRandomOffset f item cr w = f item (cr & crPos %~ (+.+ offV)) $ set randGen g w
withRandomOffset f ams item cr w = f ams item (cr & crPos %~ (+.+ offV)) $ set randGen g w
where
(offsetVal, g) = randomR (- offsetAmount, offsetAmount) $ _randGen w
offV = rotateV (_crDir cr) (V2 0 offsetVal)
@@ -561,15 +559,15 @@ torqueBefore ::
-- | Max possible rotation
Float ->
ChainEffect
torqueBefore torque feff item cr w
torqueBefore torque feff ams item cr w
| cid == 0 =
feff item (cr & crDir +~ rot) $
feff ams item (cr & crDir +~ rot) $
w
& randGen .~ g
& cWorld . lWorld . creatures . ix cid . crDir +~ rot
& wCam . camRot +~ rot
& rotateScope
| otherwise = feff item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) w
| otherwise = feff ams item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) w
where
cid = _crID cr
(rot, g) = randomR (- torque, torque) $ _randGen w
@@ -586,15 +584,15 @@ torqueBeforeAtLeast ::
-- | Extra possible rotation
Float ->
ChainEffect
torqueBeforeAtLeast minTorque exTorque feff item cr w
torqueBeforeAtLeast minTorque exTorque feff ams item cr w
| cid == 0 =
feff item (cr & crDir +~ rot') $
feff ams item (cr & crDir +~ rot') $
w
& randGen .~ g
& cWorld . lWorld . creatures . ix cid . crDir +~ rot'
& wCam . camRot +~ rot'
& rotateScope
| otherwise = feff item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot') w
| otherwise = feff ams item cr $ set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot') w
where
cid = _crID cr
(rot, g) = randomR (- exTorque, exTorque) $ _randGen w
@@ -607,11 +605,11 @@ torqueBeforeAtLeast minTorque exTorque feff item cr w
-- | Rotate a randomly creature after applying an effect.
withTorqueAfter :: ChainEffect
withTorqueAfter feff item cr w
withTorqueAfter feff ams item cr w
-- | cid == 0 = rotateScope . set randGen g $ over (wCam . camRot) (+ rot) $ feff item cr w
-- | otherwise = set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) $ feff item cr w
| cid == 0 = w
& feff item cr
& feff ams item cr
& wCam . camRot +~ rot
& rotateScope
& randGen .~ g
@@ -631,8 +629,8 @@ sideEffectOnFrame ::
Int ->
(Item -> Creature -> WdWd) ->
ChainEffect
sideEffectOnFrame i sf f it cr w =
f it cr w
sideEffectOnFrame i sf f ams it cr w =
f ams it cr w
& cWorld . lWorld . delayedEvents .:~ (i, sf it cr)
torqueSideEffect :: Float -> Item -> Creature -> World -> World
@@ -649,8 +647,8 @@ torqueSideEffect torque _ cr w
-- pump the updated creature into the chain in later frames
repeatOnFrames :: [Int] -> HeldMod -> ChainEffect
--repeatOnFrames is hm f it cr w = f it cr w
repeatOnFrames is hm f it cr w =
f it cr $
repeatOnFrames is hm f ams it cr w =
f ams it cr $
w
& cWorld . lWorld . delayedEvents .++~ (is <&> (,WdWdFromItCrixWdWd (it & itUse . heldMods .~ hm) (_crID cr) ItCrWdItemEffect))
@@ -660,18 +658,18 @@ repeatOnFrames is hm f it cr w =
-- return $ f it cr' w'
duplicateLoaded :: ChainEffect
duplicateLoaded eff it cr w = foldr f w (take numbul [1::Int .. ])
duplicateLoaded eff ams it cr w = foldr f w (take numbul [1::Int .. ])
where
f _ = eff it cr
f _ = eff ams it cr
numbul = fromMaybe 0 $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix (i+1) . itUse . amagLoadStatus . iaLoaded
i <- ams ^? ix 0 . itLocation . ipInvID
cr ^? crInv . ix i . itUse . amagLoadStatus . iaLoaded
duplicateNumBarrels :: Int -> ChainEffect
duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim . aimMuzzles)
duplicateNumBarrels n eff ams itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim . aimMuzzles)
where
f brl w' =
eff
eff ams
itm
( cr & crPos +~ rotateV (_crDir cr) (_mzPos brl + aimingWeaponZeroPos cr itm)
& crDir +~ (_mzRot brl + a)
@@ -682,20 +680,20 @@ duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim
(a,g) = randomR (-inacc,inacc) $ _randGen w'
duplicateLoadedBarrels :: ChainEffect
duplicateLoadedBarrels eff itm cr = duplicateNumBarrels numbul eff itm cr
duplicateLoadedBarrels eff ams itm cr = duplicateNumBarrels numbul eff ams itm cr
where
numbul :: Int
numbul = fromMaybe 0 $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix (i+1) . itUse . amagLoadStatus . iaLoaded
i <- ams ^? ix 0 . itLocation . ipInvID
cr ^? crInv . ix i . itUse . amagLoadStatus . iaLoaded
duplicateOffsetsFocus :: [Float] -> ChainEffect
duplicateOffsetsFocus xs eff item cr w = foldr f w poss
duplicateOffsetsFocus xs eff ams item cr w = foldr f w poss
where
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0) xs
f pos =
eff item $
eff ams item $
cr
& crPos %~ (+.+ pos)
& crDir .~ thedir pos
@@ -709,12 +707,12 @@ duplicateOffsetsFocus xs eff item cr w = foldr f w poss
thedir pos = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
duplicateItem :: (Item -> [Item]) -> ChainEffect
duplicateItem fit eff itm cr w = foldr f w (fit itm)
duplicateItem fit eff ams itm cr w = foldr f w (fit itm)
where
f itm' = eff itm' cr
f itm' = eff ams itm' cr
duplicateOffsetsV2 :: [Point2] -> ChainEffect
duplicateOffsetsV2 xs eff item cr w = foldr f w poss
duplicateOffsetsV2 xs eff ams item cr w = foldr f w poss
where
poss = map (rotateV (_crDir cr)) xs
f pos = eff item (cr & crPos +.+.~ pos)
f pos = eff ams item (cr & crPos +.+.~ pos)