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