Split item consumables from item use
This commit is contained in:
@@ -142,7 +142,7 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
||||
let as = _mzAmmoSlot mz
|
||||
amamount = _mzAmmoPerShot mz
|
||||
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
||||
availableammo <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
|
||||
availableammo <- mag ^? ldtValue . itConsumables . magLoadStatus . iaLoaded
|
||||
let usedammo = case amamount of
|
||||
UseUpTo x -> min x availableammo
|
||||
UseExactly x
|
||||
@@ -150,7 +150,8 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
||||
| otherwise -> 0
|
||||
guard $ usedammo > 0
|
||||
return
|
||||
( t & ldtLeft . ix i . _2 . ldtValue . itUse . amagLoadStatus . iaLoaded -~ usedammo
|
||||
( t & ldtLeft . ix i . _2 . ldtValue . itConsumables . magLoadStatus . iaLoaded
|
||||
-~ usedammo
|
||||
, Just (mz, usedammo, mag)
|
||||
)
|
||||
|
||||
@@ -337,8 +338,8 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
|
||||
. ix (_crID cr)
|
||||
. crInv
|
||||
. ix magid
|
||||
. itUse
|
||||
. amagLoadStatus
|
||||
. itConsumables
|
||||
. magLoadStatus
|
||||
. iaLoaded
|
||||
-~ x
|
||||
|
||||
@@ -350,7 +351,7 @@ getBulletType ::
|
||||
World ->
|
||||
Maybe Bullet
|
||||
getBulletType itmtree magtree mz cr w =
|
||||
magtree ^? ldtValue . itUse . amagParams . ampBullet
|
||||
magtree ^? ldtValue . itConsumables . magParams . ampBullet
|
||||
<&> buTrajectory .~ btraj
|
||||
<&> buPayload .~ bpayload
|
||||
<&> buEffect .~ beffect
|
||||
@@ -453,7 +454,7 @@ useGasParams mmagid mz itm cr w =
|
||||
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
|
||||
gastype = fromMaybe (error "cannot find gas ammo") $ do
|
||||
magid <- mmagid
|
||||
fueltype <- cr ^? crInv . ix magid . itUse . amagParams . ampCreateGas
|
||||
fueltype <- cr ^? crInv . ix magid . itConsumables . magParams . ampCreateGas
|
||||
gc <- itm ^? itUse . heldParams . gasCreation
|
||||
return $ gasCreate fueltype gc
|
||||
--pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
||||
@@ -533,7 +534,7 @@ createProjectile magtree muz itmtree cr = fromMaybe failsound $ do
|
||||
magid <- magtree ^? ldtValue . itLocation . ilInvID
|
||||
ammoitem <- cr ^? crInv . ix magid
|
||||
let homing = determineProjectileTracking magtree itmtree
|
||||
aparams <- ammoitem ^? itUse . amagParams . ampPayload
|
||||
aparams <- ammoitem ^? itConsumables . magParams . ampPayload
|
||||
return $
|
||||
createShell homing aparams muz cr
|
||||
. startthesound
|
||||
|
||||
Reference in New Issue
Block a user