This commit is contained in:
2025-06-04 21:53:50 +01:00
parent 62cac29a59
commit 37fafa9123
2 changed files with 33 additions and 77 deletions
+32 -73
View File
@@ -88,10 +88,12 @@ hammerCheck ::
World World
hammerCheck f pt it cr hammerCheck f pt it cr
| BurstTrigger is <- baseTriggerType (it ^. ldtValue) | BurstTrigger is <- baseTriggerType (it ^. ldtValue)
, pt == InitialPress = f it cr , pt == InitialPress =
f it cr
. (cWorld . lWorld . delayedEvents .++~ map g is) . (cWorld . lWorld . delayedEvents .++~ map g is)
| BurstTrigger {} <- baseTriggerType (it ^. ldtValue) | BurstTrigger{} <- baseTriggerType (it ^. ldtValue)
, pt /= InitialPress = id , pt /= InitialPress =
id
| t <- baseTriggerType (it ^. ldtValue) | t <- baseTriggerType (it ^. ldtValue)
, t == HammerTrigger || t == AlwaysSingleTrigger , t == HammerTrigger || t == AlwaysSingleTrigger
, isNothing $ lookup MakeAutoLink (it ^. ldtRight) , isNothing $ lookup MakeAutoLink (it ^. ldtRight)
@@ -103,8 +105,9 @@ hammerCheck f pt it cr
upitm x = upitm x =
it -- & ldtValue . itUse . heldParams . weaponRepeat .~ [] it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
& ldtValue . itUse . heldFrame .~ x & ldtValue . itUse . heldFrame .~ x
--g x = (x, WdWdBurstFireRepeats (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
--g x = (x, WdWdBurstFireRepeats (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
-- | Applies a world effect after an item use cooldown check. -- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
@@ -134,8 +137,9 @@ heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -
heldEffectMuzzles t cr w = heldEffectMuzzles t cr w =
doHeldUseEffect t cr $ doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew uncurry (applyCME (_ldtValue t) cr) cmew
-- & doWeaponRepetitions upitm cr
where where
-- & doWeaponRepetitions upitm cr
muzzles = t ^. ldtValue . itUse . heldMuzzles muzzles = t ^. ldtValue . itUse . heldMuzzles
--(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles --(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
(_, loadedmuzzles) = mapAccumR loadMuzzle t muzzles (_, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
@@ -191,7 +195,7 @@ applyCME itm cr cme
itemSidePush :: HeldItemType -> Float itemSidePush :: HeldItemType -> Float
itemSidePush = \case itemSidePush = \case
BANGSTICK {} -> 0 BANGSTICK{} -> 0
REWINDER -> 0 REWINDER -> 0
TIMESTOPPER -> 0 TIMESTOPPER -> 0
TIMESCROLLER -> 0 TIMESCROLLER -> 0
@@ -201,7 +205,7 @@ itemSidePush = \case
SMG -> 30 SMG -> 30
BANGCONE -> 0 BANGCONE -> 0
BLUNDERBUSS -> 0 BLUNDERBUSS -> 0
GRAPECANNON {} -> 0 GRAPECANNON{} -> 0
MINIGUNX i -> 10 + fromIntegral i MINIGUNX i -> 10 + fromIntegral i
VOLLEYGUN{} -> 0 VOLLEYGUN{} -> 0
RIFLE -> 0 RIFLE -> 0
@@ -234,11 +238,11 @@ itemSidePush = \case
BLINKERUNSAFE -> 0 BLINKERUNSAFE -> 0
applyInvLock :: Item -> Creature -> World -> World applyInvLock :: Item -> Creature -> World -> World
applyInvLock itm cr applyInvLock itm cr
| i <- itemInvLock itm | i <- itemInvLock itm
, i > 0 = , i > 0 =
(cWorld . lWorld . delayedEvents .:~ (i, UnlockInv cid)) (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv cid))
. lockInv cid . lockInv cid
| otherwise = id | otherwise = id
where where
cid = _crID cr cid = _crID cr
@@ -266,9 +270,9 @@ applySoundCME itm cr = fromMaybe id $ do
cid = _crID cr cid = _crID cr
applyRecoil :: Item -> Creature -> World -> World applyRecoil :: Item -> Creature -> World -> World
applyRecoil itm cr = cWorld . lWorld . creatures . ix (_crID cr) . crPos +~ pushback applyRecoil itm cr =
where cWorld . lWorld . creatures . ix (_crID cr) . crPos
pushback = rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0) +~ rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0)
recoilAmount :: Item -> Float recoilAmount :: Item -> Float
recoilAmount itm recoilAmount itm
@@ -368,24 +372,19 @@ applySidePush :: Float -> Creature -> World -> World
applySidePush 0 _ w = w applySidePush 0 _ w = w
applySidePush maxSide cr w = applySidePush maxSide cr w =
w w
& cWorld . lWorld . creatures . ix cid %~ push & cWorld . lWorld . creatures . ix cid . crPos +~ push
& randGen .~ g & randGen .~ g
where where
cid = _crID cr cid = _crID cr
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr))) push = rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr))
(pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w (pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w
applyTorqueCME :: Item -> Creature -> World -> World applyTorqueCME :: Item -> Creature -> World -> World
applyTorqueCME itm cr w applyTorqueCME itm cr w =
| cid == 0 = w
w & cWorld . lWorld . creatures . ix cid . crDir +~ rot
& wCam . camRot -~ rot & randGen .~ g
& cWorld . lWorld . creatures . ix cid . crDir +~ rot & if cid == 0 then wCam . camRot -~ rot else id
& randGen .~ g
| otherwise =
w
& cWorld . lWorld . creatures . ix cid . crDir +~ rot
& randGen .~ g
where where
cid = _crID cr cid = _crID cr
(rot, g) = randomR (- torque, torque) $ _randGen w (rot, g) = randomR (- torque, torque) $ _randGen w
@@ -685,16 +684,6 @@ shootLaser so lt pv p dir col w =
} }
& soundContinue so p tone440sawtoothquietS (Just 2) & soundContinue so p tone440sawtoothquietS (Just 2)
--lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> Laser
--lasRayAt col dam phasev pos dir =
-- Laser
-- { _lpType = DamageLaser dam
-- , _lpPhaseV = phasev
-- , _lpPos = pos
-- , _lpDir = dir
-- , _lpColor = col
-- }
removeAmmoFromMag :: Int -> Maybe Int -> Creature -> World -> World removeAmmoFromMag :: Int -> Maybe Int -> Creature -> World -> World
removeAmmoFromMag x mid cr = fromMaybe id $ do removeAmmoFromMag x mid cr = fromMaybe id $ do
magid <- mid magid <- mid
@@ -708,9 +697,7 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
. iaLoaded . iaLoaded
-~ x -~ x
getBulletType :: getBulletType :: LabelDoubleTree ComposeLinkType Item -> Maybe Bullet
LabelDoubleTree ComposeLinkType Item ->
Maybe Bullet
getBulletType magtree = getBulletType magtree =
magtree ^? ldtValue . itConsumables . magParams . ampBullet magtree ^? ldtValue . itConsumables . magParams . ampBullet
-- <&> buTrajectory .~ btraj -- <&> buTrajectory .~ btraj
@@ -776,7 +763,7 @@ makeBullet' bu itm cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
itemRandomOffset :: HeldItemType -> Float itemRandomOffset :: HeldItemType -> Float
itemRandomOffset = \case itemRandomOffset = \case
BANGSTICK {} -> 0 BANGSTICK{} -> 0
REWINDER -> 0 REWINDER -> 0
TIMESTOPPER -> 0 TIMESTOPPER -> 0
TIMESCROLLER -> 0 TIMESCROLLER -> 0
@@ -787,7 +774,7 @@ itemRandomOffset = \case
BANGCONE -> 12 BANGCONE -> 12
BLUNDERBUSS -> 12 BLUNDERBUSS -> 12
GRAPECANNON i -> 12 + 4 * fromIntegral i GRAPECANNON i -> 12 + 4 * fromIntegral i
MINIGUNX {} -> 10 MINIGUNX{} -> 10
VOLLEYGUN{} -> 0 VOLLEYGUN{} -> 0
RIFLE -> 0 RIFLE -> 0
ALTERIFLE -> 0 ALTERIFLE -> 0
@@ -818,7 +805,6 @@ itemRandomOffset = \case
BLINKER -> 0 BLINKER -> 0
BLINKERUNSAFE -> 0 BLINKERUNSAFE -> 0
makeBullet :: Bullet -> Item -> Point2 -> Float -> World -> World makeBullet :: Bullet -> Item -> Point2 -> Float -> World -> World
makeBullet thebullet itm bulpos dir w = makeBullet thebullet itm bulpos dir w =
w & randGen .~ g'' w & randGen .~ g''
@@ -933,15 +919,9 @@ mcUseHeld hit = case hit of
useGasParams :: Maybe Int -> Muzzle -> Item -> Creature -> World -> World useGasParams :: Maybe Int -> Muzzle -> Item -> Creature -> World -> World
useGasParams mmagid mz itm cr w = useGasParams mmagid mz itm cr w =
createGas w
gastype & createGas gastype pressure pos dir cr
pressure & randGen .~ g'
pos
dir
cr
w
& randGen
.~ g'
where where
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w) (pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
gastype = fromMaybe (error "cannot find gas ammo") $ do gastype = fromMaybe (error "cannot find gas ammo") $ do
@@ -1004,29 +984,8 @@ doGenFloat :: RandomGen g => GenFloat -> g -> (Float, g)
doGenFloat (ConstFloat x) g = (x, g) doGenFloat (ConstFloat x) g = (x, g)
doGenFloat (UniRandFloat x y) g = randomR (x, y) g doGenFloat (UniRandFloat x y) g = randomR (x, y) g
--caneStickSoundChoice :: Item -> SoundID
--caneStickSoundChoice _ = tap3S
-- -- | (it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded) < 2 = tap3S
-- -- | otherwise = shotgunS
--bangStickSoundChoice :: Item -> SoundID
--bangStickSoundChoice = caneStickSoundChoice
-- do
-- wth <- state $ randomR (1, 5)
-- return (itUse . heldConsumption . laAmmoType . amBullet . buWidth .~ wth)
--coneRandItemParams :: State StdGen (Item -> Item)
--coneRandItemParams = do
-- muzv <- state $ randomR (0.5, 1)
-- rifl <- state $ randomR (0.3, 0.9)
-- return $ \it ->
-- it & itUse . heldParams . muzVel .~ muzv
-- & itUse . heldParams . rifling .~ rifl
mcShootLaser :: Item -> Machine -> World -> World mcShootLaser :: Item -> Machine -> World -> World
mcShootLaser _ mc = mcShootLaser _ mc =
--cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos dir
shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
where where
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
+1 -4
View File
@@ -15,10 +15,7 @@ bangCone =
defaultBulletWeapon defaultBulletWeapon
& itUse . heldDelay . rateMax .~ 20 & itUse . heldDelay . rateMax .~ 20
& itUse . heldMuzzles & itUse . heldMuzzles
.~ replicate .~ [Muzzle (V2 15 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 0]
15
(Muzzle (V2 15 0) 0 0.5 0 NoFlare MuzzleShootBullet (UseExactly 1) 0)
& itUse . heldMuzzles . ix 0 . mzFlareType .~ BasicFlare
& itType .~ HELD BANGCONE & itType .~ HELD BANGCONE
blunderbuss :: Item blunderbuss :: Item