Fix volleyGun
This commit is contained in:
+45
-34
@@ -81,14 +81,11 @@ hammerCheck ::
|
||||
World ->
|
||||
World
|
||||
hammerCheck f pt it cr
|
||||
| BurstTrigger is <- baseTriggerType (it ^. ldtValue)
|
||||
| BurstTrigger is <- itemTriggerType (it ^. ldtValue)
|
||||
, pt == InitialPress =
|
||||
f it cr
|
||||
. (cWorld . lWorld . delayedEvents .++~ map g is)
|
||||
| BurstTrigger{} <- baseTriggerType (it ^. ldtValue)
|
||||
, pt /= InitialPress =
|
||||
id
|
||||
| t <- baseTriggerType (it ^. ldtValue)
|
||||
f it cr . (cWorld . lWorld . delayedEvents .++~ map g is)
|
||||
| BurstTrigger{} <- itemTriggerType (it ^. ldtValue) = id
|
||||
| t <- itemTriggerType (it ^. ldtValue)
|
||||
, t == HammerTrigger || t == AlwaysSingleTrigger
|
||||
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
|
||||
, pt /= InitialPress =
|
||||
@@ -97,29 +94,31 @@ hammerCheck f pt it cr
|
||||
where
|
||||
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
|
||||
|
||||
-- | Applies a world effect after an item use cooldown check.
|
||||
-- input buffering?
|
||||
{- | Applies a world effect after an item use cooldown check.
|
||||
input buffering?
|
||||
-}
|
||||
useTimeCheck :: ChainEffect
|
||||
useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
|
||||
FixedRate rate
|
||||
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr w
|
||||
-- note that the time last used must be updated later in the chain!
|
||||
-- note that the time last used must be updated later in the chain!
|
||||
FixedRate{} -> w
|
||||
WarmUpNoDelay wm
|
||||
| _wTime (_itParams $ _ldtValue item) < wm ->
|
||||
w & setwarming
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . itType) (Just 2)
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
WarmUpNoDelay {} -> f item cr w & setwarming
|
||||
WarmUpNoDelay{} -> f item cr w & setwarming
|
||||
WarmUpCoolDown ws _ _
|
||||
| _wTime (_itParams $ _ldtValue item) < ws ->
|
||||
w & setwarming
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . itType) (Just 2)
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
WarmUpCoolDown _ cs _
|
||||
| _wTime (_itParams $ _ldtValue item) < cs -> f item cr w & setwarming
|
||||
| _wTime (_itParams $ _ldtValue item) < cs ->
|
||||
f item cr w & setwarming
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
WarmUpCoolDown {} -> w & setwarming
|
||||
WarmUpCoolDown{} -> w & setwarming
|
||||
NoDelay -> f item cr w
|
||||
where
|
||||
lastused = item ^. ldtValue . itTimeLastUsed
|
||||
@@ -133,7 +132,7 @@ useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
|
||||
|
||||
heldEffectMuzzles :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
|
||||
heldEffectMuzzles t cr w =
|
||||
setusetime . doHeldUseEffect t cr
|
||||
setusetime . doHeldUseEffect t cr
|
||||
. uncurry (applyCME (_ldtValue t) cr)
|
||||
. foldl' (useLoadedAmmo t cr) (False, w)
|
||||
$ loadedmuzzles
|
||||
@@ -144,12 +143,15 @@ heldEffectMuzzles t cr w =
|
||||
.~ w ^. cWorld . lWorld . lClock
|
||||
itid = t ^?! ldtValue . itLocation . ilInvID
|
||||
|
||||
|
||||
itemMuzzles :: Item -> [Muzzle]
|
||||
itemMuzzles itm = case itm ^. itType of
|
||||
HELD ALTERIFLE ->
|
||||
dbwMuzzles & ix 0 . mzPos .~ V2 25 0
|
||||
& ix 0 . mzAmmoSlot .~ _alteRifleSwitch (_itParams itm)
|
||||
HELD (VOLLEYGUN i) -> fromMaybe [] $ do
|
||||
j <- itm ^? itParams . unfiredBarrels . ix 0
|
||||
x <- vgunMuzzles i ^? ix j
|
||||
return [x]
|
||||
HELD hit -> heldItemMuzzles hit
|
||||
DETECTOR{} ->
|
||||
dbwMuzzles & ix 0 . mzEffect .~ MuzzleDetector
|
||||
@@ -167,8 +169,8 @@ heldItemMuzzles = \case
|
||||
NoFlare
|
||||
MuzzleShootBullet
|
||||
(UseExactly 1)
|
||||
-- 0
|
||||
| a <- spreadAroundCenter i baseStickSpread
|
||||
| -- 0
|
||||
a <- spreadAroundCenter i baseStickSpread
|
||||
]
|
||||
& ix 0 . mzFlareType .~ NoLightFlare
|
||||
& ix (i `div` 2) . mzFlareType .~ BasicFlare
|
||||
@@ -212,7 +214,7 @@ heldItemMuzzles = \case
|
||||
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
|
||||
GRAPECANNON _ -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
|
||||
TORCH -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
|
||||
VOLLEYGUN i -> vgunMuzzles i
|
||||
VOLLEYGUN {} -> error "should get volleygun muzzles earlier"
|
||||
FLAMETHROWER -> flameMuzzles
|
||||
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
|
||||
RLAUNCHER ->
|
||||
@@ -285,7 +287,7 @@ heldItemMuzzles = \case
|
||||
, _mzFlareType = NoFlare
|
||||
, _mzEffect = MuzzleShootBullet
|
||||
, _mzAmmoPerShot = UseExactly 1
|
||||
-- , _mzFrame = 0
|
||||
-- , _mzFrame = 0
|
||||
}
|
||||
]
|
||||
|
||||
@@ -319,18 +321,25 @@ vgunMuzzles i =
|
||||
<*> pure BasicFlare
|
||||
<*> pure MuzzleShootBullet
|
||||
<*> pure (UseExactly 1)
|
||||
-- <*> ZipList [0 .. i -1]
|
||||
-- <*> ZipList [0 .. i -1]
|
||||
)
|
||||
|
||||
doHeldUseEffect :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
|
||||
doHeldUseEffect t cr w = case t ^. ldtValue . itType of
|
||||
-- HELD (VOLLEYGUN x) -> fromMaybe w $ do
|
||||
-- i <- t ^? ldtValue . itLocation . ilInvID
|
||||
-- let g = w ^. randGen
|
||||
-- (is, g') = runState (shuffle [0 .. x -1]) g
|
||||
-- return $
|
||||
-- w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
|
||||
-- & randGen .~ g'
|
||||
HELD (VOLLEYGUN j) -> case itm ^? itParams . unfiredBarrels of
|
||||
Just [_] -> fromMaybe w $ do
|
||||
let (is, g) = runState (shuffle [0 .. j -1]) $ w ^. randGen
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
return $ w
|
||||
& randGen .~ g
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
|
||||
. itParams . unfiredBarrels %~ const is
|
||||
Just (_:_:_) -> fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
return $ w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
|
||||
. itParams . unfiredBarrels %~ tail
|
||||
_ -> w
|
||||
HELD ALTERIFLE -> fromMaybe w $ do
|
||||
i <- t ^? ldtValue . itLocation . ilInvID
|
||||
return $
|
||||
@@ -344,6 +353,8 @@ doHeldUseEffect t cr w = case t ^. ldtValue . itType of
|
||||
-- . mzAmmoSlot
|
||||
%~ ((`mod` 2) . (+ 1))
|
||||
_ -> w
|
||||
where
|
||||
itm = t ^. ldtValue
|
||||
|
||||
--doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
|
||||
-- Just (RandomiseMuzzleFrames x) -> fromMaybe w $ do
|
||||
@@ -387,10 +398,10 @@ applyCME itm cr cme
|
||||
. applyTorqueCME itm cr
|
||||
. applyRecoil itm cr
|
||||
| otherwise = case itm ^. itType of
|
||||
HELD MACHINEPISTOL ->
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itid . itParams .~
|
||||
WarmTime (coolstart - 1) True Nothing
|
||||
-- the above is quite hacky for now
|
||||
HELD MACHINEPISTOL ->
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itid . itParams
|
||||
.~ WarmTime (coolstart - 1) True Nothing
|
||||
-- the above is quite hacky for now
|
||||
_ -> failsound
|
||||
where
|
||||
coolstart = fromMaybe 0 $ useDelay itm ^? coolStart
|
||||
@@ -688,7 +699,7 @@ makeMuzzleFlare mz itmtree cr = case mz ^. mzFlareType of
|
||||
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
dir = _crDir cr + mrot
|
||||
oddcheck f w
|
||||
oddcheck f w
|
||||
| odd (w ^. cWorld . lWorld . lClock) = f w
|
||||
| otherwise = w
|
||||
|
||||
@@ -1394,8 +1405,8 @@ dropInventoryPath i ip loc cr = fromMaybe id $ do
|
||||
|
||||
warmupSound :: ItemType -> SoundID
|
||||
warmupSound = \case
|
||||
HELD MINIGUNX {} -> crankSlowS
|
||||
HELD MACHINEPISTOL {} -> whirupS
|
||||
HELD MINIGUNX{} -> crankSlowS
|
||||
HELD MACHINEPISTOL{} -> whirupS
|
||||
_ -> crankSlowS
|
||||
|
||||
useInventoryPath ::
|
||||
|
||||
Reference in New Issue
Block a user