Fix empty bark crash

This commit is contained in:
2022-04-26 09:35:30 +01:00
parent f32b212b47
commit 8ad33d2f8b
+4 -3
View File
@@ -65,13 +65,14 @@ chaseCritAwarenessUpdate w cr = case _crAttentionDir $ _crPerception cr of
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
randBool = takeOne [False,True] & evalState $ _randGen w
maybeBark
| becomesCognizant && randBool =
crActionPlan . crStrategy .~ StrategyActions WarningCry
[DoImpulses [Bark $ fromJust $ vocalizationTest cr]
| becomesCognizant && randBool = case vocalizationTest cr of
Just soundid -> crActionPlan . crStrategy .~ StrategyActions WarningCry
[DoImpulses [Bark soundid]
`DoActionThen` 20
`WaitThen` DoImpulses [ChangeStrategy $ CloseToMelee 0]
, AimAt 0 (_crPos $ _creatures w IM.! 0)
]
Nothing -> id
| otherwise = id
cogRaised :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel