Start removing heldDelay records

This commit is contained in:
2025-06-05 10:33:41 +01:00
parent 324a64814e
commit f3c56a6b5f
13 changed files with 43 additions and 47 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -50,6 +50,7 @@ data Item = Item
, _itAmmoSlots :: IM.IntMap AmmoType
, _itParams :: ItemParams
, _itScroll :: ItemScroll
, _itTimeLastUsed :: Int
}
data ItemScroll
+1 -14
View File
@@ -14,24 +14,11 @@ data UseDelay -- should just be Delay
= NoDelay
| FixedRate
{ _rateMax :: Int
, _rateTimeLastUsed :: Int -- set to be _lClock when used, starts at 0
}
-- | VariableRate
-- { _rateMax :: Int
-- , _rateTime :: Int
-- , _rateMaxMax :: Int
-- , _rateMinMax :: Int
-- }
| WarmUpNoDelay
{ _warmTime :: Int
, _warmMax :: Int
{ _warmMax :: Int
, _warmSound :: SoundID
}
-- | ChargingRate
-- { _chargeTime :: Int
-- , _chargeMax :: Int
-- , _chargeSound :: Maybe SoundID
-- }
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''UseDelay
+1
View File
@@ -19,6 +19,7 @@ data ItemParams
| NozzleAngle {_nzAngle :: Float}
| VolleyUnfiredBarrels {_unfiredBarrels :: [Int]}
| AlteRifleSwitch {_alteRifleSwitch :: Int}
| WarmTime {_wTime :: Int}
data ShrinkGunStatus = FullSize | Shrunk
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1
View File
@@ -27,6 +27,7 @@ defaultHeldItem =
, _itParams = NoParams
, _itUseCondition = UseableWhenAimed
, _itScroll = NoItemScroll
, _itTimeLastUsed = 0
}
--defaultLeftItem :: Item
+1 -1
View File
@@ -15,6 +15,6 @@ defaultEquipUse =
defaultHeldUse :: ItemUse
defaultHeldUse =
UseHeld
{ _heldDelay = FixedRate{_rateMax = 8, _rateTimeLastUsed = 0}
{ _heldDelay = FixedRate{_rateMax = 8} --, _rateTimeLastUsed = 0}
, _heldFrame = 0
}
+19 -11
View File
@@ -111,23 +111,29 @@ hammerCheck f pt 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)
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
Just FixedRate{} -> w
Just (WarmUpNoDelay wt wm ws)
| wt < wm ->
--Just (WarmUpNoDelay wt wm ws)
Just (WarmUpNoDelay wm ws)
-- | wt < wm ->
| _wTime (_itParams $ _ldtValue item) < wm ->
w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~ 2
Just (WarmUpNoDelay _ wm _) ->
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~ 2
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 2
Just (WarmUpNoDelay wm _) ->
f item cr w
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime .~ (wm + 1)
Just NoDelay -> f item cr w
Nothing -> w
where
lastused = item ^. ldtValue . itTimeLastUsed
cid = _crID cr
setUseRate =
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTimeLastUsed
--cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTimeLastUsed
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
-- the following is unsafe, but if ilInvID isn't correctly set we probably
-- will have problems elsewhere also
@@ -1165,17 +1171,19 @@ mcShootLaser _ mc =
mcShootAuto :: Item -> Machine -> World -> World
mcShootAuto itm mc w
| Just (FixedRate rate lastused) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
| Just (FixedRate rate) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
, w ^. cWorld . lWorld . lClock - rate > lastused =
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse
. heldDelay
. rateTimeLastUsed
. itTimeLastUsed
-- . itUse
-- . heldDelay
-- . rateTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
& makeBullet defaultBullet itm pos dir
| otherwise = w
where
lastused = itm ^. itTimeLastUsed
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
dir = mc ^?! mcType . _McTurret . tuDir
+4 -2
View File
@@ -25,11 +25,13 @@ doInvEffect = \case
pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
ItemCancelExamineInventory -> \_ _ -> cancelExamineInventory
ItemCopierUpdate -> copierItemUpdate
ItemReduceWarmTime -> \itm _ -> pointerToItem itm . itUse . heldDelay . warmTime
--ItemReduceWarmTime -> \itm _ -> pointerToItem itm . itUse . heldDelay . warmTime
ItemReduceWarmTime -> \itm _ -> pointerToItem itm . itParams . wTime
%~ (max 0 . subtract 1)
-- use of pointerToItemID rather than pointerToItem because the item
-- location is changing
ItemSetWarmTime x -> \itm _ -> pointerToItemID (_itID itm) . itUse . heldDelay . warmTime
--ItemSetWarmTime x -> \itm _ -> pointerToItemID (_itID itm) . itUse . heldDelay . warmTime
ItemSetWarmTime x -> \itm _ -> pointerToItemID (_itID itm) . itParams . wTime
.~ x
copierItemUpdate :: Item -> Creature -> World -> World
+2 -1
View File
@@ -43,7 +43,8 @@ itemInternalValue itm
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
Nothing -> Nothing
Just m -> case m - (_warmTime . _heldDelay $ _itUse it) of
--Just m -> case m - (_warmTime . _heldDelay $ _itUse it) of
Just m -> case m - (_wTime $ _itParams it) of
x
| x <= 1 -> Just "*WARM"
| otherwise ->
+2 -1
View File
@@ -354,7 +354,8 @@ volleyGunShape i =
miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin
where
spin = (-10) + _warmTime (_heldDelay $ _itUse it)
--spin = (-10) + _warmTime (_heldDelay $ _itUse it)
spin = (-10) + _wTime (_itParams it)
miniGunXPict :: Int -> Int -> SPic
miniGunXPict i spin =
+5 -14
View File
@@ -8,14 +8,10 @@ module Dodge.Item.Held.Cane (
) where
import Dodge.SoundLogic.ExternallyGeneratedSounds
--import Dodge.Base
import Dodge.Data.Item
import Dodge.Default
import qualified Data.IntMap.Strict as IM
--import Dodge.Reloading.Action
--import Geometry.Data
import LensHelp
--import Control.Applicative
defaultBangCane :: Item
defaultBangCane =
@@ -41,9 +37,7 @@ volleyGun i =
-- & itUse . heldUseEffect .~ RandomiseMuzzleFrames i
rifle :: Item
rifle =
defaultBangCane
& itType .~ HELD RIFLE
rifle = defaultBangCane & itType .~ HELD RIFLE
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 25 0
alteRifle :: Item
@@ -52,12 +46,6 @@ alteRifle = rifle
& itAmmoSlots .~ IM.fromList (zip [0..1] $ repeat BulletAmmo)
& itParams .~ AlteRifleSwitch 0
--repeater :: Item
--repeater =
-- rifle
-- & itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
-- & itType . iyBase .~ HELD REPEATER
autoRifle :: Item
autoRifle =
rifle
@@ -73,7 +61,9 @@ burstRifle =
miniGunX :: Int -> Item
miniGunX i =
autoRifle
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
& itUse . heldDelay .~ WarmUpNoDelay{
--_warmTime = 0,
_warmMax = 100, _warmSound = crankSlowS}
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
-- & itUse . heldMuzzles
-- .~ replicate i
@@ -81,3 +71,4 @@ miniGunX i =
& itType .~ HELD (MINIGUNX i)
& itEffect . ieInv .~ ItemReduceWarmTime
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
& itParams .~ WarmTime 0
+1 -1
View File
@@ -24,7 +24,7 @@ flameSpitter :: Item
flameSpitter =
flameThrower
& itType .~ HELD FLAMESPITTER
& itUse . heldDelay .~ FixedRate{_rateMax = 3, _rateTimeLastUsed = 0}
& itUse . heldDelay .~ FixedRate{_rateMax = 3} --, _rateTimeLastUsed = 0}
-- & itUse . heldParams . weaponInvLock .~ 10
-- & itUse . heldParams . weaponRepeat .~ [1..9]
-- & itUse . heldMuzzles . ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
+4 -1
View File
@@ -53,8 +53,11 @@ autoPistol = pistol & itType .~ HELD AUTOPISTOL
machinePistol :: Item
machinePistol =
autoPistol
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 50, _warmSound = crankSlowS}
& itUse . heldDelay .~ WarmUpNoDelay{
--_warmTime = 0,
_warmMax = 50, _warmSound = crankSlowS}
& itType .~ HELD MACHINEPISTOL
& itParams .~ WarmTime 0
smg :: Item
smg =