Add sounds

This commit is contained in:
2025-12-26 20:45:24 +00:00
parent 60a69d0092
commit 2fd4a3d2e3
18 changed files with 687 additions and 606 deletions
+81 -30
View File
@@ -1,8 +1,7 @@
--{-# LANGUAGE LambdaCase #-}
--{-# OPTIONS_GHC -Wno-unused-imports #-}
-- {-# LANGUAGE LambdaCase #-}
-- {-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.Projectile.Update (updateProjectile) where
import Dodge.WorldEvent.Cloud
import Control.Monad
import Data.List (delete)
import Data.Maybe
@@ -14,7 +13,8 @@ import Dodge.Item.Location
import Dodge.Movement.Turn
import Dodge.Payload
import Dodge.SoundLogic
--import Dodge.WorldEvent.Cloud
import Dodge.WorldEvent.Cloud
-- import Dodge.WorldEvent.Cloud
import Dodge.WorldEvent.Sound
import Geometry
import qualified IntMapHelp as IM
@@ -50,7 +50,7 @@ applyGravityPU pj
shellExplosionCheck :: Projectile -> World -> World
shellExplosionCheck pj
| RetiredProjectile <- pj ^. pjType
, timeout =
, timeout =
destroyProjectile pj
| timeout = explodeShell pj
| otherwise = id
@@ -63,7 +63,7 @@ shellHitWall p n wl pj
(topj . pjType .~ Grenade (GStuckWall (wl ^. wlStructure)))
. stickHitSound pj
| Just x <- pj ^? pjType . gnHitEffect . bounceTolerance
, abs (dot (pj ^. pjVel) (normalize n)) < x =
, abs (dot (pj ^. pjVel) (normalize n)) < x =
(topj . pjVel %~ reflectInNormal n)
. (topj . pjPos .~ p + normalize n)
. bounceSound pj
@@ -76,7 +76,10 @@ bounceSound pj = soundStart (ShellSound (pj ^. pjID)) (pj ^. pjPos . _xy) click1
stickHitSound :: Projectile -> World -> World
stickHitSound pj =
soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy)
soundOriginIDsAt
(ShellSound (pj ^. pjID))
[slapS, slap1S, slap2S, slap3S, slap4S, slap5S, slap6S, slap7S]
(pj ^. pjPos . _xy)
shellHitCreature :: Point3 -> Creature -> Projectile -> World -> World
shellHitCreature p cr pj
@@ -89,7 +92,7 @@ shellHitCreature p cr pj
gren =
GStuckCreature
(cr ^. crID)
(rotate3z (- cr ^. crDir) (p - cr ^. crPos))
(rotate3z (-cr ^. crDir) (p - cr ^. crPos))
(pj ^. pjDir - cr ^. crDir)
shellHitFloor :: Point3 -> Projectile -> World -> World
@@ -129,8 +132,15 @@ tryThrust pj = fromMaybe id $ do
doThrust :: Projectile -> Maybe RocketSmoke -> World -> World
doThrust pj smoke w =
w
& randGen .~ g
& cWorld . lWorld . projectiles . ix i . pjVel . _xy %~ (\v -> accel + frict *^ v)
& randGen
.~ g
& cWorld
. lWorld
. projectiles
. ix i
. pjVel
. _xy
%~ (\v -> accel + frict *^ v)
& soundContinue (ShellSound i) (ep ^. _xy) missileLaunchS (Just 1)
& makeFlamelet
(sp - 0.5 *^ vel)
@@ -157,15 +167,28 @@ doThrust pj smoke w =
doBarrelSpin :: Int -> Float -> Projectile -> World -> World
doBarrelSpin cid i pj w =
w & cWorld . lWorld . projectiles . ix pjid . pjSpin .~ newSpin
& cWorld . lWorld . projectiles . ix pjid . pjBarrelSpin .~ Nothing
w
& cWorld
. lWorld
. projectiles
. ix pjid
. pjSpin
.~ newSpin
& cWorld
. lWorld
. projectiles
. ix pjid
. pjBarrelSpin
.~ Nothing
where
pjid = _pjID pj
dir = argV $ pj ^. pjVel . _xy
newSpin = case w ^? cWorld . lWorld . creatures . ix cid of
Just cr ->
negate $
min 0.2 $ max (-0.2) $ normalizeAnglePi (dir - _crDir cr) / spinFactor
min 0.2 $
max (-0.2) $
normalizeAnglePi (dir - _crDir cr) / spinFactor
_ -> 0
spinFactor = 5 * (6 - i)
@@ -176,17 +199,25 @@ pjRemoteSetDirection ph pj w = case ph of
| lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
== lw ^? items . ix (_unNInt screenid) . itLocation . ilInvID ->
w
& pjlens . pjDir .~ mousedir
& pjlens . pjSpin .~ 0.5 * diffAngles mousedir pjdir
& pjlens
. pjDir
.~ mousedir
& pjlens
. pjSpin
.~ 0.5
* diffAngles mousedir pjdir
HomeUsingTargeting itid
| Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just ->
w
& pjlens . pjDir %~ turnTo 0.2 (pj ^. pjPos . _xy) tp
& pjlens . pjSpin
.~ 0.5
* diffAngles
(turnTo 0.2 (pj ^. pjPos . _xy) tp pjdir)
pjdir
& pjlens
. pjDir
%~ turnTo 0.2 (pj ^. pjPos . _xy) tp
& pjlens
. pjSpin
.~ 0.5
* diffAngles
(turnTo 0.2 (pj ^. pjPos . _xy) tp pjdir)
pjdir
_ -> w
where
pjdir = pj ^. pjDir
@@ -201,9 +232,17 @@ moveStuckGrenade cid poff d pj w = fromMaybe (w & pjlens . pjType .~ Grenade GSt
cdir = cr ^. crDir
return $
w
& pjlens . pjPos . _xy .~ xyV3 (cpos + rotate3z cdir poff)
& pjlens . pjDir .~ d + cdir
& pjlens . pjVel .~ (cpos - cr ^. crOldPos)
& pjlens
. pjPos
. _xy
.~ xyV3 (cpos + rotate3z cdir poff)
& pjlens
. pjDir
.~ d
+ cdir
& pjlens
. pjVel
.~ (cpos - cr ^. crOldPos)
where
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
@@ -219,9 +258,15 @@ moveProjectile pj w
(_, Just (_, OChasmWall)) -> w & pjlens . pjTimer .~ 0 -- no stick or bounce for now
_ ->
w
& pjlens . pjSpin *~ 0.99
& pjlens . pjPos +~ _pjVel pj
& pjlens . pjDir +~ _pjSpin pj
& pjlens
. pjSpin
*~ 0.99
& pjlens
. pjPos
+~ _pjVel pj
& pjlens
. pjDir
+~ _pjSpin pj
where
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
sp = _pjPos pj
@@ -229,9 +274,15 @@ moveProjectile pj w
explodeShell :: Projectile -> World -> World
explodeShell pj w =
w
& pjlens . pjType .~ RetiredProjectile
& pjlens . pjVel .~ 0
& pjlens . pjTimer .~ 30
& pjlens
. pjType
.~ RetiredProjectile
& pjlens
. pjVel
.~ 0
& pjlens
. pjTimer
.~ 30
& usePayload (_pjPayload pj) (pj ^. pjPos) (pj ^. pjVel)
& stopSoundFrom (ShellSound pjid)
& updatedetonator