Allow for partial reloading
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module Dodge.Item.Weapon.AmmoParams
|
||||
( useAmmoParams
|
||||
, useAmmoParamsRate
|
||||
, loadedAmmo
|
||||
-- , loadedAmmo
|
||||
, useAmmoParamsVelMod
|
||||
, fractionLoadedAmmo
|
||||
, fractionLoadedAmmo2
|
||||
@@ -73,13 +73,14 @@ withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : )
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
|
||||
|
||||
-- this shouldn't really be used
|
||||
loadedAmmo :: Item -> Int
|
||||
loadedAmmo it
|
||||
| _wpReloadState (_itConsumption it) == 0 = _wpLoadedAmmo (_itConsumption it)
|
||||
| _reloadState (_itConsumption it) == Nothing' = _ammoLoaded (_itConsumption it)
|
||||
| otherwise = 0
|
||||
|
||||
fractionLoadedAmmo :: Item -> Float
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_itConsumption it))
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_ammoMax (_itConsumption it))
|
||||
|
||||
fractionLoadedAmmo2 :: Item -> Float
|
||||
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_itConsumption it)))**2
|
||||
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_ammoMax (_itConsumption it)))**2
|
||||
|
||||
@@ -38,9 +38,9 @@ teslaGun = defaultGun
|
||||
{ _itName = "TESLA"
|
||||
, _itIdentity = TeslaGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 200
|
||||
, _wpLoadedAmmo = 200
|
||||
, _wpReloadTime = 80
|
||||
{ _ammoMax = 200
|
||||
, _ammoLoaded = 200
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseInstant (const aTeslaArc) NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -65,9 +65,9 @@ lasGun = defaultAutoGun
|
||||
{ _itName = "LASGUN ////"
|
||||
, _itIdentity = LasGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 200
|
||||
, _wpLoadedAmmo = 200
|
||||
, _wpReloadTime = 80
|
||||
{ _ammoMax = 200
|
||||
, _ammoLoaded = 200
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseInstant (const aLaser) NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -121,9 +121,9 @@ tractorGun = defaultAutoGun
|
||||
{ _itName = "TRACTORGUN"
|
||||
, _itIdentity = TractorGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 10000
|
||||
, _wpLoadedAmmo = 10000
|
||||
, _wpReloadTime = 40
|
||||
{ _ammoMax = 10000
|
||||
, _ammoLoaded = 10000
|
||||
, _reloadTime = 40
|
||||
}
|
||||
, _itUse = ruseInstant aTractorBeam NoHammer
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -43,7 +43,7 @@ bezierGun = defaultGun
|
||||
, _itEffect = rbSetTarget
|
||||
-- , _itZoom = defaultItZoom
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 50
|
||||
{ _ammoMax = 50
|
||||
}
|
||||
}
|
||||
bezierGunSPic :: Item -> SPic
|
||||
|
||||
@@ -37,8 +37,8 @@ boostSelfL
|
||||
-> World
|
||||
-> World
|
||||
boostSelfL x cr invid w = case boostPoint x cr w of
|
||||
Left p -> crEff p (itConsumption . wpLoadedAmmo .~ 0)
|
||||
Right p -> crEff p (itConsumption . wpLoadedAmmo -~ 1)
|
||||
Left p -> crEff p (itConsumption . ammoLoaded .~ 0)
|
||||
Right p -> crEff p (itConsumption . ammoLoaded -~ 1)
|
||||
where
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
@@ -114,9 +114,9 @@ boosterGun = defaultGun
|
||||
{ _itName = "BOOSTER"
|
||||
, _itIdentity = Blinker
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 20
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 20
|
||||
}
|
||||
, _itUse = luseInstantNoH $ boostSelfL 10
|
||||
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
|
||||
|
||||
@@ -39,9 +39,9 @@ autoGun = defaultAutoGun
|
||||
, _itIdentity = AutoGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
, _wpMaxAmmo = 30
|
||||
, _wpLoadedAmmo = 30
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 30
|
||||
, _ammoLoaded = 30
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 4 NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -85,7 +85,7 @@ autoGunPic it = noPic $
|
||||
)
|
||||
<> translateSHf 0 (-1) (rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW (negate $ 3 + 0.25 * x) 0 3 (-5))
|
||||
where
|
||||
x = fromIntegral $ loadedAmmo it
|
||||
x = fromIntegral $ _ammoLoaded $ _itConsumption it
|
||||
|
||||
pistol :: Item
|
||||
pistol = defaultGun
|
||||
@@ -93,9 +93,10 @@ pistol = defaultGun
|
||||
, _itIdentity = Pistol
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
, _wpMaxAmmo = 15
|
||||
, _wpLoadedAmmo = 15
|
||||
, _wpReloadTime = 40
|
||||
, _ammoMax = 15
|
||||
, _ammoLoaded = 15
|
||||
, _reloadTime = 10
|
||||
, _reloadType = PartialActive 1
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 8 upHammer
|
||||
[ ammoCheckI
|
||||
@@ -127,7 +128,7 @@ pistolPic it = noPic $ colorSH green (prismPoly
|
||||
)
|
||||
<> translateSH (V3 (-4) 5.5 4) (rotateSH pi $ bulletClip am)
|
||||
where
|
||||
am = loadedAmmo it
|
||||
am = _ammoLoaded $ _itConsumption it
|
||||
|
||||
bulletClip :: Int -> Shape
|
||||
bulletClip x = rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW 3 0 (3 - 0.25 * am) (-5)
|
||||
@@ -140,9 +141,9 @@ hvAutoGun = defaultAutoGun
|
||||
, _itIdentity = HvAutoGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = hvBullet
|
||||
, _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 200
|
||||
, _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 200
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 25 NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -157,6 +158,11 @@ hvAutoGun = defaultAutoGun
|
||||
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
|
||||
, _itFloorPict = hvAutoGunPic
|
||||
, _itInvSize = 3
|
||||
, _itInvDisplay = \it -> basicWeaponDisplay it ++
|
||||
["* FRATE: *"
|
||||
,"* " ++ fromMaybe " " (maybeRateStatus it) ++ " *"
|
||||
]
|
||||
}
|
||||
hvAutoGunPic :: Item -> SPic
|
||||
hvAutoGunPic it =
|
||||
@@ -168,16 +174,16 @@ hvAutoGunPic it =
|
||||
, mempty
|
||||
)
|
||||
where
|
||||
am = loadedAmmo it
|
||||
am = _ammoLoaded $ _itConsumption it
|
||||
ltAutoGun :: Item
|
||||
ltAutoGun = defaultAutoGun
|
||||
{ _itName = "AUTO-LT"
|
||||
, _itIdentity = LtAutoGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = ltBullet
|
||||
, _wpMaxAmmo = 25
|
||||
, _wpLoadedAmmo = 25
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 25
|
||||
, _ammoLoaded = 25
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 2 NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -207,16 +213,16 @@ ltAutoGunPic it =
|
||||
, mempty
|
||||
)
|
||||
where
|
||||
am = loadedAmmo it
|
||||
am = _ammoLoaded $ _itConsumption it
|
||||
miniGun :: Item
|
||||
miniGun = defaultAutoGun
|
||||
{ _itName = "MINI-G"
|
||||
, _itIdentity = MiniGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
, _wpMaxAmmo = 1500
|
||||
, _wpLoadedAmmo = 1500
|
||||
, _wpReloadTime = 200
|
||||
, _ammoMax = 1500
|
||||
, _ammoLoaded = 1500
|
||||
, _reloadTime = 200
|
||||
}
|
||||
, _itUse = ruseInstant (useAmmoParamsVelMod vm4) NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -281,9 +287,9 @@ miniGun = defaultAutoGun
|
||||
--[ 0.75, 0.5, 0.25]
|
||||
--[ 0, 0, 0]
|
||||
miniGunPictItem :: Item -> SPic
|
||||
miniGunPictItem it = miniGunPict spin (loadedAmmo it)
|
||||
miniGunPictItem it = miniGunPict spin (_ammoLoaded $ _itConsumption it)
|
||||
where
|
||||
spin = (-10) * _wpLoadedAmmo (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
|
||||
spin = (-10) * _ammoLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
|
||||
|
||||
miniGunPict :: Int -> Int -> SPic
|
||||
miniGunPict spin am =
|
||||
@@ -313,9 +319,9 @@ spreadGun = defaultGun
|
||||
, _itIdentity = SpreadGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
, _wpMaxAmmo = 5
|
||||
, _wpLoadedAmmo = 5
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 5
|
||||
, _ammoLoaded = 5
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 20 upHammer
|
||||
[ ammoCheckI
|
||||
@@ -345,16 +351,16 @@ spreadGunPic it =
|
||||
, mempty
|
||||
)
|
||||
where
|
||||
am = loadedAmmo it
|
||||
am = _ammoLoaded $ _itConsumption it
|
||||
multGun :: Item
|
||||
multGun = defaultGun
|
||||
{ _itName = "MULTGUN"
|
||||
, _itIdentity = MultGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
, _wpMaxAmmo = 2
|
||||
, _wpLoadedAmmo = 2
|
||||
, _wpReloadTime = 40
|
||||
, _ammoMax = 2
|
||||
, _ammoLoaded = 2
|
||||
, _reloadTime = 40
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 20 upHammer
|
||||
[ ammoCheckI
|
||||
@@ -395,17 +401,17 @@ multGunSPic it =
|
||||
barrel y = prismPoly
|
||||
(map (addZ 5) $ rectNSEW y (y-4) 2 0 )
|
||||
(map (addZ 0) $ rectNSEW y (y-4) 2 (-2))
|
||||
am = loadedAmmo it
|
||||
am = _ammoLoaded $ _itConsumption it
|
||||
longGun :: Item
|
||||
longGun = defaultGun
|
||||
{ _itName = "LONGGUN"
|
||||
, _itIdentity = LongGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = hvBullet
|
||||
, _wpMaxAmmo = 1
|
||||
, _wpLoadedAmmo = 1
|
||||
, _wpReloadTime = 100
|
||||
, _wpReloadType = PassiveReload skwareFadeTwoSecS
|
||||
, _ammoMax = 1
|
||||
, _ammoLoaded = 1
|
||||
, _reloadTime = 100
|
||||
, _reloadType = PassiveReload skwareFadeTwoSecS
|
||||
}
|
||||
, _itUse = useAmmoParamsRate 100 upHammer
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -24,9 +24,9 @@ lasDrones = defaultGun
|
||||
, _itIdentity = Generic
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
|
||||
, _wpMaxAmmo = 2
|
||||
, _wpLoadedAmmo = 2
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 2
|
||||
, _ammoLoaded = 2
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseRate 20 aDroneWithItemParams upHammer
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -81,8 +81,10 @@ itemLaserScopeEffect
|
||||
-- _ -> ep -.- 2 *.* unitVectorAtAngle d
|
||||
wpammo = _itConsumption $ (cr ^. crInv) IM.! invid
|
||||
reloadFrac
|
||||
| _wpLoadedAmmo wpammo == 0 = 1
|
||||
| otherwise = fromIntegral (_wpReloadState wpammo) / fromIntegral (_wpReloadTime wpammo)
|
||||
| _ammoLoaded wpammo == 0 = 1
|
||||
| otherwise = case _reloadState wpammo of
|
||||
Just' rs -> fromIntegral rs / fromIntegral (_reloadTime wpammo)
|
||||
Nothing' -> 1
|
||||
--col = mixColors reloadFrac (1-reloadFrac) red green
|
||||
{- | Automatically send out radar pulses that detect walls. -}
|
||||
autoRadarEffect :: ItEffect
|
||||
|
||||
@@ -4,6 +4,7 @@ Display of weapon strings in the inventory.
|
||||
module Dodge.Item.Weapon.InventoryDisplay
|
||||
( basicWeaponDisplay
|
||||
, maybeWarmupStatus
|
||||
, maybeRateStatus
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Padding
|
||||
@@ -17,9 +18,9 @@ basicWeaponDisplay it = [midPadL 10 ' ' thename (' ' : thenumber) ++ theparam]
|
||||
where
|
||||
thename = _itName it
|
||||
thenumber = case it ^? itConsumption of
|
||||
Just am@LoadableAmmo{} -> case _wpReloadState am of
|
||||
0 -> show $ _wpLoadedAmmo am
|
||||
x -> "R" ++ show x
|
||||
Just am@LoadableAmmo{} -> case _reloadState am of
|
||||
Nothing' -> show (_ammoLoaded am)
|
||||
Just' x -> show x ++ "R" ++ show (_ammoLoaded am)
|
||||
Just am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||
Just x@ItemItselfConsumable{} -> show $ _itMaxStack' x
|
||||
Nothing -> ""
|
||||
@@ -28,7 +29,7 @@ basicWeaponDisplay it = [midPadL 10 ' ' thename (' ' : thenumber) ++ theparam]
|
||||
$ mapMaybe ($ it)
|
||||
[ maybeModeStatus
|
||||
-- , maybeWarmupStatus
|
||||
, maybeRateStatus
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
|
||||
maybeModeStatus :: Item -> Maybe String
|
||||
@@ -40,7 +41,7 @@ maybeModeStatus it = case it ^? itAttachment of
|
||||
maybeRateStatus :: Item -> Maybe String
|
||||
maybeRateStatus it = case it ^? itUse . useDelay . rateMaxMax of
|
||||
Nothing -> Nothing
|
||||
_ -> Just $ ' ' : "T" ++ leftPad 3 ' ' (show (_rateMax . _useDelay $ _itUse it))
|
||||
_ -> Just $ ' ' : " " ++ leftPad 4 ' ' (show (_rateMax . _useDelay $ _itUse it))
|
||||
|
||||
maybeWarmupStatus :: Item -> Maybe String
|
||||
maybeWarmupStatus it = case it ^? itUse . useDelay . warmMax of
|
||||
|
||||
@@ -44,9 +44,9 @@ launcher = defaultGun
|
||||
, _amString = "EXPLOSIVE SHELL"
|
||||
, _amPjDraw = shellPic
|
||||
}
|
||||
, _wpMaxAmmo = 30
|
||||
, _wpLoadedAmmo = 30
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 30
|
||||
, _ammoLoaded = 30
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseRate 20 aRocketWithItemParams upHammer
|
||||
[ ammoCheckI
|
||||
@@ -267,9 +267,9 @@ remoteLauncher = defaultGun
|
||||
, _amString = ""
|
||||
, _amPjDraw = shellPic
|
||||
}
|
||||
, _wpMaxAmmo = 30
|
||||
, _wpLoadedAmmo = 30
|
||||
, _wpReloadTime = 80
|
||||
, _ammoMax = 30
|
||||
, _ammoLoaded = 30
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseRate 10 (const fireRemoteLauncher) upHammer
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -22,9 +22,9 @@ radar = defaultGun
|
||||
{ _itName = "RADAR"
|
||||
, _itIdentity = Generic
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 200
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 200
|
||||
}
|
||||
, _itUse = ruseRate 120 (const aRadarPulse) upHammer
|
||||
[ ammoUseCheck
|
||||
@@ -42,9 +42,9 @@ sonar = defaultGun
|
||||
{ _itName = "SONAR"
|
||||
, _itIdentity = Generic
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 200
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 200
|
||||
}
|
||||
, _itUse = ruseRate 120 (const aSonarPulse) upHammer
|
||||
[ ammoUseCheck
|
||||
|
||||
@@ -18,9 +18,9 @@ spawnGun :: Creature -> Item
|
||||
spawnGun cr = defaultGun
|
||||
{ _itName = "SPAWNER"
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 1
|
||||
, _wpLoadedAmmo = 1
|
||||
, _wpReloadTime = 80
|
||||
{ _ammoMax = 1
|
||||
, _ammoLoaded = 1
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseRate 100
|
||||
(\_ -> spawnCrNextTo cr)
|
||||
|
||||
@@ -35,9 +35,9 @@ poisonSprayer = defaultAutoGun
|
||||
{ _itName = "POISON"
|
||||
, _itIdentity = PoisonSprayer
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 500
|
||||
, _wpLoadedAmmo = 500
|
||||
, _wpReloadTime = 100
|
||||
{ _ammoMax = 500
|
||||
, _ammoLoaded = 500
|
||||
, _reloadTime = 100
|
||||
}
|
||||
, _itUse = ruseInstant (const aGasCloud) NoHammer
|
||||
[ ammoCheckI
|
||||
@@ -59,9 +59,9 @@ flamer = defaultAutoGun
|
||||
{ _itName = "FLAMER"
|
||||
, _itIdentity = Flamethrower
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 250
|
||||
, _wpLoadedAmmo = 250
|
||||
, _wpReloadTime = 100
|
||||
{ _ammoMax = 250
|
||||
, _ammoLoaded = 250
|
||||
, _reloadTime = 100
|
||||
}
|
||||
, _itUse = ruseInstant (\_ -> randWalkAngle aFlame) NoHammer
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -95,12 +95,12 @@ withThickSmokeI eff item cr w = eff item cr
|
||||
-- fire.
|
||||
ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff item cr w
|
||||
| _wpLoadedAmmo (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
|
||||
| _wpReloadState (_itConsumption item) > 0 = w
|
||||
| _ammoLoaded (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
|
||||
| _reloadState (_itConsumption item) /= Nothing' = w
|
||||
| otherwise = eff item cr w
|
||||
|
||||
itUseAmmo :: Int -> Item -> Item
|
||||
itUseAmmo x = itConsumption . wpLoadedAmmo %~ (max 0 . subtract x)
|
||||
itUseAmmo x = itConsumption . ammoLoaded %~ (max 0 . subtract x)
|
||||
|
||||
{- | Fires at an increasing rate.
|
||||
Has different effect after first fire.
|
||||
@@ -128,15 +128,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
||||
itRef = _crInvSel cr
|
||||
pointItem = creatures . ix cid . crInv . ix itRef
|
||||
currentRate = _rateMax (_useDelay (_itUse item))
|
||||
repeatFire = _wpReloadState (_itConsumption item) == 0 && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _wpReloadState (_itConsumption item) == 0 && _rateTime (_useDelay (_itUse item)) == 0
|
||||
repeatFire = _reloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _reloadState (_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
|
||||
| _wpReloadState (_itConsumption item) /= 0 = w
|
||||
| _reloadState (_itConsumption item) /= Nothing' = w
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
||||
@@ -221,7 +221,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) . itConsumption . wpLoadedAmmo -~ amAmount)
|
||||
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded -~ amAmount)
|
||||
{- |
|
||||
Applies a world effect after an item use cooldown check. -}
|
||||
useTimeCheck :: ChainEffect
|
||||
@@ -254,10 +254,10 @@ ammoUseCheck f item cr w
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = _wpReloadState (_itConsumption item) == 0
|
||||
fireCondition = _reloadState (_itConsumption item) == Nothing'
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _wpLoadedAmmo (_itConsumption item) > 0
|
||||
reloadCondition = _wpLoadedAmmo (_itConsumption item) == 0
|
||||
&& _ammoLoaded (_itConsumption item) > 0
|
||||
reloadCondition = _ammoLoaded (_itConsumption item) == 0
|
||||
{- | Applies a world effect after a hammer position check.
|
||||
Arbitrary inventory position. -}
|
||||
hammerCheckL
|
||||
@@ -289,10 +289,10 @@ shootL f cr invid w
|
||||
cid = _crID cr
|
||||
item = _crInv cr IM.! invid
|
||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||
fireCondition = _wpReloadState (_itConsumption item) == 0
|
||||
fireCondition = _reloadState (_itConsumption item) == Nothing'
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _wpLoadedAmmo (_itConsumption item) > 0
|
||||
reloadCondition = _wpLoadedAmmo (_itConsumption item) == 0
|
||||
&& _ammoLoaded (_itConsumption item) > 0
|
||||
reloadCondition = _ammoLoaded (_itConsumption item) == 0
|
||||
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
||||
withTempLight time rad col eff item cr = eff item cr
|
||||
. over tempLightSources (theTLS :)
|
||||
|
||||
@@ -57,9 +57,9 @@ shrinkGun = defaultGun
|
||||
{ _itName = "SHRINKER"
|
||||
, _itIdentity = Generic
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 20
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 20
|
||||
}
|
||||
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
|
||||
& useHammer .~ upHammer
|
||||
@@ -87,9 +87,9 @@ blinkGun = defaultGun
|
||||
{ _itName = "BLINKER"
|
||||
, _itIdentity = Blinker
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 20
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 20
|
||||
}
|
||||
, _itUse = defaultlUse
|
||||
{_lUse = hammerCheckL $ shootL aSelfL
|
||||
@@ -119,10 +119,10 @@ forceFieldGun = defaultGun
|
||||
{ _itName = "FORCEFIELD"
|
||||
, _itIdentity = ForceFieldGun
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _wpMaxAmmo = 100
|
||||
, _wpLoadedAmmo = 100
|
||||
, _wpReloadTime = 40
|
||||
, _wpReloadState = 0
|
||||
{ _ammoMax = 100
|
||||
, _ammoLoaded = 100
|
||||
, _reloadTime = 40
|
||||
, _reloadState = Nothing'
|
||||
}
|
||||
, _itUse = undefined
|
||||
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
|
||||
|
||||
Reference in New Issue
Block a user