Split item consumables from item use
This commit is contained in:
File diff suppressed because one or more lines are too long
+12
-12
@@ -201,7 +201,7 @@ trySynthBullet loc w = fromMaybe w $ do
|
|||||||
then do
|
then do
|
||||||
bat <- loc ^? locLDT . ldtLeft . ix 0 . _2 . ldtValue . _1
|
bat <- loc ^? locLDT . ldtLeft . ix 0 . _2 . ldtValue . _1
|
||||||
j <- bat ^? itLocation . ilInvID
|
j <- bat ^? itLocation . ilInvID
|
||||||
y <- bat ^? itUse . amagLoadStatus . iaLoaded
|
y <- bat ^? itConsumables . magLoadStatus . iaLoaded
|
||||||
guard $ y > 0
|
guard $ y > 0
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
@@ -217,15 +217,15 @@ trySynthBullet loc w = fromMaybe w $ do
|
|||||||
. ix 0
|
. ix 0
|
||||||
. crInv
|
. crInv
|
||||||
. ix j
|
. ix j
|
||||||
. itUse
|
. itConsumables
|
||||||
. amagLoadStatus
|
. magLoadStatus
|
||||||
. iaLoaded
|
. iaLoaded
|
||||||
-~ 1
|
-~ 1
|
||||||
else do
|
else do
|
||||||
mag <- loc ^? locLdtContext . cldtParent . _1
|
mag <- loc ^? locLdtContext . cldtParent . _1
|
||||||
j <- mag ^? itLocation . ilInvID
|
j <- mag ^? itLocation . ilInvID
|
||||||
y <- mag ^? itUse . amagLoadStatus . iaLoaded
|
y <- mag ^? itConsumables . magLoadStatus . iaLoaded
|
||||||
ymax <- mag ^? itUse . amagLoadStatus . iaMax
|
ymax <- mag ^? itConsumables . magLoadStatus . iaMax
|
||||||
guard $ y < ymax
|
guard $ y < ymax
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
@@ -241,8 +241,8 @@ trySynthBullet loc w = fromMaybe w $ do
|
|||||||
. ix 0
|
. ix 0
|
||||||
. crInv
|
. crInv
|
||||||
. ix j
|
. ix j
|
||||||
. itUse
|
. itConsumables
|
||||||
. amagLoadStatus
|
. magLoadStatus
|
||||||
. iaLoaded
|
. iaLoaded
|
||||||
+~ 1
|
+~ 1
|
||||||
where
|
where
|
||||||
@@ -306,7 +306,7 @@ shineTargetLaser ::
|
|||||||
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||||
guard (crIsAiming cr)
|
guard (crIsAiming cr)
|
||||||
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
||||||
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
|
i <- mag ^? ldtValue . _1 . itConsumables . magLoadStatus . iaLoaded
|
||||||
guard $ i >= x
|
guard $ i >= x
|
||||||
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||||
return $
|
return $
|
||||||
@@ -315,8 +315,8 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
|
|||||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
. crInv
|
. crInv
|
||||||
. ix maginvid
|
. ix maginvid
|
||||||
. itUse
|
. itConsumables
|
||||||
. amagLoadStatus
|
. magLoadStatus
|
||||||
. iaLoaded
|
. iaLoaded
|
||||||
-~ x
|
-~ x
|
||||||
& cWorld . lWorld . lasers
|
& cWorld . lWorld . lasers
|
||||||
@@ -347,14 +347,14 @@ shineTorch ::
|
|||||||
World
|
World
|
||||||
shineTorch cr itmtree (p, q) = fromMaybe id $ do
|
shineTorch cr itmtree (p, q) = fromMaybe id $ do
|
||||||
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
||||||
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
|
i <- mag ^? ldtValue . _1 . itConsumables . magLoadStatus . iaLoaded
|
||||||
guard $ crIsAiming cr
|
guard $ crIsAiming cr
|
||||||
guard $ i >= x
|
guard $ i >= x
|
||||||
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||||
return $
|
return $
|
||||||
--(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
|
--(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
|
||||||
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
|
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
|
||||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . amagLoadStatus . iaLoaded -~ x)
|
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . magLoadStatus . iaLoaded -~ x)
|
||||||
where
|
where
|
||||||
x = 10
|
x = 10
|
||||||
isammolink AmmoInLink{} = True
|
isammolink AmmoInLink{} = True
|
||||||
|
|||||||
@@ -53,16 +53,11 @@ data ItemUse
|
|||||||
| UseCraft
|
| UseCraft
|
||||||
| UseAttach {_uaParams :: AttachParams}
|
| UseAttach {_uaParams :: AttachParams}
|
||||||
| UseAmmoMag
|
| UseAmmoMag
|
||||||
{ _amagLoadStatus :: ReloadStatus
|
-- { _amagLoadStatus :: ReloadStatus
|
||||||
, _amagParams :: AmmoParams
|
-- , _amagParams :: AmmoParams
|
||||||
, _amagType :: AmmoType
|
-- , _amagType :: AmmoType
|
||||||
}
|
|
||||||
| UseScope { _uScope :: Scope }
|
|
||||||
-- | UseTargeting
|
|
||||||
-- { _tgPos :: Maybe Point2
|
|
||||||
-- , _tgID :: Maybe Int
|
|
||||||
-- , _tgActive :: Bool
|
|
||||||
-- }
|
-- }
|
||||||
|
| UseScope { _uScope :: Scope }
|
||||||
| UseBulletMod { _ubMod :: BulletMod }
|
| UseBulletMod { _ubMod :: BulletMod }
|
||||||
deriving (Eq, Show, Read)
|
deriving (Eq, Show, Read)
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
|||||||
let as = _mzAmmoSlot mz
|
let as = _mzAmmoSlot mz
|
||||||
amamount = _mzAmmoPerShot mz
|
amamount = _mzAmmoPerShot mz
|
||||||
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
||||||
availableammo <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
|
availableammo <- mag ^? ldtValue . itConsumables . magLoadStatus . iaLoaded
|
||||||
let usedammo = case amamount of
|
let usedammo = case amamount of
|
||||||
UseUpTo x -> min x availableammo
|
UseUpTo x -> min x availableammo
|
||||||
UseExactly x
|
UseExactly x
|
||||||
@@ -150,7 +150,8 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
|||||||
| otherwise -> 0
|
| otherwise -> 0
|
||||||
guard $ usedammo > 0
|
guard $ usedammo > 0
|
||||||
return
|
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)
|
, Just (mz, usedammo, mag)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -337,8 +338,8 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
|
|||||||
. ix (_crID cr)
|
. ix (_crID cr)
|
||||||
. crInv
|
. crInv
|
||||||
. ix magid
|
. ix magid
|
||||||
. itUse
|
. itConsumables
|
||||||
. amagLoadStatus
|
. magLoadStatus
|
||||||
. iaLoaded
|
. iaLoaded
|
||||||
-~ x
|
-~ x
|
||||||
|
|
||||||
@@ -350,7 +351,7 @@ getBulletType ::
|
|||||||
World ->
|
World ->
|
||||||
Maybe Bullet
|
Maybe Bullet
|
||||||
getBulletType itmtree magtree mz cr w =
|
getBulletType itmtree magtree mz cr w =
|
||||||
magtree ^? ldtValue . itUse . amagParams . ampBullet
|
magtree ^? ldtValue . itConsumables . magParams . ampBullet
|
||||||
<&> buTrajectory .~ btraj
|
<&> buTrajectory .~ btraj
|
||||||
<&> buPayload .~ bpayload
|
<&> buPayload .~ bpayload
|
||||||
<&> buEffect .~ beffect
|
<&> buEffect .~ beffect
|
||||||
@@ -453,7 +454,7 @@ useGasParams mmagid mz itm cr w =
|
|||||||
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
|
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
|
||||||
gastype = fromMaybe (error "cannot find gas ammo") $ do
|
gastype = fromMaybe (error "cannot find gas ammo") $ do
|
||||||
magid <- mmagid
|
magid <- mmagid
|
||||||
fueltype <- cr ^? crInv . ix magid . itUse . amagParams . ampCreateGas
|
fueltype <- cr ^? crInv . ix magid . itConsumables . magParams . ampCreateGas
|
||||||
gc <- itm ^? itUse . heldParams . gasCreation
|
gc <- itm ^? itUse . heldParams . gasCreation
|
||||||
return $ gasCreate fueltype gc
|
return $ gasCreate fueltype gc
|
||||||
--pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
--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
|
magid <- magtree ^? ldtValue . itLocation . ilInvID
|
||||||
ammoitem <- cr ^? crInv . ix magid
|
ammoitem <- cr ^? crInv . ix magid
|
||||||
let homing = determineProjectileTracking magtree itmtree
|
let homing = determineProjectileTracking magtree itmtree
|
||||||
aparams <- ammoitem ^? itUse . amagParams . ampPayload
|
aparams <- ammoitem ^? itConsumables . magParams . ampPayload
|
||||||
return $
|
return $
|
||||||
createShell homing aparams muz cr
|
createShell homing aparams muz cr
|
||||||
. startthesound
|
. startthesound
|
||||||
|
|||||||
+32
-25
@@ -21,17 +21,18 @@ import Dodge.Item.Weapon.Bullet
|
|||||||
megaTinMag :: Int -> Item
|
megaTinMag :: Int -> Item
|
||||||
megaTinMag x =
|
megaTinMag x =
|
||||||
tinMag
|
tinMag
|
||||||
& itUse . amagLoadStatus . iaMax .~ x
|
& itConsumables . magLoadStatus . iaMax .~ x
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ x
|
& itConsumables . magLoadStatus . iaLoaded .~ x
|
||||||
|
|
||||||
tinMag :: Item
|
tinMag :: Item
|
||||||
tinMag =
|
tinMag =
|
||||||
defaultHeldItem & itType .~ AMMOMAG TINMAG
|
defaultHeldItem & itType .~ AMMOMAG TINMAG
|
||||||
& itUse
|
& itUse
|
||||||
.~ UseAmmoMag
|
.~ UseAmmoMag
|
||||||
{ _amagParams = BulletParams defaultBullet
|
& itConsumables .~ AmmoMag
|
||||||
, _amagType = BulletAmmo
|
{ _magParams = BulletParams defaultBullet
|
||||||
, _amagLoadStatus =
|
, _magType = BulletAmmo
|
||||||
|
, _magLoadStatus =
|
||||||
ReloadStatus
|
ReloadStatus
|
||||||
{ _iaMax = 15
|
{ _iaMax = 15
|
||||||
, _iaLoaded = 15
|
, _iaLoaded = 15
|
||||||
@@ -48,59 +49,63 @@ tinMag =
|
|||||||
drumMag :: Item
|
drumMag :: Item
|
||||||
drumMag =
|
drumMag =
|
||||||
tinMag & itType . ibtAmmoMag .~ DRUMMAG
|
tinMag & itType . ibtAmmoMag .~ DRUMMAG
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ 30
|
& itConsumables . magLoadStatus . iaLoaded .~ 30
|
||||||
& itUse . amagLoadStatus . iaMax .~ 30
|
& itConsumables . magLoadStatus . iaMax .~ 30
|
||||||
|
|
||||||
beltMag :: Item
|
beltMag :: Item
|
||||||
beltMag =
|
beltMag =
|
||||||
tinMag & itType . ibtAmmoMag .~ BELTMAG
|
tinMag & itType . ibtAmmoMag .~ BELTMAG
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ 10000
|
& itConsumables . magLoadStatus . iaLoaded .~ 10000
|
||||||
& itUse . amagLoadStatus . iaMax .~ 20000
|
& itConsumables . magLoadStatus . iaMax .~ 20000
|
||||||
& itUse . amagType .~ BeltBulletAmmo
|
& itConsumables . magType .~ BeltBulletAmmo
|
||||||
|
|
||||||
megaShellMag :: Item
|
megaShellMag :: Item
|
||||||
megaShellMag =
|
megaShellMag =
|
||||||
shellMag
|
shellMag
|
||||||
& itUse . amagLoadStatus . iaMax .~ 1000000
|
& itConsumables . magLoadStatus . iaMax .~ 1000000
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ 1000000
|
& itConsumables . magLoadStatus . iaLoaded .~ 1000000
|
||||||
|
|
||||||
shellMag :: Item
|
shellMag :: Item
|
||||||
shellMag =
|
shellMag =
|
||||||
defaultHeldItem & itType .~ AMMOMAG SHELLMAG
|
defaultHeldItem & itType .~ AMMOMAG SHELLMAG
|
||||||
& itUse
|
& itUse
|
||||||
.~ UseAmmoMag
|
.~ UseAmmoMag
|
||||||
{ _amagParams =
|
& itConsumables
|
||||||
|
.~ AmmoMag
|
||||||
|
{ _magParams =
|
||||||
ProjectileParams
|
ProjectileParams
|
||||||
{ _ampPayload = ExplosionPayload
|
{ _ampPayload = ExplosionPayload
|
||||||
}
|
}
|
||||||
, _amagLoadStatus =
|
, _magLoadStatus =
|
||||||
ReloadStatus
|
ReloadStatus
|
||||||
{ _iaMax = 1
|
{ _iaMax = 1
|
||||||
, _iaLoaded = 1
|
, _iaLoaded = 1
|
||||||
}
|
}
|
||||||
, _amagType = LauncherAmmo
|
, _magType = LauncherAmmo
|
||||||
}
|
}
|
||||||
|
|
||||||
megaBattery :: Item
|
megaBattery :: Item
|
||||||
megaBattery =
|
megaBattery =
|
||||||
battery
|
battery
|
||||||
& itUse . amagLoadStatus . iaMax .~ 1000000
|
& itConsumables . magLoadStatus . iaMax .~ 1000000
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ 1000000
|
& itConsumables . magLoadStatus . iaLoaded .~ 1000000
|
||||||
|
|
||||||
smallBattery :: Item
|
smallBattery :: Item
|
||||||
smallBattery =
|
smallBattery =
|
||||||
battery
|
battery
|
||||||
& itUse . amagLoadStatus . iaMax .~ 999
|
& itConsumables . magLoadStatus . iaMax .~ 999
|
||||||
& itUse . amagLoadStatus . iaLoaded .~ 999
|
& itConsumables . magLoadStatus . iaLoaded .~ 999
|
||||||
|
|
||||||
battery :: Item
|
battery :: Item
|
||||||
battery =
|
battery =
|
||||||
defaultHeldItem & itType .~ AMMOMAG BATTERY
|
defaultHeldItem & itType .~ AMMOMAG BATTERY
|
||||||
& itUse
|
& itUse
|
||||||
.~ UseAmmoMag
|
.~ UseAmmoMag
|
||||||
{ _amagParams = BulletParams defaultBullet
|
& itConsumables
|
||||||
, _amagType = ElectricalAmmo
|
.~ AmmoMag
|
||||||
, _amagLoadStatus =
|
{ _magParams = BulletParams defaultBullet
|
||||||
|
, _magType = ElectricalAmmo
|
||||||
|
, _magLoadStatus =
|
||||||
ReloadStatus
|
ReloadStatus
|
||||||
{ _iaMax = 10 ^ (9 :: Int)
|
{ _iaMax = 10 ^ (9 :: Int)
|
||||||
, _iaLoaded = 10 ^ (9 :: Int)
|
, _iaLoaded = 10 ^ (9 :: Int)
|
||||||
@@ -112,9 +117,11 @@ chemFuelPouch =
|
|||||||
defaultHeldItem & itType .~ AMMOMAG CHEMFUELPOUCH
|
defaultHeldItem & itType .~ AMMOMAG CHEMFUELPOUCH
|
||||||
& itUse
|
& itUse
|
||||||
.~ UseAmmoMag
|
.~ UseAmmoMag
|
||||||
{ _amagParams = GasParams ChemFuel
|
& itConsumables
|
||||||
, _amagType = GasAmmo
|
.~ AmmoMag
|
||||||
, _amagLoadStatus =
|
{ _magParams = GasParams ChemFuel
|
||||||
|
, _magType = GasAmmo
|
||||||
|
, _magLoadStatus =
|
||||||
ReloadStatus
|
ReloadStatus
|
||||||
{ _iaMax = 1000
|
{ _iaMax = 1000
|
||||||
, _iaLoaded = 1000
|
, _iaLoaded = 1000
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
|
|||||||
(_,UseConsume {},_) -> []
|
(_,UseConsume {},_) -> []
|
||||||
(_,UseAttach (APInt i),_) -> [show i]
|
(_,UseAttach (APInt i),_) -> [show i]
|
||||||
(_,UseAttach {},_) -> []
|
(_,UseAttach {},_) -> []
|
||||||
(_,UseAmmoMag {},_) -> [maybe "" shortShow $ itm ^? itUse . amagLoadStatus . iaLoaded]
|
(_,UseAmmoMag {},_) -> [maybe "" shortShow
|
||||||
|
$ itm ^? itConsumables . magLoadStatus . iaLoaded]
|
||||||
(_,UseScope OpticScope {_opticZoom = x},_) -> [shortShow x]
|
(_,UseScope OpticScope {_opticZoom = x},_) -> [shortShow x]
|
||||||
(_,UseBulletMod {},_) -> mempty
|
(_,UseBulletMod {},_) -> mempty
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ ammoMagSPic it = \case
|
|||||||
_ -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- y) (-1) 1)
|
_ -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- y) (-1) 1)
|
||||||
where
|
where
|
||||||
y = fromIntegral y' * 0.3
|
y = fromIntegral y' * 0.3
|
||||||
y' = fromMaybe 0 $ it ^? itUse . amagLoadStatus . iaLoaded
|
y' = fromMaybe 0 $ it ^? itConsumables . magLoadStatus . iaLoaded
|
||||||
am = fractionLoadedAmmo (it ^?! itUse . amagLoadStatus)
|
am = fractionLoadedAmmo (it ^?! itConsumables . magLoadStatus)
|
||||||
|
|
||||||
fractionLoadedAmmo :: ReloadStatus -> Float
|
fractionLoadedAmmo :: ReloadStatus -> Float
|
||||||
fractionLoadedAmmo rs = fromIntegral (_iaLoaded rs) / fromIntegral (_iaMax rs)
|
fractionLoadedAmmo rs = fromIntegral (_iaLoaded rs) / fromIntegral (_iaMax rs)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
|||||||
, [(TriggerSF,TriggerLink),(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
, [(TriggerSF,TriggerLink),(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
||||||
)
|
)
|
||||||
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
|
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
|
||||||
atype <- itm ^? itUse . amagType
|
atype <- itm ^? itConsumables . magType
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
[ (AmmoModifierSF atype, AmmoModLink)
|
[ (AmmoModifierSF atype, AmmoModLink)
|
||||||
@@ -89,7 +89,7 @@ itemToFunction itm = case itm ^. itType of
|
|||||||
HELD DETECTOR{} -> GadgetPlatformSF
|
HELD DETECTOR{} -> GadgetPlatformSF
|
||||||
HELD LASER -> WeaponTargetingSF
|
HELD LASER -> WeaponTargetingSF
|
||||||
HELD{} -> HeldPlatformSF
|
HELD{} -> HeldPlatformSF
|
||||||
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itUse . amagType
|
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
|
||||||
ATTACH REMOTESCREEN -> RemoteScreenSF
|
ATTACH REMOTESCREEN -> RemoteScreenSF
|
||||||
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
|
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
|
||||||
ATTACH ZOOMSCOPE -> WeaponScopeSF
|
ATTACH ZOOMSCOPE -> WeaponScopeSF
|
||||||
|
|||||||
Reference in New Issue
Block a user