Allow a spring and hardware to make weapons automatic

This commit is contained in:
2024-12-23 16:29:10 +00:00
parent 205c0a5c19
commit 90ec2a3738
6 changed files with 87 additions and 55 deletions
+2
View File
@@ -252,6 +252,8 @@ inventoryX c = case c of
[ battery
, zoomScope
, augmentedHUD
, makeTypeCraft SPRING
, makeTypeCraft HARDWARE
, autoRifle
, alteRifle
, megaTinMag 10200
+2
View File
@@ -24,6 +24,7 @@ data ComposeLinkType
| RemoteScreenLink
| AugmentedHUDLink
| FunctionChangeLink
| MakeAutoLink
deriving (Eq, Ord, Show, Read)
data ItemStructuralFunction
@@ -42,6 +43,7 @@ data ItemStructuralFunction
| AmmoPayloadSF AmmoType
| AmmoEffectSF AmmoType
| FunctionChangeSF
| MakeAutoSF
deriving (Eq, Ord, Show, Read)
type ComposedItem = (Item, ItemStructuralFunction, LinkTest)
+4 -1
View File
@@ -49,10 +49,13 @@ type ChainEffect =
hammerCheck :: ChainEffect
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
Just HammerTrigger -> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just HammerTrigger | nomakeauto
-> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
_ -> w
_ -> f it cr w
where
nomakeauto = not . isJust $ lookup MakeAutoLink (it ^. ldtRight)
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
+24 -4
View File
@@ -56,10 +56,11 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
(_, HeldPlatformSF) ->
( getAmmoLinks itm
, [(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
<> getAutoSpringLinks itm
)
(_, GadgetPlatformSF) ->
( getAmmoLinks itm
, [(TriggerSF,TriggerLink),(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
, [(TriggerSF, TriggerLink), (WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
)
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
atype <- itm ^? itConsumables . magType
@@ -78,6 +79,11 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
_ -> ([], [])
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAutoSpringLinks itm = case itm ^? itUse . heldTriggerType of
Just HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAmmoLinks itm =
map
@@ -90,9 +96,10 @@ itemToFunction itm = case itm ^. itType of
HELD{} -> case itm ^? itUseCondition of
Just MustBeHeld -> HeldPlatformSF
_ -> GadgetPlatformSF
_ | Just amtype <- itm ^? itConsumables . magType
, Just _ <- itm ^? itLocation . ilEquipSite . _Just
-> AmmoMagSF amtype
_
| Just amtype <- itm ^? itConsumables . magType
, Just _ <- itm ^? itLocation . ilEquipSite . _Just ->
AmmoMagSF amtype
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
ATTACH REMOTESCREEN -> RemoteScreenSF
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
@@ -114,6 +121,7 @@ basePCI itm = case _itType itm of
itemBaseConnections :: Item -> LinkTest
itemBaseConnections itm = case _itType itm of
HELD LASER -> laserLinkTest itm
CRAFT SPRING -> springLinkTest itm
_ -> uncurry useBreakL $ itemToBreakLists itm (itemToFunction itm)
laserLinkTest :: Item -> LinkTest
@@ -137,6 +145,18 @@ toLasgunUpdate itm =
(\(par, _, _) -> (par, HeldPlatformSF, uncurry useBreakL $ itemToBreakLists itm HeldPlatformSF))
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
springLinkTest :: Item -> LinkTest
springLinkTest itm = LTest (const Nothing) $
\ci -> case ci ^. _1 . itType of
CRAFT HARDWARE ->
Just
( LUpdate
(ILink FunctionChangeLink orientAttachment)
(\(par, _, up) -> (par, MakeAutoSF, up))
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
)
_ -> Nothing
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
--itemLinkTestLeft itm = _tryLeftLink $
-- uncurry useBreakL $ itemToBreakLists itm
+1
View File
@@ -9,6 +9,7 @@ import Dodge.Data.ComposedItem
itemInvColor :: ComposedItem -> Color
itemInvColor ci = case ci ^. _2 of
HeldPlatformSF -> white
MakeAutoSF -> white
EquipmentPlatformSF -> yellow
GadgetPlatformSF -> white
TriggerSF -> yellow