Fold together useDelay and itemTriggerType

This commit is contained in:
2025-07-03 22:25:32 +01:00
parent 8a00450e3f
commit a207073846
12 changed files with 404 additions and 365 deletions
+3 -2
View File
@@ -7,7 +7,8 @@ module Dodge.Item.Display (
itemInternalValue,
) where
import Dodge.Item.UseDelay
import Dodge.BaseTriggerType
--import Dodge.Item.UseDelay
import ShortShow
import Data.Maybe
import Dodge.Data.World
@@ -42,7 +43,7 @@ itemInternalValue itm
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case useDelay it ^? warmMax of
maybeWarmupStatus it = case itemTriggerType it ^? warmMax of
Nothing -> Nothing
--Just m -> case m - (_warmTime . _heldDelay $ _itUse it) of
Just m -> case m - _wTime (_itParams it) of
+2 -1
View File
@@ -92,7 +92,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
getAutoSpringLinks itm = case itemTriggerType itm of
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
HammerTrigger _ -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
@@ -158,6 +158,7 @@ structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
ATTACH GIMBAL -> S.singleton ProjectileStabiliserSF
ATTACH GYROSCOPE -> S.singleton ProjectileStabiliserSF
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
HELD BURSTRIFLE -> S.singleton UnderBarrelPlatformSF
_ -> S.singleton (ldt ^. ldtValue . _2)
baseCI :: Item -> CItem
+41 -29
View File
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.HeldOffset (
turretItemOffset,
twoFlatHRot,
@@ -7,20 +8,21 @@ module Dodge.Item.HeldOffset (
heldItemOrient2D,
heldItemOrient2D',
itemRelativeOrient,
locOrientation,
) where
import Dodge.Item.Orientation
import Dodge.DoubleTree
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Creature.Radius
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import qualified Quaternion as Q
import Dodge.Data.ComposedItem
import Dodge.Data.Creature
import Dodge.Data.DoubleTree
import Dodge.Data.Machine
import Dodge.DoubleTree
import Dodge.Item.AimStance
import Dodge.Item.Orientation
import Geometry
import LensHelp
import qualified Quaternion as Q
turretItemOffset :: Item -> Turret -> Machine -> Point3 -> Point3
turretItemOffset it tu mc =
@@ -33,31 +35,31 @@ transToHandle itm = (-.-.- V3 x y 0)
V2 x y = handlePos itm
heldItemOrient2D :: Item -> Creature -> Point2 -> Float -> (Point2, Float)
heldItemOrient2D itm cr p a = (V2 x y, argV . Q.qToV2 $ q )
heldItemOrient2D itm cr p a = (V2 x y, argV . Q.qToV2 $ q)
where
(V3 x y _,q) = heldItemRelativeOrient itm cr (p `v2z` 0, Q.axisAngle (V3 0 0 1) a)
(V3 x y _, q) = heldItemRelativeOrient itm cr (p `v2z` 0, Q.axisAngle (V3 0 0 1) a)
heldItemOrient2D' :: OItem -> Creature -> Point2 -> Float -> (Point2, Float)
heldItemOrient2D' (itm,_,(p1,q1)) cr p a = (V2 x y, argV . Q.qToV2 $ q )
heldItemOrient2D' (itm, _, (p1, q1)) cr p a = (V2 x y, argV . Q.qToV2 $ q)
where
(V3 x y _,q) = heldItemRelativeOrient itm cr (p1 + Q.rotate q1 (p `v2z` 0), q1 * Q.axisAngle (V3 0 0 1) a)
(V3 x y _, q) = heldItemRelativeOrient itm cr (p1 + Q.rotate q1 (p `v2z` 0), q1 * Q.axisAngle (V3 0 0 1) a)
heldItemRelativeOrient
:: Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
heldItemRelativeOrient itm cr (p,q)
| Aiming {} <- _posture (_crStance cr) =
heldItemRelativeOrient ::
Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
heldItemRelativeOrient itm cr (p, q)
| Aiming{} <- _posture (_crStance cr) =
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
| TwoHandFlat <- itemBaseStance itm =
| TwoHandFlat <- itemBaseStance itm =
( V3 (crRad $ cr ^. crType) 0 handD + rotate3 (twoFlatHRot cr) (transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (twoFlatHRot cr) * q
)
| OneHand <- itemBaseStance itm =
( V3 (crRad (cr ^. crType) * 0.7 + handPos) (crRad (cr ^. crType) * negate 0.7) handD
+ transToHandle itm p
, Q.qID * q
)
| otherwise =
( V3 (crRad $ cr ^. crType) 0 handD
| OneHand <- itemBaseStance itm =
( V3 (crRad (cr ^. crType) * 0.7 + handPos) (crRad (cr ^. crType) * negate 0.7) handD
+ transToHandle itm p
, Q.qID * q
)
| otherwise =
( V3 (crRad $ cr ^. crType) 0 handD
+ rotate3 (strideRot cr + 1.2) (V3 (-8) 0 0 + transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2) * q
)
@@ -69,6 +71,13 @@ heldItemRelativeOrient itm cr (p,q)
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
locOrientation :: LocationLDT ItemLink OItem -> Creature -> Point3Q
locOrientation loc cr =
heldItemRelativeOrient
(locToTop loc ^. locLDT . ldtValue . _1)
cr
(loc ^. locLDT . ldtValue . _3)
aimingWeaponZeroPos :: Creature -> Item -> Point2
aimingWeaponZeroPos cr it = aimStanceHandlePos cr it - handlePos it
@@ -81,7 +90,7 @@ aimStanceHandlePos _ it = case itemBaseStance it of
TwoHandFlat -> V2 10 0
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p,Q.qID))
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p, Q.qID))
shoulderHeight :: Float
shoulderHeight = 18
@@ -143,12 +152,15 @@ heldHandlePos = \case
SHATTERGUN -> V2 3 0
TORCH -> V2 3 0
FLATSHIELD -> V2 3 0
KEYCARD {} -> V2 3 0
KEYCARD{} -> V2 3 0
BLINKER -> V2 3 0
BLINKERUNSAFE -> V2 3 0
itemRelativeOrient :: LocationLDT ItemLink Item -> Creature
-> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
itemRelativeOrient loc cr
= heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue) cr
. orientLocation (V3 0 0 0,Q.qID) loc
itemRelativeOrient ::
LocationLDT ItemLink Item ->
Creature ->
(Point3, Q.Quaternion Float) ->
(Point3, Q.Quaternion Float)
itemRelativeOrient loc cr =
heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue) cr
. orientLocation (V3 0 0 0, Q.qID) loc
+51 -50
View File
@@ -1,60 +1,61 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.UseDelay
(useDelay
, module Dodge.Data.UseDelay
(-- useDelay
module Dodge.Data.UseDelay
) where
import Dodge.Data.UseDelay
import Control.Lens
import Dodge.Data.Item
useDelay :: Item -> ItemUseDelay
useDelay itm = case itm ^. itType of
HELD hit -> heldUseDelay hit
DETECTOR _ -> FixedRate 20
_ -> NoDelay
--useDelay :: Item -> ItemUseDelay
--useDelay itm = case itm ^. itType of
-- HELD hit -> heldUseDelay hit
-- DETECTOR _ -> FixedRate 20
-- _ -> NoDelay
heldUseDelay :: HeldItemType -> ItemUseDelay
heldUseDelay = \case
BANGSTICK _ -> FixedRate 8
REWINDER -> FixedRate 20
TIMESTOPPER -> FixedRate 20
TIMESCROLLER -> FixedRate 20
PISTOL -> FixedRate 6
AUTOPISTOL -> FixedRate 8
SMG -> FixedRate 8
MACHINEPISTOL -> WarmUpCoolDown 50 100 200
BURSTRIFLE -> FixedRate 8 -- time last used gets updated after the last burst fire
BANGCONE -> FixedRate 20
BLUNDERBUSS -> FixedRate 20
GRAPECANNON _ -> FixedRate 20
MINIGUNX _ -> WarmUpNoDelay 100
VOLLEYGUN{} -> FixedRate 15
RIFLE -> FixedRate 6
ALTERIFLE -> FixedRate 6
AUTORIFLE -> FixedRate 6
BANGROD -> FixedRate 12
ELEPHANTGUN -> FixedRate 12
AMR -> FixedRate 12
AUTOAMR -> FixedRate 12
SNIPERRIFLE -> FixedRate 12
FLAMESPITTER -> FixedRate 6
FLAMETHROWER -> NoDelay
FLAMETORRENT -> NoDelay
FLAMEWALL -> NoDelay
POISONSPRAYER -> NoDelay
BLOWTORCH -> NoDelay
SPARKGUN -> NoDelay
TESLAGUN -> NoDelay
LASER -> NoDelay
TRACTORGUN -> NoDelay
RLAUNCHER -> FixedRate 20
RLAUNCHERX{} -> FixedRate 20
GLAUNCHER -> FixedRate 20
SHATTERGUN -> FixedRate 20
BLINKER -> FixedRate 20
BLINKERUNSAFE -> FixedRate 20
TORCH -> NoDelay
FLATSHIELD -> NoDelay
KEYCARD _ -> NoDelay
--heldUseDelay :: HeldItemType -> ItemUseDelay
--heldUseDelay = \case
-- BANGSTICK _ -> FixedRate 8
-- REWINDER -> FixedRate 20
-- TIMESTOPPER -> FixedRate 20
-- TIMESCROLLER -> FixedRate 20
-- PISTOL -> FixedRate 6
-- AUTOPISTOL -> FixedRate 8
-- SMG -> FixedRate 8
-- MACHINEPISTOL -> WarmUpCoolDown 50 100 200
-- --BURSTRIFLE -> FixedRate 8 -- time last used gets updated after the last burst fire
-- BURSTRIFLE -> NoDelay
-- BANGCONE -> FixedRate 20
-- BLUNDERBUSS -> FixedRate 20
-- GRAPECANNON _ -> FixedRate 20
-- MINIGUNX _ -> WarmUpNoDelay 100
-- VOLLEYGUN{} -> FixedRate 15
-- RIFLE -> FixedRate 6
-- ALTERIFLE -> FixedRate 6
-- AUTORIFLE -> FixedRate 6
-- BANGROD -> FixedRate 12
-- ELEPHANTGUN -> FixedRate 12
-- AMR -> FixedRate 12
-- AUTOAMR -> FixedRate 12
-- SNIPERRIFLE -> FixedRate 12
-- FLAMESPITTER -> FixedRate 6
-- FLAMETHROWER -> NoDelay
-- FLAMETORRENT -> NoDelay
-- FLAMEWALL -> NoDelay
-- POISONSPRAYER -> NoDelay
-- BLOWTORCH -> NoDelay
-- SPARKGUN -> NoDelay
-- TESLAGUN -> NoDelay
-- LASER -> NoDelay
-- TRACTORGUN -> NoDelay
-- RLAUNCHER -> FixedRate 20
-- RLAUNCHERX{} -> FixedRate 20
-- GLAUNCHER -> FixedRate 20
-- SHATTERGUN -> FixedRate 20
-- BLINKER -> FixedRate 20
-- BLINKERUNSAFE -> FixedRate 20
-- TORCH -> NoDelay
-- FLATSHIELD -> NoDelay
-- KEYCARD _ -> NoDelay