Fix volleyGun

This commit is contained in:
2025-06-26 11:41:24 +01:00
parent cccb4f38db
commit 2f0e039d39
6 changed files with 328 additions and 329 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.BaseTriggerType (
baseTriggerType,
itemTriggerType,
module Dodge.Data.TriggerType,
) where
@@ -9,8 +9,8 @@ import Control.Lens
import Dodge.Data.Item
import Dodge.Data.TriggerType
baseTriggerType :: Item -> TriggerType
baseTriggerType itm = case itm ^. itType of
itemTriggerType :: Item -> TriggerType
itemTriggerType itm = case itm ^. itType of
HELD hit -> heldTriggerType hit
_ -> NoTrigger
@@ -28,7 +28,7 @@ heldTriggerType = \case
BLUNDERBUSS -> HammerTrigger
GRAPECANNON{} -> HammerTrigger
MINIGUNX{} -> AutoTrigger
VOLLEYGUN i -> BurstTrigger [1 .. i-1]
VOLLEYGUN i -> BurstTrigger $ fmap (3*) [1 .. i-1]
RIFLE -> HammerTrigger
ALTERIFLE -> HammerTrigger
AUTORIFLE -> AutoTrigger
+45 -34
View File
@@ -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 ::
+16 -15
View File
@@ -6,18 +6,18 @@ module Dodge.Item.BackgroundEffect (
removeShieldWall,
) where
import Dodge.Creature.Radius
import Color
import Dodge.Default.Wall
import Dodge.Wall.Delete
import Dodge.Item.HeldOffset
import Dodge.Creature.Test
import Geometry.Vector
import Dodge.Wall.Move
import Dodge.Wall.Create
import Dodge.Item.Location
import Dodge.Data.World
import Control.Lens
import Dodge.Creature.Radius
import Dodge.Creature.Test
import Dodge.Data.World
import Dodge.Default.Wall
import Dodge.Item.HeldOffset
import Dodge.Item.Location
import Dodge.Wall.Create
import Dodge.Wall.Delete
import Dodge.Wall.Move
import Geometry.Vector
cancelExamineInventory :: World -> World
cancelExamineInventory = hud . hudElement . subInventory %~ f
@@ -39,7 +39,7 @@ rootNotrootEff f g it
createShieldWall :: Item -> Creature -> World -> World
createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
Nothing ->
let (wlid, w') = createWall ((shieldWall' crid){_wlLine = wlline, _wlID = wlid}) w
let (wlid, w') = createWall ((shieldWall crid){_wlLine = wlline, _wlID = wlid}) w
in w' & pointerToItem it . itParams .~ FlatShieldParams (Just wlid)
Just wid -> moveWallID wid wlline w
where
@@ -67,14 +67,15 @@ itEffectOnPickup _ _ = id
itEffectOnDrop :: Item -> Creature -> World -> World
itEffectOnDrop itm cr w = case itm ^. itType of
HELD MINIGUNX{} -> w & pointerToItemID (_itID itm) . itParams . wTime .~ 0
HELD MACHINEPISTOL{} -> w & pointerToItemID (_itID itm) . itParams
.~ WarmTime 0 False Nothing
HELD MACHINEPISTOL{} ->
w & pointerToItemID (_itID itm) . itParams
.~ WarmTime 0 False Nothing
ITEMSCAN -> cancelExamineInventory w
HELD FLATSHIELD -> removeShieldWall itm cr w
_ -> w
shieldWall' :: Int -> Wall
shieldWall' crid =
shieldWall :: Int -> Wall
shieldWall crid =
defaultWall
{ _wlColor = yellow
, _wlOpacity = SeeAbove
+1 -1
View File
@@ -119,7 +119,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
_ -> ([], [])
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAutoSpringLinks itm = case baseTriggerType itm of
getAutoSpringLinks itm = case itemTriggerType itm of
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
+3 -27
View File
@@ -13,34 +13,19 @@ import Dodge.Default
import LensHelp
volleyGun :: Int -> Item
volleyGun i =
defaultHeldItem
-- & itUse . heldMuzzles .~ getZipList
-- (ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
-- <*> ZipList [0..i-1]
-- <*> pure MiniGunFlare
-- <*> pure MuzzleShootBullet
-- <*> pure (UseExactly 1)
-- <*> ZipList [0..i-1]
-- )
& itType .~ HELD (VOLLEYGUN i)
-- & itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
-- & itUse . heldUseEffect .~ RandomiseMuzzleFrames i
volleyGun i = defaultHeldItem & itType .~ HELD (VOLLEYGUN i)
& itParams .~ VolleyUnfiredBarrels [0..i-1]
rifle :: Item
rifle = defaultHeldItem & itType .~ HELD RIFLE
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 25 0
alteRifle :: Item
alteRifle = rifle
& itType .~ HELD ALTERIFLE
-- & itAmmoSlots .~ IM.fromList (zip [0..1] $ repeat BulletAmmo)
& itParams .~ AlteRifleSwitch 0
autoRifle :: Item
autoRifle =
rifle
& itType .~ HELD AUTORIFLE
autoRifle = rifle & itType .~ HELD AUTORIFLE
burstRifle :: Item
burstRifle = rifle & itType .~ HELD BURSTRIFLE
@@ -48,14 +33,5 @@ burstRifle = rifle & itType .~ HELD BURSTRIFLE
miniGunX :: Int -> Item
miniGunX i =
autoRifle
-- & itUse . heldDelay .~ WarmUpNoDelay{
-- --_warmTime = 0,
-- _warmMax = 100, _warmSound = crankSlowS}
-- & itAmmoSlots .~ singleAmmo BeltBulletAmmo
-- & itUse . heldMuzzles
-- .~ replicate i
-- (Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
& itType .~ HELD (MINIGUNX i)
-- & itEffect . ieInv .~ ItemReduceWarmTime
-- & itEffect . ieOnDrop .~ ItemSetWarmTime 0
& itParams .~ WarmTime 0 False Nothing
+259 -248
View File
File diff suppressed because it is too large Load Diff