Generalise pathing, usable with flying creatures
This commit is contained in:
@@ -11,6 +11,7 @@ module Dodge.Creature.ReaderUpdate (
|
||||
chaseCritMv,
|
||||
setMvPos,
|
||||
setViewPos,
|
||||
hoverCritMv,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
@@ -148,6 +149,20 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
& crIntention . mvToPoint .~ Nothing
|
||||
_ -> viewTarget w cr
|
||||
|
||||
hoverCritMv :: World -> Creature -> Creature
|
||||
hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
WarningCry -> cr
|
||||
MeleeStrike -> cr
|
||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||
Just p
|
||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||
cr & crActionPlan . apAction .~ [PathTo p]
|
||||
| otherwise ->
|
||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
||||
& crActionPlan . apStrategy .~ WatchAndWait
|
||||
& crIntention . mvToPoint .~ Nothing
|
||||
_ -> viewTarget w cr
|
||||
|
||||
goToTarget :: World -> Creature -> Creature
|
||||
goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
||||
Just p -> cr & crActionPlan . apAction .~ [PathTo p]
|
||||
|
||||
Reference in New Issue
Block a user