Fold some ammo data into its own type

This commit is contained in:
2021-11-27 13:40:56 +00:00
parent bfdac2fad5
commit 92a8dd59b8
21 changed files with 175 additions and 115 deletions
+5 -5
View File
@@ -152,20 +152,20 @@ startReloadingWeapon cr w =
it = _crInv cr IM.! _crInvSel cr
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
in case it of
Weapon {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA,_wpReloadState=rS,_wpReloadTime=rT}
| lA < maxA && rS == 0 -> Just $ set ( itRef . wpLoadedAmmo) maxA
Weapon {_wpAmmo = LoadableAmmo {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA },_wpReloadState=rS,_wpReloadTime=rT}
| lA < maxA && rS == 0 -> Just $ set ( itRef . wpAmmo . wpLoadedAmmo) maxA
$ set ( itRef . wpReloadState) rT w
_ -> Nothing
{- | Start reloading if clip is empty. -}
crAutoReload :: Creature -> Creature
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo of
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo of
Just 0 | _posture (_crStance cr) /= Aiming
-> cr & crInv . ix (_crInvSel cr) . wpReloadState %~ (`fromMaybe` reloadT)
& crInv . ix (_crInvSel cr) . wpLoadedAmmo %~ (`fromMaybe` maxA)
& crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo %~ (`fromMaybe` maxA)
_ -> cr
where
reloadT = cr ^? crInv . ix (_crInvSel cr) . wpReloadTime
maxA = cr ^? crInv . ix (_crInvSel cr) . wpMaxAmmo
maxA = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpMaxAmmo
{- | Teleport a creature to the mouse position -}
blinkAction
:: Creature
+1 -1
View File
@@ -122,7 +122,7 @@ reloadOverrideR
:: Creature
-> Reader World Creature
reloadOverrideR cr
| cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo == Just 0
| cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo == Just 0
&& cr ^. crStance . posture == Aiming
= return $ cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
| otherwise = return cr
+1 -1
View File
@@ -114,7 +114,7 @@ crAwayFromPostR cr = return $ case find sentinelGoal $ _crGoal $ _crActionPlan c
sentinelGoal _ = False
crHasAmmo :: (World,Creature) -> Bool
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo
crCanShoot :: (World,Creature) -> Bool
crCanShoot p = crIsAiming p && crHasAmmo p
+6 -6
View File
@@ -294,15 +294,15 @@ data ItemUse
| LeftUse { _lUse :: Creature -> Int -> World -> World }
| NoUse
data ItemAmmo
= LoadbleAmmo
= LoadableAmmo
{ _aoType :: AmmoType
}
data Item
= Weapon
{ _itName :: String
, _wpMaxAmmo :: Int
, _wpLoadedAmmo :: Int
, _wpAmmo :: AmmoType
}
data Item
= Weapon
{ _itName :: String
, _wpAmmo :: ItemAmmo
, _wpReloadTime :: Int
, _wpReloadState :: Int
, _wpReloadType :: ReloadType
+8 -3
View File
@@ -10,14 +10,19 @@ import Shape
import Geometry.Vector3D
import Geometry
defaultAmmo :: ItemAmmo
defaultAmmo = LoadableAmmo
{ _aoType = GenericAmmo
, _wpMaxAmmo = 15
, _wpLoadedAmmo = 15
}
defaultGun :: Item
defaultGun = Weapon
{ _itName = "default"
, _itCurseStatus = Uncursed
, _itIdentity = Pistol
, _wpMaxAmmo = 15
, _wpLoadedAmmo = 15
, _wpAmmo = GenericAmmo
, _wpAmmo = defaultAmmo
, _wpReloadTime = 40
, _wpReloadState = 0
, _wpReloadType = ActiveReload
+5 -5
View File
@@ -120,16 +120,16 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
invKeyDown = ScancodeCapsLock `S.member` _keys w
moveYourAmmoSel :: Int -> World -> World
moveYourAmmoSel i w = case yourItem w ^? wpAmmo . amPjParams of
moveYourAmmoSel i w = case yourItem w ^? wpAmmo . aoType. amPjParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. wpAmmo . amParamSel %~ (`mod` length l) . subtract i
. wpAmmo . aoType. amParamSel %~ (`mod` length l) . subtract i
_ -> w
moveYourAmmoParam :: Int -> World -> World
moveYourAmmoParam i w = case yourItem w ^? wpAmmo . amPjParams . ix paramid . pjMaxParam of
moveYourAmmoParam i w = case yourItem w ^? wpAmmo . aoType. amPjParams . ix paramid . pjMaxParam of
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. wpAmmo . amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
. wpAmmo . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
_ -> w
where
paramid = _amParamSel $ _wpAmmo $ yourItem w
paramid = _amParamSel $ _aoType $ _wpAmmo $ yourItem w
+5 -5
View File
@@ -12,13 +12,13 @@ import Geometry
import Control.Lens
useAmmoParams :: ItemUse
useAmmoParams = RightUse $ \it -> let b = _wpAmmo it
useAmmoParams = RightUse $ \it -> let b = _aoType $ _wpAmmo it
in withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
b = _wpAmmo it
b = _aoType $ _wpAmmo it
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
withVelWthHiteff
@@ -53,11 +53,11 @@ withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : )
loadedAmmo :: Item -> Int
loadedAmmo it
| _wpReloadState it == 0 = _wpLoadedAmmo it
| _wpReloadState it == 0 = _wpLoadedAmmo (_wpAmmo it)
| otherwise = 0
fractionLoadedAmmo :: Item -> Float
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo it)
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_wpAmmo it))
fractionLoadedAmmo2 :: Item -> Float
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo it))**2
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_wpAmmo it)))**2
+12 -6
View File
@@ -37,8 +37,10 @@ teslaGun :: Item
teslaGun = defaultGun
{ _itName = "TESLA"
, _itIdentity = TeslaGun
, _wpMaxAmmo = 200
, _wpLoadedAmmo = 200
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 200
, _wpLoadedAmmo = 200
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 0
@@ -71,8 +73,10 @@ lasGun :: Item
lasGun = defaultAutoGun
{ _itName = "LASGUN ////"
, _itIdentity = LasGun
, _wpMaxAmmo = 200
, _wpLoadedAmmo = 200
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 200
, _wpLoadedAmmo = 200
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 0
@@ -111,8 +115,10 @@ tractorGun :: Item
tractorGun = defaultAutoGun
{ _itName = "TRACTORGUN"
, _itIdentity = TractorGun
, _wpMaxAmmo = 10000
, _wpLoadedAmmo = 10000
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 10000
, _wpLoadedAmmo = 10000
}
, _wpReloadTime = 40
, _wpReloadState = 0
, _itUseRate = 0
+3 -1
View File
@@ -40,7 +40,9 @@ bezierGun = defaultGun
, _itEffect = rbSetTarget
, _itZoom = defaultItZoom
, _itAimingRange = 0
, _wpMaxAmmo = 50
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 50
}
, _itUseRate = 6
, _itAimStance = TwoHandTwist
}
+6 -4
View File
@@ -37,8 +37,8 @@ boostSelfL
-> World
-> World
boostSelfL x cr invid w = case boostPoint x cr w of
Left p -> crEff p (wpLoadedAmmo .~ 0)
Right p -> crEff p (wpLoadedAmmo -~ 1)
Left p -> crEff p (wpAmmo . wpLoadedAmmo .~ 0)
Right p -> crEff p (wpAmmo . wpLoadedAmmo -~ 1)
where
cid = _crID cr
cpos = _crPos cr
@@ -113,8 +113,10 @@ boosterGun :: Item
boosterGun = defaultGun
{ _itName = "BOOSTER"
, _itIdentity = Blinker
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 20
, _wpReloadState = 0
, _itUseRate = 0
+41 -25
View File
@@ -35,8 +35,11 @@ autoGun :: Item
autoGun = defaultAutoGun
{ _itName = "AUTOGUN"
, _itIdentity = AutoGun
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
, _wpAmmo = LoadableAmmo
{_aoType = basicBullet
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 5
@@ -70,7 +73,6 @@ autoGun = defaultAutoGun
, _itAttachment = ItCharMode $ Seq.fromList "MS"
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
, _wpAmmo = basicBullet
}
autoGunPic :: Item -> SPic
autoGunPic it = noPic $
@@ -86,8 +88,11 @@ pistol :: Item
pistol = defaultGun
{ _itName = "PISTOL"
, _itIdentity = Pistol
, _wpMaxAmmo = 15
, _wpLoadedAmmo = 15
, _wpAmmo = LoadableAmmo
{ _aoType = basicBullet
, _wpMaxAmmo = 15
, _wpLoadedAmmo = 15
}
, _wpReloadTime = 40
, _wpReloadState = 0
, _itUseRate = 8
@@ -114,7 +119,6 @@ pistol = defaultGun
, _itInvColor = white
, _itTargeting = Nothing
, _itWorldTrigger = Nothing
, _wpAmmo = basicBullet
}
pistolPic :: Item -> SPic
pistolPic it = noPic $ colorSH green (prismPoly
@@ -134,8 +138,11 @@ hvAutoGun :: Item
hvAutoGun = defaultAutoGun
{ _itName = "AUTO-HV"
, _itIdentity = HvAutoGun
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = LoadableAmmo
{ _aoType = hvBullet
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 200
, _wpReloadState = 0
, _itUseRate = 25
@@ -152,7 +159,6 @@ hvAutoGun = defaultAutoGun
, _itFloorPict = hvAutoGunPic
, _itAimingSpeed = 0.2
, _itAimingRange = 1
, _wpAmmo = hvBullet
}
hvAutoGunPic :: Item -> SPic
hvAutoGunPic it =
@@ -169,8 +175,11 @@ ltAutoGun :: Item
ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
, _itIdentity = LtAutoGun
, _wpMaxAmmo = 25
, _wpLoadedAmmo = 25
, _wpAmmo = LoadableAmmo
{ _aoType = ltBullet
, _wpMaxAmmo = 25
, _wpLoadedAmmo = 25
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 3
@@ -193,7 +202,6 @@ ltAutoGun = defaultAutoGun
, _itAimingRange = 0
, _itZoom = defaultItZoom
, _itAimStance = OneHand
, _wpAmmo = ltBullet
}
& itDimension . muzzleLength .~ 10
ltAutoGunPic :: Item -> SPic
@@ -210,8 +218,11 @@ miniGun :: Item
miniGun = defaultAutoGun
{ _itName = "MINI-G"
, _itIdentity = MiniGun
, _wpMaxAmmo = 1500
, _wpLoadedAmmo = 1500
, _wpAmmo = LoadableAmmo
{ _aoType = basicBullet
, _wpMaxAmmo = 1500
, _wpLoadedAmmo = 1500
}
, _wpReloadTime = 200
, _wpReloadState = 0
, _wpMaxWarmUp = 100
@@ -256,7 +267,6 @@ miniGun = defaultAutoGun
, _itAimingSpeed = 0.4
, _itAimingRange = 1
, _itEquipPict = pictureWeaponAim miniGunPictItem
, _wpAmmo = basicBullet
} & itDimension . muzzleLength .~ 15
where
recoilAmount = 5
@@ -273,7 +283,7 @@ miniGun = defaultAutoGun
miniGunPictItem :: Item -> SPic
miniGunPictItem it = miniGunPict spin (loadedAmmo it)
where
spin = (-10) * _wpLoadedAmmo it + _wpCurWarmUp it
spin = (-10) * _wpLoadedAmmo (_wpAmmo it) + _wpCurWarmUp it
miniGunPict :: Int -> Int -> SPic
miniGunPict spin am =
@@ -301,8 +311,11 @@ spreadGun :: Item
spreadGun = defaultGun
{ _itName = "SPREAD"
, _itIdentity = SpreadGun
, _wpMaxAmmo = 5
, _wpLoadedAmmo = 5
, _wpAmmo = LoadableAmmo
{ _aoType = basicBullet
, _wpMaxAmmo = 5
, _wpLoadedAmmo = 5
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 20
@@ -324,7 +337,6 @@ spreadGun = defaultGun
, _itFloorPict = spreadGunPic
, _itAimingSpeed = 1
, _itAimingRange = 0
, _wpAmmo = basicBullet
, _wpNumBarrels = 50
}
spreadGunPic :: Item -> SPic
@@ -339,8 +351,11 @@ multGun :: Item
multGun = defaultGun
{ _itName = "MULTGUN"
, _itIdentity = MultGun
, _wpMaxAmmo = 2
, _wpLoadedAmmo = 2
, _wpAmmo = LoadableAmmo
{ _aoType = basicBullet
, _wpMaxAmmo = 2
, _wpLoadedAmmo = 2
}
, _wpReloadTime = 40
, _wpReloadState = 0
, _itUseRate = 20
@@ -364,7 +379,6 @@ multGun = defaultGun
, _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomFac = 1.5}
, _itAimStance = TwoHandTwist
, _wpAmmo = basicBullet
, _wpNumBarrels = 5
}
multGunSPic :: Item -> SPic
@@ -386,8 +400,11 @@ longGun :: Item
longGun = defaultGun
{ _itName = "LONGGUN"
, _itIdentity = LongGun
, _wpMaxAmmo = 1
, _wpLoadedAmmo = 1
, _wpAmmo = LoadableAmmo
{ _aoType = hvBullet
, _wpMaxAmmo = 1
, _wpLoadedAmmo = 1
}
, _wpReloadTime = 100
, _wpReloadState = 0
, _wpReloadType = PassiveReload skwareFadeTwoSecS
@@ -413,7 +430,6 @@ longGun = defaultGun
, _itScroll = zoomLongGun
, _itAttachment = ItScope (V2 0 0) 0 1 False
, _itEffect = itemLaserScopeEffect
, _wpAmmo = hvBullet
, _itAimStance = TwoHandTwist
}
longGunSPic :: Item -> SPic
+6 -5
View File
@@ -22,8 +22,11 @@ lasDrones :: Item
lasDrones = defaultGun
{ _itName = "DRONES"
, _itIdentity = Generic
, _wpMaxAmmo = 2
, _wpLoadedAmmo = 2
, _wpAmmo = LoadableAmmo
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
, _wpMaxAmmo = 2
, _wpLoadedAmmo = 2
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 20
@@ -42,8 +45,6 @@ lasDrones = defaultGun
, _itAimingRange = 0.5
, _itHammer = NoHammer
, _itEffect = NoItEffect
, _wpAmmo = DroneAmmo
{ _amString = "LASDRONE" }
, _itAimStance = TwoHandTwist
}
@@ -71,7 +72,7 @@ aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw am
, _prDraw = _amPjDraw $ _aoType am
, _pjID = i
, _pjUpdate = const id
}
+1 -1
View File
@@ -82,7 +82,7 @@ itemLaserScopeEffect
-- _ -> ep -.- 2 *.* unitVectorAtAngle d
it = (cr ^. crInv) IM.! invid
reloadFrac
| _wpLoadedAmmo it == 0 = 1
| _wpLoadedAmmo (_wpAmmo it) == 0 = 1
| otherwise = fromIntegral (_wpReloadState it) / fromIntegral (_wpReloadTime it)
--col = mixColors reloadFrac (1-reloadFrac) red green
{- | Automatically send out radar pulses that detect walls. -}
+1 -1
View File
@@ -17,6 +17,6 @@ basicWeaponDisplay it = case it ^? itAttachment of
_ -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded)
where
aIfLoaded = case it ^? wpReloadState of
Just 0 -> show $ _wpLoadedAmmo it
Just 0 -> show $ _wpLoadedAmmo (_wpAmmo it)
Just x -> "R" ++ show x
_ -> ""
+23 -13
View File
@@ -37,8 +37,16 @@ launcher :: Item
launcher = defaultGun
{ _itName = "ROCKO"
, _itIdentity = Launcher
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
, _wpAmmo = LoadableAmmo
{ _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt
, _amString = ""
, _amPjParams = basicAmPjMoves
, _amPjDraw = shellPic
}
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 20
@@ -57,12 +65,6 @@ launcher = defaultGun
, _itAimingRange = 0.5
, _itHammer = NoHammer
, _itEffect = NoItEffect
, _wpAmmo = defaultShellAmmo
{ _amPayload = makeExplosionAt
, _amString = ""
, _amPjParams = basicAmPjMoves
, _amPjDraw = shellPic
}
, _itAimStance = TwoHandTwist
}
@@ -147,16 +149,16 @@ aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
i = IM.newKey $ _props w
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
dir = _crDir cr
ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams am)
ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams $ _aoType am)
theShell = defaultShell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _pjAcc = rotateV dir (V2 3 0)
, _prDraw = _amPjDraw am
, _prDraw = _amPjDraw $ _aoType am
, _pjID = i
, _pjUpdate = \pj -> ammoMvs pj . decTimMvVel pj . moveShell pj
, _pjPayload = _amPayload am
, _pjPayload = _amPayload $ _aoType am
, _pjTimer = 50
}
@@ -238,8 +240,16 @@ remoteLauncher :: Item
remoteLauncher = defaultGun
{ _itName = "ROCKO-REM"
, _itIdentity = RemoteLauncher
, _wpMaxAmmo = 1
, _wpLoadedAmmo = 1
, _wpAmmo = LoadableAmmo
{ _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt
, _amString = ""
, _amPjParams = basicAmPjMoves
, _amPjDraw = shellPic
}
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 10
+8 -4
View File
@@ -20,8 +20,10 @@ radar :: Item
radar = defaultGun
{ _itName = "RADAR"
, _itIdentity = Generic
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 200
, _wpReloadState = 0
, _itUseRate = 120
@@ -45,8 +47,10 @@ sonar :: Item
sonar = defaultGun
{ _itName = "SONAR"
, _itIdentity = Generic
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 200
, _wpReloadState = 0
, _itUseRate = 120
+4 -2
View File
@@ -16,8 +16,10 @@ Creates a creature next to the creature using the item. -}
spawnGun :: Creature -> Item
spawnGun cr = defaultGun
{ _itName = "SPAWNER"
, _wpMaxAmmo = 1
, _wpLoadedAmmo = 1
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 1
, _wpLoadedAmmo = 1
}
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 100
+8 -4
View File
@@ -34,8 +34,10 @@ poisonSprayer :: Item
poisonSprayer = defaultAutoGun
{ _itName = "POISON"
, _itIdentity = PoisonSprayer
, _wpMaxAmmo = 500
, _wpLoadedAmmo = 500
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 500
, _wpLoadedAmmo = 500
}
, _wpReloadTime = 100
, _wpReloadState = 0
, _itUseRate = 0
@@ -60,8 +62,10 @@ flamer :: Item
flamer = defaultAutoGun
{ _itName = "FLAMER"
, _itIdentity = Flamethrower
, _wpMaxAmmo = 250
, _wpLoadedAmmo = 250
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 250
, _wpLoadedAmmo = 250
}
, _wpReloadTime = 100
, _wpReloadState = 0
, _itUseRate = 0
+10 -10
View File
@@ -94,7 +94,7 @@ withThickSmokeI eff item cr w = eff item cr
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff item cr w
| _wpLoadedAmmo item <= 0
| _wpLoadedAmmo (_wpAmmo item) <= 0
= fromMaybe w (startReloadingWeapon cr w)
| _wpReloadState item > 0 = w
| otherwise = eff item cr w
@@ -111,12 +111,12 @@ rateIncABI
rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
| repeatFire = w
& pointItem %~ ( (itUseRate .~ max fastRate (currentRate - 1))
. (wpLoadedAmmo -~ 1)
. (wpAmmo . wpLoadedAmmo -~ 1)
. (itUseTime .~ currentRate) )
& exeffCont eff item cr
| firstFire = w
& pointItem %~ ( (itUseRate .~ startRate - 1)
. (wpLoadedAmmo -~ 1)
. (wpAmmo . wpLoadedAmmo -~ 1)
. (itUseTime .~ startRate) )
& exeffFirst eff item cr
| otherwise = w
@@ -217,7 +217,7 @@ useAmmo
:: Int -- ^ amount of ammo to use
-> ChainEffect
useAmmo amAmount eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . wpLoadedAmmo -~ amAmount)
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo -~ amAmount)
{- |
Applies a world effect after an item use cooldown check. -}
useTimeCheckI :: ChainEffect
@@ -240,7 +240,7 @@ hammerCheckI f it cr w = case it ^? itHammer of
ammoUseCheckI :: ChainEffect
ammoUseCheckI f item cr w
| fireCondition = f item cr w & pointerToItem %~
( (wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) )
( (wpAmmo . wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) )
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w
where
@@ -249,8 +249,8 @@ ammoUseCheckI f item cr w
pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _wpReloadState item == 0
&& _itUseTime item == 0
&& _wpLoadedAmmo item > 0
reloadCondition = _wpLoadedAmmo item == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
{- | Applies a world effect after a hammer position check.
Arbitrary inventory position. -}
hammerCheckL
@@ -276,7 +276,7 @@ shootL
-> World
shootL f cr invid w
| fireCondition = f cr invid w & pointerToItem %~
( (wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) )
( (wpAmmo . wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) )
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w
where
@@ -285,8 +285,8 @@ shootL f cr invid w
pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _wpReloadState item == 0
&& _itUseTime item == 0
&& _wpLoadedAmmo item > 0
reloadCondition = _wpLoadedAmmo item == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr = eff item cr
. over tempLightSources (theTLS :)
+18 -10
View File
@@ -20,17 +20,19 @@ rewindGun :: Item
rewindGun = defaultGun
{ _itName = "REWINDER"
, _itIdentity = Rewinder
, _wpMaxAmmo = 0
, _wpLoadedAmmo = 0
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 0
, _wpLoadedAmmo = 0
}
, _itEffect = ItRewindEffect rewindEffect []
, _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
}
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
rewindEffect _ cr invid w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take 250 . (w' : ))
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w)
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ length (_rewindWorlds w)
| otherwise = w & rewindWorlds .~ []
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ 0
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ 0
where
w' = w & rewindWorlds .~ []
& rewinding .~ True
@@ -52,8 +54,10 @@ shrinkGun :: Item
shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itIdentity = Generic
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 20
, _wpReloadState = 0
, _itUseRate = 0
@@ -90,8 +94,10 @@ blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
, _itIdentity = Blinker
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 20
, _wpReloadState = 0
, _itUseRate = 0
@@ -129,8 +135,10 @@ forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELD"
, _itIdentity = ForceFieldGun
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 40
, _wpReloadState = 0
, _itUseRate = 10
+3 -3
View File
@@ -57,7 +57,7 @@ subInventoryDisplay w = case _inventoryMode w of
col = itCol it
cursorsZ :: World -> Int -> Item -> Picture
cursorsZ w ipos it = case it ^? wpAmmo . amParamSel of
cursorsZ w ipos it = case it ^? wpAmmo . aoType . amParamSel of
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5)))
where
@@ -74,12 +74,12 @@ topInvCursor col iPos w
| otherwise = mainListCursor col iPos w
ammoTweakStrings :: Item -> [String]
ammoTweakStrings it = case it ^? wpAmmo . amPjParams of
ammoTweakStrings it = case it ^? wpAmmo . aoType . amPjParams of
Just l -> map pjTweakString l
_ -> ["NOT TWEAKABLE"]
mCurs :: Item -> World -> Picture
mCurs it w = case it ^? wpAmmo . amParamSel of
mCurs it w = case it ^? wpAmmo . aoType . amParamSel of
Nothing -> []
Just i
| ButtonRight `S.member` _mouseButtons w ->