Make reloading based upon creature stance
This commit is contained in:
@@ -66,11 +66,11 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
|
||||
return $ \pt -> pt
|
||||
& ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
||||
|
||||
-- this shouldn't really be used
|
||||
---- this shouldn't really be used
|
||||
loadedAmmo :: Item -> Int
|
||||
loadedAmmo it
|
||||
| _laReloadState (_itConsumption it) == Nothing' = _laLoaded (_itConsumption it)
|
||||
| otherwise = 0
|
||||
loadedAmmo = _laLoaded . _itConsumption
|
||||
-- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it)
|
||||
-- | otherwise = 0
|
||||
|
||||
fractionLoadedAmmo :: Item -> Float
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it)
|
||||
|
||||
@@ -208,7 +208,7 @@ targetLaserUpdate it cr w t
|
||||
wpammo = _itConsumption it
|
||||
reloadFrac
|
||||
| _laLoaded wpammo == 0 = 1
|
||||
| otherwise = case _laReloadState wpammo of
|
||||
Just' rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
|
||||
Nothing' -> 1
|
||||
| otherwise = case _laTransfer wpammo of
|
||||
Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
|
||||
NoTransfer -> 1
|
||||
col = mixColors reloadFrac (1-reloadFrac) blue red
|
||||
|
||||
@@ -125,7 +125,7 @@ withThickSmokeI eff item cr w = eff item cr
|
||||
-- fire.
|
||||
ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff item cr w
|
||||
| _laLoaded (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
|
||||
| _laLoaded (_itConsumption item) <= 0 = w -- fromMaybe w (startReloadingWeapon cr w)
|
||||
-- | _reloadState (_itConsumption item) /= Nothing' = w
|
||||
| otherwise = eff item cr $ w & creatures . ix (_crID cr) %~ crStopReloading
|
||||
|
||||
@@ -133,7 +133,7 @@ ammoCheckI eff item cr w
|
||||
-- hammer is down?
|
||||
ammoHammerCheck :: ChainEffect
|
||||
ammoHammerCheck eff it cr w
|
||||
| _laLoaded (_itConsumption it) <= 0 = fromMaybe w (startReloadingWeapon cr w)
|
||||
| _laLoaded (_itConsumption it) <= 0 = w -- 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
|
||||
@@ -173,15 +173,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
||||
itRef = _crInvSel cr
|
||||
pointItem = creatures . ix cid . crInv . ix itRef
|
||||
currentRate = _rateMax (_useDelay (_itUse item))
|
||||
repeatFire = _laReloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _laReloadState (_itConsumption item) == Nothing' && _rateTime (_useDelay (_itUse item)) == 0
|
||||
repeatFire = _laTransfer (_itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _laTransfer (_itConsumption item) == NoTransfer && _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
|
||||
| _laReloadState (_itConsumption item) /= Nothing' = w
|
||||
| _laTransfer (_itConsumption item) /= NoTransfer = w
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
||||
@@ -317,16 +317,16 @@ ammoUseCheck f item cr w
|
||||
| fireCondition = f item cr w & pointerToItem %~
|
||||
( itUseAmmo 1
|
||||
. (itUse . useDelay . rateTime .~ _rateMax ( _useDelay (_itUse item)) ))
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| otherwise = w
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = _laReloadState (_itConsumption item) == Nothing'
|
||||
fireCondition = _laTransfer (_itConsumption item) == NoTransfer
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _laLoaded (_itConsumption item) > 0
|
||||
reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
{- | Applies a world effect after a hammer position check.
|
||||
Arbitrary inventory position. -}
|
||||
hammerCheckL
|
||||
@@ -353,16 +353,16 @@ shootL f item cr w
|
||||
| fireCondition = f item cr w & pointerToItem %~
|
||||
( itUseAmmo 1
|
||||
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| otherwise = w
|
||||
where
|
||||
cid = _crID cr
|
||||
invid = fromJust $ _itInvPos item
|
||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||
fireCondition = _laReloadState (_itConsumption item) == Nothing'
|
||||
fireCondition = _laTransfer (_itConsumption item) == NoTransfer
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _laLoaded (_itConsumption item) > 0
|
||||
reloadCondition = _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
|
||||
|
||||
Reference in New Issue
Block a user