Add new chase crit sounds

This commit is contained in:
2022-05-19 13:37:59 +01:00
parent 6ba41d3c0b
commit f8af186691
7 changed files with 127 additions and 114 deletions
+11 -14
View File
@@ -64,6 +64,7 @@ basicAwarenessUpdate cr = case _crAttentionDir $ _crPerception cr of
Nothing -> id
| otherwise = id
-- TODO fold in randgen update, requires that this is a world to world function
chaseCritAwarenessUpdate :: World -> Creature -> Creature
chaseCritAwarenessUpdate w cr = case _crAttentionDir $ _crPerception cr of
Fixated i -> cr & crPerception . crAwarenessLevel
@@ -76,23 +77,19 @@ chaseCritAwarenessUpdate w cr = case _crAttentionDir $ _crPerception cr of
oldAwareness = _crAwarenessLevel $ _crPerception cr
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
randBool = takeOne [False,True] & evalState $ _randGen w
--randBool = takeOne [False,True] & evalState $ _randGen w
thejitter = do
p <- randInCirc 2
return $ Move p
maybeBark
| becomesCognizant && randBool = case vocalizationTest cr of
Just soundid -> crActionPlan . crStrategy .~ StrategyActions WarningCry
[ImpulsesList ([Bark soundid]: replicate 20 [RandomImpulse thejitter]++
[[ChangeStrategy $ CloseToMelee 0] ])
, AimAt 0 (_crPos $ _creatures w IM.! 0)
]
--[ImpulsesList [Bark soundid: replicate 20 (RandomImpulse thejitter)]
-- `DoActionThen` 20
-- `WaitThen` DoImpulses [ChangeStrategy $ CloseToMelee 0]
--, AimAt 0 (_crPos $ _creatures w IM.! 0)
--]
Nothing -> id
maybeBark
| becomesCognizant -- && randBool
&& cr ^? crVocalization . vcCoolDown == Just 0
= let soundid = evalState (takeOne (_vcWarnings (_crVocalization cr))) (_randGen w)
in crActionPlan . crStrategy .~ StrategyActions WarningCry
[ImpulsesList ([Bark soundid]: replicate 20 [RandomImpulse thejitter]++
[[ChangeStrategy $ CloseToMelee 0] ])
, AimAt 0 (_crPos $ _creatures w IM.! 0)
]
| otherwise = id
cogRaised :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel