This commit is contained in:
2025-01-04 21:25:11 +00:00
parent 02f5bdae31
commit 51297d0cb2
5 changed files with 853355 additions and 877919 deletions
-7
View File
@@ -426,13 +426,6 @@ setRBCreatureTargeting cr w ituse
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos
Just $ hasLOS cpos (_crPos cr) w
--updateAutoRecharge :: Item -> Item
--updateAutoRecharge it = case it ^? itUse . leftConsumption of
-- Just (AutoRecharging l m t p)
-- | l < m && p <= 0 -> it & itUse . leftConsumption .~ AutoRecharging (l + 1) m t t
-- | l < m -> it & itUse . leftConsumption . arProgress -~ 1
-- _ -> it
updateMovement :: Creature -> Creature
updateMovement cr
| isFrictionless cr = over crPos (+.+ momentum) cr
+59 -41
View File
@@ -8,13 +8,13 @@ module Dodge.HeldUse (
mcUseHeld,
) where
import qualified Data.IntMap.Strict as IM
import Dodge.Creature.Action
import Color
import Control.Applicative
import Control.Monad
import qualified Data.IntMap.Strict as IM
import Data.Maybe
import Dodge.Base.Collide
import Dodge.Creature.Action
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.MuzzleEffect
@@ -43,14 +43,17 @@ gadgetEffect ::
World ->
World
gadgetEffect pt loc
| UseHeld {} <- loc ^. locLDT . ldtValue . _1 . itUse = heldEffect pt
(bimap _iatType (^. _1) (loc ^. locLDT))
| UseHeld{} <- loc ^. locLDT . ldtValue . _1 . itUse =
heldEffect
pt
(bimap _iatType (^. _1) (loc ^. locLDT))
| DROPPER x <- loc ^. locLDT . ldtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
, pt == InitialPress = dropInventoryPath i x loc
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
, pt == InitialPress =
dropInventoryPath i x loc
| CLICKER x <- loc ^. locLDT . ldtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
= useInventoryPath pt i x loc
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt =
useInventoryPath pt i x loc
| otherwise = const id
heldEffect ::
@@ -79,21 +82,18 @@ hammerCheck ::
t1 ->
t2 ->
t2
hammerCheck pt f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
Just HammerTrigger | nomakeauto ->
case pt of
InitialPress -> f it cr w
_ -> w
_ -> f it cr w
where
nomakeauto = isNothing $ lookup MakeAutoLink (it ^. ldtRight)
hammerCheck pt f it cr
| Just HammerTrigger <- it ^? ldtValue . itUse . heldTriggerType
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
, pt /= InitialPress = id
| otherwise = f it cr
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
Just (FixedRate rate lastused)
Just (FixedRate rate lastused)
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
Just FixedRate {} -> w
Just FixedRate{} -> w
Just (WarmUpNoDelay wt wm ws)
| wt < wm ->
w
@@ -103,7 +103,6 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
f item cr w
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
Just NoDelay -> f item cr w
-- Just (VariableRate rmax rtime rmaxmax rminmax) -> undefined
Nothing -> w
where
cid = _crID cr
@@ -118,7 +117,6 @@ heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -
heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
where
muzzles = t ^. ldtValue . itUse . heldAim . aimMuzzles
@@ -347,8 +345,13 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
w
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
MuzzleShatter -> shootShatter itm cr w
MuzzleDetector -> itemDetectorEffect itm (getAttachedSFLink MapperSF itmtree)
(getAttachedSFLink ARHUDSF itmtree) cr w
MuzzleDetector ->
itemDetectorEffect
itm
(getAttachedSFLink MapperSF itmtree)
(getAttachedSFLink ARHUDSF itmtree)
cr
w
MuzzleBlink -> unsafeBlinkAction cr w
MuzzleUnsafeBlink -> blinkActionMousePos cr w
MuzzleRewind -> useRewindGun (itm ^. itID) w
@@ -358,12 +361,19 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
mid = magtree ^? ldtValue . itLocation . ilInvID
itm = itmtree ^. ldtValue
getAttachedSFLink :: ItemStructuralFunction
-> LabelDoubleTree ComposeLinkType Item -> Maybe (NewInt ItmInt)
getAttachedSFLink ::
ItemStructuralFunction ->
LabelDoubleTree ComposeLinkType Item ->
Maybe (NewInt ItmInt)
getAttachedSFLink sf = (^? ldtRight . folding (lookup (SFLink sf)) . ldtValue . itID)
itemDetectorEffect :: Item -> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt) -> Creature -> World -> World
itemDetectorEffect ::
Item ->
Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) ->
Creature ->
World ->
World
itemDetectorEffect itm mitid armitid cr w = fromMaybe w $ do
DETECTOR dt <- itm ^? itType
return $ aRadarPulse (itm ^. itID) mitid armitid (f dt) cr w
@@ -372,7 +382,6 @@ itemDetectorEffect itm mitid armitid cr w = fromMaybe w $ do
f CREATUREDETECTOR = ObCreature
f WALLDETECTOR = ObWall
walkNozzle :: Int -> Muzzle -> Item -> Creature -> World -> World
walkNozzle mzid mz itm cr w = fromMaybe w $ do
invid <- itm ^? itLocation . ilInvID
@@ -618,7 +627,7 @@ mcShootLaser _ mc = cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos
mcShootAuto :: Item -> Machine -> World -> World
mcShootAuto itm mc w
| Just (FixedRate rate lastused) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
, w ^. cWorld . lWorld . lClock - rate > lastused =
, w ^. cWorld . lWorld . lClock - rate > lastused =
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse
@@ -695,7 +704,6 @@ getGrenadeHitEffect t = case lookup GrenadeHitEffectLink (t ^. ldtRight) of
Just STICKYMOD -> GStick
_ -> GBounce 2
_ -> GBounce 2
createProjectile ::
ProjectileType ->
@@ -775,9 +783,13 @@ useRewindGun i =
, _scrollItemID = i
}
dropInventoryPath :: Int -> InventoryPathing -> LocationLDT ItemLink ComposedItem
-> Creature
-> World -> World
dropInventoryPath ::
Int ->
InventoryPathing ->
LocationLDT ItemLink ComposedItem ->
Creature ->
World ->
World
dropInventoryPath i ip loc cr w = case ip of
ABSOLUTE -> fromMaybe w $ do
guard $ i `IM.member` (cr ^. crInv)
@@ -791,24 +803,30 @@ dropInventoryPath i ip loc cr w = case ip of
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ dropItem cr (i + j) w
useInventoryPath :: PressType ->
Int -> InventoryPathing -> LocationLDT ItemLink ComposedItem
-> Creature
-> World -> World
useInventoryPath ::
PressType ->
Int ->
InventoryPathing ->
LocationLDT ItemLink ComposedItem ->
Creature ->
World ->
World
useInventoryPath pt i ip loc cr w = case ip of
ABSOLUTE -> fromMaybe w $ do
guard $ i `IM.member` (cr ^. crInv)
return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem i pt)
return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem i pt)
RELCURS -> fromMaybe w $ do
j <- cr ^? crManipulation . manObject . imSelectedItem
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ w
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
return $
w
& cWorld . lWorld . delayedEvents .:~ (1, UseInvItem (i + j) pt)
RELITEM -> fromMaybe w $ do
j <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ w
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
return $
w
& cWorld . lWorld . delayedEvents .:~ (1, UseInvItem (i + j) pt)
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
-- [w'] -> w & cwTime . maybeWorld .~ Just' w'