Reduce positional effect on sounds
This commit is contained in:
+33
-29
@@ -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
|
||||
|
||||
@@ -8,7 +8,6 @@ module Dodge.Item.Held.BatteryGuns (
|
||||
import Control.Lens
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Default.Item
|
||||
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Geometry.Data
|
||||
|
||||
sparkGun :: Item
|
||||
@@ -69,7 +68,7 @@ laser =
|
||||
tractorGun :: Item
|
||||
tractorGun =
|
||||
defaultHeldItem
|
||||
& itUse . heldParams .~ BeamShooterParams-- (Just (tone440sawtoothquietS, 2))
|
||||
& itUse . heldParams .~ BeamShooterParams
|
||||
& itAmmoSlots .~ singleAmmo ElectricalAmmo
|
||||
& itUse . heldTriggerType .~ AutoTrigger
|
||||
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
|
||||
|
||||
@@ -157,15 +157,23 @@ Within 10 units considers the sound to be directly in front.
|
||||
soundAngle :: Point2 -> World -> Int16
|
||||
{-# INLINE soundAngle #-}
|
||||
soundAngle p w
|
||||
| dist p earPos < 10 = 0
|
||||
| d < 10 = 0
|
||||
| otherwise =
|
||||
round
|
||||
. radToDeg
|
||||
. f
|
||||
. normalizeAngle
|
||||
. (+ pi)
|
||||
$ argV (vNormal (p -.- earPos)) - (w ^. wCam . camRot)
|
||||
where
|
||||
earPos = w ^. wCam . camViewFrom
|
||||
d = dist p earPos
|
||||
-- the following should soften the positional effect
|
||||
-- when you are close to the sound source
|
||||
f x | x < pi / 2 = x * dfact
|
||||
| x < 3 * pi / 2 = pi + (dfact * (x - pi))
|
||||
| otherwise = 2*pi + (dfact * (x - 2*pi))
|
||||
dfact = min ((d - 10) / 100) 1
|
||||
|
||||
{- | Uses the first free origin from a list.
|
||||
Does nothing if all origins are already creating sounds.
|
||||
|
||||
Reference in New Issue
Block a user