From 8ad33d2f8b809212f16b145807c93e872e8a33c4 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 26 Apr 2022 09:35:30 +0100 Subject: [PATCH] Fix empty bark crash --- src/Dodge/Creature/Perception.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Dodge/Creature/Perception.hs b/src/Dodge/Creature/Perception.hs index 2f8c6601a..77e57dc9e 100644 --- a/src/Dodge/Creature/Perception.hs +++ b/src/Dodge/Creature/Perception.hs @@ -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