Split item consumables from item use

This commit is contained in:
2024-12-18 19:35:39 +00:00
parent db8e26b99d
commit 5600b29714
8 changed files with 63 additions and 59 deletions
+32 -25
View File
@@ -21,17 +21,18 @@ import Dodge.Item.Weapon.Bullet
megaTinMag :: Int -> Item
megaTinMag x =
tinMag
& itUse . amagLoadStatus . iaMax .~ x
& itUse . amagLoadStatus . iaLoaded .~ x
& itConsumables . magLoadStatus . iaMax .~ x
& itConsumables . magLoadStatus . iaLoaded .~ x
tinMag :: Item
tinMag =
defaultHeldItem & itType .~ AMMOMAG TINMAG
& itUse
.~ UseAmmoMag
{ _amagParams = BulletParams defaultBullet
, _amagType = BulletAmmo
, _amagLoadStatus =
& itConsumables .~ AmmoMag
{ _magParams = BulletParams defaultBullet
, _magType = BulletAmmo
, _magLoadStatus =
ReloadStatus
{ _iaMax = 15
, _iaLoaded = 15
@@ -48,59 +49,63 @@ tinMag =
drumMag :: Item
drumMag =
tinMag & itType . ibtAmmoMag .~ DRUMMAG
& itUse . amagLoadStatus . iaLoaded .~ 30
& itUse . amagLoadStatus . iaMax .~ 30
& itConsumables . magLoadStatus . iaLoaded .~ 30
& itConsumables . magLoadStatus . iaMax .~ 30
beltMag :: Item
beltMag =
tinMag & itType . ibtAmmoMag .~ BELTMAG
& itUse . amagLoadStatus . iaLoaded .~ 10000
& itUse . amagLoadStatus . iaMax .~ 20000
& itUse . amagType .~ BeltBulletAmmo
& itConsumables . magLoadStatus . iaLoaded .~ 10000
& itConsumables . magLoadStatus . iaMax .~ 20000
& itConsumables . magType .~ BeltBulletAmmo
megaShellMag :: Item
megaShellMag =
shellMag
& itUse . amagLoadStatus . iaMax .~ 1000000
& itUse . amagLoadStatus . iaLoaded .~ 1000000
& itConsumables . magLoadStatus . iaMax .~ 1000000
& itConsumables . magLoadStatus . iaLoaded .~ 1000000
shellMag :: Item
shellMag =
defaultHeldItem & itType .~ AMMOMAG SHELLMAG
& itUse
.~ UseAmmoMag
{ _amagParams =
& itConsumables
.~ AmmoMag
{ _magParams =
ProjectileParams
{ _ampPayload = ExplosionPayload
}
, _amagLoadStatus =
, _magLoadStatus =
ReloadStatus
{ _iaMax = 1
, _iaLoaded = 1
}
, _amagType = LauncherAmmo
, _magType = LauncherAmmo
}
megaBattery :: Item
megaBattery =
battery
& itUse . amagLoadStatus . iaMax .~ 1000000
& itUse . amagLoadStatus . iaLoaded .~ 1000000
& itConsumables . magLoadStatus . iaMax .~ 1000000
& itConsumables . magLoadStatus . iaLoaded .~ 1000000
smallBattery :: Item
smallBattery =
battery
& itUse . amagLoadStatus . iaMax .~ 999
& itUse . amagLoadStatus . iaLoaded .~ 999
& itConsumables . magLoadStatus . iaMax .~ 999
& itConsumables . magLoadStatus . iaLoaded .~ 999
battery :: Item
battery =
defaultHeldItem & itType .~ AMMOMAG BATTERY
& itUse
.~ UseAmmoMag
{ _amagParams = BulletParams defaultBullet
, _amagType = ElectricalAmmo
, _amagLoadStatus =
& itConsumables
.~ AmmoMag
{ _magParams = BulletParams defaultBullet
, _magType = ElectricalAmmo
, _magLoadStatus =
ReloadStatus
{ _iaMax = 10 ^ (9 :: Int)
, _iaLoaded = 10 ^ (9 :: Int)
@@ -112,9 +117,11 @@ chemFuelPouch =
defaultHeldItem & itType .~ AMMOMAG CHEMFUELPOUCH
& itUse
.~ UseAmmoMag
{ _amagParams = GasParams ChemFuel
, _amagType = GasAmmo
, _amagLoadStatus =
& itConsumables
.~ AmmoMag
{ _magParams = GasParams ChemFuel
, _magType = GasAmmo
, _magLoadStatus =
ReloadStatus
{ _iaMax = 1000
, _iaLoaded = 1000
+2 -1
View File
@@ -91,7 +91,8 @@ itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
(_,UseConsume {},_) -> []
(_,UseAttach (APInt i),_) -> [show i]
(_,UseAttach {},_) -> []
(_,UseAmmoMag {},_) -> [maybe "" shortShow $ itm ^? itUse . amagLoadStatus . iaLoaded]
(_,UseAmmoMag {},_) -> [maybe "" shortShow
$ itm ^? itConsumables . magLoadStatus . iaLoaded]
(_,UseScope OpticScope {_opticZoom = x},_) -> [shortShow x]
(_,UseBulletMod {},_) -> mempty
where
+2 -2
View File
@@ -53,8 +53,8 @@ ammoMagSPic it = \case
_ -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- y) (-1) 1)
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itUse . amagLoadStatus . iaLoaded
am = fractionLoadedAmmo (it ^?! itUse . amagLoadStatus)
y' = fromMaybe 0 $ it ^? itConsumables . magLoadStatus . iaLoaded
am = fractionLoadedAmmo (it ^?! itConsumables . magLoadStatus)
fractionLoadedAmmo :: ReloadStatus -> Float
fractionLoadedAmmo rs = fromIntegral (_iaLoaded rs) / fromIntegral (_iaMax rs)
+2 -2
View File
@@ -62,7 +62,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
, [(TriggerSF,TriggerLink),(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
)
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
atype <- itm ^? itUse . amagType
atype <- itm ^? itConsumables . magType
return
(
[ (AmmoModifierSF atype, AmmoModLink)
@@ -89,7 +89,7 @@ itemToFunction itm = case itm ^. itType of
HELD DETECTOR{} -> GadgetPlatformSF
HELD LASER -> WeaponTargetingSF
HELD{} -> HeldPlatformSF
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itUse . amagType
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
ATTACH ZOOMSCOPE -> WeaponScopeSF