Make launcherX use multiple ammo sources

This commit is contained in:
2024-06-28 22:40:24 +01:00
parent 009a6cd30f
commit 32cb2b2e80
17 changed files with 220 additions and 342 deletions
+24 -51
View File
@@ -58,10 +58,10 @@ useMod hm = case hm of
, ammoCheckI
]
LauncherMod ->
[ useAmmoAmount 1
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
--[ useAmmoAmount 1
-- , withSoundStart tap4S
[ useTimeCheck
-- , ammoCheckI
, blCheck
]
TeslaMod ->
@@ -108,11 +108,11 @@ useMod hm = case hm of
, duplicateLoadedBarrels
, ammoCheckI
]
LauncherXMod i ->
[ useAmmoAmount i
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
LauncherXMod _ ->
--[ useAmmoAmount i
--, withSoundStart tap4S
[ useTimeCheck
--, ammoCheckI
, blCheck
]
ShatterMod ->
@@ -314,30 +314,6 @@ useMod hm = case hm of
, useTimeCheck
, ammoCheckI
]
RevolverXMod ->
[ withRecoil
, withTorqueAfter
, withFlare
, duplicateLoadedBarrels
, useAmmoUpTo 1
, withSoundStart tap3S
, repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod
, lockInvFor 10
, -- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
useTimeCheck
, ammoCheckI
, blCheck
]
RevolverXRepeatMod ->
[ withRecoil
, withTorqueAfter
, withFlare
, duplicateLoadedBarrels
, useAmmoUpTo 1
, withSoundStart tap3S
, ammoCheckI
]
BangConeMod ->
[ withRandomItem coneRandItemParams
, withRandomItemUpdate coneRandItemUpdate
@@ -388,7 +364,7 @@ useHeld hu = case hu of
HeldUseAmmoParams -> shootBullet
HeldOverNozzlesUseGasParams -> overNozzles useGasParams
HeldPJCreation -> usePjCreation
HeldPJCreationX i -> usePjCreationX i
HeldPJCreationX _ -> usePjCreationX
HeldFireRemoteShell -> fireRemoteShell
HeldDetectorEffect dt -> const $ detectorEffect dt
HeldTeslaArc -> shootTeslaArc
@@ -403,20 +379,17 @@ useHeld hu = case hu of
usePjCreation :: [Item] -> Item -> Creature -> World -> World
usePjCreation ams itm cr = fromMaybe id $ do
apm <- ams ^? ix 0 . itUse . amagParams
return $ createProjectile apm itm cr
apm <- ams ^? ix 0
muz <- itm ^? itUse . heldAim . aimMuzzles . ix 0
return $ createProjectile apm muz itm cr
usePjCreationX :: Int -> [Item] -> Item -> Creature -> World -> World
usePjCreationX i ams itm cr =
foldr
f
(createProjectile apm itm cr)
[1 .. i -1]
usePjCreationX :: [Item] -> Item -> Creature -> World -> World
usePjCreationX ams itm cr = fromMaybe id $ do
muzs <- itm ^? itUse . heldAim . aimMuzzles
return $ foldr
f id (zip muzs ams)
where
apm = fromMaybe (error "cannot find shell ammo projectile") $ do
invid <- itm ^? itLocation . ipInvID
cr ^? crInv . ix (invid + 1) . itUse . amagParams
f n = (. createProjectile apm itm (cr & crDir +~ (2 * pi * fromIntegral n / fromIntegral i)))
f (muz,am) = (createProjectile am muz itm cr .)
overNozzles ::
(Nozzle -> [Item] -> Item -> Creature -> World -> World) ->
@@ -469,7 +442,7 @@ getAmmoMagazine itm cr = do
return mag
useGasParams :: Nozzle -> [Item] -> Item -> Creature -> World -> World
useGasParams nz ams it cr =
useGasParams nz ams _ cr =
createGas
gastype
(_nzPressure nz)
@@ -478,7 +451,6 @@ useGasParams nz ams it cr =
cr
where
gastype = fromMaybe (error "cannot find gas ammo") $ ams ^? ix 0 . itUse . amagParams . ampCreateGas
-- amag = fromMaybe (error "cannot find gas ammo") $ getAmmoMagazine it cr
dir = _crDir cr
pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr))
@@ -493,10 +465,11 @@ fireRemoteShell ams it cr w =
i = IM.newKey $ w ^. cWorld . lWorld . props
cid = _crID cr
apm = fromMaybe (error "cannot find shell ammo projectile") $ do
invid <- it ^? itLocation . ipInvID
cr ^? crInv . ix (invid + 1) . itUse . amagParams
ams ^? ix 0
addRemRocket =
makeShell apm
-- the following is unsafe!
(it ^?! itUse . heldAim . aimMuzzles . ix 0)
it
cr
[ PJRemoteShellCollisionCheck
@@ -539,7 +512,7 @@ mcShootLaser it mc = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParam
-- | assumes that the item is held
shootTeslaArc :: [Item] -> Item -> Creature -> World -> World
shootTeslaArc ams it cr w =
shootTeslaArc _ it cr w =
w'
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
where