Fix burst rifle rate delay bug, various cleanups

This commit is contained in:
2025-06-25 23:47:41 +01:00
parent 1bdf426c42
commit 5b35b4c6c8
19 changed files with 440 additions and 469 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ import Dodge.Item.Draw.SPic
import Dodge.Item.HeldOffset
import ShapePicture
itemEquipPict :: Creature -> LabelDoubleTree ItemLink ComposedItem -> SPic
itemEquipPict :: Creature -> LabelDoubleTree ItemLink CItem -> SPic
itemEquipPict cr itmtree
| Just i <- itm ^? itLocation . ilInvID
, Just esite <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
+2 -3
View File
@@ -20,13 +20,12 @@ import Picture
import Shape
import ShapePicture
itemTreeSPic :: LabelDoubleTree ItemLink ComposedItem -> SPic
itemTreeSPic :: LabelDoubleTree ItemLink CItem -> SPic
itemTreeSPic (LDT (itm,_,_) l r) =
itemSPic itm
<> foldMap (itemRotTreeSPic itm) (l <> r)
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink ComposedItem)
-> SPic
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink CItem) -> SPic
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
where
(p, q) = _iatOrient il par (_iatType il) itm
+27 -27
View File
@@ -29,14 +29,14 @@ import LensHelp
import ListHelp
tryAttachItems ::
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink ComposedItem ->
Maybe (LabelDoubleTree ItemLink ComposedItem)
LabelDoubleTree ItemLink CItem ->
LabelDoubleTree ItemLink CItem ->
Maybe (LabelDoubleTree ItemLink CItem)
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
useBreakL ::
[(ItemStructuralFunction, ComposeLinkType)] ->
[(ItemStructuralFunction, ComposeLinkType)] ->
[(ItemStructuralFunction, CLinkType)] ->
[(ItemStructuralFunction, CLinkType)] ->
LinkTest
useBreakL x y = useBreakListsLinkTest (map (uncurry noa) x) (map (uncurry noa) y)
where
@@ -68,7 +68,7 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
itemToBreakLists ::
Item ->
ItemStructuralFunction ->
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
([(ItemStructuralFunction, CLinkType)], [(ItemStructuralFunction, CLinkType)])
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
(HELD TORCH, _) -> (getAmmoLinks itm, [])
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
@@ -118,12 +118,12 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
_ -> ([], [])
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAutoSpringLinks itm = case baseTriggerType itm of
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
extraWeaponLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinks itm = case itm ^. itType of
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
HELD RLAUNCHER -> launcherlinks
@@ -132,14 +132,14 @@ extraWeaponLinks itm = case itm ^. itType of
where
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinksBelow itm
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
| TwoHandUnder <- aStance itm
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
| otherwise = []
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAmmoLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAmmoLinks itm =
map
(\(i, a) -> (AmmoMagSF a, AmmoInLink i a))
@@ -181,7 +181,7 @@ itemToFunction itm = case itm ^. itType of
_ -> NoSF
structureToPotentialFunction ::
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink CItem ->
S.Set ItemStructuralFunction
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
STICKYMOD -> S.singleton GrenadeHitEffectSF
@@ -190,7 +190,7 @@ structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
_ -> S.singleton (ldt ^. ldtValue . _2)
baseCI :: Item -> ComposedItem
baseCI :: Item -> CItem
baseCI itm = (itm, itemToFunction itm, itemBaseConnections itm)
itemBaseConnections :: Item -> LinkTest
@@ -202,13 +202,13 @@ itemBaseConnections itm = case _itType itm of
laserLinkTest :: Item -> LinkTest
laserLinkTest itm = LTest (llleft itm) (llright itm)
llleft :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
llleft :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
llleft itm =
_tryLeftLink
. uncurry useBreakL
$ itemToBreakLists itm WeaponTargetingSF
llright :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
llright :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
llright itm pci = case pci ^. ldtValue . _1 . itType of
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm WeaponTargetingSF) pci
@@ -232,20 +232,20 @@ springLinkTest = LTest (const Nothing) $
)
_ -> Nothing
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
--itemLinkTestLeft :: Item -> PartiallyCItem -> Maybe LinkUpdate
--itemLinkTestLeft itm = _tryLeftLink $
-- uncurry useBreakL $ itemToBreakLists itm
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
leftIsParentCombine :: LDTComb ComposedItem ItemLink
leftIsParentCombine :: LDTComb CItem ItemLink
leftIsParentCombine ltree rtree = do
lu <- (ltree ^. ldtValue . _3 . tryRightLink) rtree --(rtree ^. ldtValue)
return $
ltree & ldtValue %~ (lu ^. luParentUpdate)
& ldtRight %~ (++ [(lu ^. luLinkType, rtree & ldtValue %~ (lu ^. luChildUpdate))])
rightIsParentCombine :: LDTComb ComposedItem ItemLink
rightIsParentCombine :: LDTComb CItem ItemLink
rightIsParentCombine ltree rtree = do
lu <- (rtree ^. ldtValue . _3 . tryLeftLink) ltree -- (ltree ^. ldtValue)
return $
@@ -276,7 +276,7 @@ joinItemsInList f xs = snd $ h (xs, [])
Just w -> h (w : ys, zs)
-- this puts the first elements in the intmap at the end of the list
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink ComposedItem]
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink CItem]
invLDT =
joinItemsInList tryAttachItems . IM.elems
. fmap (singleLDT . baseCI)
@@ -306,28 +306,28 @@ invAdj = IM.unions . map g . invLDT
$ itm ^? itLocation . ilInvID
-- returns an intmap with trees for (only!) root items, indexed by inventory position
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink CItem)
invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT
where
getid ::
LabelDoubleTree ItemLink ComposedItem ->
(Int, LabelDoubleTree ItemLink ComposedItem)
LabelDoubleTree ItemLink CItem ->
(Int, LabelDoubleTree ItemLink CItem)
getid t = (t ^?! ldtValue . _1 . itLocation . ilInvID, t)
-- returns an intmap with indents and locations for all items
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink CItem)
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
where
f t = cldtPropagateFold h h g 0 t id
h x _ _ _ = x + 1
g ::
Int ->
LocationLDT ItemLink ComposedItem ->
( IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
LocationLDT ItemLink CItem ->
( IM.IntMap (Int, LocationLDT ItemLink CItem) ->
IM.IntMap (Int, LocationLDT ItemLink CItem)
) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
IM.IntMap (Int, LocationLDT ItemLink CItem) ->
IM.IntMap (Int, LocationLDT ItemLink CItem)
g x ldt =
(.)
( IM.insert
+1 -5
View File
@@ -43,11 +43,7 @@ autoRifle =
& itType .~ HELD AUTORIFLE
burstRifle :: Item
burstRifle =
rifle
& itType .~ HELD BURSTRIFLE
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
-- & itUse . heldDelay . rateMax .~ 6
burstRifle = rifle & itType .~ HELD BURSTRIFLE
miniGunX :: Int -> Item
miniGunX i =
+1 -1
View File
@@ -6,7 +6,7 @@ import Color
import Control.Lens
import Dodge.Data.ComposedItem
itemInvColor :: ComposedItem -> Color
itemInvColor :: CItem -> Color
itemInvColor ci = case ci ^. _2 of
MapperSF -> white
GrenadeHitEffectSF -> yellow
+2 -2
View File
@@ -13,14 +13,14 @@ orientChild itm = case _itType itm of
HELD LASER -> (V3 15 (-5) 0, Q.qID)
_ -> (0, Q.qID)
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
orientByLink :: Item -> CLinkType -> (Point3, Q.Quaternion Float)
orientByLink itm lt = case (_itType itm, lt) of
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.qID)
(HELD _, AmmoInLink{}) -> (V3 7 (-2) 0, Q.qID)
(HELD _, WeaponScopeLink) -> (V3 5 0 5, Q.qID)
_ -> (0, Q.qID)
orientAttachment :: Item -> ComposeLinkType -> Item -> (Point3, Q.Quaternion Float)
orientAttachment :: Item -> CLinkType -> Item -> (Point3, Q.Quaternion Float)
orientAttachment par lnk ch = case (_itType par, lnk, _itType ch) of
-- (HELD BURSTRIFLE, _, HELD TORCH) -> (V3 20 0 0, Q.axisAngle (V3 0 0 1) (pi/2))
-- (HELD LAUNCHER, _, HELD TORCH) -> (V3 0 20 0, Q.axisAngle (V3 0 0 1) (pi/4))