Move around ammo source checks

This commit is contained in:
2024-06-22 16:23:34 +01:00
parent 25cecb8ea6
commit c723d1b1e1
25 changed files with 218 additions and 263 deletions
+11 -1
View File
@@ -459,15 +459,25 @@ overNozzle eff it cr w nz =
maxa = _nzMaxWalkAngle nz
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
getAmmoMagazine :: Item -> Creature -> Maybe ItemUse
getAmmoMagazine itm cr = do
invid <- itm ^? itLocation . ipInvID
amtype <- itm ^? itUse . heldConsumption . ix 0
mag <- cr ^? crInv . ix (invid + 1) . itUse
magtype <- mag ^? amagType
guard $ amtype == magtype
return mag
useGasParams :: Nozzle -> Item -> Creature -> World -> World
useGasParams nz it cr =
createGas
(_amCreateGas (_laAmmoType (_heldConsumption (_itUse it))))
(_ampCreateGas (_amagParams amag))
(_nzPressure nz)
pos
dir
cr
where
amag = fromMaybe (error "cannot find gas ammo") $ getAmmoMagazine it cr
dir = _crDir cr
pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr))