This commit is contained in:
2025-08-27 22:35:33 +01:00
parent 3c2369d979
commit 2a0e6d1e6e
3 changed files with 15 additions and 25 deletions
+10 -14
View File
@@ -641,8 +641,9 @@ loadMuzzle loc cr (b, w) mz = maybe (b, w) (True,) $ case mz ^. mzAmmoSlot of
| x <= availableammo -> x
| otherwise -> 0
guard $ usedammo > 0
return $ useLoadedAmmo loc cr mz (Just (usedammo, mag)) $
removeAmmoFromMag usedammo mid w
return $
useLoadedAmmo loc cr mz (Just (usedammo, mag)) $
removeAmmoFromMag usedammo mid w
makeMuzzleFlare :: Muzzle -> LocationDT OItem -> Creature -> World -> World
makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
@@ -720,7 +721,7 @@ useLoadedAmmo ::
World ->
World
useLoadedAmmo loc cr mz m w =
makeMuzzleFlare mz loc cr $ case _mzEffect mz of
makeMuzzleFlare mz loc cr $ case _mzEffect mz of
MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w
MuzzleLaser -> creatureShootLaser loc cr mz w
MuzzlePulseLaser -> creatureShootPulseLaser loc cr mz w
@@ -737,7 +738,7 @@ useLoadedAmmo loc cr mz m w =
mz
cr
w
MuzzleNozzle{} -> useGasParams mid mz loc cr $ walkNozzle mz itm w
MuzzleNozzle{} -> useGasParams mitid mz loc cr $ walkNozzle mz itm w
MuzzleShatter -> shootShatter itm cr w
MuzzleDetector ->
itemDetectorEffect
@@ -753,7 +754,7 @@ useLoadedAmmo loc cr mz m w =
MuzzleScroller -> useTimeScrollGun itm cr w
where
itmtree = loc ^. locDT
mid = magtree ^? dtValue . _1 . itLocation . ilInvID
mitid = magtree ^. dtValue . _1 . itID
itm = itmtree ^. dtValue . _1
(x, magtree) = fromJust m
@@ -918,11 +919,7 @@ shootPulseBall p dir w =
removeAmmoFromMag :: Int -> Int -> World -> World
removeAmmoFromMag x magid =
cWorld . lWorld . items
. ix magid
. itConsumables
. _Just
-~ x
cWorld . lWorld . items . ix magid . itConsumables . _Just -~ x
getBulletType :: DTree OItem -> Maybe Bullet
getBulletType magtree =
@@ -1113,13 +1110,13 @@ mcUseHeld hit = case hit of
_ -> mcShootAuto
useGasParams ::
Maybe (NewInt InvInt) ->
NewInt ItmInt ->
Muzzle ->
LocationDT OItem ->
Creature ->
World ->
World
useGasParams mmagid mz loc cr w =
useGasParams (NInt magitid) mz loc cr w =
w
& createGas gastype pressure pos dir cr
& randGen .~ g'
@@ -1127,9 +1124,8 @@ useGasParams mmagid mz loc cr w =
itm = loc ^. locDT . dtValue . _1
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
gastype = fromMaybe (error "cannot find gas ammo") $ do
magid <- mmagid
hit <- itm ^? itType . ibtHeld
fueltype <- cr ^? crInv . ix magid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= magAmmoParams >>= (^? ampCreateGas)
fueltype <- w ^? cWorld . lWorld . items . ix magitid >>= magAmmoParams >>= (^? ampCreateGas)
gasType hit fueltype
(V3 x y _, q) =
locOrient loc cr