Move towards incorporating sound into ai

This commit is contained in:
2021-09-08 17:41:13 +01:00
parent 45bbf9b005
commit 643cd5a420
25 changed files with 150 additions and 144 deletions
+11 -2
View File
@@ -9,13 +9,15 @@ module Dodge.Creature.ReaderUpdate
, overrideInternalRRR
, goToTarget
, flockACCR
, setMvPos
)
where
import Dodge.Data
import Dodge.Creature.Stance.Data
import Dodge.Creature.Memory.Data
import Dodge.Creature.Test
import Dodge.Creature.Volition
import Dodge.Creature.AlertLevel.Data
import Dodge.Creature.Perception.Data
import Dodge.Base
import Geometry
import FoldableHelp
@@ -23,6 +25,8 @@ import FoldableHelp
import qualified Data.IntMap.Strict as IM
import Control.Monad.Reader
import Control.Lens
import Control.Applicative
import Data.Maybe
overrideMeleeCloseTargetR
:: Creature
@@ -40,6 +44,11 @@ tryMeleeAttack cr tcr
where
cpos = _crPos cr
setMvPos :: Creature -> Reader World Creature
setMvPos cr = pure $ cr & crMvTarget .~ mpos
where
mpos = (_crPos <$> _crTarget cr) <|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
setTargetMv
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
-> Creature
@@ -126,6 +135,6 @@ listGuard ( (test,y):ps, z ) x
listGuard (_,z) _ = z
targetYouWhenCognizantR :: Creature -> Reader World Creature
targetYouWhenCognizantR cr = reader $ \w -> case cr ^? crAwarenessLevel . ix 0 of
targetYouWhenCognizantR cr = reader $ \w -> case cr ^? crPerception . crAwarenessLevel . ix 0 of
Just (Cognizant _) -> cr {_crTarget = Just $! _creatures w IM.! 0}
_ -> cr & crTarget .~ Nothing