Remove old ammo code, add magazines to some test loadouts
This commit is contained in:
+41
-25
@@ -1,38 +1,54 @@
|
||||
module Dodge.Item.Ammo where
|
||||
|
||||
import Dodge.Reloading.Action
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Default.Item
|
||||
import Dodge.Reloading.Action
|
||||
|
||||
revolveMag :: Item
|
||||
revolveMag = defaultHeldItem & itType . iyBase .~ ATTACH (AMMOATTACH REVOLVEMAG)
|
||||
& itUse .~ AttachUse {_attachParams = AmmoAttachParams {_ammoAttachParams = InternalAmmo
|
||||
{ _iaMax = 6
|
||||
, _iaLoaded = 6
|
||||
, _iaPrimed = True
|
||||
, _iaCycle = [loadPartialInsert 10 1]
|
||||
, _iaProgress = Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
revolveMag =
|
||||
defaultHeldItem & itType . iyBase .~ ATTACH (AMMOATTACH REVOLVEMAG)
|
||||
& itUse
|
||||
.~ AttachUse
|
||||
{ _attachParams =
|
||||
AmmoAttachParams
|
||||
{ _ammoParams = DefaultAmmoParams
|
||||
, _ammoLoadStatus =
|
||||
InternalAmmo
|
||||
{ _iaMax = 6
|
||||
, _iaLoaded = 6
|
||||
, _iaPrimed = True
|
||||
, _iaCycle = [loadPartialInsert 10 1]
|
||||
, _iaProgress = Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tinMag :: Item
|
||||
tinMag = defaultHeldItem & itType . iyBase .~ ATTACH (AMMOATTACH TINMAG)
|
||||
& itUse .~ AttachUse {_attachParams = AmmoAttachParams {_ammoAttachParams = InternalAmmo
|
||||
{ _iaMax = 15
|
||||
, _iaLoaded = 15
|
||||
, _iaPrimed = True
|
||||
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
|
||||
, _iaProgress = Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
tinMag =
|
||||
defaultHeldItem & itType . iyBase .~ ATTACH (AMMOATTACH TINMAG)
|
||||
& itUse
|
||||
.~ AttachUse
|
||||
{ _attachParams =
|
||||
AmmoAttachParams
|
||||
{ _ammoParams = DefaultAmmoParams
|
||||
, _ammoLoadStatus =
|
||||
InternalAmmo
|
||||
{ _iaMax = 15
|
||||
, _iaLoaded = 15
|
||||
, _iaPrimed = True
|
||||
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
|
||||
, _iaProgress = Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drumMag :: Item
|
||||
drumMag = tinMag & itType . iyBase .~ ATTACH (AMMOATTACH DRUMMAG)
|
||||
& itUse . attachParams . ammoAttachParams . iaMax .~ 30
|
||||
drumMag =
|
||||
tinMag & itType . iyBase .~ ATTACH (AMMOATTACH DRUMMAG)
|
||||
& itUse . attachParams . ammoLoadStatus . iaMax .~ 30
|
||||
|
||||
beltMag :: Item
|
||||
beltMag = tinMag & itType . iyBase .~ ATTACH (AMMOATTACH BULLETBELT)
|
||||
|
||||
beltMag =
|
||||
tinMag & itType . iyBase .~ ATTACH (AMMOATTACH BULLETBELT)
|
||||
& itUse . attachParams . ammoLoadStatus . iaMax .~ 2000
|
||||
|
||||
@@ -153,7 +153,7 @@ showEquipmentNumber _ itm = case _eeUse ee of
|
||||
|
||||
showReloadProgress :: Creature -> Item -> String
|
||||
showReloadProgress _ itm = fromMaybe [] $ do
|
||||
ia <- itm ^? itUse . attachParams . ammoAttachParams
|
||||
ia <- itm ^? itUse . attachParams . ammoLoadStatus
|
||||
return $ case ia ^? iaProgress . _Just . ix 0 of
|
||||
Nothing -> maybe "" show $ ia ^? iaLoaded
|
||||
Just la -> showLoadActionType la ia
|
||||
|
||||
@@ -142,7 +142,7 @@ withThickSmokeI eff item cr w =
|
||||
ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
|
||||
invid <- itm ^? itLocation . ipInvID
|
||||
x <- cr ^? crInv . ix (invid + 1) . itUse . attachParams . ammoAttachParams . iaLoaded
|
||||
x <- cr ^? crInv . ix (invid + 1) . itUse . attachParams . ammoLoadStatus . iaLoaded
|
||||
guard $ x > 0
|
||||
return $ eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
where
|
||||
@@ -340,13 +340,13 @@ 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 . attachParams . ammoAttachParams . iaLoaded .~ 0)
|
||||
. itUse . attachParams . ammoLoadStatus . 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 . attachParams . ammoAttachParams . iaLoaded
|
||||
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (invid + 1) . itUse . attachParams . ammoLoadStatus . iaLoaded
|
||||
%~ (max 0 . subtract amAmount)
|
||||
)
|
||||
|
||||
@@ -358,7 +358,7 @@ useAmmoAmount amAmount eff item cr =
|
||||
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 . attachParams . ammoAttachParams . iaLoaded -~ x
|
||||
useAmmoAmount' itref x inv = inv & ix (itref + 1) . itUse . attachParams . ammoLoadStatus . iaLoaded -~ x
|
||||
|
||||
-- . crInv . ix itRef . itUse . heldConsumption . laSource
|
||||
|
||||
@@ -659,7 +659,7 @@ duplicateLoaded eff it cr w = foldr f w (take numbul [1::Int .. ])
|
||||
f _ = eff it cr
|
||||
numbul = fromMaybe 0 $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr ^? crInv . ix (i+1) . itUse . attachParams . ammoAttachParams . iaLoaded
|
||||
cr ^? crInv . ix (i+1) . itUse . attachParams . ammoLoadStatus . iaLoaded
|
||||
|
||||
duplicateNumBarrels :: Int -> ChainEffect
|
||||
duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim . aimMuzzles)
|
||||
@@ -681,7 +681,7 @@ duplicateLoadedBarrels eff itm cr = duplicateNumBarrels numbul eff itm cr
|
||||
numbul :: Int
|
||||
numbul = fromMaybe 0 $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
cr ^? crInv . ix (i+1) . itUse . attachParams . ammoAttachParams . iaLoaded
|
||||
cr ^? crInv . ix (i+1) . itUse . attachParams . ammoLoadStatus . iaLoaded
|
||||
|
||||
duplicateOffsetsFocus :: [Float] -> ChainEffect
|
||||
duplicateOffsetsFocus xs eff item cr w = foldr f w poss
|
||||
|
||||
Reference in New Issue
Block a user