Reduce positional effect on sounds

This commit is contained in:
2025-06-02 11:13:19 +01:00
parent b442001246
commit 6706ac494a
4 changed files with 163 additions and 153 deletions
+33 -29
View File
@@ -188,9 +188,10 @@ applyInvLock itm cr = case itm ^? itUse . heldParams . weaponInvLock of
applySoundCME :: Item -> Creature -> World -> World
applySoundCME itm cr = fromMaybe id $ do
(soundid, x) <- itm ^? itUse . heldParams . bulGunSound . _Just
return $ if x > 0
then soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid (Just x)
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 5]] (_crPos cr) soundid Nothing
return $
if x > 0
then soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid (Just x)
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 5]] (_crPos cr) soundid Nothing
where
cid = _crID cr
@@ -406,7 +407,8 @@ walkNozzle mzid mz itm cr w = fromMaybe w $ do
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
shootTractorBeam :: Creature -> World -> World
shootTractorBeam cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
shootTractorBeam cr w =
w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
& soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2)
where
cpos = _crPos cr
@@ -433,19 +435,18 @@ creatureShootLaser ::
Muzzle ->
World ->
World
creatureShootLaser itmtree cr mz w = w
creatureShootLaser itmtree cr mz w =
w
& randGen .~ g
& shootLaser (CrWeaponSound (_crID cr) 0) (getLaserDamage itmtree)
(getLaserPhaseV itmtree) pos dir (getLaserColor itmtree)
-- & cWorld . lWorld . lasers
-- .:~ Laser
-- { _lpType = getLaserDamage itmtree
-- , _lpPhaseV = getLaserPhaseV itmtree
-- , _lpPos = pos
-- , _lpDir = dir
-- , _lpColor = getLaserColor itmtree
-- }
& shootLaser
(CrWeaponSound (_crID cr) 0)
(getLaserDamage itmtree)
(getLaserPhaseV itmtree)
pos
dir
(getLaserColor itmtree)
where
itm = itmtree ^. ldtValue
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
pos = _crPos cr + rotateV (_crDir cr) moff
@@ -462,24 +463,27 @@ shootLaser ::
Color ->
World ->
World
shootLaser so lt pv p dir col w = w & cWorld . lWorld . lasers .:~ Laser
shootLaser so lt pv p dir col w =
w
& cWorld . lWorld . lasers
.:~ Laser
{ _lpType = lt
, _lpPhaseV = pv
, _lpPos = p
, _lpDir = dir
, _lpColor = col
}
& 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
}
--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 x mid cr = fromMaybe id $ do
@@ -643,12 +647,12 @@ doGenFloat (UniRandFloat x y) g = randomR (x, y) g
-- & itUse . heldParams . rifling .~ rifl
mcShootLaser :: Item -> Machine -> World -> World
mcShootLaser _ mc = cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos dir
mcShootLaser _ mc =
--cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos dir
shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
where
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
dir = mc ^?! mcType . _McTurret . tuDir
phasev = 1
dam = 11
mcShootAuto :: Item -> Machine -> World -> World
mcShootAuto itm mc w