Move weapon repetitions into trigger type
This commit is contained in:
@@ -75,15 +75,9 @@ data AttachParams
|
||||
|
||||
data HeldParams
|
||||
= DefaultHeldParams
|
||||
| GasSprayParams
|
||||
{ _weaponInvLock :: Int
|
||||
, _weaponRepeat :: [Int]
|
||||
}
|
||||
| GasSprayParams { _weaponInvLock :: Int }
|
||||
| BeamShooterParams
|
||||
| BulletShooterParams
|
||||
{ _weaponInvLock :: Int
|
||||
, _weaponRepeat :: [Int]
|
||||
}
|
||||
| BulletShooterParams { _weaponInvLock :: Int }
|
||||
deriving (Eq, Show, Read) --Generic, Flat)
|
||||
|
||||
data AmmoParams
|
||||
|
||||
@@ -18,6 +18,7 @@ import Geometry.Data
|
||||
import Sound.Data
|
||||
|
||||
data ItCrWdWd = ItCrWdItemHeldEffect
|
||||
| ItCrWdItemHeldEffectNoHammer
|
||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data WdWd
|
||||
|
||||
@@ -26,11 +26,9 @@ defaultEquipUse = UseEquip
|
||||
defaultHeldUse :: ItemUse
|
||||
defaultHeldUse = UseHeld
|
||||
{ _heldDelay = FixedRate{_rateMax = 8, _rateTimeLastUsed = 0}
|
||||
-- , _heldHammer = HammerUp
|
||||
, _heldMuzzles = defaultMuzzles
|
||||
, _heldParams = BulletShooterParams
|
||||
{ _weaponInvLock = 0
|
||||
, _weaponRepeat = []
|
||||
}
|
||||
, _heldFrame = 0
|
||||
, _heldUseEffect = NoHeldUseEffect
|
||||
|
||||
+24
-16
@@ -80,19 +80,28 @@ type ChainEffect =
|
||||
World
|
||||
|
||||
hammerCheck ::
|
||||
(LabelDoubleTree ComposeLinkType Item -> t1 -> t2 -> t2) ->
|
||||
(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World) ->
|
||||
PressType ->
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
t1 ->
|
||||
t2 ->
|
||||
t2
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
hammerCheck f pt it cr
|
||||
| BurstTrigger is <- baseTriggerType (it ^. ldtValue)
|
||||
, pt == InitialPress = f it cr
|
||||
. (cWorld . lWorld . delayedEvents .++~ map g is)
|
||||
| t <- baseTriggerType (it ^. ldtValue)
|
||||
, t == HammerTrigger || t == AlwaysSingleTrigger
|
||||
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
|
||||
, pt /= InitialPress =
|
||||
id
|
||||
| otherwise = f it cr
|
||||
where
|
||||
g x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffectNoHammer)
|
||||
upitm x =
|
||||
it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||
& ldtValue . itUse . heldFrame .~ x
|
||||
|
||||
|
||||
-- | Applies a world effect after an item use cooldown check.
|
||||
useTimeCheck :: ChainEffect
|
||||
@@ -123,7 +132,7 @@ heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -
|
||||
heldEffectMuzzles t cr w =
|
||||
doHeldUseEffect t cr $
|
||||
uncurry (applyCME (_ldtValue t) cr) cmew
|
||||
& doWeaponRepetitions upitm cr
|
||||
-- & doWeaponRepetitions upitm cr
|
||||
where
|
||||
muzzles = t ^. ldtValue . itUse . heldMuzzles
|
||||
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
|
||||
@@ -151,17 +160,16 @@ doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
|
||||
Just NoHeldUseEffect -> w
|
||||
Nothing -> w
|
||||
|
||||
-- need to be careful about inventory lock or item ids here
|
||||
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
|
||||
Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
|
||||
_ -> id
|
||||
where
|
||||
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||
upitm x =
|
||||
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
||||
& ldtValue . itUse . heldFrame .~ x
|
||||
---- need to be careful about inventory lock or item ids here
|
||||
--doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
--doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
|
||||
-- Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
|
||||
-- _ -> id
|
||||
-- where
|
||||
-- f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||
-- upitm x =
|
||||
-- itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||
-- & ldtValue . itUse . heldFrame .~ x
|
||||
|
||||
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
|
||||
applyCME itm cr cme
|
||||
|
||||
@@ -41,7 +41,7 @@ volleyGun i =
|
||||
-- & itUse . heldParams . recoil .~ 30
|
||||
& itType .~ HELD (VOLLEYGUN i)
|
||||
& itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
|
||||
& itUse . heldParams . weaponRepeat .~ [1..i-1]
|
||||
-- & itUse . heldParams . weaponRepeat .~ [1..i-1]
|
||||
& itUse . heldUseEffect .~ RandomiseMuzzleFrames i
|
||||
|
||||
rifle :: Item
|
||||
@@ -75,7 +75,6 @@ burstRifle =
|
||||
& itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
|
||||
& itUse . heldDelay . rateMax .~ 6
|
||||
& itUse . heldParams . weaponInvLock .~ 7
|
||||
& itUse . heldParams . weaponRepeat .~ [3,6]
|
||||
& itUse . heldMuzzles %~ doreplicate
|
||||
where
|
||||
doreplicate (x:_) = [x,x & mzFrame .~ 3,x & mzFrame .~ 6]
|
||||
|
||||
@@ -26,7 +26,7 @@ flameSpitter =
|
||||
& itType .~ HELD FLAMESPITTER
|
||||
& itUse . heldDelay .~ FixedRate{_rateMax = 3, _rateTimeLastUsed = 0}
|
||||
& itUse . heldParams . weaponInvLock .~ 10
|
||||
& itUse . heldParams . weaponRepeat .~ [1..9]
|
||||
-- & itUse . heldParams . weaponRepeat .~ [1..9]
|
||||
& itUse . heldMuzzles . ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
|
||||
|
||||
flameTorrent :: Item
|
||||
@@ -81,5 +81,5 @@ flameThrower =
|
||||
& itType .~ HELD FLAMETHROWER
|
||||
& itUse . heldParams .~ GasSprayParams
|
||||
{ _weaponInvLock = 0
|
||||
, _weaponRepeat = mempty
|
||||
-- , _weaponRepeat = mempty
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ doWdWd we = case we of
|
||||
doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
doItCrWdWd icww = case icww of
|
||||
ItCrWdItemHeldEffect -> heldEffect InitialPress
|
||||
ItCrWdItemHeldEffectNoHammer -> heldEffectNoHammerCheck
|
||||
|
||||
accessTerminal :: Maybe Int -> World -> World
|
||||
accessTerminal mtmid w = fromMaybe w $ do
|
||||
|
||||
Reference in New Issue
Block a user