Rethink weapon repetitions

This commit is contained in:
2025-06-04 21:03:25 +01:00
parent 9797f610aa
commit 62cac29a59
7 changed files with 166 additions and 187 deletions
-14
View File
@@ -33,7 +33,6 @@ data ItemUse
= UseHeld
{ _heldDelay :: UseDelay
, _heldMuzzles :: [Muzzle]
-- , _heldParams :: HeldParams
, _heldFrame :: Int
, _heldUseEffect :: HeldUseEffect
}
@@ -73,13 +72,6 @@ data AttachParams
| APNothing
deriving (Eq, Show, Read)
--data HeldParams
-- = DefaultHeldParams
-- | GasSprayParams { _weaponInvLock :: Int }
-- | BeamShooterParams
-- | BulletShooterParams { _weaponInvLock :: Int }
-- deriving (Eq, Show, Read) --Generic, Flat)
data AmmoParams
= BulletParams {_ampBullet :: Bullet}
| ProjectileParams {_ampPayload :: Payload}
@@ -146,10 +138,7 @@ data Muzzle = Muzzle
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''ItemUse
--makeLenses ''AimParams
makeLenses ''Muzzle
--makeLenses ''HeldParams
makeLenses ''AttachParams
makeLenses ''AmmoParams
makeLenses ''MuzzleEffect
@@ -163,10 +152,7 @@ deriveJSON defaultOptions ''UseCondition
deriveJSON defaultOptions ''MuzzleEffect
deriveJSON defaultOptions ''FlareType
deriveJSON defaultOptions ''AmmoParams
--deriveJSON defaultOptions ''HeldParams
deriveJSON defaultOptions ''AmmoPerShot
deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AttachParams
--deriveJSON defaultOptions ''AimParams
deriveJSON defaultOptions ''ItemUse
+1
View File
@@ -35,6 +35,7 @@ data WdWd
| WdWdFromItCrixWdWd (LabelDoubleTree ComposeLinkType Item) Int ItCrWdWd
| MakeTempLight LSParam Int
| UseInvItem Int PressType
| WdWdBurstFireRepeats Int Int
--deriving (Eq, Show, Read) --, Generic)
--h--deriving (Eq, Show, Read) --Generic, Flat)
+7 -4
View File
@@ -90,6 +90,8 @@ hammerCheck f pt it cr
| BurstTrigger is <- baseTriggerType (it ^. ldtValue)
, pt == InitialPress = f it cr
. (cWorld . lWorld . delayedEvents .++~ map g is)
| BurstTrigger {} <- baseTriggerType (it ^. ldtValue)
, pt /= InitialPress = id
| t <- baseTriggerType (it ^. ldtValue)
, t == HammerTrigger || t == AlwaysSingleTrigger
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
@@ -101,8 +103,8 @@ hammerCheck f pt it cr
upitm x =
it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
& ldtValue . itUse . heldFrame .~ x
--g x = (x, WdWdBurstFireRepeats (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
@@ -135,7 +137,8 @@ heldEffectMuzzles t cr w =
-- & doWeaponRepetitions upitm cr
where
muzzles = t ^. ldtValue . itUse . heldMuzzles
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
--(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
@@ -263,9 +266,9 @@ applySoundCME itm cr = fromMaybe id $ do
cid = _crID cr
applyRecoil :: Item -> Creature -> World -> World
applyRecoil itm cr = cWorld . lWorld . creatures . ix (_crID cr) %~ pushback
applyRecoil itm cr = cWorld . lWorld . creatures . ix (_crID cr) . crPos +~ pushback
where
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0))
pushback = rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0)
recoilAmount :: Item -> Float
recoilAmount itm
-8
View File
@@ -15,8 +15,6 @@ import Dodge.Data.Item
import Dodge.Default.Item
import Linear
--import Geometry.Data
flatShield :: Item
flatShield =
defaultHeldItem
@@ -39,9 +37,7 @@ detector dt =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldParams .~ DefaultHeldParams
& itType .~ DETECTOR dt
& itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleDetector
& itUse . heldMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 100
@@ -51,9 +47,7 @@ blinker =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldParams .~ DefaultHeldParams
& itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleBlink
& itUse . heldMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 10000000
& itType .~ HELD BLINKER
@@ -64,8 +58,6 @@ unsafeBlinker =
& itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleUnsafeBlink
& itType .~ HELD BLINKERUNSAFE
-- & itUse . uequipEffect . eeViewDist ?~ 400
rewinder :: Item
rewinder =
blinker
+6
View File
@@ -5,6 +5,7 @@ module Dodge.WorldEffect (
lineOutputTerminal,
) where
import Dodge.Item.Grammar
import Dodge.Creature.Impulse.UseItem
import Dodge.BlBl
import Dodge.Data.Input
@@ -44,6 +45,11 @@ 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
cr <- w ^? cWorld . lWorld . creatures . ix cid
itree <- bimap _iatType (^. _1) <$>
allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
return $ heldEffectNoHammerCheck itree cr w
doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doItCrWdWd icww = case icww of