Compare commits

...
2 Commits
Author SHA1 Message Date
justin 60e5e6ecae Add extra warning cries to chaseCrits 2023-05-01 14:01:27 +01:00
justin b34a9f5b09 Cleanup 2023-05-01 10:30:33 +01:00
16 changed files with 39 additions and 47 deletions
-2
View File
@@ -29,8 +29,6 @@ updateBullet w bu = case _buDelayFraction bu of
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet) mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
mvBullet x w bu mvBullet x w bu
-- | magV (_buVel bu) < 1 = (w, Nothing)
-- | _buTimer bu <= 0 = (endspawn w, Nothing)
| magV (_buVel bu) < 1 || _buTimer bu <= 0 = (endspawn w, Nothing) | magV (_buVel bu) < 1 || _buTimer bu <= 0 = (endspawn w, Nothing)
| otherwise = | otherwise =
second (fmap updateBulVel) second (fmap updateBulVel)
+1 -1
View File
@@ -56,5 +56,5 @@ chaseCritVocalization =
, seagullCry1S , seagullCry1S
, seagullCry2S , seagullCry2S
] ]
50 (50,100)
0 0
+2 -2
View File
@@ -39,7 +39,7 @@ followImpulse cr w imp = case imp of
RandomImpulse rimp -> RandomImpulse rimp ->
let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w) let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w)
in first ((randGen .~ newgen) .) $ followImpulse cr w newimp 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 Move p -> crup $ crMvBy p cr
MoveForward x -> crup $ crMvForward x cr MoveForward x -> crup $ crMvForward x cr
Turn a -> crup $ creatureTurn a 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 rr a = randomR (- a, a) $ _randGen w
hitCr i = hitCr i =
( cWorld . lWorld . creatures . ix i . crState . csDamage ( 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 . 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 oldAwareness = _cpAwareness $ _crPerception cr
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
thejitter = RandImpulseCircMove 2 thejitter = RandImpulseCircMove 3
maybeBark maybeBark
| becomesCognizant -- && randBool | becomesCognizant -- && randBool
&& cr ^? crVocalization . vcCoolDown == Just 0 = && cr ^? crVocalization . vcCoolDown == Just 0 =
+15 -3
View File
@@ -14,12 +14,13 @@ module Dodge.Creature.ReaderUpdate (
setViewPos, setViewPos,
) where ) where
import RandomHelp
import Dodge.Creature.Perception import Dodge.Creature.Perception
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Data.List (sortOn) import Data.List (sortOn)
import Control.Applicative import Control.Applicative
import Control.Lens import LensHelp
import Control.Monad --import Control.Monad
import Data.Bifunctor import Data.Bifunctor
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
@@ -114,11 +115,22 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
StrategyActions _ _ -> cr StrategyActions _ _ -> cr
WarningCry -> cr WarningCry -> cr
MeleeStrike -> 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 _ -> case cr ^? crIntention . mvToPoint . _Just of
Just p Just p
| dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p] | dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p]
| otherwise -> | otherwise ->
cr & crActionPlan . apAction .~ [bfsThenReturn 500] cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
& crActionPlan . apStrategy .~ WatchAndWait
& crIntention . mvToPoint .~ Nothing & crIntention . mvToPoint .~ Nothing
_ -> viewTarget w cr _ -> viewTarget w cr
+7 -4
View File
@@ -1,15 +1,18 @@
module Dodge.Creature.Vocalization where module Dodge.Creature.Vocalization where
import Control.Lens import Control.Lens
import Dodge.Data.Creature import Dodge.Data.World
import Sound.Data import Sound.Data
import System.Random
vocalizationTest :: Creature -> Maybe SoundID vocalizationTest :: Creature -> Maybe SoundID
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
Just 0 -> Just $ _vcSound $ _crVocalization cr Just 0 -> Just $ _vcSound $ _crVocalization cr
_ -> Nothing _ -> Nothing
resetCrVocCoolDown :: Creature -> Creature resetCrVocCoolDown :: World -> Creature -> Creature
resetCrVocCoolDown cr = case cr ^? crVocalization . vcMaxCoolDown of resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
Just i -> cr & crVocalization . vcCoolDown .~ i Just (i,j) -> cr & crVocalization . vcCoolDown .~ x
where
x = fst $ randomR (i,j) (_randGen w)
Nothing -> cr Nothing -> cr
+1 -1
View File
@@ -29,7 +29,7 @@ data Vocalization
| Vocalization | Vocalization
{ _vcSound :: SoundID { _vcSound :: SoundID
, _vcWarnings :: [SoundID] , _vcWarnings :: [SoundID]
, _vcMaxCoolDown :: Int , _vcMaxCoolDown :: (Int, Int)
, _vcCoolDown :: Int , _vcCoolDown :: Int
} }
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
+2
View File
@@ -70,6 +70,8 @@ debugSelectCreatureList cid u =
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crMemory) (u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crMemory)
, debugList "Strategy" , debugList "Strategy"
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crActionPlan . apStrategy) (u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crActionPlan . apStrategy)
, debugList "Vocalization"
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crVocalization)
] ]
+1 -1
View File
@@ -16,7 +16,7 @@ defaultLoadable =
} }
defaultBulletLoadable :: HeldConsumption defaultBulletLoadable :: HeldConsumption
defaultBulletLoadable = defaultLoadable & laAmmoType .~ basicBullet defaultBulletLoadable = defaultLoadable & laAmmoType .~ basicBulletAmmo
defaultLeftLoadable :: LeftConsumption defaultLeftLoadable :: LeftConsumption
defaultLeftLoadable = AutoRecharging 10 10 100 100 defaultLeftLoadable = AutoRecharging 10 10 100 100
+1
View File
@@ -23,6 +23,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
, targetYouWhenCognizant , targetYouWhenCognizant
, const searchIfDamaged , const searchIfDamaged
, const (crMeleeCooldown %~ max 0 . subtract 1) , const (crMeleeCooldown %~ max 0 . subtract 1)
, const (crVocalization . vcCoolDown %~ max 0 . subtract 1)
] ]
cr cr
SpreadGunAI -> SpreadGunAI ->
+1 -1
View File
@@ -40,7 +40,7 @@ bangRod =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30 & itUse . heldAim . aimMuzPos .~ 30
& itUse . heldConsumption . laAmmoType .~ hvBullet & itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
elephantGun :: Item elephantGun :: Item
elephantGun = elephantGun =
+6 -6
View File
@@ -1,6 +1,6 @@
module Dodge.Item.Weapon.Bullet ( module Dodge.Item.Weapon.Bullet (
basicBullet, basicBulletAmmo,
hvBullet, hvBulletAmmo,
defaultBullet, defaultBullet,
) where ) where
@@ -8,8 +8,8 @@ import Dodge.Data.Item.Use.Consumption.Ammo
import Control.Lens import Control.Lens
import Geometry.Data import Geometry.Data
basicBullet :: AmmoType basicBulletAmmo :: AmmoType
basicBullet = basicBulletAmmo =
BulletAmmo BulletAmmo
{ _amString = "BASIC" { _amString = "BASIC"
, _amBullet = defaultBullet , _amBullet = defaultBullet
@@ -37,8 +37,8 @@ basicBulDams =
[ Damage PIERCING 100 0 0 0 $ PushBackDamage 2 [ Damage PIERCING 100 0 0 0 $ PushBackDamage 2
] ]
hvBullet :: AmmoType hvBulletAmmo :: AmmoType
hvBullet = hvBulletAmmo =
BulletAmmo BulletAmmo
{ _amString = "HVBULLET" { _amString = "HVBULLET"
, _amBullet = , _amBullet =
-2
View File
@@ -14,8 +14,6 @@ damageMaterial dm mt = case mt of
Stone -> damageStone dm Stone -> damageStone dm
_ -> defDamageMaterial dm _ -> defDamageMaterial dm
-- Glass -> damageGlass dm
defDamageMaterial :: Damage -> Float -> World -> (Int, World) defDamageMaterial :: Damage -> Float -> World -> (Int, World)
defDamageMaterial dm _ w = (_dmAmount dm, w) defDamageMaterial dm _ w = (_dmAmount dm, w)
-21
View File
@@ -1,21 +0,0 @@
module Dodge.Particle.Damage where
import Dodge.Data.Bullet
import Geometry
simpleDam' :: DamageType -> Int -> Bullet -> Point2 -> [Damage]
simpleDam' dt amount bt p = [Damage dt amount sp p ep NoDamageEffect]
where
sp = _buPos bt
bulVel = _buVel bt
ep = sp +.+ bulVel
hvBulDams :: [Damage]
hvBulDams =
[ Damage PIERCING 25 0 0 0 NoDamageEffect
, Damage PIERCING 25 0 0 0 NoDamageEffect
, Damage PIERCING 25 0 0 0 NoDamageEffect
, Damage PIERCING 25 0 0 0 NoDamageEffect
, Damage PIERCING 25 0 0 0 $ TorqueDamage 0.7
, Damage PIERCING 25 0 0 0 $ PushBackDamage 3
]
-1
View File
@@ -58,7 +58,6 @@ makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . pathGraph) <$> makePathB
bfsNodePoints :: Int -> World -> [Point2] bfsNodePoints :: Int -> World -> [Point2]
bfsNodePoints n w = mapMaybe (lab g) $ bfs n g bfsNodePoints n w = mapMaybe (lab g) $ bfs n g
where where
--g = _pathGraph (_cWorld w)
g = w ^. cWorld . pathGraph g = w ^. cWorld . pathGraph
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2 pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2
+1 -1
View File
@@ -295,7 +295,7 @@ advanceScrollAmount u =
updatePastWorlds :: World -> World updatePastWorlds :: World -> World
--updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. cWorld . lWorld) :)) --updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. cWorld . lWorld) :))
updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 300 . ((w ^. cWorld . lWorld) :)) updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 600 . ((w ^. cWorld . lWorld) :))
doWorldEvents :: World -> World doWorldEvents :: World -> World
doWorldEvents w = doWorldEvents w =