Move towards moving muzzles out of records

This commit is contained in:
2025-06-05 08:16:20 +01:00
parent e05061a268
commit b2a971d8c3
12 changed files with 226 additions and 234 deletions
+7 -6
View File
@@ -157,12 +157,13 @@ inventoryX c = case c of
, detector WALLDETECTOR
, battery
]
'E' -> fold
[ makeTypeCraftNum 3 PIPE
, makeTypeCraftNum 5 HARDWARE
, makeTypeCraftNum 1 TIN
, makeTypeCraftNum 1 SPRING
, makeTypeCraftNum 1 PLANK
'E' -> [alteRifle
, tinMag
, tinMag
] <>
fold
[ makeTypeCraftNum 1 SPRING
, makeTypeCraftNum 1 HARDWARE
, makeTypeCraftNum 1 PLATE
, makeTypeCraftNum 1 STEELDRUM
, makeTypeCraftNum 1 MOTOR
+3 -4
View File
@@ -15,10 +15,9 @@ data ItemParams
| FlatShieldParams
{_flatShieldWlMIX :: Maybe Int}
| Arcing
{ _currentArc :: [ArcStep]
-- , _arcSize :: Float
-- , _arcNumber :: Int
}
{ _currentArc :: [ArcStep]}
| NozzleAngle {_nzAngle :: Float}
| VolleyUnfiredBarrels {_unfiredBarrels :: [Int]}
data ShrinkGunStatus = FullSize | Shrunk
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
-19
View File
@@ -34,7 +34,6 @@ data ItemUse
{ _heldDelay :: UseDelay
, _heldMuzzles :: [Muzzle]
, _heldFrame :: Int
, _heldUseEffect :: HeldUseEffect
}
| UseEquip {_uequipEffect :: EquipEffect}
| UseAttach {_uaParams :: AttachParams}
@@ -50,12 +49,6 @@ data ItemUse
}
deriving (Eq, Show, Read)
data HeldUseEffect
= NoHeldUseEffect
| RandomiseMuzzleFrames Int
| SwitchAlteRifle
deriving (Eq, Show, Read)
data UseFocus
= UseFromRoot
| UseFromLocation
@@ -99,7 +92,6 @@ data MuzzleEffect
| MuzzleNozzle
{ _nzPressure :: GenFloat
, _nzMaxWalkAngle :: Float
, _nzCurrentWalkAngle :: Float
, _nzWalkSpeed :: Float
}
| MuzzleShatter
@@ -125,15 +117,6 @@ data Muzzle = Muzzle
, _mzEffect :: MuzzleEffect
, _mzAmmoPerShot :: AmmoPerShot
, _mzFrame :: Int
-- , _mzChargeRequirement :: Maybe Int
-- , _mzRecoil :: Float
-- , _mzTorque :: Float
-- , _mzSidePush :: Float
-- , _mzRandomOffset :: Float
-- , _mzVel :: Float
-- , _mzRifling :: Float
-- , _mzAmmoSlot :: Either Int
-- , _mzAmmoPerShot :: Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
@@ -145,8 +128,6 @@ makeLenses ''MuzzleEffect
makeLenses ''AmmoPerShot
makeLenses ''UseCondition
makeLenses ''UseFocus
makeLenses ''HeldUseEffect
deriveJSON defaultOptions ''HeldUseEffect
deriveJSON defaultOptions ''UseFocus
deriveJSON defaultOptions ''UseCondition
deriveJSON defaultOptions ''MuzzleEffect
+6 -2
View File
@@ -1,9 +1,12 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.MuzzleEffect where
import Control.Lens
--import Data.Aeson
--import Data.Aeson.TH
--import Dodge.Data.Item.Use.Consumption.Ammo
@@ -13,5 +16,6 @@ data CumulativeMuzzleEffect = CME
, _cmeTorque :: Float
, _cmeSound :: Bool
}
deriving (Eq,Ord,Show,Read)
deriving (Eq, Ord, Show, Read)
makeLenses ''CumulativeMuzzleEffect
+1 -1
View File
@@ -35,7 +35,7 @@ data WdWd
| WdWdFromItCrixWdWd (LabelDoubleTree ComposeLinkType Item) Int ItCrWdWd
| MakeTempLight LSParam Int
| UseInvItem Int PressType
| WdWdBurstFireRepeats Int Int
| WdWdBurstFireRepetition Int Int
--deriving (Eq, Show, Read) --, Generic)
--h--deriving (Eq, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -31,5 +31,5 @@ defaultHeldUse = UseHeld
-- { _weaponInvLock = 0
-- }
, _heldFrame = 0
, _heldUseEffect = NoHeldUseEffect
-- , _heldUseEffect = NoHeldUseEffect
}
+39 -17
View File
@@ -107,7 +107,7 @@ hammerCheck f pt it cr
-- it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
-- & ldtValue . itUse . heldFrame .~ x
g x = (x, WdWdBurstFireRepeats (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
@@ -136,26 +136,26 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew
doHeldUseEffect t cr .
uncurry (applyCME (_ldtValue t) cr) .
foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
where
-- & doWeaponRepetitions upitm cr
muzzles = t ^. ldtValue . itUse . heldMuzzles
--(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
(_, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
cmew = foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
doHeldUseEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
Just (RandomiseMuzzleFrames x) -> fromMaybe w $ do
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'
Just SwitchAlteRifle -> fromMaybe w $ do
HELD ALTERIFLE -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
return $
w
@@ -165,8 +165,27 @@ doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
. ix 0
. mzAmmoSlot
%~ ((`mod` 2) . (+ 1))
Just NoHeldUseEffect -> w
Nothing -> w
_ -> w
--doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
-- Just (RandomiseMuzzleFrames 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'
-- Just SwitchAlteRifle -> fromMaybe w $ do
-- i <- t ^? ldtValue . itLocation . ilInvID
-- return $
-- w
-- & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
-- . itUse
-- . heldMuzzles
-- . ix 0
-- . mzAmmoSlot
-- %~ ((`mod` 2) . (+ 1))
-- Just NoHeldUseEffect -> w
-- Nothing -> w
---- need to be careful about inventory lock or item ids here
--doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
@@ -603,19 +622,21 @@ walkNozzle mzid mz itm cr w = fromMaybe w $ do
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv
. ix invid
. itUse
. heldMuzzles
. ix mzid
. mzEffect
. nzCurrentWalkAngle
.~ wa
. itParams . nzAngle %~ f
-- . itUse
-- . heldMuzzles
-- . ix mzid
-- . mzEffect
-- . nzCurrentWalkAngle
-- .~ wa
& randGen .~ g
where
nz = _mzEffect mz
(walkamount, g) = randomR (- aspeed, aspeed) (_randGen w)
aspeed = _nzWalkSpeed nz
maxa = _nzMaxWalkAngle nz
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
f x = min maxa $ max (negate maxa) (x + walkamount)
-- wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
shootTractorBeam :: Creature -> World -> World
shootTractorBeam cr w =
@@ -935,7 +956,8 @@ useGasParams mmagid mz itm cr w =
pos = _crPos cr + rotateV (_crDir cr) moff
(a, g') = randomR (- inacc, inacc) g
inacc = _mzInaccuracy mz
dir = _crDir cr + mrot + a + _nzCurrentWalkAngle (_mzEffect mz)
--dir = _crDir cr + mrot + a + _nzCurrentWalkAngle (_mzEffect mz)
dir = _crDir cr + mrot + a + _nzAngle (_itParams itm)
gasType :: HeldItemType -> GasFuel -> Maybe GasCreate
gasType hit _ = case hit of
+1 -10
View File
@@ -28,7 +28,6 @@ defaultBangCane =
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldMuzzles .~ getZipList
(ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
<*> ZipList [0..i-1]
@@ -37,23 +36,19 @@ volleyGun i =
<*> pure (UseExactly 1)
<*> ZipList [0..i-1]
)
-- & itUse . heldParams . recoil .~ 30
& itType .~ HELD (VOLLEYGUN i)
& itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
-- & itUse . heldParams . weaponRepeat .~ [1..i-1]
& itUse . heldUseEffect .~ RandomiseMuzzleFrames i
-- & itUse . heldUseEffect .~ RandomiseMuzzleFrames i
rifle :: Item
rifle =
defaultBangCane
& itType .~ HELD RIFLE
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldMuzzles . ix 0 . mzPos .~ V2 25 0
alteRifle :: Item
alteRifle = rifle
& itType .~ HELD ALTERIFLE
& itUse . heldUseEffect .~ SwitchAlteRifle
& itAmmoSlots .~ IM.fromList (zip [0..1] $ repeat BulletAmmo)
--repeater :: Item
@@ -73,10 +68,6 @@ burstRifle =
& itType .~ HELD BURSTRIFLE
& itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 6
& itUse . heldMuzzles %~ doreplicate
where
doreplicate (x:_) = [x,x & mzFrame .~ 3,x & mzFrame .~ 6]
doreplicate [] = error "tried to replicate non-existing burstRifle muzzle"
miniGunX :: Int -> Item
miniGunX i =
+2 -2
View File
@@ -64,7 +64,7 @@ flameWall =
flameThrower :: Item
flameThrower =
defaultHeldItem
& itParams .~ NoParams
& itParams .~ NozzleAngle 0
& itUse . heldDelay .~ NoDelay
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldMuzzles .~ [Muzzle (V2 18 0) 0 0 0 NoFlare
@@ -72,7 +72,7 @@ flameThrower =
{ _nzPressure = ConstFloat 4
, _nzMaxWalkAngle = 0.2
, _nzWalkSpeed = 0.01
, _nzCurrentWalkAngle = 0
-- , _nzCurrentWalkAngle = 0
}
(UseExactly 1)
0
+1 -2
View File
@@ -45,8 +45,7 @@ doWdWd we = case we of
MakeTempLight x t -> (cWorld . lWorld . lights .:~ x)
. (cWorld . lWorld . worldEvents .:~ MakeTempLight x (t-1))
UseInvItem invid pt -> \w -> fromMaybe w (useItem invid pt w)
WdWdBurstFireRepeats cid invid -> \w -> fromMaybe w $ do
-- undefined
WdWdBurstFireRepetition cid invid -> \w -> fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix cid
itree <- bimap _iatType (^. _1) <$>
allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT