Redo sound travel distances

This commit is contained in:
2022-05-21 10:10:17 +01:00
parent c9dcdd20e4
commit bc0f7ada3c
76 changed files with 379 additions and 372 deletions
+1
View File
@@ -54,6 +54,7 @@ flockArmourChaseCrit = defaultCreature
armourChaseCrit :: Creature
armourChaseCrit = chaseCrit
{ _crName = "armourChaseCrit"
--, _crUpdate = defaultImpulsive []
, _crInv = IM.fromList
[(0,frontArmour)
,(1,medkit 200)
+10 -4
View File
@@ -2,7 +2,7 @@
module Dodge.Creature.Perception
( perceptionUpdate
, chaseCritPerceptionUpdate
, newSounds
-- , newSounds
) where
import Dodge.Data
import Dodge.Creature.Vocalization
@@ -165,7 +165,13 @@ rememberSounds w cr = cr
where
awakeupdate | null closesounds = id
| otherwise = crPerception . crAwakeLevel .~ Vigilant
closesounds = map fst (filter (soundIsClose cr) (newSounds w))
closesounds = map fst (filter (soundIsClose w cr) (newSounds w))
soundIsClose :: Creature -> (Point2,Float) -> Bool
soundIsClose cr (pos,vol) = vol > (_auDist . _crAudition $ _crPerception cr) (dist pos (_crPos cr))
-- TODO work out correct form for sounds passing through walls
soundIsClose :: World -> Creature -> (Point2,Float) -> Bool
soundIsClose w cr (pos,vol)
| dist cpos pos > 2000 = False
| hasLOS cpos pos w = vol > (_auDist . _crAudition $ _crPerception cr) (dist pos cpos)
| otherwise = False
where
cpos = _crPos cr