From c4b9142d0f92633d51baa322d118597170c55af8 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 24 Dec 2024 14:54:32 +0000 Subject: [PATCH] Tweak explosions --- src/Dodge/Barreloid.hs | 2 +- src/Dodge/EnergyBall.hs | 8 +++++++- src/Dodge/Machine/Destroy.hs | 2 +- src/Dodge/Payload.hs | 4 ++-- src/Dodge/PressPlate.hs | 2 +- src/Dodge/Projectile/Update.hs | 4 +--- src/Dodge/SelectUse.hs | 2 +- src/Dodge/WorldEvent/Explosion.hs | 9 +++++---- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Dodge/Barreloid.hs b/src/Dodge/Barreloid.hs index 2930a9cba..8380503a6 100644 --- a/src/Dodge/Barreloid.hs +++ b/src/Dodge/Barreloid.hs @@ -19,7 +19,7 @@ updateBarreloid cr = case cr ^?! crType . barrelType of updateExpBarrel :: Creature -> World -> World updateExpBarrel cr w | _crHP cr > 0 = foldl' (flip ($)) (hiss w & cWorld . lWorld . creatures . at (_crID cr) .~ newCr) pierceSparks - | otherwise = makeExplosionAt (_crPos cr) $ stopSounds w & cWorld . lWorld . creatures . at (_crID cr) .~ Nothing + | otherwise = makeExplosionAt (_crPos cr) 0 $ stopSounds w & cWorld . lWorld . creatures . at (_crID cr) .~ Nothing where g = _randGen w damages = _csDamage $ _crState cr diff --git a/src/Dodge/EnergyBall.hs b/src/Dodge/EnergyBall.hs index 1966011b8..41b3b542d 100644 --- a/src/Dodge/EnergyBall.hs +++ b/src/Dodge/EnergyBall.hs @@ -5,6 +5,8 @@ module Dodge.EnergyBall , makeFlamelet ) where +import Dodge.Base.Collide +import Data.Maybe import Dodge.DamageCircle import Dodge.Data.World import Geometry @@ -47,8 +49,12 @@ updateEnergyBall w eb | _ebTimer eb <= 0 = (w, Nothing) | otherwise = ( ebFlicker eb $ uncurry (damageCircle 5 (_ebPos eb)) (_ebEff eb) w - , Just $ eb & ebTimer -~ 1 & ebPos .+.+~ _ebVel eb & ebVel .*.*~ 0.9 +-- , Just $ eb & ebTimer -~ 1 & ebPos .+.+~ _ebVel eb & ebVel .*.*~ 0.9 + , Just $ eb & ebTimer -~ 1 & ebPos .~ bp & ebVel .~ 0.7 * bv ) + where + p = eb ^. ebPos + eb ^. ebVel + (bp,bv) = fromMaybe (p,eb^.ebVel) $ bouncePoint (const True) 0 (eb ^. ebPos) p w incBallAt :: Point2 -> World -> World incBallAt p w = diff --git a/src/Dodge/Machine/Destroy.hs b/src/Dodge/Machine/Destroy.hs index ca98d5cb9..99c6bb467 100644 --- a/src/Dodge/Machine/Destroy.hs +++ b/src/Dodge/Machine/Destroy.hs @@ -13,7 +13,7 @@ destroyMachine :: Machine -> World -> World destroyMachine mc = (cWorld . lWorld . machines %~ IM.delete (_mcID mc)) . deleteWallIDs (_mcWallIDs mc) - . makeExplosionAt (_mcPos mc) + . makeExplosionAt (_mcPos mc) 0 . mcKillTerm mc . mcKillBut mc . destroyMcType (mc ^. mcType) mc diff --git a/src/Dodge/Payload.hs b/src/Dodge/Payload.hs index bc34877d9..61e0906b5 100644 --- a/src/Dodge/Payload.hs +++ b/src/Dodge/Payload.hs @@ -4,7 +4,7 @@ import Dodge.Data.World import Dodge.WorldEvent.Explosion import Geometry.Data -usePayload :: Payload -> Point2 -> World -> World +usePayload :: Payload -> Point2 -> Point2 -> World -> World usePayload payload = case payload of ExplosionPayload -> makeExplosionAt - DudPayload -> const id + DudPayload -> const (const id) diff --git a/src/Dodge/PressPlate.hs b/src/Dodge/PressPlate.hs index 83297ee63..b6e58a7b7 100644 --- a/src/Dodge/PressPlate.hs +++ b/src/Dodge/PressPlate.hs @@ -12,5 +12,5 @@ doPressPlateEvent ppe = case ppe of ppLevelReset :: PressPlate -> World -> World ppLevelReset pp w - | dist (_crPos $ you w) (_ppPos pp) < 20 = makeExplosionAt (_ppPos pp) w + | dist (_crPos $ you w) (_ppPos pp) < 20 = makeExplosionAt (_ppPos pp) 0 w | otherwise = w diff --git a/src/Dodge/Projectile/Update.hs b/src/Dodge/Projectile/Update.hs index 43580611b..757b39fd8 100644 --- a/src/Dodge/Projectile/Update.hs +++ b/src/Dodge/Projectile/Update.hs @@ -156,9 +156,7 @@ explodeShell mitid pjid w = w & cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU mitid 30] & cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile --- & itPoint . itUse . heldUse .~ HeldDoNothing --- & itPoint . itUse . heldMods .~ DoNothingMod - & usePayload (_prjPayload thepj) (_prjPos thepj) + & usePayload (_prjPayload thepj) (_prjPos thepj) (_prjVel thepj) & stopSoundFrom (ShellSound pjid) where -- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid diff --git a/src/Dodge/SelectUse.hs b/src/Dodge/SelectUse.hs index 5bd221091..549fd3624 100644 --- a/src/Dodge/SelectUse.hs +++ b/src/Dodge/SelectUse.hs @@ -22,7 +22,7 @@ selectUse itm _ w = fromMaybe w $ do & cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile -- & itPoint . itUse . heldUse .~ HeldDoNothing -- & itPoint . itUse . heldMods .~ DoNothingMod - & usePayload (_prjPayload thepj) (_prjPos thepj) + & usePayload (_prjPayload thepj) (_prjPos thepj) (_prjVel thepj) where notdestroyed DestroyPU{} = False notdestroyed _ = True diff --git a/src/Dodge/WorldEvent/Explosion.hs b/src/Dodge/WorldEvent/Explosion.hs index 51e083950..f1e00f074 100644 --- a/src/Dodge/WorldEvent/Explosion.hs +++ b/src/Dodge/WorldEvent/Explosion.hs @@ -70,8 +70,8 @@ makeFlameExplosionAt p w = -- the ( Nthing :: Maybe Int ) here is "maybe" a creature id that the -- particle passes through for the first frame of its existence -makeExplosionAt :: Point2 -> World -> World -makeExplosionAt p w = +makeExplosionAt :: Point2 -> Point2 -> World -> World +makeExplosionAt p vel w = w & soundMultiFrom [Explosion 0, Explosion 1] p bangS Nothing & addFlames @@ -93,8 +93,9 @@ makeExplosionAt p w = fVs' = zipWith (+.+) fVs $ map inversePushOut fPs' sizes = randomRs (2, 9) $ _randGen w times = randomRs (15, 20) $ _randGen w - mF q z v size time = makeFlamelet q z v size time - newFs = zipWith5 mF fPs zs (fmap (3 *.*) fVs') sizes times + mF q z v size time = makeFlamelet (q - vel) z (v + vel) size time + --newFs = zipWith5 mF fPs zs (fmap (3 *.*) fVs') sizes times + newFs = zipWith4 (mF p) zs (zipWith ((+) . xyV3) fPs'' (fmap (3 *.*) fVs')) sizes times addFlames w' = foldl' (flip ($)) w' newFs --pushAgainstWalls q = maybe q (uncurry (+.+)) $ reflectPointWalls p q wls --pushAgainstWalls q = maybe q fst $ reflectPointWalls p q wls