Continue to refactor item datatypes, add a shape to rockets

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