Add extra warning cries to chaseCrits

This commit is contained in:
2023-05-01 14:01:27 +01:00
parent b34a9f5b09
commit 60e5e6ecae
14 changed files with 39 additions and 24 deletions
+1 -1
View File
@@ -56,5 +56,5 @@ chaseCritVocalization =
, seagullCry1S
, seagullCry2S
]
50
(50,100)
0
+2 -2
View File
@@ -39,7 +39,7 @@ followImpulse cr w imp = case imp of
RandomImpulse rimp ->
let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w)
in first ((randGen .~ newgen) .) $ followImpulse cr w newimp
Bark sid -> (soundStart (CrMouth cid) cpos sid Nothing, resetCrVocCoolDown cr)
Bark sid -> (soundStart (CrMouth cid) cpos sid Nothing, resetCrVocCoolDown w cr)
Move p -> crup $ crMvBy p cr
MoveForward x -> crup $ crMvForward x cr
Turn a -> crup $ creatureTurn a cr
@@ -83,6 +83,6 @@ followImpulse cr w imp = case imp of
rr a = randomR (- a, a) $ _randGen w
hitCr i =
( cWorld . lWorld . creatures . ix i . crState . csDamage
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) (PushBackDamage 3)
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) (PushBackDamage 5)
)
. soundStart (CrSound cid) cpos hitS Nothing
+1 -1
View File
@@ -80,7 +80,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
oldAwareness = _cpAwareness $ _crPerception cr
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
thejitter = RandImpulseCircMove 2
thejitter = RandImpulseCircMove 3
maybeBark
| becomesCognizant -- && randBool
&& cr ^? crVocalization . vcCoolDown == Just 0 =
+15 -3
View File
@@ -14,12 +14,13 @@ module Dodge.Creature.ReaderUpdate (
setViewPos,
) where
import RandomHelp
import Dodge.Creature.Perception
import qualified IntMapHelp as IM
import Data.List (sortOn)
import Control.Applicative
import Control.Lens
import Control.Monad
import LensHelp
--import Control.Monad
import Data.Bifunctor
import Data.Maybe
import Dodge.Base
@@ -114,11 +115,22 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
StrategyActions _ _ -> cr
WarningCry -> cr
MeleeStrike -> cr
CloseToMelee cid | Just 0 == (cr ^? crVocalization . vcCoolDown)
-> cr & crActionPlan . apAction
.:~ ImpulsesList ( [Bark soundid] : replicate numjits [RandomImpulse thejitter]
++ [[ChangeStrategy (CloseToMelee cid)]])
& crVocalization . vcCoolDown .~ 10
& crActionPlan . apStrategy .~ WarningCry
where
thejitter = RandImpulseCircMove 3
soundid = evalState (takeOne (_vcWarnings (_crVocalization cr))) (_randGen w)
numjits = fst $ randomR (15, 25) (_randGen w)
_ -> case cr ^? crIntention . mvToPoint . _Just of
Just p
| dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p]
| otherwise ->
cr & crActionPlan . apAction .~ [bfsThenReturn 500]
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
& crActionPlan . apStrategy .~ WatchAndWait
& crIntention . mvToPoint .~ Nothing
_ -> viewTarget w cr
+7 -4
View File
@@ -1,15 +1,18 @@
module Dodge.Creature.Vocalization where
import Control.Lens
import Dodge.Data.Creature
import Dodge.Data.World
import Sound.Data
import System.Random
vocalizationTest :: Creature -> Maybe SoundID
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
Just 0 -> Just $ _vcSound $ _crVocalization cr
_ -> Nothing
resetCrVocCoolDown :: Creature -> Creature
resetCrVocCoolDown cr = case cr ^? crVocalization . vcMaxCoolDown of
Just i -> cr & crVocalization . vcCoolDown .~ i
resetCrVocCoolDown :: World -> Creature -> Creature
resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
Just (i,j) -> cr & crVocalization . vcCoolDown .~ x
where
x = fst $ randomR (i,j) (_randGen w)
Nothing -> cr