Continue to refactor item datatypes, add a shape to rockets
This commit is contained in:
@@ -30,6 +30,9 @@ takeUntil :: Foldable t => (a -> Bool) -> t a -> [a]
|
||||
takeUntil p = foldr (\x xs -> x : if p x then [] else xs) []
|
||||
|
||||
|
||||
decreaseToZero :: Int -> Int
|
||||
decreaseToZero x = max 0 (x - 1)
|
||||
|
||||
safeHead :: [a] -> Maybe a
|
||||
safeHead (x:_) = Just x
|
||||
safeHead _ = Nothing
|
||||
|
||||
@@ -163,8 +163,8 @@ startCr = defaultCreature
|
||||
{- | Items you start with. -}
|
||||
startInvList :: [Item]
|
||||
startInvList =
|
||||
[ rewindGun
|
||||
, pistol
|
||||
[ miniGun
|
||||
, hvAutoGun
|
||||
]
|
||||
startInventory :: IM.IntMap Item
|
||||
startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem
|
||||
@@ -172,6 +172,7 @@ stackedInventory :: IM.IntMap Item
|
||||
stackedInventory = IM.fromList (zip [0..25]
|
||||
(
|
||||
[spreadGun
|
||||
,rewindGun
|
||||
,tractorGun
|
||||
,longGun
|
||||
,autoGun
|
||||
|
||||
+25
-11
@@ -3,6 +3,7 @@ module Dodge.Creature.State
|
||||
, doDamage
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Creature.State.WalkCycle
|
||||
--import Dodge.Creature.Test
|
||||
--import Dodge.Base
|
||||
@@ -43,7 +44,7 @@ stateUpdate :: CRUpdate -> CRUpdate
|
||||
stateUpdate u cr w = case u (updateMovement cr) w of
|
||||
(f, maybeCr) ->
|
||||
( Endo $ invSideEff (fromMaybe cr maybeCr) . movementSideEff cr . deathEff . appEndo f
|
||||
, fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
||||
, fmap (stepReloading . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
||||
)
|
||||
where
|
||||
crOrCorpse cr'
|
||||
@@ -115,12 +116,33 @@ movementSideEff cr w
|
||||
(randDir,g) = randomR (-0.5,0.5) $ _randGen w
|
||||
(randAng,_) = randomR (0,2*pi) $ _randGen w
|
||||
|
||||
|
||||
heldItemUpdate :: Item -> Item
|
||||
heldItemUpdate = invItemUpdate
|
||||
. (itUse %~ useupdate)
|
||||
where
|
||||
useupdate = (useDelay . rateTime %~ decreaseToZero)
|
||||
|
||||
invItemUpdate :: Item -> Item
|
||||
invItemUpdate = itUse %~ useupdate
|
||||
where
|
||||
useupdate = (useHammer . hammerPosition %~ moveHammerUp)
|
||||
. (useDelay . warmTime %~ decreaseToZero)
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
moveHammerUp HammerReleased = HammerUp
|
||||
moveHammerUp HammerUp = HammerUp
|
||||
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
f i it w' = case it ^? itEffect . itInvEffect of
|
||||
Nothing -> w'
|
||||
Just g -> g (_itEffect it) cr i w'
|
||||
Nothing -> w' & doitemupdate
|
||||
Just g -> g (_itEffect it) cr i w' & doitemupdate
|
||||
where
|
||||
doitemupdate
|
||||
| i == _crInvSel cr = itpointer %~ heldItemUpdate
|
||||
| otherwise = itpointer %~ invItemUpdate
|
||||
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of
|
||||
@@ -163,17 +185,9 @@ isFrictionless cr = case cr ^? crStance . carriage of
|
||||
Just Floating -> True
|
||||
_ -> False
|
||||
|
||||
stepItemUseCooldown :: Creature -> Creature
|
||||
stepItemUseCooldown cr = cr & crInv . ix iSel %~
|
||||
(itUse . useDelay . rateTime %~ decreaseToZero) . (wpCurWarmUp %~ decreaseToZero)
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
stepReloading cr = over (crInv . ix iSel . wpAmmo . wpReloadState) decreaseToZero cr
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
|
||||
decreaseToZero :: Int -> Int
|
||||
decreaseToZero x = max 0 (x - 1)
|
||||
|
||||
|
||||
+19
-9
@@ -291,10 +291,20 @@ data ItemPos
|
||||
| OnFloor { _itFlID :: Int }
|
||||
data UseDelay -- should just be Delay
|
||||
= NoDelay
|
||||
| DelayRate
|
||||
| FixedRate
|
||||
{_rateMax :: Int
|
||||
,_rateTime :: Int
|
||||
}
|
||||
| VariableRate
|
||||
{_rateMax :: Int
|
||||
,_rateTime :: Int
|
||||
,_rateMaxMax :: Int
|
||||
,_rateMinMax :: Int
|
||||
}
|
||||
| WarmUpNoDelay
|
||||
{_warmTime :: Int
|
||||
,_warmMax :: Int
|
||||
}
|
||||
data ItemUse
|
||||
= RightUse
|
||||
{ _rUse :: Item -> Creature -> World -> World
|
||||
@@ -334,23 +344,19 @@ data Item
|
||||
= Weapon
|
||||
{ _itName :: String
|
||||
, _wpAmmo :: ItemAmmo
|
||||
, _wpMaxWarmUp :: Int
|
||||
, _wpCurWarmUp :: Int
|
||||
, _wpMaxCoolDown :: Int
|
||||
, _wpCurCoolDown :: Int
|
||||
, _itUse :: ItemUse
|
||||
, _wpSpread :: Float
|
||||
, _wpRange :: Float
|
||||
, _itFloorPict :: Item -> SPic
|
||||
, _itZoom :: ItZoom
|
||||
, _itEquipPict :: Creature -> Int -> SPic
|
||||
, _itScroll :: Float -> Creature -> Item -> Item
|
||||
, _itIdentity :: ItemIdentity
|
||||
, _itScroll :: Float -> Creature -> Item -> Item
|
||||
, _itIdentity :: ItemIdentity
|
||||
, _itAttachment :: ItAttachment
|
||||
, _itID :: Maybe Int
|
||||
, _itEffect :: ItEffect
|
||||
, _itEffect :: ItEffect
|
||||
, _itInvDisplay :: Item -> String
|
||||
, _itInvColor :: Color
|
||||
, _itInvColor :: Color
|
||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
||||
, _itWorldTrigger :: Maybe (Int -> World -> Bool)
|
||||
, _wpNumBarrels :: Int
|
||||
@@ -433,6 +439,10 @@ data ReloadType = ActiveReload | PassiveReload SoundID
|
||||
|
||||
-- I believe this is called every frame, not sure when though
|
||||
data ItEffect = NoItEffect
|
||||
| ItSimpleInvEffect
|
||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
-- the Int is the items inventory position
|
||||
}
|
||||
| ItInvEffect
|
||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
-- the Int is the items inventory position
|
||||
|
||||
@@ -5,7 +5,6 @@ Description : Instances of data structures
|
||||
This module contains prototypical data structures.
|
||||
-}
|
||||
module Dodge.Default where
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Default.Weapon
|
||||
import Dodge.Data
|
||||
import Dodge.SoundLogic
|
||||
@@ -158,7 +157,7 @@ defaultConsumable = Consumable
|
||||
, _itID = Nothing
|
||||
, _itInvColor = blue
|
||||
, _itInvDisplay = \it -> _itName it ++ " x" ++ show (_itAmount it)
|
||||
, _itEffect = wpRecock
|
||||
, _itEffect = NoItEffect
|
||||
, _itDimension = defaultItemDimension
|
||||
}
|
||||
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Dodge.Default.Weapon
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Item.Draw
|
||||
import Picture
|
||||
@@ -29,7 +28,7 @@ ruseRate :: Int
|
||||
-> ItemUse
|
||||
ruseRate i f ht usemods = RightUse
|
||||
{ _rUse = f
|
||||
, _useDelay = DelayRate
|
||||
, _useDelay = FixedRate
|
||||
{ _rateMax = i
|
||||
, _rateTime = 0
|
||||
}
|
||||
@@ -54,7 +53,7 @@ ruseInstant f ht usemods = RightUse
|
||||
defaultrUse :: ItemUse
|
||||
defaultrUse = RightUse
|
||||
{ _rUse = \_ _ -> id
|
||||
, _useDelay = DelayRate {_rateMax = 8, _rateTime = 0}
|
||||
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
||||
, _useMods = []
|
||||
, _useHammer = HasHammer HammerUp
|
||||
, _useAim = defaultAimParams
|
||||
@@ -62,7 +61,7 @@ defaultrUse = RightUse
|
||||
defaultlUse :: ItemUse
|
||||
defaultlUse = LeftUse
|
||||
{ _lUse = \_ _ -> id
|
||||
, _useDelay = DelayRate {_rateMax = 8, _rateTime = 0}
|
||||
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
||||
, _useHammer = NoHammer
|
||||
}
|
||||
|
||||
@@ -86,10 +85,6 @@ defaultGun = Weapon
|
||||
, _itCurseStatus = Uncursed
|
||||
, _itIdentity = Pistol
|
||||
, _wpAmmo = defaultAmmo
|
||||
, _wpMaxWarmUp = 0
|
||||
, _wpCurWarmUp = 0
|
||||
, _wpMaxCoolDown = 0
|
||||
, _wpCurCoolDown = 0
|
||||
, _itUse = defaultrUse
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
@@ -102,7 +97,7 @@ defaultGun = Weapon
|
||||
, _itScroll = \_ _ -> id
|
||||
, _itAttachment = NoItAttachment
|
||||
, _itID = Nothing
|
||||
, _itEffect = wpRecock
|
||||
, _itEffect = NoItEffect
|
||||
, _itInvDisplay = basicWeaponDisplay
|
||||
, _itInvColor = white
|
||||
, _itTargeting = Nothing
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module Dodge.Hammer where
|
||||
--import Dodge.Item.Data
|
||||
|
||||
@@ -18,7 +18,7 @@ useAmmoParamsRate :: Int
|
||||
-> ItemUse
|
||||
useAmmoParamsRate rate ht usemods = RightUse
|
||||
{ _rUse = useAmmoParams
|
||||
, _useDelay = DelayRate {_rateMax = rate,_rateTime = 0}
|
||||
, _useDelay = FixedRate {_rateMax = rate,_rateTime = 0}
|
||||
, _useMods = usemods
|
||||
, _useHammer = ht
|
||||
, _useAim = defaultAimParams
|
||||
|
||||
@@ -41,7 +41,7 @@ autoGun = defaultAutoGun
|
||||
, _wpLoadedAmmo = 30
|
||||
, _wpReloadTime = 80
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 5 NoHammer
|
||||
, _itUse = useAmmoParamsRate 4 NoHammer
|
||||
[ ammoCheckI
|
||||
, charFiringStratI
|
||||
[('S', hammerCheckI)
|
||||
@@ -137,7 +137,7 @@ hvAutoGun = defaultAutoGun
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 25 NoHammer
|
||||
[ ammoCheckI
|
||||
, rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
|
||||
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
|
||||
, withSoundStart bangEchoS
|
||||
, withThinSmokeI
|
||||
, withMuzFlareI
|
||||
@@ -146,6 +146,7 @@ hvAutoGun = defaultAutoGun
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = hvAutoGunPic
|
||||
}
|
||||
@@ -170,7 +171,7 @@ ltAutoGun = defaultAutoGun
|
||||
, _wpLoadedAmmo = 25
|
||||
, _wpReloadTime = 80
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 3 NoHammer
|
||||
, _itUse = useAmmoParamsRate 2 NoHammer
|
||||
[ ammoCheckI
|
||||
, useTimeCheck
|
||||
, withSoundStart tap1S
|
||||
@@ -206,10 +207,9 @@ miniGun = defaultAutoGun
|
||||
, _wpLoadedAmmo = 1500
|
||||
, _wpReloadTime = 200
|
||||
}
|
||||
, _wpMaxWarmUp = 100
|
||||
, _itUse = ruseInstant (useAmmoParamsVelMod vm4) NoHammer
|
||||
[ ammoCheckI
|
||||
, withWarmUpI crankSlowS
|
||||
, withWarmUp crankSlowS
|
||||
--, afterRecoil recoilAmount
|
||||
, withSoundForI mini1S 2
|
||||
--, withThinSmokeI
|
||||
@@ -230,15 +230,16 @@ miniGun = defaultAutoGun
|
||||
, withRandomOffsetI 10
|
||||
, withOldDir od2
|
||||
, trigDoAlso (useAmmoParamsVelMod vm3)
|
||||
, useAmmo 4
|
||||
--, torqueBeforeForcedI 0.001
|
||||
, withSidePushI 50
|
||||
, afterRecoil recoilAmount
|
||||
, withRandomOffsetI 9
|
||||
, withMuzFlareI
|
||||
, withOldDir od3
|
||||
, useAmmo 4
|
||||
, withMuzFlareI
|
||||
, withSmoke 1 black 20 200 5
|
||||
]
|
||||
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200}
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
@@ -262,7 +263,7 @@ miniGun = defaultAutoGun
|
||||
miniGunPictItem :: Item -> SPic
|
||||
miniGunPictItem it = miniGunPict spin (loadedAmmo it)
|
||||
where
|
||||
spin = (-10) * _wpLoadedAmmo (_wpAmmo it) + _wpCurWarmUp it
|
||||
spin = (-10) * _wpLoadedAmmo (_wpAmmo it) + _warmTime (_useDelay $ _itUse it)
|
||||
|
||||
miniGunPict :: Int -> Int -> SPic
|
||||
miniGunPict spin am =
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
Extra weapon effects, supplementing explicit use effects.
|
||||
-}
|
||||
module Dodge.Item.Weapon.ExtraEffect
|
||||
( wpRecock
|
||||
, itemLaserScopeEffect
|
||||
(-- wpRecock
|
||||
itemLaserScopeEffect
|
||||
, autoSonarEffect
|
||||
, autoRadarEffect
|
||||
, rbSetTarget
|
||||
@@ -28,17 +28,17 @@ import qualified Data.Set as S
|
||||
import qualified SDL
|
||||
{- |
|
||||
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
|
||||
wpRecock :: ItEffect
|
||||
wpRecock = ItInvEffect
|
||||
{_itInvEffect = f
|
||||
,_itEffectCounter = 0
|
||||
}
|
||||
where
|
||||
f _ cr invid = creatures . ix (_crID cr) . crInv . ix invid
|
||||
. itUse . useHammer . hammerPosition %~ moveHammerUp
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
moveHammerUp HammerReleased = HammerUp
|
||||
moveHammerUp HammerUp = HammerUp
|
||||
--wpRecock :: ItEffect
|
||||
--wpRecock = ItInvEffect
|
||||
-- {_itInvEffect = f
|
||||
-- ,_itEffectCounter = 0
|
||||
-- }
|
||||
-- where
|
||||
-- f _ cr invid = creatures . ix (_crID cr) . crInv . ix invid
|
||||
-- . itUse . useHammer . hammerPosition %~ moveHammerUp
|
||||
-- moveHammerUp HammerDown = HammerReleased
|
||||
-- moveHammerUp HammerReleased = HammerUp
|
||||
-- moveHammerUp HammerUp = HammerUp
|
||||
--{- |
|
||||
--Special recock for the bezier gun.
|
||||
--Not sure of its purpose at this time... -}
|
||||
|
||||
@@ -12,7 +12,6 @@ import Dodge.Zone
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Item.Draw
|
||||
import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Item.Attachment
|
||||
import Picture
|
||||
import Geometry
|
||||
@@ -44,7 +43,7 @@ grenade = Throwable
|
||||
, _itAttachment = ItFuse fuseTime
|
||||
, _itInvColor = white
|
||||
, _itInvDisplay = basicWeaponDisplay
|
||||
, _itEffect = wpRecock
|
||||
, _itEffect = NoItEffect
|
||||
, _itScroll = changeFuse
|
||||
}
|
||||
where
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Data
|
||||
import Padding
|
||||
|
||||
import Data.Maybe
|
||||
import Data.Sequence
|
||||
import Control.Lens
|
||||
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
|
||||
@@ -20,7 +21,29 @@ basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam
|
||||
x -> "R" ++ show x
|
||||
Just am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||
Nothing -> ""
|
||||
theparam = case it ^? itAttachment of
|
||||
Just ItCharMode {_itCharMode = (c :<| _)} -> [' ',c]
|
||||
Just ItMode {_itMode = i} -> show i
|
||||
_ -> []
|
||||
theparam = fromMaybe []
|
||||
. listToMaybe
|
||||
$ mapMaybe ($ it)
|
||||
[ maybeModeStatus
|
||||
, maybeWarmupStatus
|
||||
, maybeRateStatus
|
||||
]
|
||||
|
||||
maybeModeStatus :: Item -> Maybe String
|
||||
maybeModeStatus it = case it ^? itAttachment of
|
||||
Just ItCharMode {_itCharMode = (c :<| _)} -> Just [' ',c]
|
||||
Just ItMode {_itMode = i} -> Just $ show i
|
||||
_ -> Nothing
|
||||
|
||||
maybeRateStatus :: Item -> Maybe String
|
||||
maybeRateStatus it = case it ^? itUse . useDelay . rateMaxMax of
|
||||
Nothing -> Nothing
|
||||
_ -> Just $ ' ' : "T" ++ leftPad 3 ' ' (show (_rateMax . _useDelay $ _itUse it))
|
||||
|
||||
maybeWarmupStatus :: Item -> Maybe String
|
||||
maybeWarmupStatus it = case it ^? itUse . useDelay . warmMax of
|
||||
Nothing -> Nothing
|
||||
Just m -> case m - (_warmTime . _useDelay $ _itUse it) of
|
||||
x | x <= 1 -> Just " WARM"
|
||||
| otherwise -> let n = show x
|
||||
in Just $ ' ' : Prelude.take (4 - Prelude.length n) "WARM" ++ n
|
||||
|
||||
@@ -188,11 +188,16 @@ reduceSpinBy :: Float -> Prop -> World -> World
|
||||
reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x
|
||||
|
||||
shellPic :: Prop -> SPic
|
||||
shellPic pj = (,) mempty $ setDepth 20 . uncurryV translate pos $ rotate (argV accel) basePic
|
||||
shellPic pj = noPic $ translateSHz 18 . uncurryV translateSHf pos $ rotateSH (argV accel) basePic
|
||||
where
|
||||
basePic = color black $ polygon $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
|
||||
basePic = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
|
||||
accel = _pjAcc pj
|
||||
pos = _pjPos pj
|
||||
--shellPic pj = (,) mempty $ setDepth 20 . uncurryV translate pos $ rotate (argV accel) basePic
|
||||
-- where
|
||||
-- basePic = color blackSH $ polygon $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
|
||||
-- accel = _pjAcc pj
|
||||
-- pos = _pjPos pj
|
||||
|
||||
pjEffTimeRange
|
||||
:: (Int,Int)
|
||||
|
||||
@@ -7,7 +7,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, trigDoAlso
|
||||
, withTempLight
|
||||
, ammoUseCheck
|
||||
, rateIncABI
|
||||
, rateIncAB
|
||||
, torqueBefore
|
||||
, torqueBeforeAtLeast
|
||||
, torqueAfterI
|
||||
@@ -23,7 +23,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, afterRecoil
|
||||
, withSidePushAfterI
|
||||
, withSidePushI
|
||||
, withWarmUpI
|
||||
, withWarmUp
|
||||
, spreadNumI
|
||||
, numI
|
||||
, randWalkAngle -- ^ should be made into a modifier, perhaps
|
||||
@@ -98,17 +98,14 @@ ammoCheckI eff item cr w
|
||||
= fromMaybe w (startReloadingWeapon cr w)
|
||||
| _wpReloadState (_wpAmmo item) > 0 = w
|
||||
| otherwise = eff item cr w
|
||||
{- |
|
||||
Fires at an increasing rate.
|
||||
{- | Fires at an increasing rate.
|
||||
Has different effect after first fire.
|
||||
Applies ammo check and use cooldown check. -}
|
||||
rateIncABI
|
||||
:: Int -- ^ Start rate
|
||||
-> Int -- ^ End rate
|
||||
-> ChainEffect -- ^ Extra effect on first fire
|
||||
rateIncAB
|
||||
:: ChainEffect -- ^ Extra effect on first fire
|
||||
-> ChainEffect -- ^ Extra effect on continued fire
|
||||
-> ChainEffect
|
||||
rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
|
||||
rateIncAB exeffFirst exeffCont eff item cr w
|
||||
| repeatFire = w
|
||||
& pointItem %~ ( (itUse . useDelay . rateMax .~ max fastRate (currentRate - 1))
|
||||
. (wpAmmo . wpLoadedAmmo -~ 1)
|
||||
@@ -121,6 +118,8 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
|
||||
& exeffFirst eff item cr
|
||||
| otherwise = w
|
||||
where
|
||||
fastRate = _rateMinMax . _useDelay $ _itUse item
|
||||
startRate = _rateMaxMax . _useDelay $ _itUse item
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
pointItem = creatures . ix cid . crInv . ix itRef
|
||||
@@ -128,23 +127,24 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
|
||||
repeatFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 0
|
||||
{- | Apply effect after a warm up. -}
|
||||
withWarmUpI
|
||||
-- note this is quite unsafe, requires the item to have the correct delay type
|
||||
withWarmUp
|
||||
:: SoundID -- ^ warm up sound id
|
||||
-> ChainEffect
|
||||
withWarmUpI soundID f item cr w
|
||||
withWarmUp soundID f item cr w
|
||||
| _wpReloadState (_wpAmmo item) /= 0 = w
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . wpCurWarmUp +~ 2
|
||||
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
||||
| otherwise = w
|
||||
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
||||
& pointerToItem . itUse . useDelay . warmTime .~ maxWarmUp
|
||||
& f item cr
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
curWarmUp = _wpCurWarmUp item
|
||||
maxWarmUp = _wpMaxWarmUp item
|
||||
curWarmUp = _warmTime . _useDelay $ _itUse item
|
||||
maxWarmUp = _warmMax . _useDelay $ _itUse item
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position. -}
|
||||
withSoundStart
|
||||
|
||||
@@ -15,6 +15,10 @@ leftPad :: Int -> a -> [a] -> [a]
|
||||
{-# INLINE leftPad #-}
|
||||
leftPad i x xs = reverse $ take i $ reverse (take i xs) ++ repeat x
|
||||
|
||||
--fourCharInt :: Int -> String
|
||||
--fourCharInt x
|
||||
-- | x < 10000 = leftPad 4 ' ' $ show x
|
||||
|
||||
rightPad :: Int -> a -> [a] -> [a]
|
||||
{-# INLINE rightPad #-}
|
||||
rightPad i x xs = take i $ xs ++ repeat x
|
||||
|
||||
Reference in New Issue
Block a user