This commit is contained in:
2025-07-03 22:36:57 +01:00
parent a207073846
commit 978823c87c
6 changed files with 14 additions and 139 deletions
+1 -3
View File
@@ -26,7 +26,6 @@ import Dodge.Data.Damage.Type
import Dodge.Data.World import Dodge.Data.World
import Dodge.DoubleTree import Dodge.DoubleTree
import Dodge.Euse import Dodge.Euse
import Dodge.HeldUse
import Dodge.Inventory.SelectionList import Dodge.Inventory.SelectionList
import Dodge.Item.BackgroundEffect import Dodge.Item.BackgroundEffect
import Dodge.Item.Grammar import Dodge.Item.Grammar
@@ -218,9 +217,8 @@ doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
tryUseParent :: LocationLDT ItemLink OItem -> World -> World tryUseParent :: LocationLDT ItemLink OItem -> World -> World
tryUseParent loc w = fromMaybe w $ do tryUseParent loc w = fromMaybe w $ do
t <- locUp loc t <- locUp loc
let t' = t ^. locLDT
cr <- w ^? cWorld . lWorld . creatures . ix 0 cr <- w ^? cWorld . lWorld . creatures . ix 0
return $ heldEffect InitialPress t' cr w return $ gadgetEffect InitialPress t cr w
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
trySynthBullet loc w = fromMaybe w $ do trySynthBullet loc w = fromMaybe w $ do
-2
View File
@@ -21,10 +21,8 @@ module Dodge.Data (
module Dodge.Data.MountedObject, module Dodge.Data.MountedObject,
module Dodge.Data.AimStance, module Dodge.Data.AimStance,
module Dodge.Data.TriggerType, module Dodge.Data.TriggerType,
module Dodge.Data.UseDelay,
) where ) where
import Dodge.Data.UseDelay
import Dodge.Data.TriggerType import Dodge.Data.TriggerType
import Dodge.Data.AimStance import Dodge.Data.AimStance
import Dodge.Data.Config import Dodge.Data.Config
-17
View File
@@ -1,17 +0,0 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.UseDelay where
import Control.Lens
data ItemUseDelay -- should just be Delay
= NoDelay
| FixedRate
{ _rateMax :: Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''ItemUseDelay
+3 -45
View File
@@ -4,12 +4,11 @@
module Dodge.HeldUse ( module Dodge.HeldUse (
gadgetEffect, gadgetEffect,
heldEffect, -- heldEffect,
mcUseHeld, mcUseHeld,
heldEffectMuzzles, heldEffectMuzzles,
) where ) where
import qualified Quaternion as Q
import Color import Color
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
@@ -39,6 +38,7 @@ import LensHelp
import ListHelp import ListHelp
import NewInt import NewInt
import Picture.Base import Picture.Base
import qualified Quaternion as Q
import RandomHelp import RandomHelp
import qualified SDL import qualified SDL
import Sound.Data import Sound.Data
@@ -60,7 +60,6 @@ gadgetEffect pt loc
heldEffect :: PressType -> LDTree ItemLink OItem -> Creature -> World -> World heldEffect :: PressType -> LDTree ItemLink OItem -> Creature -> World -> World
heldEffect = hammerCheck heldEffectMuzzles heldEffect = hammerCheck heldEffectMuzzles
--heldEffect = useTimeCheck . hammerCheck heldEffectMuzzles
hammerCheck :: hammerCheck ::
(LDTree ItemLink OItem -> Creature -> World -> World) -> (LDTree ItemLink OItem -> Creature -> World -> World) ->
@@ -107,6 +106,7 @@ hammerCheck f pt it cr w = case itemTriggerType $ it ^. ldtValue . _1 of
AutoTrigger t AutoTrigger t
| w ^. cWorld . lWorld . lClock - t > timelastused -> | w ^. cWorld . lWorld . lClock - t > timelastused ->
f it cr w f it cr w
NoTrigger -> f it cr w
_ -> w _ -> w
where where
cid = _crID cr cid = _crID cr
@@ -124,48 +124,6 @@ getVolleyBurst i g =
let (is, g') = runState (replicateM (i -1) (state $ randomR (0, 6))) g let (is, g') = runState (replicateM (i -1) (state $ randomR (0, 6))) g
in (scanl1 (+) is, g') in (scanl1 (+) is, g')
{- | Applies a world effect after an item use cooldown check.
input buffering?
-}
useTimeCheck ::
(LDTree ItemLink OItem -> Creature -> World -> World) ->
LDTree ItemLink OItem ->
Creature ->
World ->
World
useTimeCheck f item cr w = w
-- case useDelay $ item ^. ldtValue . _1 of
-- FixedRate rate
-- | w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr w
-- -- note that the time last used must be updated later in the chain!
-- FixedRate{} -> w
-- WarmUpNoDelay wm
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < wm ->
-- w & setwarming
-- & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . _1 . itType) (Just 2)
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
-- WarmUpNoDelay{} -> f item cr w & setwarming
-- WarmUpCoolDown ws _ _
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < ws ->
-- w & setwarming
-- & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . _1 . itType) (Just 2)
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
-- WarmUpCoolDown _ cs _
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < cs ->
-- f item cr w & setwarming
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
-- WarmUpCoolDown{} -> w & setwarming
-- NoDelay -> f item cr w
-- where
-- lastused = item ^. ldtValue . _1 . itTimeLastUsed
-- cid = _crID cr
-- setwarming =
-- cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . isWarming
-- %~ const True
-- -- the following is unsafe, but if ilInvID isn't correctly set we probably
-- -- will have problems elsewhere also
-- itRef = item ^?! ldtValue . _1 . itLocation . ilInvID
heldEffectMuzzles :: LDTree ItemLink OItem -> Creature -> World -> World heldEffectMuzzles :: LDTree ItemLink OItem -> Creature -> World -> World
heldEffectMuzzles t cr w = heldEffectMuzzles t cr w =
setusetime . doHeldUseEffect t cr setusetime . doHeldUseEffect t cr
-61
View File
@@ -1,61 +0,0 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.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
--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
-1
View File
@@ -1,7 +1,6 @@
{-# OPTIONS_GHC -Wno-unused-imports #-} {-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.TestString where module Dodge.TestString where
import Dodge.Item.UseDelay
import qualified SDL import qualified SDL
import Linear import Linear
import Dodge.ListDisplayParams import Dodge.ListDisplayParams