Simplify vocalization

This commit is contained in:
2026-04-01 20:30:31 +01:00
parent b77170c4bc
commit 735cc8d92d
11 changed files with 144 additions and 142 deletions
+8 -3
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.ChaseCrit (
smallChaseCrit,
invisibleChaseCrit,
chaseCrit,
hoverCrit,
) where
--import Dodge.Data.Equipment.Misc
@@ -30,8 +31,12 @@ chaseCrit =
& crName .~ "chaseCrit"
& crHP .~ HP 150
& crFaction .~ ColorFaction green
& crVocalization .~ chaseCritVocalization
& crStance . strideLength .~ 30
chaseCritVocalization :: Vocalization
chaseCritVocalization = Vocalization (50, 200) 0 20
hoverCrit :: Creature
hoverCrit =
defaultCreature
& crName .~ "chaseCrit"
& crHP .~ HP 150
& crFaction .~ ColorFaction green
& crStance . strideLength .~ 30
+3 -3
View File
@@ -5,13 +5,13 @@ module Dodge.Creature.Perception (
visionCheck,
) where
import Dodge.Creature.Vocalization
import Control.Lens
import Control.Monad
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base.Collide
import Dodge.Creature.Radius
import Dodge.Creature.Vocalization
import Dodge.Data.World
import Dodge.FloatFunction
import Geometry.Data
@@ -56,7 +56,7 @@ basicAwarenessUpdate cr = case _cpAttention $ _crPerception cr of
thejitter = [RandomImpulse $ RandImpulseCircMove 1]
maybeBark = fromMaybe id $ do
guard becomesCognizant
sid <- vocalizationTest cr
sid <- crVocalizationSound cr
return $
crActionPlan . apAction
.~ [ImpulsesList ([Bark sid] : replicate 5 thejitter)]
@@ -83,7 +83,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
thejitter = [RandomImpulse $ RandImpulseCircMove 3]
maybeBark = fromMaybe id $ do
guard becomesCognizant
guard $ cr ^? crVocalization . vcCoolDown == Just 0
guard $ cr ^. crVocalization == VocReady
let soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
numjits = fst $ randomR (15, 25) (_randGen w)
return $
+1 -1
View File
@@ -75,7 +75,7 @@ chaseUpperBody cr = colorSH (_skinUpper cskin)
mcool = 1 - min 10 (fromIntegral . _meleeCooldown $ _crType cr) / 10
neckq = torsoq `Q.comp` (V3 6 0 0,Q.axisAngle (V3 0 1 0) (-1.8*mcool))
headq = neckq `Q.comp` (V3 16 0 0, Q.axisAngle (V3 0 1 0) (2*mcool+vocaltilt))
vocaltilt = case cr ^? crVocalization . vcTimer of
vocaltilt = case cr ^? crVocalization . vcTime of
Just x | x < 20 -> -pi * 0.05 * (10 - abs (fromIntegral x - 10))
_ -> 0
sLen = _strideLength $ _crStance cr
+2 -2
View File
@@ -124,7 +124,7 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
WarningCry -> cr
MeleeStrike -> cr
CloseToMelee cid
| Just 0 == (cr ^? crVocalization . vcCoolDown) ->
| VocReady == (cr ^. crVocalization) ->
cr
& crActionPlan . apAction
.:~ ImpulsesList
@@ -132,7 +132,7 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
replicate numjits [RandomImpulse thejitter]
++ [[ChangeStrategy (CloseToMelee cid)]]
)
& crVocalization . vcCoolDown .~ 10
& resetCrVocCoolDown w
& crActionPlan . apStrategy .~ WarningCry
where
thejitter = RandImpulseCircMove 3
+5 -11
View File
@@ -3,7 +3,7 @@
module Dodge.Creature.Vocalization (
crWarningSounds,
crDeathSounds,
vocalizationTest,
crVocalizationSound,
resetCrVocCoolDown,
) where
@@ -59,15 +59,9 @@ defaultDeathSounds = \case
PlainDeath -> mempty
GibsDeath -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S]
vocalizationTest :: Creature -> Maybe SoundID
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
Just 0 -> crVocalizationSound cr
_ -> Nothing
crVocalResetTime :: Creature -> StdGen -> Int
crVocalResetTime _ = fst . randomR (50,100)
-- this should update the randgen as well
resetCrVocCoolDown :: World -> Creature -> Creature
resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
Just (i, j) -> cr & crVocalization . vcCoolDown .~ x
& crVocalization . vcTimer .~ 0
where
x = fst $ randomR (i, j) (_randGen w)
Nothing -> cr
resetCrVocCoolDown w cr = cr & crVocalization .~ VocTimer 0 (crVocalResetTime cr (w ^. randGen))
+2 -6
View File
@@ -16,12 +16,8 @@ import Dodge.Data.Material
import Geometry.Data
data Vocalization
= Mute
| Vocalization
{ _vcMaxCoolDown :: (Int, Int)
, _vcCoolDown :: Int
, _vcTimer :: Int
}
= VocTimer {_vcTime :: Int ,_vcMaxTime :: Int }
| VocReady
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data CrMvType
+1 -1
View File
@@ -42,7 +42,7 @@ defaultCreature =
, _posture = AtEase
, _strideLength = yourDefaultStrideLength
}
, _crVocalization = Mute
, _crVocalization = VocReady
, _crActionPlan = ActionPlan [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
, _crPerception = defaultPerceptionState
, _crMemory = defaultCreatureMemory
+5 -2
View File
@@ -19,10 +19,13 @@ chaseCritInternal w cr =
, targetYouWhenCognizant
, const searchIfDamaged
, const (crType . meleeCooldown %~ max 0 . subtract 1)
, const (crVocalization . vcCoolDown %~ max 0 . subtract 1)
, const (crVocalization . vcTimer +~ 1)
, const (crVocalization %~ updateVocTimer)
]
updateVocTimer :: Vocalization -> Vocalization
updateVocTimer VocTimer {_vcTime=x,_vcMaxTime=y} | x < y = VocTimer (x+1) y
updateVocTimer _ = VocReady
-- SpreadGunAI ->
-- defaultImpulsive
-- [ performActions
+1
View File
@@ -7,3 +7,4 @@ import RandomHelp
randC1 :: PSType
randC1 = RandPS $ takeOne $ map PutCrit $ armourChaseCrit : replicate 50 chaseCrit
--randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit]
+5 -2
View File
@@ -55,7 +55,8 @@ tutAnoTree = do
foldMTRS
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
, corDoor
, loadAmmoTut
, chasmSpitTerminal
-- , loadAmmoTut
, corDoor
, tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns
, corDoor
@@ -445,7 +446,9 @@ loadAmmoTut = do
return $
tToBTree "loadAmmoTest" $
treePost
[ amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
[ croom
, door
, amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
, triggerDoorRoom i
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
, triggerDoorRoom j