Work on crab evasion
This commit is contained in:
@@ -10,6 +10,7 @@ module Dodge.Creature.Action (
|
||||
youDropItem,
|
||||
) where
|
||||
|
||||
import RandomHelp
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
@@ -103,10 +104,11 @@ performAction cr w ac = case ac of
|
||||
NoAction -> ([], NoAction)
|
||||
|
||||
tryEvadeSideways :: Creature -> World -> Point2 -> Float -> Int -> ActionUpdate
|
||||
tryEvadeSideways _ _ p a i = jumpleft -- (mv,mempty)
|
||||
tryEvadeSideways _ w p a i = jumpleft -- (mv,mempty)
|
||||
where
|
||||
jumpleft = (mv,EvadeAim p a (i-1))
|
||||
mv = [Move (V2 0 3)]
|
||||
jumpleft = (mv,DoReplicate 5 (DoImpulses mv))
|
||||
mv = [Walk (V2 0 d)]
|
||||
d = evalState (takeOne [3,-3]) (w ^. randGen)
|
||||
|
||||
performAimAt :: Creature -> World -> Int -> Point2 -> ActionUpdate
|
||||
performAimAt cr w tcid p = ([TurnToward tpos aimSp], AimAt tcid tpos)
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Creature.ChaseCrit (
|
||||
) where
|
||||
|
||||
--import Dodge.Data.Equipment.Misc
|
||||
import Dodge.Data.FloatFunction
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
@@ -39,6 +40,7 @@ crabCrit = defaultCreature
|
||||
& crHP .~ HP 350
|
||||
& crType .~ CrabCrit 0 LeftForward 0 0
|
||||
& crFaction .~ ColorFaction red
|
||||
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
||||
|
||||
hoverCrit :: Creature
|
||||
hoverCrit =
|
||||
|
||||
@@ -31,6 +31,7 @@ followImpulse cid w = \case
|
||||
soundStart (CrMouth cid) cpos sid Nothing $
|
||||
w & clens %~ resetCrVocCoolDown w
|
||||
Move p -> crup $ crMvBy p (w ^. cWorld . lWorld)
|
||||
Walk p -> crup $ crWalk p (w ^. cWorld . lWorld)
|
||||
MoveForward x -> crup $ crMvForward x (w ^. cWorld . lWorld)
|
||||
MoveNoStride p -> crup $ crMvByNoStride p (w ^. cWorld . lWorld)
|
||||
Turn a -> crup $ crDir +~ a
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Creature.Impulse.Movement (
|
||||
creatureTurnTowardDir,
|
||||
crMvAbsolute,
|
||||
crMvBy,
|
||||
crWalk,
|
||||
crMvByNoStride,
|
||||
crMvForward,
|
||||
creatureTurnTo,
|
||||
@@ -27,6 +28,14 @@ crMvBy ::
|
||||
Creature
|
||||
crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
|
||||
|
||||
crWalk ::
|
||||
-- | Movement translation vector, will be made relative to creature direction
|
||||
Point2 ->
|
||||
LWorld ->
|
||||
Creature ->
|
||||
Creature
|
||||
crWalk p lw cr = crWalkAbsolute lw (rotateV (_crDir cr) p) cr
|
||||
|
||||
crMvByNoStride ::
|
||||
-- | Movement translation vector, will be made relative to creature direction
|
||||
Point2 ->
|
||||
@@ -43,6 +52,15 @@ crMvAbsolute lw p' cr =
|
||||
where
|
||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||
|
||||
crWalkAbsolute :: LWorld -> Point2 -> Creature -> Creature
|
||||
crWalkAbsolute lw p' cr
|
||||
| Walking <- cr ^. crStance . carriage = cr
|
||||
& crPos . _xy +~ p
|
||||
& crMvDir .~ argV (p + cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy)
|
||||
| otherwise = cr
|
||||
where
|
||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||
|
||||
crMvAbsoluteNoStride :: LWorld -> Point2 -> Creature -> Creature
|
||||
crMvAbsoluteNoStride lw p' cr = cr & crPos . _xy +~ p
|
||||
where
|
||||
|
||||
@@ -8,7 +8,7 @@ crMvType :: Creature -> CrMvType
|
||||
crMvType cr = case _crType cr of
|
||||
Avatar {} -> MvWalking 1.5
|
||||
ChaseCrit {} -> defaultChaseMvType & mvSpeed .~ 1.8
|
||||
CrabCrit {} -> defaultChaseMvType & mvSpeed .~ 1
|
||||
CrabCrit {} -> defaultChaseMvType & mvSpeed .~ 0.5
|
||||
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.16
|
||||
SwarmCrit -> defaultChaseMvType
|
||||
AutoCrit -> defaultAimMvType
|
||||
|
||||
@@ -15,6 +15,7 @@ module Dodge.Creature.ReaderUpdate (
|
||||
hoverCritMv,
|
||||
) where
|
||||
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Bifunctor
|
||||
@@ -123,9 +124,11 @@ flockACC w cr = fromMaybe cr $ do
|
||||
crabCritMv :: World -> Creature -> Creature
|
||||
crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
WarningCry -> cr
|
||||
CloseToMelee tid | Just (p,a) <- aimi tid -> cr & crActionPlan . apAction .~ EvadeAim p a 3
|
||||
& crType . dodgeCooldown .~ 20
|
||||
CloseToMelee tid | Just (p,a) <- aimi tid -> cr & crActionPlan . apAction .~ EvadeAim p a 10
|
||||
& crType . dodgeCooldown .~ dc
|
||||
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||
Wander | Just tid <- cr ^? crIntention . targetCr . _Just
|
||||
, canSee tid (cr ^. crID) w -> cr & crActionPlan . apStrategy .~ CloseToMelee tid
|
||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||
Just p
|
||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||
@@ -136,9 +139,11 @@ crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
& crIntention . mvToPoint .~ Nothing
|
||||
_ -> viewTarget w cr
|
||||
where
|
||||
dc = fst $ randomR (15,25) (w ^. randGen)
|
||||
notpath = \case
|
||||
Just NoAction -> False
|
||||
Just PathTo {} -> False
|
||||
Just AimAt {} -> False
|
||||
_ -> True
|
||||
aimi tid = do
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix tid
|
||||
@@ -148,6 +153,8 @@ crabCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
0 <- cr ^? crType . dodgeCooldown
|
||||
guard $ hasLOS cxy txy w
|
||||
&& abs (nearZeroAngle (tcr^.crDir - argV (cxy - txy))) < 0.3
|
||||
&& isWalkable txy cxy w
|
||||
&& diffAngles (cr ^. crDir) (argV (txy - cxy)) < 0.1
|
||||
return (txy, tcr ^. crDir)
|
||||
|
||||
chaseCritMv :: World -> Creature -> Creature
|
||||
@@ -182,6 +189,7 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
notpath = \case
|
||||
Just NoAction -> False
|
||||
Just PathTo {} -> False
|
||||
Just AimAt {} -> False
|
||||
_ -> True
|
||||
|
||||
hoverCritMv :: World -> Creature -> Creature
|
||||
@@ -201,6 +209,7 @@ hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
notpath = \case
|
||||
Just NoAction -> False
|
||||
Just PathTo {} -> False
|
||||
Just AimAt {} -> False
|
||||
_ -> True
|
||||
|
||||
--goToTarget :: World -> Creature -> Creature
|
||||
|
||||
@@ -24,6 +24,7 @@ data ActionPlan
|
||||
|
||||
data Impulse
|
||||
= Move Point2
|
||||
| Walk Point2
|
||||
| MoveForward Float
|
||||
| MoveNoStride Point2
|
||||
| Turn Float
|
||||
|
||||
@@ -57,6 +57,8 @@ tutAnoTree = do
|
||||
foldMTRS
|
||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||
, corDoor
|
||||
, chasmSpitTerminal
|
||||
, corDoor
|
||||
, loadAmmoTut
|
||||
, corDoor
|
||||
, chasmSpitTerminal
|
||||
@@ -341,10 +343,10 @@ chasmSpitTerminal = do
|
||||
tToBTree "chasmTerm" $
|
||||
Node
|
||||
(addDoorToggleTerminal' i1 (PS 150 0) y')
|
||||
[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit chaseCrit)]
|
||||
[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)]
|
||||
--[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit hoverCrit)]
|
||||
--[ treePost [triggerDoorRoom i1, deadEndRoom]
|
||||
, treePost [triggerDoorRoom i1, deadEndPSType (PutCrit chaseCrit)]
|
||||
, treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)]
|
||||
, return $ cleatOnward $ triggerDoorRoom i1
|
||||
]
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user