Implement bullet synth
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -217,7 +217,11 @@ inventoryX c = case c of
|
||||
, makeTypeCraftNum 1 SOUNDSENSOR
|
||||
, makeTypeCraftNum 1 HEATSENSOR
|
||||
]
|
||||
'L' -> [scrollWatch]
|
||||
'L' -> [burstRifle
|
||||
,tinMag
|
||||
, bulletSynthesizer
|
||||
, battery
|
||||
]
|
||||
'M' -> stackedInventory
|
||||
'N' -> [zoomScope,laser,battery, sniperRifle, tinMag]
|
||||
'O' -> [ launcherX 2
|
||||
|
||||
@@ -67,6 +67,7 @@ crUpdate f =
|
||||
, f
|
||||
, footstepSideEffect
|
||||
, updateInv -- upInv must be called before invSideEff 22.05.23
|
||||
, invRootItemEffs
|
||||
, invSideEff
|
||||
, equipmentEffects
|
||||
]
|
||||
@@ -163,6 +164,40 @@ invSideEff cr = alaf Endo foldMap f (_crInv cr) . updateHeldRootItem cr
|
||||
where
|
||||
f it = maybe id (\g -> doInvEffect g it cr) (it ^? itEffect . ieInv)
|
||||
|
||||
-- a loop going over all root inventory items
|
||||
invRootItemEffs :: Creature -> World -> World
|
||||
invRootItemEffs cr = appEndo $ foldMap (reduceLocLDT (Endo . invItemLocUpdate) . LocLDT TopLDT)
|
||||
(invLDT (_crInv cr))
|
||||
|
||||
invItemLocUpdate :: LocationLDT ItemLink PartiallyComposedItem -> World -> World
|
||||
invItemLocUpdate loc w = case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
x <- itm ^? itUse . uaParams . apInt
|
||||
if x < 100
|
||||
then do
|
||||
bat <- loc ^? locLDT . ldtLeft . ix 0 . _2 . ldtValue . _1
|
||||
j <- bat ^? itLocation . ilInvID
|
||||
y <- bat ^? itUse . amagLoadStatus . iaLoaded
|
||||
guard $ y > 0
|
||||
return $ w & cWorld . lWorld . creatures
|
||||
. ix 0 . crInv . ix i . itUse . uaParams . apInt +~ 1
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0 . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
|
||||
else do
|
||||
mag <- loc ^? locLdtContext . cldtParent . _1
|
||||
j <- mag ^? itLocation . ilInvID
|
||||
y <- mag ^? itUse . amagLoadStatus . iaLoaded
|
||||
ymax <- mag ^? itUse . amagLoadStatus . iaMax
|
||||
guard $ y < ymax
|
||||
return $ w & cWorld . lWorld . creatures
|
||||
. ix 0 . crInv . ix i . itUse . uaParams . apInt .~ 0
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0 . crInv . ix j . itUse . amagLoadStatus . iaLoaded +~ 1
|
||||
_ -> w
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
updateHeldRootItem :: Creature -> World -> World
|
||||
updateHeldRootItem cr = fromMaybe id $ do
|
||||
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
|
||||
@@ -77,7 +77,7 @@ data CraftType
|
||||
|
||||
data AttachType
|
||||
= ZOOMSCOPE
|
||||
| BULLETSYNTHESIZER
|
||||
| BULLETSYNTH
|
||||
| REMOTESCREEN
|
||||
| HOMINGMODULE
|
||||
| AUGMENTEDHUD
|
||||
|
||||
@@ -74,6 +74,7 @@ data AttachParams
|
||||
{_apLinkedProjectile :: Maybe Int}
|
||||
| APItEffect
|
||||
{_apItEffect :: ItEffect }
|
||||
| APInt {_apInt :: Int}
|
||||
| APNothing
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
|
||||
@@ -252,3 +252,7 @@ cldtPropagateFold lf rf up x loc =
|
||||
(LocLDT con' t'))
|
||||
(locGoRight loc)
|
||||
. up x loc
|
||||
|
||||
reduceLocLDT :: Monoid m => (LocationLDT b a -> m) -> LocationLDT b a -> m
|
||||
reduceLocLDT f x =foldMap (reduceLocLDT f) (locGoLeft x) <> f x
|
||||
<> foldMap (reduceLocLDT f) (locGoRight x)
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ itemFromAmmoMag at = case at of
|
||||
itemFromAttachType :: AttachType -> Item
|
||||
itemFromAttachType at = case at of
|
||||
ZOOMSCOPE -> zoomScope
|
||||
BULLETSYNTHESIZER -> bulletSynthesizer
|
||||
BULLETSYNTH -> bulletSynthesizer
|
||||
REMOTESCREEN -> remoteScreen
|
||||
-- ROCKETHOMER -> rocketHomer
|
||||
HOMINGMODULE -> homingModule
|
||||
|
||||
@@ -122,4 +122,5 @@ chemFuelPouch =
|
||||
}
|
||||
|
||||
bulletSynthesizer :: Item
|
||||
bulletSynthesizer = makeAttach BULLETSYNTHESIZER
|
||||
bulletSynthesizer = makeAttach BULLETSYNTH
|
||||
& itUse .~ UseAttach (APInt 0)
|
||||
|
||||
@@ -61,7 +61,7 @@ itemBaseName itm = case _itType itm of
|
||||
showAttachItem :: AttachType -> Item -> String
|
||||
showAttachItem t itm = case t of
|
||||
ZOOMSCOPE -> "ZOOMSCOPE"
|
||||
BULLETSYNTHESIZER -> "BSYNTH"
|
||||
BULLETSYNTH -> "BSYNTH"
|
||||
REMOTESCREEN -> "REMOTE SCREEN " ++ show (itm ^? itUse . uaParams . apLinkedProjectile . _Just)
|
||||
HOMINGMODULE -> "HOMING MOD"
|
||||
AUGMENTEDHUD -> "AUGMENTED HUD"
|
||||
@@ -93,20 +93,21 @@ showAutoRechargeProgress lc = case lc of
|
||||
-- ic = (itm ^?! itUse . heldConsumption . laSource)
|
||||
|
||||
itemNumberDisplay :: Creature -> ComposedItem -> [String]
|
||||
itemNumberDisplay cr ci = case (ci ^. cItemFunction,iu) of
|
||||
(WeaponTargetingSF,_) -> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
|
||||
itemNumberDisplay cr ci = case (ci ^. cItemFunction, itm ^?! itUse) of
|
||||
(WeaponTargetingSF,_)
|
||||
-> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
|
||||
(_,UseHeld{}) -> []
|
||||
(_,UseHotkey{}) -> [showAutoRechargeProgress (_leftConsumption iu)]
|
||||
(_,UseHotkey{_leftConsumption=lc}) -> [showAutoRechargeProgress lc]
|
||||
(_,UseEquip{}) -> showEquipmentNumber cr itm
|
||||
(_,UseCraft) -> []
|
||||
(_,UseConsume {}) -> []
|
||||
(_,UseAttach (APInt i)) -> [show i]
|
||||
(_,UseAttach {}) -> []
|
||||
(_,UseAmmoMag {}) -> [maybe "" shortShow $ itm ^? itUse . amagLoadStatus . iaLoaded]
|
||||
(_,UseScope OpticScope {_opticZoom = x}) -> [shortShow x]
|
||||
(_,UseBulletMod {}) -> mempty
|
||||
where
|
||||
itm = ci ^. cItem
|
||||
iu = itm ^?! itUse
|
||||
|
||||
showEquipmentNumber :: Creature -> Item -> [String]
|
||||
showEquipmentNumber _ itm = case _eeUse ee of
|
||||
|
||||
@@ -21,6 +21,12 @@ import Dodge.Item.Orientation
|
||||
import LensHelp
|
||||
import ListHelp
|
||||
|
||||
tryAttachItems ::
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
Maybe (LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
|
||||
|
||||
useBreakL ::
|
||||
[(ItemStructuralFunction, ComposeLinkType)] ->
|
||||
[(ItemStructuralFunction, ComposeLinkType)] ->
|
||||
@@ -66,6 +72,8 @@ itemToBreakLists ci = case (itm ^. itType, ci ^. cItemFunction) of
|
||||
, []
|
||||
)
|
||||
(_, WeaponTargetingSF) -> (getAmmoLinks itm ++ [(AugmentedHUDSF, AugmentedHUDLink)], [])
|
||||
(ATTACH BULLETSYNTH, _)
|
||||
-> ([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)],[])
|
||||
_ -> ([], [])
|
||||
where
|
||||
itm = ci ^. cItem
|
||||
@@ -78,10 +86,11 @@ getAmmoLinks itm =
|
||||
|
||||
itemToFunction :: Item -> ItemStructuralFunction
|
||||
itemToFunction itm = case itm ^. itType of
|
||||
HELD LASER -> WeaponTargetingSF
|
||||
HELD{} -> WeaponPlatformSF
|
||||
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itUse . amagType
|
||||
ATTACH REMOTESCREEN -> RemoteScreenSF
|
||||
ATTACH BULLETSYNTHESIZER -> AmmoModifierSF BulletAmmo
|
||||
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
|
||||
ATTACH ZOOMSCOPE -> WeaponScopeSF
|
||||
ATTACH HOMINGMODULE -> AmmoTargetingSF ProjectileAmmo
|
||||
ATTACH AUGMENTEDHUD -> AugmentedHUDSF
|
||||
@@ -89,8 +98,8 @@ itemToFunction itm = case itm ^. itType of
|
||||
BULLETMOD BulletModPayload{} -> AmmoPayloadSF BulletAmmo
|
||||
BULLETMOD BulletModEffect{} -> AmmoEffectSF BulletAmmo
|
||||
TARGETING{} -> WeaponTargetingSF
|
||||
LEFT {} -> EquipmentPlatformSF
|
||||
EQUIP {} -> EquipmentPlatformSF
|
||||
LEFT{} -> EquipmentPlatformSF
|
||||
EQUIP{} -> EquipmentPlatformSF
|
||||
_ -> UncomposableIsolateSF
|
||||
|
||||
pciToCI :: PartiallyComposedItem -> ComposedItem
|
||||
@@ -98,8 +107,12 @@ pciToCI (x, y, _) = CItem x y
|
||||
|
||||
basePCI :: Item -> PartiallyComposedItem
|
||||
basePCI itm = case _itType itm of
|
||||
HELD LASER -> (itm, WeaponTargetingSF, laserLinkTest itm)
|
||||
_ -> (itm, itemToFunction itm, uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm)))
|
||||
_ -> (itm, itemToFunction itm, itemBaseConnections itm)
|
||||
|
||||
itemBaseConnections :: Item -> LinkTest
|
||||
itemBaseConnections itm = case _itType itm of
|
||||
HELD LASER -> laserLinkTest itm
|
||||
_ -> uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm))
|
||||
|
||||
laserLinkTest :: Item -> LinkTest
|
||||
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
||||
@@ -171,7 +184,7 @@ joinItemsInList f xs = snd $ h (xs, [])
|
||||
-- this puts the first elements in the intmap at the end of the list
|
||||
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink PartiallyComposedItem]
|
||||
invLDT =
|
||||
joinItemsInList (leftRightCombine leftIsParentCombine rightIsParentCombine) . IM.elems
|
||||
joinItemsInList tryAttachItems . IM.elems
|
||||
. fmap (singleLDT . basePCI)
|
||||
|
||||
-- this assumes the creature inventory is well formed, specifically the
|
||||
|
||||
@@ -12,6 +12,7 @@ itInvHeight :: Item -> Int
|
||||
itInvHeight x = case x ^. itType of
|
||||
HELD (MINIGUNX i) -> (i + 3) `div` 2
|
||||
HELD LAUNCHER -> 3
|
||||
HELD LAUNCHERX{} -> 3
|
||||
HELD FLATSHIELD -> 3
|
||||
HELD (BANGSTICK i) -> max 1 (i `div` 2)
|
||||
_ -> 1
|
||||
@@ -27,7 +28,7 @@ itDim x = case x ^. itType of
|
||||
& dimCenter .~ V3 9 0 0
|
||||
HELD y | hasCaneGunDim y -> did & dimRad .~ 8
|
||||
& dimCenter .~ V3 5 0 0
|
||||
HELD (MINIGUNX {}) -> did & dimRad .~ 20
|
||||
HELD MINIGUNX {} -> did & dimRad .~ 20
|
||||
& dimCenter .~ V3 5 0 0
|
||||
& dimAttachPos .~ V3 5 (-5) 0
|
||||
HELD LAUNCHER -> did & dimRad .~ 9
|
||||
|
||||
Reference in New Issue
Block a user