Refactor reloading to use list of required steps
This commit is contained in:
@@ -31,16 +31,20 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
|
||||
|
||||
showConsumption :: ItemConsumption -> String
|
||||
showConsumption ic = case ic of
|
||||
am@LoadableAmmo{} -> showLoading (_laLoadType ic) ++ show (_laLoaded am)
|
||||
am@LoadableAmmo{} -> showLoading (_laProgress ic) ++ show (_laLoaded am)
|
||||
am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||
x@ItemItselfConsumable{} -> show (_icAmount x)
|
||||
NoConsumption -> ""
|
||||
showLoading :: LoadType -> String
|
||||
showLoading lt = case lt ^? loadProgress of
|
||||
Just (Eject t) -> show t ++ "E"
|
||||
Just (Insert t _) -> show t ++ "R"
|
||||
Just NoTransfer -> ""
|
||||
showLoading :: LoadProgress -> String
|
||||
showLoading lt = case lt ^? futureActions . ix 0 of
|
||||
Just lap -> show (_actionTime (_actionType lap) - _actionProgress lap)
|
||||
++ showLoadActionType (_actionType lap)
|
||||
Nothing -> ""
|
||||
showLoadActionType :: LoadAction -> String
|
||||
showLoadActionType la = case la of
|
||||
Eject {} -> "E"
|
||||
Insert {} -> "L"
|
||||
Prime {} -> "P"
|
||||
|
||||
-- & itInvDisplay .~ \it -> head (basicItemDisplay it) :
|
||||
-- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it)
|
||||
|
||||
@@ -74,8 +74,7 @@ teslaGun :: Item
|
||||
teslaGun = defaultBatteryGun
|
||||
{ _itConsumption = defaultLoadable
|
||||
& laMax .~ 200
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 10, Insert 10 Nothing, Prime 60]
|
||||
, _itUse = ruseInstant shootTeslaArc NoHammer
|
||||
[ ammoCheckI
|
||||
, withTempLight 1 100 (V3 0 0 1)
|
||||
@@ -254,8 +253,7 @@ lasGun :: Item
|
||||
lasGun = defaultAutoBatteryGun
|
||||
{ _itConsumption = defaultLoadable
|
||||
& laMax .~ 200
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 10, Insert 10 Nothing, Prime 60]
|
||||
, _itUse = ruseInstant shootLaser NoHammer
|
||||
[ ammoCheckI
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
@@ -320,8 +318,7 @@ tractorGun :: Item
|
||||
tractorGun = lasGun
|
||||
{ _itConsumption = defaultLoadable
|
||||
& laMax .~ 10000
|
||||
& laLoadType . ejectTime .~ 20
|
||||
& laLoadType . insertTime .~ 20
|
||||
& laCycle .~ [Eject 10, Insert 10 Nothing, Prime 60]
|
||||
, _itUse = ruseInstant aTractorBeam NoHammer
|
||||
[ ammoCheckI
|
||||
]
|
||||
|
||||
@@ -73,7 +73,7 @@ bangCane = defaultBulletWeapon
|
||||
} & itUse . useAim . aimStance .~ OneHand
|
||||
& itType . iyBase .~ BANGCANE
|
||||
& itConsumption . laMax .~ 1
|
||||
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
|
||||
& itConsumption . laCycle .~ [Insert 10 (Just 1)]
|
||||
bangCaneX :: Int -> Item
|
||||
bangCaneX i = bangCane
|
||||
{ _itUse = ruseAmmoParamsRate 6 upHammer
|
||||
@@ -139,7 +139,7 @@ rifle = bangCane
|
||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||
& itType . iyBase .~ RIFLE
|
||||
& itConsumption . laMax .~ 1
|
||||
& itConsumption . laLoadType .~ ActiveEject 5 5 NoTransfer
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 5 Nothing,Prime 5]
|
||||
& itUse . useAim . aimWeight .~ 6
|
||||
& itUse . useAim . aimRange .~ 1
|
||||
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||
@@ -148,8 +148,7 @@ repeater :: Item
|
||||
repeater = rifle
|
||||
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
|
||||
& itType . iyBase .~ REPEATER
|
||||
& itConsumption . laLoadType . ejectTime .~ 40
|
||||
& itConsumption . laLoadType . insertTime .~ 40
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 15 Nothing,Prime 15]
|
||||
& itConsumption . laMax .~ 15
|
||||
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
|
||||
<> makeTinClipAt 0 (V3 10 (-2) 0) it
|
||||
@@ -252,8 +251,7 @@ miniGunX i = defaultAutoGun
|
||||
{ _laMax = 1500
|
||||
, _laLoaded = 1500
|
||||
}
|
||||
& laLoadType . ejectTime .~ 60
|
||||
& laLoadType . insertTime .~ 60
|
||||
& laCycle .~ [Eject 40, Insert 40 Nothing,Prime 40]
|
||||
, _itUse = miniGunUse i
|
||||
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 100}
|
||||
& useAim . aimWeight .~ 6
|
||||
|
||||
@@ -70,8 +70,7 @@ bangRod = defaultBulletWeapon
|
||||
}
|
||||
}
|
||||
& itConsumption . laMax .~ 1
|
||||
& itConsumption . laLoadType . ejectTime .~ 10
|
||||
& itConsumption . laLoadType . insertTime .~ 10
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 10 Nothing, Prime 5]
|
||||
& itType . iyBase .~ BANGROD
|
||||
& itUse . useAim . aimWeight .~ 8
|
||||
& itUse . useAim . aimRange .~ 1
|
||||
@@ -142,7 +141,6 @@ machineGun = bangRod
|
||||
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
|
||||
)
|
||||
& itConsumption . laMax .~ 100
|
||||
& itConsumption . laLoadType . ejectTime .~ 25
|
||||
& itConsumption . laLoadType . insertTime .~ 25
|
||||
& itConsumption . laCycle .~ [Eject 10, Insert 40 Nothing, Prime 10]
|
||||
& itInvSize .~ 3
|
||||
& itParams. torqueAfter .~ 0.2 -- not sure if this is necessary?
|
||||
|
||||
@@ -78,7 +78,7 @@ bangStick i = defaultBulletWeapon
|
||||
}
|
||||
& itType . iyBase .~ BANGSTICK i
|
||||
& itConsumption . laMax .~ i
|
||||
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
|
||||
& itConsumption . laCycle .~ [Insert 10 (Just 1)]
|
||||
baseStickShapeX :: Int -> Shape
|
||||
baseStickShapeX i = foldMap f [0..i-1]
|
||||
where
|
||||
@@ -108,7 +108,7 @@ revolver = pistol
|
||||
& itConsumption .~
|
||||
(defaultBulletLoadable
|
||||
& laMax .~ 6
|
||||
& laLoadType .~ ActivePartial 10 1 NoTransfer )
|
||||
& laCycle .~ [Insert 10 (Just 1)] )
|
||||
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
|
||||
& itType . iyBase .~ REVOLVER
|
||||
|
||||
@@ -157,8 +157,7 @@ pistol :: Item
|
||||
pistol = (bangStick 1)
|
||||
& itConsumption .~ ( defaultBulletLoadable
|
||||
& laMax .~ 15
|
||||
& laLoadType . ejectTime .~ 20
|
||||
& laLoadType . insertTime .~ 20 )
|
||||
& laCycle .~ [Eject 5, Insert 5 Nothing, Prime 5] )
|
||||
& itUse .~ ruseAmmoParamsRate 6 upHammer (ammoHammerCheck : pistolAfterHamMods)
|
||||
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
|
||||
& itParams %~
|
||||
|
||||
@@ -44,8 +44,7 @@ autoGun = defaultAutoGun
|
||||
{ _laMax = 30
|
||||
, _laLoaded = 30
|
||||
}
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 30, Insert 30 Nothing, Prime 10]
|
||||
, _itUse = ruseAmmoParamsRate 4 NoHammer
|
||||
[ ammoCheckI
|
||||
, charFiringStratI
|
||||
@@ -132,8 +131,7 @@ bangCone = defaultBulletWeapon
|
||||
}
|
||||
& itType . iyBase .~ BANGCONE
|
||||
& itConsumption . laMax .~ 5
|
||||
& itConsumption . laLoadType . ejectTime .~ 10
|
||||
& itConsumption . laLoadType . insertTime .~ 10
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 20 Nothing, Prime 5]
|
||||
coneRandItemUpdate :: State StdGen (Item -> Item)
|
||||
coneRandItemUpdate = do
|
||||
wth <- state $ randomR (1,5)
|
||||
@@ -161,8 +159,7 @@ blunderbuss = bangCone
|
||||
}
|
||||
}
|
||||
& itConsumption . laMax .~ 25
|
||||
& itConsumption . laLoadType . ejectTime .~ 15
|
||||
& itConsumption . laLoadType . insertTime .~ 15
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 30 Nothing, Prime 5]
|
||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||
& itUse . useAim . aimWeight .~ 6
|
||||
& itType . iyBase .~ BLUNDERBUSS
|
||||
@@ -170,8 +167,7 @@ bigBlunderbuss :: Item
|
||||
bigBlunderbuss = blunderbuss
|
||||
& itType . iyBase .~ BIGBLUNDERBUSS
|
||||
& itConsumption . laMax .~ 50
|
||||
& itConsumption . laLoadType . ejectTime .~ 18
|
||||
& itConsumption . laLoadType . insertTime .~ 18
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 40 Nothing, Prime 5]
|
||||
& itParams . recoil .~ 200
|
||||
& itParams . torqueAfter .~ 0.3
|
||||
& itParams . randomOffset .~ 16
|
||||
@@ -179,8 +175,7 @@ biggerBlunderbuss :: Item
|
||||
biggerBlunderbuss = bigBlunderbuss
|
||||
& itType . iyBase .~ BIGGERBLUNDERBUSS
|
||||
& itConsumption . laMax .~ 75
|
||||
& itConsumption . laLoadType . ejectTime .~ 20
|
||||
& itConsumption . laLoadType . insertTime .~ 20
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 50 Nothing, Prime 5]
|
||||
& itParams . recoil .~ 250
|
||||
& itParams . torqueAfter .~ 0.5
|
||||
& itParams . randomOffset .~ 20
|
||||
@@ -188,8 +183,7 @@ biggestBlunderbuss :: Item
|
||||
biggestBlunderbuss = biggerBlunderbuss
|
||||
& itType . iyBase .~ BIGGESTBLUNDERBUSS
|
||||
& itConsumption . laMax .~ 100
|
||||
& itConsumption . laLoadType . ejectTime .~ 25
|
||||
& itConsumption . laLoadType . insertTime .~ 25
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 60 Nothing, Prime 5]
|
||||
& itParams . recoil .~ 300
|
||||
& itParams . torqueAfter .~ 0.7
|
||||
& itParams . randomOffset .~ 24
|
||||
|
||||
@@ -33,8 +33,6 @@ droneLauncher = defaultWeapon
|
||||
}
|
||||
& itConsumption . laAmmoType .~ DroneAmmo { _amString = "LASDRONE" }
|
||||
& itConsumption . laMax .~ 2
|
||||
& itConsumption . laLoadType . ejectTime .~ 40
|
||||
& itConsumption . laLoadType . insertTime .~ 40
|
||||
& itType . iyBase .~ DRONELAUNCHER
|
||||
|
||||
lasDronesPic :: Item -> SPic
|
||||
|
||||
@@ -44,8 +44,7 @@ launcher = defaultWeapon
|
||||
}
|
||||
& laMax .~ 1
|
||||
& laLoaded .~ 1
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 30, Insert 30 Nothing, Prime 10]
|
||||
, _itUse = ruseRate 20 usePjCreation upHammer
|
||||
[ hammerCheckI
|
||||
, ammoCheckI
|
||||
|
||||
@@ -32,8 +32,7 @@ sonicGun :: Item
|
||||
sonicGun = defaultAutoGun
|
||||
{ _itConsumption = defaultLoadable
|
||||
& laMax .~ 10
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 10, Insert 10 Nothing, Prime 60]
|
||||
, _itUse = ruseRate 8 aSonicWave (HasHammer HammerUp)
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
|
||||
@@ -17,9 +17,6 @@ Creates a creature next to the creature using the item. -}
|
||||
spawnGun :: Creature -> Item
|
||||
spawnGun cr = defaultWeapon
|
||||
{ _itConsumption = defaultLoadable
|
||||
& laMax .~ 1
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
, _itUse = ruseRate 100
|
||||
(\_ -> spawnCrNextTo cr)
|
||||
upHammer
|
||||
|
||||
@@ -68,8 +68,7 @@ flameSpitter :: Item
|
||||
flameSpitter = flameThrower
|
||||
& itType . iyBase .~ FLAMESPITTER
|
||||
& itConsumption . laMax .~ 10
|
||||
& itConsumption . laLoadType . ejectTime .~ 10
|
||||
& itConsumption . laLoadType . insertTime .~ 10
|
||||
& itConsumption . laCycle .~ [Eject 5, Insert 10 Nothing, Prime 20]
|
||||
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
|
||||
& itUse . useAim . aimStance .~ OneHand
|
||||
& itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0}
|
||||
@@ -123,8 +122,7 @@ flameThrower = defaultAutoGun
|
||||
{_amString = "FLAME"
|
||||
,_amCreateGas = aFlame
|
||||
}
|
||||
& laLoadType . ejectTime .~ 40
|
||||
& laLoadType . insertTime .~ 40
|
||||
& laCycle .~ [Eject 5, Insert 10 Nothing, Prime 20]
|
||||
, _itUse = ruseInstant (overNozzles useGasParams) NoHammer
|
||||
[ ammoCheckI
|
||||
, useAmmoAmount 1
|
||||
|
||||
@@ -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 = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 0
|
||||
repeatFire = _laProgress (_itConsumption item) == FinishedLoading && _rateTime (_useDelay (_itUse item)) == 1
|
||||
firstFire = _laProgress (_itConsumption item) == FinishedLoading && _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
|
||||
| _loadProgress (_laLoadType $ _itConsumption item) /= NoTransfer = w
|
||||
| _laProgress (_itConsumption item) /= FinishedLoading = w
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
||||
@@ -323,7 +323,7 @@ ammoUseCheck f item cr w
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
|
||||
fireCondition = _laProgress (_itConsumption item) == FinishedLoading
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _laLoaded (_itConsumption item) > 0
|
||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
@@ -359,7 +359,7 @@ shootL f item cr w
|
||||
cid = _crID cr
|
||||
invid = fromJust $ _itInvPos item
|
||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||
fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
|
||||
fireCondition = _laProgress (_itConsumption item) == FinishedLoading
|
||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||
&& _laLoaded (_itConsumption item) > 0
|
||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
|
||||
Reference in New Issue
Block a user