This commit is contained in:
2022-06-07 21:34:34 +01:00
parent d2c3d14e46
commit e85bd36fe4
28 changed files with 222 additions and 232 deletions
+9 -9
View File
@@ -108,8 +108,8 @@ moduleCombinations =
,burstRifle
,fastBurstRifle
]
, [amod [DRUM,HARDWARE] "+DRUM MAG" (itConsumption . ammoBaseMax .~ 45)
,amod [MOTOR,HARDWARE] "+BELT FEED" (itConsumption . ammoBaseMax .~ 150)
, [amod [DRUM,HARDWARE] "+DRUM MAG" (itConsumption . laMax .~ 45)
,amod [MOTOR,HARDWARE] "+BELT FEED" (itConsumption . laMax .~ 150)
]
)
, ( ModAutoMag
@@ -138,13 +138,13 @@ moduleCombinations =
, ( ModBulletTrajectory
, bulletWeapons
, [amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . aoType . amBulVel .~ V2 10 0)
( (itConsumption . laType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . laType . amBulVel .~ V2 10 0)
)
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
(itConsumption . aoType . amBulTraj .~ FlechetteTrajectory)
(itConsumption . laType . amBulTraj .~ FlechetteTrajectory)
,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY"
(itConsumption . aoType . amBulTraj .~ BezierTrajectory)
(itConsumption . laType . amBulTraj .~ BezierTrajectory)
]
)
, ( ModDualBeam
@@ -165,12 +165,12 @@ moduleCombinations =
, ( ModLauncherHoming
, homingLaunchers
, [ amod [MICROCHIP,TRANSMITTER] "+TARGET HOMING"
(itConsumption . aoType . amPjCreation .~ fireTrackingShell)
(itConsumption . laType . amPjCreation .~ fireTrackingShell)
]
)
, ( ModBattery
, batteryGuns
, [amod [BATTERY] "+BATTERY" (itConsumption . ammoBaseMax +~ 1000)
, [amod [BATTERY] "+BATTERY" (itConsumption . laMax +~ 1000)
]
)
]
@@ -187,7 +187,7 @@ moduleCombinations =
where
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
a = argV (mouseWorldPos w -.- p)
f ameff = itConsumption . aoType . amBulEff .~ ameff
f ameff = itConsumption . laType . amBulEff .~ ameff
amod cts str func = (cts,ItemModule [str] 1 func)
homingLaunchers :: [Item]
+1 -1
View File
@@ -124,7 +124,7 @@ doStrategyActions cr = case cr ^? crActionPlan . crStrategy of
reloadOverride :: Creature -> Creature
reloadOverride cr
| cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded == Just 0
| cr ^? crInv . ix (_crInvSel cr) . itConsumption . laLoaded == Just 0
&& cr ^. crStance . posture == Aiming
= cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
| otherwise = cr
+6 -6
View File
@@ -234,15 +234,15 @@ doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
Just am@LoadableAmmo{} -> case _reloadType am of
PassiveReload stype |Just' (_reloadTime am) == _reloadState am
Just am@LoadableAmmo{} -> case _laReloadType am of
PassiveReload stype | Just' (_laReloadTime am) == _laReloadState am
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
PassiveReload _ -> w
ActiveClear | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
ActiveClear | _reloadState am == Nothing' -> w
ActiveClear | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
ActiveClear | _laReloadState am == Nothing' -> w
ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
ActivePartial{} | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
ActivePartial{} | _reloadState am == Nothing' -> w
ActivePartial{} | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
ActivePartial{} | _laReloadState am == Nothing' -> w
ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
Just ChargeableAmmo {} -> w
Just NoConsumption {} -> w
+3 -3
View File
@@ -24,7 +24,7 @@ onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c
onBoth f g h x = f (g x) (h x)
crIsReloading :: Creature -> Bool
crIsReloading cr = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just' of
crIsReloading cr = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just' of
Just t -> t > 0
_ -> False
@@ -54,7 +54,7 @@ crStratConMatches :: Strategy -> Creature -> Bool
crStratConMatches strat cr = eqConstr strat (_crStrategy $ _crActionPlan cr)
crAwayFromPost :: Creature -> Bool
crAwayFromPost cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
crAwayFromPost cr = case find sentinelGoal . _crGoal $ _crActionPlan cr of
Just (SentinelAt p _) -> dist p (_crPos cr) > 15
_ -> False
where
@@ -62,7 +62,7 @@ crAwayFromPost cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
sentinelGoal _ = False
crHasAmmo :: Creature -> Bool
crHasAmmo cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
crHasAmmo cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laLoaded
crCanShoot :: Creature -> Bool
crCanShoot p = crIsAiming p && crHasAmmo p
+1 -1
View File
@@ -76,5 +76,5 @@ mouseActionsCr pkeys cr
| rbPressed = cr & crStance . posture .~ Aiming
| otherwise = cr & crStance . posture .~ AtEase
where
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just'
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just'
rbPressed = SDL.ButtonRight `S.member` pkeys
+8 -13
View File
@@ -21,6 +21,7 @@ module Dodge.Data
, module Dodge.Item.Data
, module Dodge.Config.Data
, module Dodge.Equipment.Data
, module MaybeHelp
) where
import Dodge.ShortShow
import Dodge.Creature.State.Data
@@ -47,6 +48,7 @@ import Dodge.GameRoom
import Color
import Shape
import Data.Tile
import MaybeHelp
--import qualified Data.Vector as V
import qualified Linear.Quaternion as Q
@@ -469,12 +471,12 @@ _itUseAimStance :: Item -> AimStance
_itUseAimStance = _aimStance . _useAim . _itUse
data ItemConsumption
= LoadableAmmo
{ _aoType :: AmmoType
, _ammoBaseMax :: Int
, _ammoLoaded :: Int
, _reloadTime :: Int
, _reloadState :: Maybe' Int
, _reloadType :: ReloadType
{ _laType :: AmmoType
, _laMax :: Int
, _laLoaded :: Int
, _laReloadTime :: Int
, _laReloadState :: Maybe' Int
, _laReloadType :: ReloadType
}
| ChargeableAmmo
{ _wpMaxCharge :: Int
@@ -1053,12 +1055,6 @@ data WallStructure
{ _wlStCreature :: Int
, _wlStDamCreature :: Damage -> Wall -> Int -> World -> World
}
-- | Strict maybe
data Maybe' a = Just' {__Just' :: a} | Nothing'
deriving (Eq,Ord,Show)
strictify :: Maybe a -> Maybe' a
strictify Nothing = Nothing'
strictify (Just x) = Just' x
data ActionPlan
= Inanimate
@@ -1606,7 +1602,6 @@ makeLenses ''Universe
makeLenses ''LSParam
makeLenses ''ItemParams
makeLenses ''ItemTweaks
makeLenses ''Maybe'
makeLenses ''ItemPortage
makeLenses ''Magnet
makeLenses ''Gust
+6 -6
View File
@@ -15,12 +15,12 @@ import Control.Lens
defaultAmmo :: ItemConsumption
defaultAmmo = LoadableAmmo
{ _aoType = GenericAmmo
, _ammoBaseMax = 15
, _ammoLoaded = 0
, _reloadTime = 40
, _reloadState = Nothing'
, _reloadType = ActiveClear
{ _laType = GenericAmmo
, _laMax = 15
, _laLoaded = 0
, _laReloadTime = 40
, _laReloadState = Nothing'
, _laReloadType = ActiveClear
}
ruseRate :: Int
+5 -5
View File
@@ -49,7 +49,7 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
sp = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
cid = _crID cr
dir = _crDir cr
bultype = _aoType $ _itConsumption it
bultype = _laType $ _itConsumption it
muzvel = _muzVel $ _itParams it
muzlength = aimingMuzzlePos cr it
thetraj = case _amBulTraj bultype of
@@ -69,16 +69,16 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
-- this shouldn't really be used
loadedAmmo :: Item -> Int
loadedAmmo it
| _reloadState (_itConsumption it) == Nothing' = _ammoLoaded (_itConsumption it)
| _laReloadState (_itConsumption it) == Nothing' = _laLoaded (_itConsumption it)
| otherwise = 0
fractionLoadedAmmo :: Item -> Float
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it)
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it)
where
itMaxAmmo = _ammoBaseMax . _itConsumption
itmaxammo = _laMax . _itConsumption
fractionLoadedAmmo2 :: Item -> Float
fractionLoadedAmmo2 it = 1 -
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
where
itMaxAmmo = _ammoBaseMax . _itConsumption
itMaxAmmo = _laMax . _itConsumption
+9 -9
View File
@@ -74,9 +74,9 @@ teslaGun = defaultBatteryGun
{ _itName = "TESLA"
, _itType = TESLAGUN
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 200
, _ammoLoaded = 200
, _reloadTime = 80
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
}
, _itUse = ruseInstant shootTeslaArc NoHammer
[ ammoCheckI
@@ -271,9 +271,9 @@ lasGun = defaultAutoBatteryGun
{ _itName = "LASGUN"
, _itType = LASGUN
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 200
, _ammoLoaded = 200
, _reloadTime = 80
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
}
, _itUse = ruseInstant shootLaser NoHammer
[ ammoCheckI
@@ -338,9 +338,9 @@ tractorGun = lasGun
{ _itName = "TRACTORGUN"
, _itType = TRACTORGUN
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 10000
, _ammoLoaded = 10000
, _reloadTime = 40
{ _laMax = 10000
, _laLoaded = 10000
, _laReloadTime = 40
}
, _itUse = ruseInstant aTractorBeam NoHammer
[ ammoCheckI
+5 -5
View File
@@ -35,8 +35,8 @@ boostSelfL
-> World
-> World
boostSelfL x itm cr w = case boostPoint x cr w of
Left p -> crEff p (itConsumption . ammoLoaded .~ 0)
Right p -> crEff p (itConsumption . ammoLoaded -~ 1)
Left p -> crEff p (itConsumption . laLoaded .~ 0)
Right p -> crEff p (itConsumption . laLoaded -~ 1)
where
invid = fromJust $ _itInvPos itm
cid = _crID cr
@@ -114,9 +114,9 @@ boosterGun = defaultGun
, _itType = BOOSTER
, _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
{ _laMax = 100
, _laLoaded = 100
, _laReloadTime = 20
}
, _itUse = luseInstantNoH $ boostSelfL 10
, _itEffect = resetAttachmentID
+20 -20
View File
@@ -55,10 +55,10 @@ bangCane = defaultGun
, _randomOffset = 0
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 1
, _reloadTime = 15
, _reloadType = ActivePartial 1
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 15
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck
@@ -114,7 +114,7 @@ bangCaneX i = bangCane
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . ammoBaseMax .~ i
& itConsumption . laMax .~ i
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
@@ -123,10 +123,10 @@ bangCaneX i = bangCane
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
caneStickSoundChoice :: Item -> SoundID
caneStickSoundChoice it
| _ammoLoaded (_itConsumption it) < 2 = tap3S
| _laLoaded (_itConsumption it) < 2 = tap3S
| otherwise = shotgunS
caneClipX :: Int -> Item -> Shape
caneClipX i it = case it ^? itConsumption . ammoLoaded of
caneClipX i it = case it ^? itConsumption . laLoaded of
Just la | la > 0 -> foldMap
( (\y -> translateSH (V3 5 0 3) . upperPrismPoly 1 $ map (+.+ V2 0 y) $ square 1.5)
. (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5)))
@@ -148,7 +148,7 @@ rifle = bangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoBaseMax .~ 1
& itConsumption . laMax .~ 1
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
@@ -158,9 +158,9 @@ repeater = rifle
& itModules . at ModRifleMag ?~ DefaultModule
& itName .~ "REPEATER"
& itType .~ REPEATER
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
& itConsumption . ammoBaseMax .~ 15
& itConsumption . laReloadType .~ ActiveClear
& itConsumption . laReloadTime .~ 80
& itConsumption . laMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
@@ -189,7 +189,7 @@ burstRifle = repeater
, useTimeCheck
, sideEffectOnFrame 7 (torqueSideEffect 0.2)
, lockInvFor 7
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [3,6]) f it
, \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [3,6]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
@@ -207,7 +207,7 @@ fastBurstRifle = repeater
, useTimeCheck
, sideEffectOnFrame 9 (torqueSideEffect 0.4)
, lockInvFor 9
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8]) f it
, \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [2,4,6,8]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
@@ -226,7 +226,7 @@ completeBurstRifle = repeater
, useTimeCheck
, sideEffectOnFrame 15 (torqueSideEffect 0.8)
, lockInvFor 15
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [1..14]) f it
, \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [1..14]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
@@ -265,10 +265,10 @@ miniGunX i = defaultAutoGun
{ _itName = "MINIGUN-" ++ show i
, _itType = MINIGUNX i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 1500
, _ammoLoaded = 1500
, _reloadTime = 200
{ _laType = basicBullet
, _laMax = 1500
, _laLoaded = 1500
, _laReloadTime = 200
}
, _itUse = miniGunUse i
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200}
@@ -310,9 +310,9 @@ miniGunX i = defaultAutoGun
& itDimension . dimPortage . muzPos .~ 40
miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin (_ammoLoaded $ _itConsumption it)
miniGunXPictItem i it = miniGunXPict i spin (_laLoaded $ _itConsumption it)
where
spin = (-10) * _ammoLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
spin = (-10) * _laLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
miniGunXPict :: Int -> Int -> Int -> SPic
miniGunXPict i spin _ =
+2 -2
View File
@@ -6,7 +6,7 @@ import Data.Maybe
import Control.Lens
makeSingleClipAt :: Point3 -> Item -> Shape
makeSingleClipAt p it = case it ^? itConsumption . ammoLoaded of
makeSingleClipAt p it = case it ^? itConsumption . laLoaded of
Just 0 -> mempty
_ -> translateSH p $ upperPrismPoly 1 $ square 1.5
@@ -14,4 +14,4 @@ makeTinClipAt :: Float -> Point3 -> Item -> Shape
makeTinClipAt r p it = translateSH p . overPosSH (rotate3z r) $ upperPrismPoly 1 $ rectNSEW 0 (-y) (-2) 2
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itConsumption . ammoLoaded
y' = fromMaybe 0 $ it ^? itConsumption . laLoaded
+6 -6
View File
@@ -73,17 +73,17 @@ bangRod = defaultGun
<> makeSingleClipAt (V3 5 0 3) it
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 1
, _reloadTime = 20
, _reloadType = ActiveClear
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 20
, _laReloadType = ActiveClear
}
}
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . aoType . amBulEff .~ expireAndDamage heavyBulDams
& itConsumption . laType . amBulEff .~ expireAndDamage heavyBulDams
baseRodShape :: Shape
baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2
baseAMRShape :: Shape
@@ -114,7 +114,7 @@ amr :: Item
amr = elephantGun
& itName .~ "ANTIMATERIELRIFLE"
& itType .~ AMR
& itConsumption . ammoBaseMax .~ 15
& itConsumption . laMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
+19 -19
View File
@@ -36,7 +36,7 @@ import LensHelp
bangStickSoundChoice :: Item -> SoundID
bangStickSoundChoice it
| _ammoLoaded (_itConsumption it) < 2 = tap3S
| _laLoaded (_itConsumption it) < 2 = tap3S
| otherwise = shotgunS
bangStick :: Int -> Item
@@ -46,10 +46,10 @@ bangStick i = defaultGun
_ -> "BANGSTICKx"++ show i
, _itType = BANGSTICK i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = i
, _reloadTime = 10
, _reloadType = ActivePartial 1
{ _laType = basicBullet
, _laMax = i
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 8 upHammer
[ ammoHammerCheck
@@ -104,7 +104,7 @@ baseSMGShape = colorSH green $ upperPrismPoly 3 $ rectXH 20 2
baseStickShape :: Shape
baseStickShape = colorSH green $ upperPrismPoly 3 $ rectXH 10 2
stickClip :: Item -> Shape
stickClip it = case it ^? itConsumption . ammoLoaded of
stickClip it = case it ^? itConsumption . laLoaded of
Just x | x > 0 -> foldMap f [0..x-1]
_ -> mempty
where
@@ -118,17 +118,17 @@ revolver = pistol
{ _itName = "REVOLVER"
, _itType = REVOLVER
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 6
, _ammoLoaded = 0
, _reloadTime = 10
, _reloadType = ActivePartial 1
{ _laType = basicBullet
, _laMax = 6
, _laLoaded = 0
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
}
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
revolverClip :: Item -> Shape
revolverClip it = case it ^? itConsumption . ammoLoaded of
revolverClip it = case it ^? itConsumption . laLoaded of
Just al | al > 0 -> translateSH (V3 5 0 1) $ foldMap f [1..al]
_ -> mempty
where
@@ -173,11 +173,11 @@ pistol = (bangStick 1)
{ _itName = "PISTOL"
, _itType = PISTOL
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 15
, _ammoLoaded = 0
, _reloadTime = 70
, _reloadType = ActiveClear
{ _laType = basicBullet
, _laMax = 15
, _laLoaded = 0
, _laReloadTime = 70
, _laReloadType = ActiveClear
}
, _itUse = ruseAmmoParamsRate 6 upHammer
(ammoHammerCheck : pistolAfterHamMods)
@@ -228,7 +228,7 @@ revolverX i = revolver
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, lockInvFor 10
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it
, \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it
, withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
@@ -237,4 +237,4 @@ revolverX i = revolver
, withTorqueAfter
, withRecoil
]
} & itConsumption . ammoBaseMax .~ i * 6
} & itConsumption . laMax .~ i * 6
+31 -31
View File
@@ -50,10 +50,10 @@ autoGun = defaultAutoGun
{ _itName = "AUTOGUN"
, _itType = AUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 30
, _ammoLoaded = 30
, _reloadTime = 80
{ _laType = basicBullet
, _laMax = 30
, _laLoaded = 30
, _laReloadTime = 80
}
, _itUse = ruseAmmoParamsRate 4 NoHammer
[ ammoCheckI
@@ -99,17 +99,17 @@ autoGunPic it = noPic $
)
<> translateSHf 0 (-1) (rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW (negate $ 3 + 0.25 * x) 0 3 (-5))
where
x = fromIntegral $ _ammoLoaded $ _itConsumption it
x = fromIntegral $ _laLoaded $ _itConsumption it
bangCone :: Item
bangCone = defaultGun
{ _itName = "BANGCONE"
, _itType = BANGCONE
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 5
, _reloadTime = 25
, _reloadType = ActiveClear
{ _laType = basicBullet
, _laMax = 5
, _laReloadTime = 25
, _laReloadType = ActiveClear
}
, _itUse = ruseAmmoParamsRate 20 upHammer
[ ammoCheckI
@@ -149,7 +149,7 @@ bangCone = defaultGun
coneRandItemUpdate :: State StdGen (Item -> Item)
coneRandItemUpdate = do
wth <- state $ randomR (1,5)
return (\it -> it & itConsumption . aoType . amBulWth .~ wth)
return (\it -> it & itConsumption . laType . amBulWth .~ wth)
coneRandItemParams :: State StdGen (ItemParams -> ItemParams)
coneRandItemParams = do
muzv <- state $ randomR (0.5,1)
@@ -174,8 +174,8 @@ blunderbuss = bangCone
<> upperPrismPoly 6 (rectNSEW 4 (-4) 30 20)
}
}
& itConsumption . ammoBaseMax .~ 25
& itConsumption . reloadTime .~ 30
& itConsumption . laMax .~ 25
& itConsumption . laReloadTime .~ 30
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimWeight .~ 6
bigBlunderbuss :: Item
@@ -183,8 +183,8 @@ bigBlunderbuss = blunderbuss
{_itName = "BIGBLUNDERBUSS"
,_itType = BIGBLUNDERBUSS
}
& itConsumption . ammoBaseMax .~ 50
& itConsumption . reloadTime .~ 36
& itConsumption . laMax .~ 50
& itConsumption . laReloadTime .~ 36
& itParams . recoil .~ 200
& itParams . torqueAfter .~ 0.3
& itParams . randomOffset .~ 16
@@ -193,8 +193,8 @@ biggerBlunderbuss = bigBlunderbuss
{_itName = "BIGGERBLUNDERBUSS"
,_itType = BIGGERBLUNDERBUSS
}
& itConsumption . ammoBaseMax .~ 75
& itConsumption . reloadTime .~ 43
& itConsumption . laMax .~ 75
& itConsumption . laReloadTime .~ 43
& itParams . recoil .~ 250
& itParams . torqueAfter .~ 0.5
& itParams . randomOffset .~ 20
@@ -203,8 +203,8 @@ biggestBlunderbuss = biggerBlunderbuss
{_itName = "BIGGESTBLUNDERBUSS"
,_itType = BIGGESTBLUNDERBUSS
}
& itConsumption . ammoBaseMax .~ 100
& itConsumption . reloadTime .~ 50
& itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 50
& itParams . recoil .~ 300
& itParams . torqueAfter .~ 0.7
& itParams . randomOffset .~ 24
@@ -217,10 +217,10 @@ hvAutoGun = defaultAutoGun
{ _itName = "AUTO-HV"
, _itType = HVAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 200
{ _laType = hvBullet
, _laMax = 100
, _laLoaded = 100
, _laReloadTime = 200
}
, _itUse = ruseAmmoParamsRate 25 NoHammer
[ ammoCheckI
@@ -247,10 +247,10 @@ ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
, _itType = LTAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 15
, _ammoLoaded = 0
, _reloadTime = 90
{ _laType = basicBullet
, _laMax = 15
, _laLoaded = 0
, _laReloadTime = 90
}
, _itUse = ruseAmmoParamsRate 2 NoHammer
[ ammoCheckI
@@ -275,11 +275,11 @@ longGun = defaultGun
{ _itName = "LONGGUN"
, _itType = LONGGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 100
, _reloadType = PassiveReload skwareFadeTwoSecS
{ _laType = hvBullet
, _laMax = 1
, _laLoaded = 1
, _laReloadTime = 100
, _laReloadType = PassiveReload skwareFadeTwoSecS
}
, _itUse = ruseAmmoParamsRate 100 upHammer
[ ammoCheckI
+5 -5
View File
@@ -23,10 +23,10 @@ lasDrones = defaultGun
{ _itName = "DRONES"
, _itType = DRONELAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
, _ammoBaseMax = 2
, _ammoLoaded = 2
, _reloadTime = 80
{ _laType = DroneAmmo { _amString = "LASDRONE" }
, _laMax = 2
, _laLoaded = 2
, _laReloadTime = 80
}
, _itUse = ruseRate 20 aDroneWithItemParams upHammer
[ ammoCheckI
@@ -64,7 +64,7 @@ aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _aoType am
, _prDraw = _amPjDraw $ _laType am
, _pjID = i
, _pjUpdate = const id
}
+3 -3
View File
@@ -206,8 +206,8 @@ targetLaserUpdate it cr w t
}
wpammo = _itConsumption it
reloadFrac
| _ammoLoaded wpammo == 0 = 1
| otherwise = case _reloadState wpammo of
Just' rs -> fromIntegral rs / fromIntegral (_reloadTime wpammo)
| _laLoaded wpammo == 0 = 1
| otherwise = case _laReloadState wpammo of
Just' rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
Nothing' -> 1
col = mixColors reloadFrac (1-reloadFrac) blue red
+3 -3
View File
@@ -23,9 +23,9 @@ basicItemDisplay it = Prelude.take (itSlotsTaken it) $
where
thename = _itName it
thenumber = case it ^? itConsumption of
Just am@LoadableAmmo{} -> case _reloadState am of
Nothing' -> show (_ammoLoaded am)
Just' x -> show x ++ "R" ++ show (_ammoLoaded am)
Just am@LoadableAmmo{} -> case _laReloadState am of
Nothing' -> show (_laLoaded am)
Just' x -> show x ++ "R" ++ show (_laLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> "x" ++ show (_itAmount x)
Just NoConsumption -> ""
+12 -12
View File
@@ -41,15 +41,15 @@ launcher = defaultGun
{ _itName = "ROCKO"
, _itType = LAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = ProjectileAmmo
{ _laType = ProjectileAmmo
{ _amPayload = makeExplosionAt
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = drawShell
, _amPjCreation = fireShell
}
, _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 80
, _laMax = 1
, _laLoaded = 1
, _laReloadTime = 80
}
, _itUse = ruseRate 20 usePjCreation upHammer
[ hammerCheckI
@@ -88,8 +88,8 @@ launcherX :: Int -> Item
launcherX i = launcher
& itName .~ ("ROCKO-" ++ show i)
& itType .~ LAUNCHERX i
& itConsumption . ammoBaseMax .~ i
& itConsumption . ammoLoaded .~ i
& itConsumption . laMax .~ i
& itConsumption . laLoaded .~ i
& itUse . rUse .~ usePjCreationX i
& itUse . useMods .~
[ hammerCheckI
@@ -100,14 +100,14 @@ launcherX i = launcher
]
usePjCreation :: Item -> Creature -> World -> World
usePjCreation it = _amPjCreation (_aoType (_itConsumption it)) it
usePjCreation it = _amPjCreation (_laType (_itConsumption it)) it
usePjCreationX :: Int -> Item -> Creature -> World -> World
usePjCreationX i it cr = foldr f
(_amPjCreation (_aoType (_itConsumption it)) it cr)
(_amPjCreation (_laType (_itConsumption it)) it cr)
[1..i-1]
where
f n = (. _amPjCreation (_aoType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
f n = (. _amPjCreation (_laType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
launcherPic :: Item -> SPic
launcherPic _ =
@@ -291,7 +291,7 @@ remoteLauncher = launcher
& itType .~ REMOTELAUNCHER
& itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . aoType . amPjDraw .~ drawRemoteShell
& itConsumption . laType . amPjDraw .~ drawRemoteShell
-- TODO consider allowing tweaking rocket speed
fireRemoteShell :: Item -> Creature -> World -> World
@@ -385,13 +385,13 @@ makeShell it cr theupdate w = w & props %~ IM.insert i Shell
, _pjZ = 20
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _aoType am
, _prDraw = _amPjDraw $ _laType am
, _pjID = i
, _pjUpdate = theupdate
, _pjAcc = rotateV dir (V2 3 0)
, _pjDir = dir
, _pjSpin = 0
, _pjPayload = _amPayload $ _aoType am
, _pjPayload = _amPayload $ _laType am
, _pjTimer = 50
}
where
-4
View File
@@ -26,10 +26,6 @@ clickDetector dt = defaultGun
{ _itName = show dt
, _itType = CLICKDETECTOR dt
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 200
}
, _itUse = ruseRate 20 (detectorEffect dt) upHammer
[ ammoUseCheck
]
+3 -3
View File
@@ -33,9 +33,9 @@ sonicGun = defaultAutoGun
{ _itName = "SONICGUN"
, _itType = SONICGUN
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 10
, _ammoLoaded = 10
, _reloadTime = 80
{ _laMax = 10
, _laLoaded = 10
, _laReloadTime = 80
}
, _itUse = ruseRate 8 aSonicWave (HasHammer HammerUp)
[ ammoHammerCheck
+3 -3
View File
@@ -18,9 +18,9 @@ spawnGun :: Creature -> Item
spawnGun cr = defaultGun
{ _itName = "SPAWNER"
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 80
{ _laMax = 1
, _laLoaded = 1
, _laReloadTime = 80
}
, _itUse = ruseRate 100
(\_ -> spawnCrNextTo cr)
+8 -8
View File
@@ -42,7 +42,7 @@ poisonSprayer = flameThrower
{ _itName = "POISONSPRAYER"
, _itType = POISONSPRAYER
}
& itConsumption . aoType .~ GasAmmo
& itConsumption . laType .~ GasAmmo
{ _amString = "POISONGAS"
, _amCreateGas = aGasCloud
}
@@ -70,8 +70,8 @@ flameSpitter :: Item
flameSpitter = flameThrower
& itName .~ "FLAMESPITTER"
& itType .~ FLAMESPITTER
& itConsumption . ammoBaseMax .~ 10
& itConsumption . reloadTime .~ 20
& itConsumption . laMax .~ 10
& itConsumption . laReloadTime .~ 20
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . useAim . aimStance .~ OneHand
& itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0}
@@ -125,10 +125,10 @@ flameThrower = defaultAutoGun
{ _itName = "FLAMETHROWER"
, _itType = FLAMETHROWER
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 250
, _ammoLoaded = 0
, _reloadTime = 100
, _aoType = GasAmmo
{ _laMax = 250
, _laLoaded = 0
, _laReloadTime = 100
, _laType = GasAmmo
{_amString = "FLAME"
,_amCreateGas = aFlame
}
@@ -199,7 +199,7 @@ overNozzle eff it cr w nz =
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
useGasParams :: Nozzle -> Item -> Creature -> World -> World
useGasParams nz it cr = _amCreateGas (_aoType (_itConsumption it)) (_nzPressure nz) pos dir cr
useGasParams nz it cr = _amCreateGas (_laType (_itConsumption it)) (_nzPressure nz) pos dir cr
where
dir = _crDir cr
pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr))
+18 -18
View File
@@ -127,7 +127,7 @@ withThickSmokeI eff item cr w = eff item cr
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff item cr w
| _ammoLoaded (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
| _laLoaded (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
-- | _reloadState (_itConsumption item) /= Nothing' = w
| otherwise = eff item cr $ w & creatures . ix (_crID cr) %~ crStopReloading
@@ -135,7 +135,7 @@ ammoCheckI eff item cr w
-- hammer is down?
ammoHammerCheck :: ChainEffect
ammoHammerCheck eff it cr w
| _ammoLoaded (_itConsumption it) <= 0 = fromMaybe w (startReloadingWeapon cr w)
| _laLoaded (_itConsumption it) <= 0 = fromMaybe w (startReloadingWeapon cr w)
& setHammerDown
| otherwise = case it ^? itUse . useHammer . hammerPosition of
Just HammerUp -> eff it cr $ setHammerDown w & creatures . ix (_crID cr) %~ crStopReloading
@@ -147,7 +147,7 @@ ammoHammerCheck eff it cr w
itUseAmmo :: Int -> Item -> Item
itUseAmmo x = itConsumption . ammoLoaded %~ (max 0 . subtract x)
itUseAmmo x = itConsumption . laLoaded %~ (max 0 . subtract x)
{- | Fires at an increasing rate.
Has different effect after first fire.
@@ -175,15 +175,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = _reloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _reloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 0
repeatFire = _laReloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _laReloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 0
{- | Apply effect after a warm up. -}
-- note this is quite unsafe, requires the item to have the correct delay type
withWarmUp
:: SoundID -- ^ warm up sound id
-> ChainEffect
withWarmUp soundID f item cr w
| _reloadState (_itConsumption item) /= Nothing' = w
| _laReloadState (_itConsumption item) /= Nothing' = w
| curWarmUp < maxWarmUp = w
& pointerToItem . itUse . useDelay . warmTime +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
@@ -285,14 +285,14 @@ withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff
(pushAmount, g) = randomR (-maxSide,maxSide) $ _randGen w
useAllAmmo :: ChainEffect
useAllAmmo eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded .~ 0)
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded .~ 0)
useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded
%~ (max 0 . subtract amAmount))
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded -~ amAmount)
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded -~ amAmount)
{- |
Applies a world effect after an item use cooldown check. -}
useTimeCheck :: ChainEffect
@@ -325,10 +325,10 @@ ammoUseCheck f item cr w
cid = _crID cr
itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _reloadState (_itConsumption item) == Nothing'
fireCondition = _laReloadState (_itConsumption item) == Nothing'
&& _rateTime (_useDelay (_itUse item)) == 0
&& _ammoLoaded (_itConsumption item) > 0
reloadCondition = _ammoLoaded (_itConsumption item) == 0
&& _laLoaded (_itConsumption item) > 0
reloadCondition = _laLoaded (_itConsumption item) == 0
{- | Applies a world effect after a hammer position check.
Arbitrary inventory position. -}
hammerCheckL
@@ -361,10 +361,10 @@ shootL f item cr w
cid = _crID cr
invid = fromJust $ _itInvPos item
pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _reloadState (_itConsumption item) == Nothing'
fireCondition = _laReloadState (_itConsumption item) == Nothing'
&& _rateTime (_useDelay (_itUse item)) == 0
&& _ammoLoaded (_itConsumption item) > 0
reloadCondition = _ammoLoaded (_itConsumption item) == 0
&& _laLoaded (_itConsumption item) > 0
reloadCondition = _laLoaded (_itConsumption item) == 0
withItem :: (Item -> ChainEffect) -> ChainEffect
withItem g f it = g it f it
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
@@ -530,7 +530,7 @@ spreadLoaded eff item cr w = foldr f w dirs
dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
f dir = eff item (cr & crDir +~ dir)
spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
numBulLoaded = _ammoLoaded $ _itConsumption item
numBulLoaded = _laLoaded $ _itConsumption item
sideEffectOnFrame :: Int
-> (Item -> Creature -> World -> World)
@@ -563,7 +563,7 @@ duplicateLoaded :: ChainEffect
duplicateLoaded eff it cr w = foldr f w [1..numBul]
where
f _ = eff it cr
numBul = _ammoLoaded $ _itConsumption it
numBul = _laLoaded $ _itConsumption it
duplicateLoadedBarrels :: ChainEffect
duplicateLoadedBarrels eff item cr w = foldr f w poss
@@ -574,7 +574,7 @@ duplicateLoadedBarrels eff item cr w = foldr f w poss
poss = map (rotateV (_crDir cr) . V2 0 . (*5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
f pos = eff item (cr & crPos %~ (+.+ pos))
numBar = _brlNum . _gunBarrels $ _itParams item
numBul = _ammoLoaded $ _itConsumption item
numBul = _laLoaded $ _itConsumption item
duplicateOffsetsFocus :: [Float] -> ChainEffect
duplicateOffsetsFocus xs eff item cr w = foldr f w poss
+1 -15
View File
@@ -68,10 +68,6 @@ shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itType = SHRINKER
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
}
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic
@@ -100,10 +96,6 @@ blinkGun = defaultGun
, _itType = BLINKER
, _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
}
, _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction)
& useHammer .~ upHammer
@@ -139,13 +131,7 @@ forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELDGUN"
, _itType = FORCEFIELDGUN
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 40
, _reloadState = Nothing'
, _aoType = ForceFieldAmmo forceField
}
, _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
+1 -1
View File
@@ -69,7 +69,7 @@ updateTurret rotSpeed mc w
thecreature = defaultCreature
& crID .~ cid
& crInv . at 0 ?~ (_tuWeapon (_mcType mc) & itDimension . dimPortage . handlePos -~ 10
& itConsumption . ammoLoaded .~ 1
& itConsumption . laLoaded .~ 1
)
& crPos .~ mcpos
& crOldPos .~ mcpos
+19 -17
View File
@@ -14,41 +14,43 @@ startReloadingWeapon :: Creature -> World -> Maybe World
startReloadingWeapon cr = (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr))
icTryStartReloading
-- TODO clean this up, rethink datatypes
icTryStartReloading :: Item -> Maybe Item
icTryStartReloading it = do
am <- it ^? itConsumption
amloaded <- am ^? ammoLoaded
ammax <- am ^? ammoBaseMax
rstate <- am ^? reloadState
amloaded <- am ^? laLoaded
ammax <- am ^? laMax
rstate <- am ^? laReloadState
if amloaded < ammax && rstate == Nothing'
then Just $ it
& itConsumption . reloadState .~ Just' (_reloadTime am)
& if _reloadType am == ActiveClear
then itConsumption . ammoLoaded .~ 0
& itConsumption . laReloadState .~ Just' (_laReloadTime am)
& if _laReloadType am == ActiveClear
then itConsumption . laLoaded .~ 0
else id
else Nothing
crStopReloading :: Creature -> Creature
crStopReloading cr = cr & crInv . ix (_crInvSel cr) . itConsumption . reloadState .~ Nothing'
crStopReloading cr = cr & crInv . ix (_crInvSel cr) . itConsumption . laReloadState .~ Nothing'
-- ugly TODO cleanup
stepReloading :: Creature -> Creature
stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _Just' of
stepReloading cr = case cr ^? crInv . ix isel . itConsumption . laReloadState . _Just' of
Just 0 -> cr & crInv . ix isel %~ doload
Just _ -> cr & crInv . ix isel . itConsumption . reloadState . _Just' %~ decreaseToZero
Just _ -> cr & crInv . ix isel . itConsumption . laReloadState . _Just' %~ decreaseToZero
Nothing -> cr
where
isel = _crInvSel cr
doload it = case _reloadType itcon of
doload it = case _laReloadType itcon of
ActivePartial x
| x + _ammoLoaded itcon < itMaxAmmo -> it & itConsumption . ammoLoaded %~ (+ x)
& itConsumption . reloadState .~ Just' (_reloadTime itcon)
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo
& itConsumption . reloadState .~ Nothing'
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo
& itConsumption . reloadState .~ Nothing'
| x + _laLoaded itcon < itMaxAmmo -> it & itConsumption . laLoaded %~ (+ x)
& itConsumption . laReloadState .~ Just' (_laReloadTime itcon)
| otherwise -> it & itConsumption . laLoaded .~ itMaxAmmo
& itConsumption . laReloadState .~ Nothing'
_ -> it & itConsumption . laLoaded .~ itMaxAmmo
& itConsumption . laReloadState .~ Nothing'
where
itcon = _itConsumption it
itMaxAmmo = _ammoBaseMax itcon
itMaxAmmo = _laMax itcon
--{- | Start reloading if clip is empty. -}
--crAutoReload :: Creature -> Creature
+15 -4
View File
@@ -3,13 +3,24 @@
module MaybeHelp where
import Control.Lens
-- | Strict maybe
data Maybe' a
= Just' {__Just' :: a }
| Nothing'
data Maybe' a = Just' {__Just' :: a} | Nothing'
deriving (Eq,Ord,Show)
fromJust' :: Maybe' a -> a
fromJust' mx = case mx of
Just' x -> x
Nothing' -> error "no fromJust'"
isJust' :: Maybe' a -> Bool
isJust' Just' {} = True
isJust' Nothing' = False
isNothing' :: Maybe' a -> Bool
isNothing' Just' {} = False
isNothing' Nothing' = True
strictify :: Maybe a -> Maybe' a
strictify Nothing = Nothing'
strictify (Just x) = Just' x
makeLenses ''Maybe'