Randomise volleygun muzzle order

This commit is contained in:
2024-12-21 19:10:34 +00:00
parent 17cb1d8ff8
commit 84821a1531
9 changed files with 326 additions and 297 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
-5
View File
@@ -63,11 +63,6 @@ data CraftType
| WIRE | WIRE
| FUELCELL | FUELCELL
| PORTABLEFUSION | PORTABLEFUSION
-- | FRAGMODULE
-- | FLASHMODULE
-- | GASINJECTOR
-- | FLAKCRAFT
-- | FRAGCRAFT
deriving (Eq, Ord, Show, Read, Enum, Bounded) deriving (Eq, Ord, Show, Read, Enum, Bounded)
data AttachType data AttachType
+8
View File
@@ -40,6 +40,7 @@ data ItemUse
, _heldParams :: HeldParams , _heldParams :: HeldParams
, _heldTriggerType :: TriggerType , _heldTriggerType :: TriggerType
, _heldFrame :: Int , _heldFrame :: Int
, _heldUseEffect :: HeldUseEffect
} }
| UseEquip { _uequipEffect :: EquipEffect } | UseEquip { _uequipEffect :: EquipEffect }
| UseAttach {_uaParams :: AttachParams} | UseAttach {_uaParams :: AttachParams}
@@ -48,6 +49,11 @@ data ItemUse
| UseBulletMod { _ubMod :: BulletMod } | UseBulletMod { _ubMod :: BulletMod }
deriving (Eq, Show, Read) deriving (Eq, Show, Read)
data HeldUseEffect
= NoHeldUseEffect
| RandomiseMuzzleFrames Int
deriving (Eq, Show, Read)
data UseFocus data UseFocus
= UseFromRoot = UseFromRoot
| UseFromLocation | UseFromLocation
@@ -202,6 +208,8 @@ makeLenses ''MuzzleEffect
makeLenses ''AmmoPerShot makeLenses ''AmmoPerShot
makeLenses ''UseCondition makeLenses ''UseCondition
makeLenses ''UseFocus makeLenses ''UseFocus
makeLenses ''HeldUseEffect
deriveJSON defaultOptions ''HeldUseEffect
deriveJSON defaultOptions ''UseFocus deriveJSON defaultOptions ''UseFocus
deriveJSON defaultOptions ''UseCondition deriveJSON defaultOptions ''UseCondition
deriveJSON defaultOptions ''MuzzleEffect deriveJSON defaultOptions ''MuzzleEffect
@@ -43,6 +43,8 @@ data AmmoType
| ElectricalAmmo | ElectricalAmmo
| DroneAmmo | DroneAmmo
| GasAmmo | GasAmmo
| PrintMaterial
| ExplosivePutty
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data ForceFieldType = DefaultForceField data ForceFieldType = DefaultForceField
+1
View File
@@ -41,4 +41,5 @@ defaultHeldUse = UseHeld
} }
, _heldTriggerType = HammerTrigger , _heldTriggerType = HammerTrigger
, _heldFrame = 0 , _heldFrame = 0
, _heldUseEffect = NoHeldUseEffect
} }
+12
View File
@@ -82,6 +82,7 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w = heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew uncurry (applyCME (_ldtValue t) cr) cmew
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles -- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr & doWeaponRepetitions upitm cr
@@ -90,6 +91,17 @@ heldEffectMuzzles t cr w =
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles (upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
cmew = foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles 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
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 . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
& randGen .~ g'
Just NoHeldUseEffect -> w
Nothing -> w
-- need to be careful about inventory lock or item ids here -- need to be careful about inventory lock or item ids here
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
+1
View File
@@ -49,6 +49,7 @@ volleyGun i =
& itType .~ HELD (VOLLEYGUN i) & itType .~ HELD (VOLLEYGUN i)
& itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo) & 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 rifle :: Item
rifle = rifle =
+14 -6
View File
@@ -6,11 +6,10 @@ module Dodge.Item.Held.Stick (
smg, smg,
) where ) where
import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Base import Dodge.Base
import Dodge.Data.Item import Dodge.Data.Item
import Dodge.Default.Item import Dodge.Default.Item
--import Dodge.Reloading.Action import Dodge.SoundLogic.ExternallyGeneratedSounds
import Geometry import Geometry
import LensHelp import LensHelp
@@ -22,8 +21,17 @@ bangStick i =
& itType .~ HELD (BANGSTICK i) & itType .~ HELD (BANGSTICK i)
& itUse . heldDelay . rateMax .~ 8 & itUse . heldDelay . rateMax .~ 8
& itUse . heldAim . aimMuzzles & itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType MuzzleShootBullet (UseExactly 1) 0 .~ [ Muzzle
| a <- spreadAroundCenter i baseStickSpread] (V2 10 0)
a
0.01
0
DefaultFlareType
MuzzleShootBullet
(UseExactly 1)
0
| a <- spreadAroundCenter i baseStickSpread
]
baseStickSpread :: Float baseStickSpread :: Float
baseStickSpread = 0.2 baseStickSpread = 0.2
@@ -48,13 +56,13 @@ autoPistol :: Item
autoPistol = autoPistol =
pistol pistol
& itUse . heldTriggerType .~ AutoTrigger & itUse . heldTriggerType .~ AutoTrigger
& itUse . heldParams . bulGunSound ?~ (tap1S,0) & itUse . heldParams . bulGunSound ?~ (tap1S, 0)
& itType .~ HELD AUTOPISTOL & itType .~ HELD AUTOPISTOL
machinePistol :: Item machinePistol :: Item
machinePistol = machinePistol =
autoPistol autoPistol
& itUse . heldDelay .~ WarmUpNoDelay {_warmTime = 0, _warmMax = 50, _warmSound = crankSlowS} & itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 50, _warmSound = crankSlowS}
& itType .~ HELD MACHINEPISTOL & itType .~ HELD MACHINEPISTOL
& itUse . heldParams . recoil .~ 20 & itUse . heldParams . recoil .~ 20
+286 -284
View File
File diff suppressed because it is too large Load Diff