Tweak chase crit perception
This commit is contained in:
@@ -14,6 +14,9 @@ module Dodge.Creature.ReaderUpdate (
|
||||
setViewPos,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.Perception
|
||||
import qualified IntMapHelp as IM
|
||||
import Data.List (sortOn)
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -51,11 +54,19 @@ setMvPos w cr = cr & crIntention . mvToPoint .~ mpos
|
||||
return $ tpos
|
||||
mpos = mtpos <|> _mvToPoint int
|
||||
|
||||
setViewPos :: Creature -> Creature
|
||||
setViewPos cr = cr & crIntention . viewPoint %~ (<|> mpos)
|
||||
setViewPos :: World -> Creature -> Creature
|
||||
setViewPos w cr = cr & crIntention . viewPoint %~ ((<|> mpos) . (attentionViewPoint w cr <|>))
|
||||
where
|
||||
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
||||
|
||||
attentionViewPoint :: World -> Creature -> Maybe Point2
|
||||
attentionViewPoint w cr = do
|
||||
attention <- cr ^? crPerception . cpAttention . getAttentiveTo
|
||||
cid <- (sortOn snd $ IM.toList attention) ^? ix 0 . _1
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
guard $ visionCheck cr (_crPos tcr) > 0
|
||||
return (_crPos tcr)
|
||||
|
||||
setTargetMv ::
|
||||
-- | Function for determining target
|
||||
(World -> Creature -> Maybe Creature) ->
|
||||
@@ -120,9 +131,10 @@ viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
|
||||
| hasLOSIndirect p (_crPos cr) w ->
|
||||
cr
|
||||
& crActionPlan . apAction
|
||||
%~ replaceNullWith
|
||||
( TurnToPoint p
|
||||
)
|
||||
.~ [TurnToPoint p]
|
||||
-- %~ replaceNullWith
|
||||
-- ( TurnToPoint p
|
||||
-- )
|
||||
& crIntention . viewPoint .~ Nothing
|
||||
| otherwise -> cr & crActionPlan . apAction %~ replaceNullWith (PathTo p)
|
||||
Nothing -> cr
|
||||
|
||||
Reference in New Issue
Block a user