Improve chase crit searching
This commit is contained in:
@@ -7,7 +7,7 @@ module Dodge.Creature.ReaderUpdate
|
||||
, watchUpdateStrat
|
||||
, reloadOverride
|
||||
, overrideInternal
|
||||
, turnIfDamaged
|
||||
, searchIfDamaged
|
||||
, goToTarget
|
||||
, flockACC
|
||||
, chaseCritMv
|
||||
@@ -19,6 +19,7 @@ import Dodge.Creature.Test
|
||||
import Dodge.Creature.Volition
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.Path
|
||||
import Geometry
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -93,7 +94,9 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
StrategyActions _ _ -> cr
|
||||
WarningCry -> cr
|
||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||
Just p -> cr & crActionPlan . apAction .~ [PathTo p]
|
||||
Just p | dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p]
|
||||
| otherwise -> cr & crActionPlan . apAction .~ [bfsThenReturn 500]
|
||||
& crIntention . mvToPoint .~ Nothing
|
||||
_ -> viewTarget w cr
|
||||
|
||||
goToTarget :: World -> Creature -> Creature
|
||||
@@ -102,11 +105,18 @@ goToTarget w cr =
|
||||
Just p -> cr & crActionPlan . apAction .~ [PathTo p]
|
||||
_ -> viewTarget w cr
|
||||
|
||||
lookAroundSelf :: Action
|
||||
lookAroundSelf = UseSelf $ \cr -> TurnToPoint (_crPos cr -.- 10 *.* unitVectorAtAngle (_crDir cr))
|
||||
|
||||
viewTarget :: World -> Creature -> Creature
|
||||
viewTarget w cr = do
|
||||
case cr ^? crIntention . viewPoint . _Just of
|
||||
Just p | hasLOSIndirect p (_crPos cr) w -> cr'
|
||||
& crActionPlan . apAction %~ replaceNullWith (TurnToA p)
|
||||
& crActionPlan . apAction %~ replaceNullWith
|
||||
(TurnToPoint p
|
||||
`DoActionThen` 40 `WaitThen` lookAroundSelf
|
||||
`DoActionThen` 20 `WaitThen` lookAroundSelf
|
||||
)
|
||||
& crIntention . viewPoint .~ Nothing
|
||||
| otherwise -> cr' & crActionPlan . apAction %~ replaceNullWith (PathTo p)
|
||||
Nothing -> cr-- & crPerception . crAwakeLevel .~ Lethargic
|
||||
@@ -119,7 +129,8 @@ replaceNullWith _ xs = xs
|
||||
|
||||
doStrategyActions :: Creature -> Creature
|
||||
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
||||
Just (StrategyActions strat acs) -> cr & crActionPlan . apAction .~ acs
|
||||
Just (StrategyActions strat acs) -> cr
|
||||
& crActionPlan . apAction .~ acs
|
||||
& crActionPlan . apStrategy .~ strat
|
||||
_ -> cr
|
||||
|
||||
@@ -165,10 +176,24 @@ targetYouWhenCognizant w cr = case cr ^? crPerception . cpAwareness . ix 0 of
|
||||
Just (Cognizant _) -> _creatures w IM.! 0 `seq` cr & crIntention . targetCr ?~ _creatures w IM.! 0
|
||||
_ -> cr & crIntention . targetCr .~ Nothing
|
||||
|
||||
turnIfDamaged :: Creature -> Creature
|
||||
turnIfDamaged cr
|
||||
searchIfDamaged :: Creature -> Creature
|
||||
searchIfDamaged cr
|
||||
| _crPastDamage cr > 0 = case _apStrategy (_crActionPlan cr) of
|
||||
WatchAndWait -> cr & crPerception . cpVigilance .~ Vigilant
|
||||
& crActionPlan . apStrategy .~ StrategyActions LookAround [TurnToA (_crPos cr -.- unitVectorAtAngle (_crDir cr))]
|
||||
& crActionPlan . apStrategy .~ StrategyActions LookAround
|
||||
[(TurnToPoint (_crPos cr -.- unitVectorAtAngle (_crDir cr)))
|
||||
`DoActionThen` 40 `WaitThen` bfsThenReturn 500
|
||||
]
|
||||
_ -> cr
|
||||
| otherwise = cr
|
||||
|
||||
bfsThenReturn :: Int -> Action
|
||||
bfsThenReturn t = ArbitraryAction theaction
|
||||
where
|
||||
theaction cr w = fromMaybe NoAction $ do
|
||||
n <- walkableNodeNear w (_crPos cr)
|
||||
let as = take 20 $ map PathTo $ bfsNodePoints n w
|
||||
return $ DoReplicate t $
|
||||
foldr DoActionThen NoAction as
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user