Add z levels to shockwaves

This commit is contained in:
2025-08-05 08:30:57 +01:00
parent 09428f2707
commit 22dafda9bd
12 changed files with 27 additions and 39 deletions
-2
View File
@@ -138,7 +138,6 @@ makeFragBullets p w = w & cWorld . lWorld . bullets .++~ bus
& buDrag .~ 0.8 & buDrag .~ 0.8
& buPos .~ p & buPos .~ p
& buOldPos .~ p & buOldPos .~ p
& buWidth .~ 1
makeFlak :: Bullet -> Point2 -> World -> World makeFlak :: Bullet -> Point2 -> World -> World
makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs] makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs]
@@ -148,7 +147,6 @@ makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs]
f x = f x =
bu & buVel %~ g x bu & buVel %~ g x
& buPayload .~ BulPlain 25 & buPayload .~ BulPlain 25
& buWidth .~ 0.5
g x v = v +.+ x *.* normalizeV (vNormal v) g x v = v +.+ x *.* normalizeV (vNormal v)
hitEffFromBul :: World -> Bullet -> (World, Bullet) hitEffFromBul :: World -> Bullet -> (World, Bullet)
+1 -1
View File
@@ -11,4 +11,4 @@ drawBullet pt =
setLayer BloomLayer setLayer BloomLayer
. setDepth 20 . setDepth 20
. color (V4 200 200 200 2) . color (V4 200 200 200 2)
$ thickLine (_buWidth pt) [_buOldPos pt, _buPos pt] $ thickLine 2 [_buOldPos pt, _buPos pt]
+4 -4
View File
@@ -27,7 +27,7 @@ blinkActionMousePos cr w =
& blinkDistortions cpos p3 & blinkDistortions cpos p3
& cWorld . lWorld . creatures . ix cid . crPos .~ p3 & cWorld . lWorld . creatures . ix cid . crPos .~ p3
& blinkShockwave cid p3 & blinkShockwave cid p3
& inverseShockwaveAt cpos 40 2 2 & inverseShockwaveAt (cpos `v2z` 20) 40 2 2
where where
cid = _crID cr cid = _crID cr
p1 = w ^. cWorld . lWorld . lAimPos p1 = w ^. cWorld . lWorld . lAimPos
@@ -63,7 +63,7 @@ unsafeBlinkAction cr w
. blinkDistortions cpos mwp . blinkDistortions cpos mwp
. set (cWorld . lWorld . creatures . ix cid . crPos) mwp . set (cWorld . lWorld . creatures . ix cid . crPos) mwp
. blinkShockwave cid mwp . blinkShockwave cid mwp
$ inverseShockwaveAt cpos 40 2 2 w $ inverseShockwaveAt (cpos `v2z` 20) 40 2 2 w
| otherwise = | otherwise =
w w
& blinkActionFail cr & blinkActionFail cr
@@ -82,7 +82,7 @@ blinkShockwave ::
Point2 -> Point2 ->
World -> World ->
World World
blinkShockwave i p = makeShockwaveAt [i] p 60 1 2 cyan blinkShockwave i p = makeShockwaveAt [i] (p `v2z` 20) 60 1 2 cyan
-- | Like a blink action, but no ingoing distortion -- | Like a blink action, but no ingoing distortion
blinkActionFail :: blinkActionFail ::
@@ -94,7 +94,7 @@ blinkActionFail cr w =
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing & soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& cWorld . lWorld . distortions .:~ distortionBulge & cWorld . lWorld . distortions .:~ distortionBulge
& cWorld . lWorld . creatures . ix cid . crPos .~ p3 & cWorld . lWorld . creatures . ix cid . crPos .~ p3
& inverseShockwaveAt cpos 40 2 2 & inverseShockwaveAt (cpos `v2z` 20) 40 2 2
where where
distR = 120 distR = 120
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
+1 -1
View File
@@ -22,7 +22,7 @@ data Bullet = Bullet
, _buDrag :: Float , _buDrag :: Float
, _buPos :: Point2 , _buPos :: Point2
, _buOldPos :: Point2 , _buOldPos :: Point2
, _buWidth :: Float -- , _buWidth :: Float
} }
deriving (Show, Eq, Ord, Read) --Generic, Flat) deriving (Show, Eq, Ord, Read) --Generic, Flat)
+1 -1
View File
@@ -18,7 +18,7 @@ data Shockwave = Shockwave
{ _swColor :: Color { _swColor :: Color
, _swDirection :: ShockwaveDirection , _swDirection :: ShockwaveDirection
, _swInvulnerableCrs :: [Int] , _swInvulnerableCrs :: [Int]
, _swPos :: Point2 , _swPos :: Point3
, _swRad :: Float , _swRad :: Float
, _swDam :: Int , _swDam :: Int
, _swPush :: Float , _swPush :: Float
-2
View File
@@ -16,8 +16,6 @@ defaultBullet =
, _buDrag = 1 , _buDrag = 1
, _buPos = 0 , _buPos = 0
, _buOldPos = 0 , _buOldPos = 0
, _buWidth = 2
-- , _buDamages = basicBulDams
} }
--basicBulDams :: [Damage] --basicBulDams :: [Damage]
+2 -5
View File
@@ -8,7 +8,6 @@ import RandomHelp
import Control.Monad import Control.Monad
import Color import Color
import Dodge.WorldEvent.Shockwave import Dodge.WorldEvent.Shockwave
import Geometry.Vector3D
import Dodge.Data.World import Dodge.Data.World
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
@@ -27,8 +26,8 @@ makeShrapnelAt p' vel' w =
w w
& soundMultiFrom [Explosion 0, Explosion 1] p bangS Nothing & soundMultiFrom [Explosion 0, Explosion 1] p bangS Nothing
& cWorld . lWorld . worldEvents & cWorld . lWorld . worldEvents
.:~ MakeTempLight (LSParam (addZ 20 p) 150 (V3 0.8 0.8 0.8)) 20 .:~ MakeTempLight (LSParam p' 150 (V3 0.8 0.8 0.8)) 20
& makeShockwaveAt [] p 50 5 0 white & makeShockwaveAt [] p' 50 5 0 white
& cWorld . lWorld . bullets .++~ buls & cWorld . lWorld . bullets .++~ buls
where where
p = p' ^. _xy p = p' ^. _xy
@@ -44,5 +43,3 @@ makeShrapnelAt p' vel' w =
& buDrag .~ drag & buDrag .~ drag
& buPos .~ (p - v) & buPos .~ (p - v)
& buOldPos .~ (p - v) & buOldPos .~ (p - v)
-- & buDamages .~ [Damage PIERCING 10 0 0 0 $ PushBackDamage 2]
& buWidth .~ 1
+1 -2
View File
@@ -18,7 +18,6 @@ data PJStabiliser
| StabSpinIncrease | StabSpinIncrease
-- assumes the mscreen is in your inventory -- assumes the mscreen is in your inventory
-- TODO take into account creature aimstance positioning
createShell :: createShell ::
(Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float) ->
Maybe (NewInt ItmInt) -> Maybe (NewInt ItmInt) ->
@@ -37,7 +36,7 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
& cWorld . lWorld . projectiles . at i & cWorld . lWorld . projectiles . at i
?~ Shell ?~ Shell
{ _pjPos = pos `v2z` 20 { _pjPos = pos `v2z` 20
, _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 5 , _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 0
, _pjID = i , _pjID = i
, _pjDir = dir' , _pjDir = dir'
, _pjSpin = 0 , _pjSpin = 0
+3 -5
View File
@@ -1,14 +1,12 @@
module Dodge.Shockwave.Draw where module Dodge.Shockwave.Draw (drawShockwave) where
import Dodge.Data.Shockwave import Dodge.Data.Shockwave
import Geometry
import Picture import Picture
drawShockwave :: Shockwave -> Picture drawShockwave :: Shockwave -> Picture
drawShockwave sw = drawShockwave sw =
setDepth 20 setLayer BloomLayer
. setLayer BloomLayer . translate3 (_swPos sw)
. uncurryV translate (_swPos sw)
. color (_swColor sw) . color (_swColor sw)
$ thickCircle rad thickness $ thickCircle rad thickness
where where
+10 -12
View File
@@ -1,10 +1,8 @@
module Dodge.Shockwave.Update (updateShockwave) where module Dodge.Shockwave.Update (updateShockwave) where
import Linear.V3
import Dodge.Damage import Dodge.Damage
import Dodge.Creature.Radius
import Dodge.Data.World import Dodge.Data.World
import Geometry.Vector
import qualified IntMapHelp as IM
import LensHelp import LensHelp
updateShockwave :: World -> Shockwave -> (World, Maybe Shockwave) updateShockwave :: World -> Shockwave -> (World, Maybe Shockwave)
@@ -24,7 +22,9 @@ moveShockwave w sw
t = _swTimer sw t = _swTimer sw
tFraction = fromIntegral t / fromIntegral (_swMaxTime sw) tFraction = fromIntegral t / fromIntegral (_swMaxTime sw)
rad = r - (3 / 4) * r * tFraction rad = r - (3 / 4) * r * tFraction
doDams = damageInCircle (Explosive dam) p rad doDams
| (p ^. _z >= 0) && (p ^. _z < 25) = damageInCircle (Explosive dam) (p ^. _xy) rad
| otherwise = id
-- doDams w' = -- doDams w' =
-- over (cWorld . lWorld . creatures) (IM.map damCr) $ -- over (cWorld . lWorld . creatures) (IM.map damCr) $
-- foldl' -- foldl'
@@ -47,17 +47,15 @@ moveInverseShockwave ::
(World, Maybe Shockwave) (World, Maybe Shockwave)
moveInverseShockwave w sw moveInverseShockwave w sw
| t <= 0 = (w, Nothing) | t <= 0 = (w, Nothing)
| otherwise = (dams w, Just $ swTimer -~ 1 $ sw) | otherwise = (w, Just $ swTimer -~ 1 $ sw)
where where
p = _swPos sw
r = _swRad sw
t = _swTimer sw t = _swTimer sw
rad = r - 0.1 * r * fromIntegral (10 - t) -- rad = r - 0.1 * r * fromIntegral (10 - t)
dams = over (cWorld . lWorld . creatures) (IM.map damCr) -- . flip (foldr (damageBlocksBy 1)) hitBlocks -- dams = over (cWorld . lWorld . creatures) (IM.map damCr) -- . flip (foldr (damageBlocksBy 1)) hitBlocks
-- hitBlocks = wallsOnCirc' p rad $ wallsNearPoint' p w -- hitBlocks = wallsOnCirc' p rad $ wallsNearPoint' p w
damCr cr -- damCr cr
| dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr -- | dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
| otherwise = cr & crDamage .:~ Explosive 1 p -- | otherwise = cr & crDamage .:~ Explosive 1 p
--where --where
-- cpos = _crPos cr -- cpos = _crPos cr
+2 -2
View File
@@ -76,8 +76,8 @@ makeExplosionAt p' vel' w =
& soundStart (Explosion (w ^. cWorld . lWorld . lClock)) (p) bangS Nothing & soundStart (Explosion (w ^. cWorld . lWorld . lClock)) (p) bangS Nothing
& addFlames & addFlames
& cWorld . lWorld . worldEvents & cWorld . lWorld . worldEvents
.:~ MakeTempLight (LSParam (addZ 20 p) 150 (V3 1 0.5 0)) 20 .:~ MakeTempLight (LSParam (p') 150 (V3 1 0.5 0)) 20
& makeShockwaveAt [] p 50 50 1 white & makeShockwaveAt [] p' 50 50 1 white
where where
p = p' ^. _xy p = p' ^. _xy
fVs = fmap (`v2z` 0) $ replicateM 100 (randInCirc 1) & evalState $ _randGen w fVs = fmap (`v2z` 0) $ replicateM 100 (randInCirc 1) & evalState $ _randGen w
+2 -2
View File
@@ -13,7 +13,7 @@ makeShockwaveAt ::
-- | IDs of invulnerable creatures. -- | IDs of invulnerable creatures.
[Int] -> [Int] ->
-- | Center of shockwave. -- | Center of shockwave.
Point2 -> Point3 ->
-- | Maximal radius. -- | Maximal radius.
Float -> Float ->
-- | Damage caused per frame. -- | Damage caused per frame.
@@ -41,7 +41,7 @@ makeShockwaveAt is p rad dam push col =
{- Create a shockwave going from an outside circle into a center point. -} {- Create a shockwave going from an outside circle into a center point. -}
inverseShockwaveAt :: inverseShockwaveAt ::
Point2 -> -- Center position Point3 -> -- Center position
Float -> -- Radius Float -> -- Radius
Int -> -- Damage Int -> -- Damage
Float -> -- Push amount Float -> -- Push amount