Improve awareness

This commit is contained in:
2021-09-05 23:58:35 +01:00
parent e366698064
commit 86311c5d41
24 changed files with 121 additions and 397 deletions
-41
View File
@@ -1,8 +1,6 @@
{- | Functions updating a creature in a Reader World environment -}
module Dodge.Creature.ReaderUpdate
( doStrategyActionsR
, chaseTargetR
, chaseTargetRR
, setTargetMv
, targetYouWhenCognizantR
, overrideMeleeCloseTargetR
@@ -43,15 +41,6 @@ tryMeleeAttack cr tcr
where
cpos = _crPos cr
chaseTargetRR
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
-> Creature
-> Reader World Creature
chaseTargetRR targFunc cr = do
targ <- targFunc cr
case targ of
Nothing -> pure cr
Just crTarg -> pure $ cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg
setTargetMv
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
-> Creature
@@ -107,26 +96,6 @@ goToTarget cr = do
trad = _mvTurnRad mvType
jit = _mvTurnJit mvType
chaseTargetR
:: (Creature -> World -> Maybe Creature) -- ^ Function for determining target
-> Creature
-> Reader World Creature
chaseTargetR targFunc cr = reader $ \w -> case targFunc cr w of
Nothing -> cr
Just crTarg -> cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg
chaseTarg :: Creature -> Creature -> [Impulse]
chaseTarg cr crT = [MoveForward speed, TurnToward tpos (trad dirOffset), RandomTurn jit]
where
cpos = _crPos cr
tpos = _crPos crT
mvType = _crMvType cr
speed = _mvSpeed mvType
trad = _mvTurnRad mvType
jit = _mvTurnJit mvType
dirOffset = abs (_crDir cr - argV (tpos -.- cpos))
doStrategyActionsR
:: Creature
-> Reader World Creature
@@ -178,13 +147,3 @@ targetYouWhenCognizantR :: Creature -> Reader World Creature
targetYouWhenCognizantR cr = reader $ \w -> case cr ^? crAwarenessLevel . ix 0 of
Just (Cognizant _) -> cr {_crTarget = Just $! _creatures w IM.! 0}
_ -> cr & crTarget .~ Nothing
--shootTargetWithStratR
-- :: (Creature -> World -> Maybe Creature) -- ^ Function for determining target
-- -> (World -> Creature -> Creature -> [Action] -> [Action])
-- -- ^ Function for determining shooting strategy given target
-- -> Creature
-- -> Reader World Creature
--shootTargetWithStratR targFunc strat cr = reader $ \w -> case targFunc cr w of
-- Nothing -> cr
-- Just crTarg -> cr & crActionPlan . crAction %~ strat w cr crTarg