Add crab crit, rethink Action datatype slightly
This commit is contained in:
@@ -179,6 +179,7 @@ crHeight cr = case cr ^. crHP of
|
|||||||
HoverCrit {} -> 10
|
HoverCrit {} -> 10
|
||||||
ChaseCrit {} -> 25
|
ChaseCrit {} -> 25
|
||||||
Avatar {} -> 25
|
Avatar {} -> 25
|
||||||
|
CrabCrit {} -> 25
|
||||||
_ -> error "Need to define crHeight for this crType"
|
_ -> error "Need to define crHeight for this crType"
|
||||||
CrIsCorpse{} -> Just 5
|
CrIsCorpse{} -> Just 5
|
||||||
CrDestroyed{} -> Nothing
|
CrDestroyed{} -> Nothing
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ performActions cid w =
|
|||||||
iss
|
iss
|
||||||
where
|
where
|
||||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||||
(iss, mayas) = foldMap (performAction cr w) $ cr ^. crActionPlan . apAction
|
(iss, mayas) = fromMaybe ([],NoAction) $ performAction cr w <$> cr ^? crActionPlan . apAction
|
||||||
|
|
||||||
type ActionUpdate = ([Impulse], [Action])
|
type ActionUpdate = ([Impulse], Action)
|
||||||
|
|
||||||
{- | Performing an action on a frame creates an ActionUpdate:
|
{- | Performing an action on a frame creates an ActionUpdate:
|
||||||
gives impulses and updates/deletes the action itself.
|
gives impulses and updates/deletes the action itself.
|
||||||
@@ -55,54 +55,61 @@ type ActionUpdate = ([Impulse], [Action])
|
|||||||
performAction :: Creature -> World -> Action -> ActionUpdate
|
performAction :: Creature -> World -> Action -> ActionUpdate
|
||||||
performAction cr w ac = case ac of
|
performAction cr w ac = case ac of
|
||||||
AimAt tcid p -> performAimAt cr w tcid p
|
AimAt tcid p -> performAimAt cr w tcid p
|
||||||
WaitThen 0 newAc -> ([], [newAc])
|
WaitThen 0 newAc -> ([], newAc)
|
||||||
WaitThen t newAc -> ([], [WaitThen (t -1) newAc])
|
WaitThen t newAc -> ([], WaitThen (t -1) newAc)
|
||||||
ImpulsesList (xs : xss) -> (xs, [ImpulsesList xss])
|
ImpulsesList (xs : xss) a -> performAction cr w a & _1 <>~ xs
|
||||||
ImpulsesList _ -> ([], mempty)
|
& _2 %~ ImpulsesList xss
|
||||||
DoImpulses imps -> (imps, mempty)
|
ImpulsesList _ a -> performAction cr w a
|
||||||
DoActionThen fsta afta -> case performAction cr w fsta of -- NOTE this only does ONE continuation action
|
DoImpulses imps -> (imps, NoAction)
|
||||||
(imps, nxta : _) -> (imps, [DoActionThen nxta afta])
|
DoActionThen fsta afta -> case performAction cr w fsta of
|
||||||
(imps, []) -> (imps, [afta])
|
(imps, NoAction) -> (imps, afta)
|
||||||
|
(imps, nxta) -> (imps, DoActionThen nxta afta)
|
||||||
DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act
|
DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act
|
||||||
DoActionWhilePartial partAc f resetAc
|
DoActionWhilePartial partAc f resetAc
|
||||||
| doWdCrBl f w cr -> case performAction cr w partAc of
|
| doWdCrBl f w cr -> case performAction cr w partAc of
|
||||||
(imps, nxta : _) -> (imps, [DoActionWhilePartial nxta f resetAc])
|
(imps, NoAction) -> (imps, DoActionWhilePartial resetAc f resetAc)
|
||||||
(imps, []) -> (imps, [DoActionWhilePartial resetAc f resetAc])
|
(imps, nxta ) -> (imps, DoActionWhilePartial nxta f resetAc)
|
||||||
| otherwise -> performAction cr w partAc
|
| otherwise -> performAction cr w partAc
|
||||||
DoActionIf f ifa
|
DoActionIf f ifa
|
||||||
| doWdCrBl f w cr -> performAction cr w ifa
|
| doWdCrBl f w cr -> performAction cr w ifa
|
||||||
| otherwise -> ([], mempty)
|
| otherwise -> ([], NoAction)
|
||||||
DoActionIfElse ifa f elsea
|
DoActionIfElse ifa f elsea
|
||||||
| doWdCrBl f w cr -> performAction cr w ifa
|
| doWdCrBl f w cr -> performAction cr w ifa
|
||||||
| otherwise -> performAction cr w elsea
|
| otherwise -> performAction cr w elsea
|
||||||
DoActionWhileInterrupt repa f afta
|
DoActionWhileInterrupt repa f afta
|
||||||
| doWdCrBl f w cr -> (fst $ performAction cr w repa, [DoActionWhileInterrupt repa f afta])
|
| doWdCrBl f w cr -> (fst $ performAction cr w repa, DoActionWhileInterrupt repa f afta)
|
||||||
| otherwise -> performAction cr w afta
|
| otherwise -> performAction cr w afta
|
||||||
DoActions [] -> ([], mempty)
|
-- DoActions [] -> ([], NoAction)
|
||||||
DoActions acs ->
|
-- DoActions acs ->
|
||||||
let (imps, newAcs) = foldMap (performAction cr w) acs
|
-- let (imps, newAcs) = foldMap (performAction cr w) acs
|
||||||
in (imps, newAcs)
|
-- in (imps, newAcs)
|
||||||
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], mempty)
|
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], NoAction)
|
||||||
PathTo p a -> performPathTo a cr w p
|
PathTo p a -> performPathTo a cr w p
|
||||||
|
EvadeAim _ _ 0 -> (mempty,NoAction)
|
||||||
|
EvadeAim p a i -> tryEvadeSideways cr w p a i
|
||||||
TurnToPoint p -> performTurnToA cr p
|
TurnToPoint p -> performTurnToA cr p
|
||||||
LeadTarget p -> fromMaybe ([], mempty) $ do
|
LeadTarget p -> fromMaybe ([], NoAction) $ do
|
||||||
i <- cr ^? crIntention . targetCr . _Just
|
i <- cr ^? crIntention . targetCr . _Just
|
||||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||||
return ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], mempty)
|
return ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], NoAction)
|
||||||
UseSelf f -> performAction cr w $ doCrAc f cr
|
UseSelf f -> performAction cr w $ doCrAc f cr
|
||||||
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
||||||
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
|
DoImpulsesAlongside sideImp mainAc -> performAction cr w mainAc & _1 <>~ sideImp
|
||||||
(imp, [nxtac]) -> (sideImp ++ imp, [DoImpulsesAlongside sideImp nxtac])
|
|
||||||
(imp, _) -> (sideImp ++ imp, mempty)
|
|
||||||
DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac
|
DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac
|
||||||
DoReplicatePartial _ 0 pac -> performAction cr w pac
|
DoReplicatePartial _ 0 pac -> performAction cr w pac
|
||||||
DoReplicatePartial startac t partac -> case performAction cr w partac of
|
DoReplicatePartial startac t partac -> case performAction cr w partac of
|
||||||
(imps, [nextac]) -> (imps, [DoReplicatePartial startac t nextac])
|
(imps, NoAction) -> (imps, DoReplicatePartial startac (t -1) startac)
|
||||||
(imps, _) -> (imps, [DoReplicatePartial startac (t -1) startac])
|
(imps, nextac) -> (imps, DoReplicatePartial startac t nextac)
|
||||||
NoAction -> ([], mempty)
|
NoAction -> ([], NoAction)
|
||||||
|
|
||||||
|
tryEvadeSideways :: Creature -> World -> Point2 -> Float -> Int -> ActionUpdate
|
||||||
|
tryEvadeSideways _ _ p a i = jumpleft -- (mv,mempty)
|
||||||
|
where
|
||||||
|
jumpleft = (mv,EvadeAim p a (i-1))
|
||||||
|
mv = [Move (V2 0 3)]
|
||||||
|
|
||||||
performAimAt :: Creature -> World -> Int -> Point2 -> ActionUpdate
|
performAimAt :: Creature -> World -> Int -> Point2 -> ActionUpdate
|
||||||
performAimAt cr w tcid p = ([TurnToward tpos aimSp], [AimAt tcid tpos])
|
performAimAt cr w tcid p = ([TurnToward tpos aimSp], AimAt tcid tpos)
|
||||||
where
|
where
|
||||||
cdir = _crDir cr
|
cdir = _crDir cr
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
@@ -121,20 +128,20 @@ crPathing cr = case cr ^. crStance . carriage of
|
|||||||
|
|
||||||
performPathTo :: Action -> Creature -> World -> Point2 -> ActionUpdate
|
performPathTo :: Action -> Creature -> World -> Point2 -> ActionUpdate
|
||||||
performPathTo a cr w p
|
performPathTo a cr w p
|
||||||
| dist cpos p <= crRad (cr ^. crType) = mempty
|
| dist cpos p <= crRad (cr ^. crType) = (mempty,NoAction)
|
||||||
| fst (crPathing cr) cpos p w = gotowards p
|
| fst (crPathing cr) cpos p w = gotowards p
|
||||||
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
|
| otherwise = case uncurry pointTowardsImpulse' (crPathing cr) cpos p w of
|
||||||
Just q -> gotowards q
|
Just q -> gotowards q
|
||||||
_ -> ([], [a])
|
_ -> ([], a)
|
||||||
where
|
where
|
||||||
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , [PathTo p a])
|
gotowards q = ( [MvTurnToward q, MvForward, RandomTurn jit] , PathTo p a)
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
jit = _mvTurnJit $ crMvType cr
|
jit = _mvTurnJit $ crMvType cr
|
||||||
|
|
||||||
performTurnToA :: Creature -> Point2 -> ActionUpdate
|
performTurnToA :: Creature -> Point2 -> ActionUpdate
|
||||||
performTurnToA cr p
|
performTurnToA cr p
|
||||||
| angleVV cdirv dirv < 0.1 = mempty
|
| angleVV cdirv dirv < 0.1 = (mempty,NoAction)
|
||||||
| otherwise = ([MvTurnToward p, RandomTurn jit], [TurnToPoint p])
|
| otherwise = ([MvTurnToward p, RandomTurn jit], TurnToPoint p)
|
||||||
where
|
where
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
cdirv = unitVectorAtAngle (_crDir cr)
|
cdirv = unitVectorAtAngle (_crDir cr)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ flockArmourChaseCrit =
|
|||||||
-- ]
|
-- ]
|
||||||
, _crActionPlan =
|
, _crActionPlan =
|
||||||
ActionPlan
|
ActionPlan
|
||||||
{ _apAction = []
|
{ _apAction = NoAction
|
||||||
, _apStrategy = FollowImpulses
|
, _apStrategy = FollowImpulses
|
||||||
, _apGoal = [Kill 0]
|
, _apGoal = [Kill 0]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Dodge.Creature.ChaseCrit (
|
module Dodge.Creature.ChaseCrit (
|
||||||
smallChaseCrit,
|
smallChaseCrit,
|
||||||
invisibleChaseCrit,
|
invisibleChaseCrit,
|
||||||
|
crabCrit,
|
||||||
chaseCrit,
|
chaseCrit,
|
||||||
hoverCrit,
|
hoverCrit,
|
||||||
) where
|
) where
|
||||||
@@ -32,6 +33,13 @@ chaseCrit =
|
|||||||
& crHP .~ HP 150
|
& crHP .~ HP 150
|
||||||
& crFaction .~ ColorFaction green
|
& crFaction .~ ColorFaction green
|
||||||
|
|
||||||
|
crabCrit :: Creature
|
||||||
|
crabCrit = defaultCreature
|
||||||
|
& crName .~ "chaseCrit"
|
||||||
|
& crHP .~ HP 350
|
||||||
|
& crType .~ CrabCrit 0 LeftForward 0 0
|
||||||
|
& crFaction .~ ColorFaction red
|
||||||
|
|
||||||
hoverCrit :: Creature
|
hoverCrit :: Creature
|
||||||
hoverCrit =
|
hoverCrit =
|
||||||
defaultCreature
|
defaultCreature
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ crMass :: CreatureType -> Float
|
|||||||
crMass = \case
|
crMass = \case
|
||||||
Avatar {} -> 10
|
Avatar {} -> 10
|
||||||
ChaseCrit {} -> 10
|
ChaseCrit {} -> 10
|
||||||
|
CrabCrit {} -> 10
|
||||||
HoverCrit {} -> 5
|
HoverCrit {} -> 5
|
||||||
SwarmCrit -> 2
|
SwarmCrit -> 2
|
||||||
AutoCrit -> 10
|
AutoCrit -> 10
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crMaterial :: CreatureType -> Material
|
|||||||
crMaterial = \case
|
crMaterial = \case
|
||||||
Avatar{_avatarMaterial = mt} -> mt
|
Avatar{_avatarMaterial = mt} -> mt
|
||||||
ChaseCrit {} -> Flesh
|
ChaseCrit {} -> Flesh
|
||||||
|
CrabCrit {} -> Flesh
|
||||||
HoverCrit {} -> Metal
|
HoverCrit {} -> Metal
|
||||||
SwarmCrit -> Flesh
|
SwarmCrit -> Flesh
|
||||||
AutoCrit -> Flesh
|
AutoCrit -> Flesh
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ crMaxHP :: CreatureType -> Int
|
|||||||
crMaxHP = \case
|
crMaxHP = \case
|
||||||
Avatar {} -> 15000
|
Avatar {} -> 15000
|
||||||
ChaseCrit {} -> 150
|
ChaseCrit {} -> 150
|
||||||
|
CrabCrit {} -> 350
|
||||||
HoverCrit {} -> 100
|
HoverCrit {} -> 100
|
||||||
SwarmCrit -> 50
|
SwarmCrit -> 50
|
||||||
AutoCrit -> 100
|
AutoCrit -> 100
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ crMvType :: Creature -> CrMvType
|
|||||||
crMvType cr = case _crType cr of
|
crMvType cr = case _crType cr of
|
||||||
Avatar {} -> MvWalking 1.5
|
Avatar {} -> MvWalking 1.5
|
||||||
ChaseCrit {} -> defaultChaseMvType & mvSpeed .~ 1.8
|
ChaseCrit {} -> defaultChaseMvType & mvSpeed .~ 1.8
|
||||||
|
CrabCrit {} -> defaultChaseMvType & mvSpeed .~ 1
|
||||||
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.16
|
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.16
|
||||||
SwarmCrit -> defaultChaseMvType
|
SwarmCrit -> defaultChaseMvType
|
||||||
AutoCrit -> defaultAimMvType
|
AutoCrit -> defaultAimMvType
|
||||||
|
|||||||
@@ -21,12 +21,8 @@ import Linear
|
|||||||
import RandomHelp
|
import RandomHelp
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
|
|
||||||
perceptionUpdate ::
|
-- | The [Int] is a list of creature ids that may direct attention and awareness
|
||||||
-- | List of creature ids that may direct attention and awareness
|
perceptionUpdate :: [Int] -> World -> Creature -> Creature
|
||||||
[Int] ->
|
|
||||||
World ->
|
|
||||||
Creature ->
|
|
||||||
Creature
|
|
||||||
perceptionUpdate is w = rememberSounds w . basicAwarenessUpdate w . basicAttentionUpdate is w
|
perceptionUpdate is w = rememberSounds w . basicAwarenessUpdate w . basicAttentionUpdate is w
|
||||||
|
|
||||||
{- | Update a creatures awareness based upon the creatures' current direction
|
{- | Update a creatures awareness based upon the creatures' current direction
|
||||||
@@ -55,9 +51,9 @@ basicAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
|||||||
return $
|
return $
|
||||||
(crActionPlan . apStrategy .~ WarningCry) .
|
(crActionPlan . apStrategy .~ WarningCry) .
|
||||||
(crActionPlan . apAction
|
(crActionPlan . apAction
|
||||||
.~ [ImpulsesList (crImpulsesOnCognizant w cr)
|
.~ ImpulsesList (crImpulsesOnCognizant w cr)
|
||||||
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy)
|
(AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy))
|
||||||
])
|
)
|
||||||
|
|
||||||
crImpulsesOnCognizant :: World -> Creature -> [[Impulse]]
|
crImpulsesOnCognizant :: World -> Creature -> [[Impulse]]
|
||||||
crImpulsesOnCognizant w cr = case cr ^. crType of
|
crImpulsesOnCognizant w cr = case cr ^. crType of
|
||||||
@@ -65,6 +61,7 @@ crImpulsesOnCognizant w cr = case cr ^. crType of
|
|||||||
<> [[ChangeStrategy $ CloseToMelee 0]]
|
<> [[ChangeStrategy $ CloseToMelee 0]]
|
||||||
HoverCrit {} | Just sid <- cognizantVoc w cr -> [Bark sid]:
|
HoverCrit {} | Just sid <- cognizantVoc w cr -> [Bark sid]:
|
||||||
[[ChangeStrategy $ CloseToMelee 0]]
|
[[ChangeStrategy $ CloseToMelee 0]]
|
||||||
|
CrabCrit {} -> [[ChangeStrategy $ CloseToMelee 0]]
|
||||||
_ | Just sid <- cognizantVoc w cr -> [Bark sid]: replicate 5 [RandomImpulse $ RandImpulseCircMove 1]
|
_ | Just sid <- cognizantVoc w cr -> [Bark sid]: replicate 5 [RandomImpulse $ RandImpulseCircMove 1]
|
||||||
_ -> replicate 5 [RandomImpulse $ RandImpulseCircMove 3]
|
_ -> replicate 5 [RandomImpulse $ RandImpulseCircMove 3]
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module Dodge.Creature.Picture (
|
|||||||
deadFeet,
|
deadFeet,
|
||||||
drawChaseCrit,
|
drawChaseCrit,
|
||||||
drawHoverCrit,
|
drawHoverCrit,
|
||||||
|
drawCrabCrit,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Base.Collide
|
import Dodge.Base.Collide
|
||||||
@@ -65,6 +66,14 @@ drawHoverCrit cr = colorSH (_skinHead cskin)
|
|||||||
f a = tpq `Q.comp` (1 & _xy .~ rotateV a 5, Q.qid)
|
f a = tpq `Q.comp` (1 & _xy .~ rotateV a 5, Q.qid)
|
||||||
tpq = (V3 0 0 0, Q.qid)
|
tpq = (V3 0 0 0, Q.qid)
|
||||||
|
|
||||||
|
drawCrabCrit :: World -> Creature -> Shape
|
||||||
|
drawCrabCrit w cr = mconcat
|
||||||
|
[ crabUpperBody w cr
|
||||||
|
, colorSH (_skinLower cskin) $ crabFeet cr
|
||||||
|
]
|
||||||
|
where
|
||||||
|
cskin = crShape $ _crType cr
|
||||||
|
|
||||||
drawChaseCrit :: World -> Creature -> Shape
|
drawChaseCrit :: World -> Creature -> Shape
|
||||||
drawChaseCrit w cr = mconcat
|
drawChaseCrit w cr = mconcat
|
||||||
[ chaseUpperBody w cr
|
[ chaseUpperBody w cr
|
||||||
@@ -74,6 +83,16 @@ drawChaseCrit w cr = mconcat
|
|||||||
cskin = crShape $ _crType cr
|
cskin = crShape $ _crType cr
|
||||||
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
|
||||||
|
|
||||||
|
crabUpperBody :: World -> Creature -> Shape
|
||||||
|
crabUpperBody _ cr = colorSH (_skinUpper cskin)
|
||||||
|
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI 5 $ polyCirc 4 12
|
||||||
|
& each . _x *~ 0.6)
|
||||||
|
)
|
||||||
|
where
|
||||||
|
torsoq = (V3 0 0 10,Q.qid)
|
||||||
|
cskin = crShape $ _crType cr
|
||||||
|
|
||||||
|
|
||||||
chaseUpperBody :: World -> Creature -> Shape
|
chaseUpperBody :: World -> Creature -> Shape
|
||||||
chaseUpperBody w cr = colorSH (_skinUpper cskin)
|
chaseUpperBody w cr = colorSH (_skinUpper cskin)
|
||||||
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI tz $ polyCirc 3 12
|
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI tz $ polyCirc 3 12
|
||||||
@@ -126,6 +145,20 @@ feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
|||||||
-- f i = 8 * (sLen - 2*i) / sLen
|
-- f i = 8 * (sLen - 2*i) / sLen
|
||||||
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
||||||
|
|
||||||
|
crabFeet :: Creature -> Shape
|
||||||
|
{-# INLINE crabFeet #-}
|
||||||
|
crabFeet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||||
|
(Just sa,Just LeftForward) -> sh (f sa)
|
||||||
|
(Just sa,Just RightForward) -> sh (-f sa)
|
||||||
|
_ -> sh 0
|
||||||
|
where
|
||||||
|
sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
|
||||||
|
aFoot = upperPrismPolyST 10 $ polyCirc 3 2
|
||||||
|
off = 10
|
||||||
|
sLen = strideLength cr
|
||||||
|
-- f i = 8 * (sLen - 2*i) / sLen
|
||||||
|
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
||||||
|
|
||||||
deadFeet :: Creature -> Shape
|
deadFeet :: Creature -> Shape
|
||||||
{-# INLINE deadFeet #-}
|
{-# INLINE deadFeet #-}
|
||||||
deadFeet = feet
|
deadFeet = feet
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crRad :: CreatureType -> Float
|
|||||||
crRad = \case
|
crRad = \case
|
||||||
Avatar {} -> 10
|
Avatar {} -> 10
|
||||||
ChaseCrit {} -> 10
|
ChaseCrit {} -> 10
|
||||||
|
CrabCrit {} -> 10
|
||||||
HoverCrit {} -> 8
|
HoverCrit {} -> 8
|
||||||
SwarmCrit -> 2
|
SwarmCrit -> 2
|
||||||
AutoCrit -> 10
|
AutoCrit -> 10
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
module Dodge.Creature.ReaderUpdate (
|
module Dodge.Creature.ReaderUpdate (
|
||||||
doStrategyActions,
|
doStrategyActions,
|
||||||
setTargetMv,
|
|
||||||
targetYouWhenCognizant,
|
targetYouWhenCognizant,
|
||||||
overrideMeleeCloseTarget,
|
overrideMeleeCloseTarget,
|
||||||
watchUpdateStrat,
|
watchUpdateStrat,
|
||||||
@@ -9,7 +9,8 @@ module Dodge.Creature.ReaderUpdate (
|
|||||||
-- goToTarget,
|
-- goToTarget,
|
||||||
flockACC,
|
flockACC,
|
||||||
chaseCritMv,
|
chaseCritMv,
|
||||||
setMvPos,
|
crabCritMv,
|
||||||
|
setMvPosToTargetCr,
|
||||||
setViewPos,
|
setViewPos,
|
||||||
hoverCritMv,
|
hoverCritMv,
|
||||||
) where
|
) where
|
||||||
@@ -45,19 +46,18 @@ tryMeleeAttack cr tcr
|
|||||||
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
|
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
|
||||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
|
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
|
||||||
cr & crActionPlan . apAction
|
cr & crActionPlan . apAction
|
||||||
.~ [ DoImpulses [Melee $ _crID tcr] `DoActionThen`
|
.~ DoImpulses [Melee $ _crID tcr] `DoActionThen`
|
||||||
DoReplicate 10 NoAction
|
DoReplicate 10 NoAction
|
||||||
`DoActionThen` DoImpulses
|
-- `DoActionThen` DoImpulses
|
||||||
[ChangeStrategy (CloseToMelee $ _crID tcr)]
|
-- [ChangeStrategy (CloseToMelee $ _crID tcr)]
|
||||||
]
|
-- & crActionPlan . apStrategy .~ MeleeStrike
|
||||||
& crActionPlan . apStrategy .~ MeleeStrike
|
|
||||||
| otherwise = cr
|
| otherwise = cr
|
||||||
where
|
where
|
||||||
cpos = cr ^. crPos . _xy
|
cpos = cr ^. crPos . _xy
|
||||||
tpos = tcr ^. crPos . _xy
|
tpos = tcr ^. crPos . _xy
|
||||||
|
|
||||||
setMvPos :: World -> Creature -> Creature
|
setMvPosToTargetCr :: World -> Creature -> Creature
|
||||||
setMvPos w cr = cr & crIntention . mvToPoint .~ mpos
|
setMvPosToTargetCr w cr = cr & crIntention . mvToPoint .~ mpos
|
||||||
where
|
where
|
||||||
int = _crIntention cr
|
int = _crIntention cr
|
||||||
mtpos = do
|
mtpos = do
|
||||||
@@ -81,17 +81,17 @@ attentionViewPoint w cr = do
|
|||||||
guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
|
guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
|
||||||
tcr ^? crPos . _xy
|
tcr ^? crPos . _xy
|
||||||
|
|
||||||
setTargetMv ::
|
--setTargetMv ::
|
||||||
-- | Function for determining target
|
-- -- | Function for determining target
|
||||||
(World -> Creature -> Maybe Creature) ->
|
-- (World -> Creature -> Maybe Creature) ->
|
||||||
World ->
|
-- World ->
|
||||||
Creature ->
|
-- Creature ->
|
||||||
Creature
|
-- Creature
|
||||||
setTargetMv targFunc w cr =
|
--setTargetMv targFunc w cr =
|
||||||
maybe
|
-- maybe
|
||||||
cr
|
-- cr
|
||||||
(\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
|
-- (\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
|
||||||
(targFunc w cr)
|
-- (targFunc w cr)
|
||||||
|
|
||||||
-- ugly
|
-- ugly
|
||||||
flockACC :: World -> Creature -> Creature
|
flockACC :: World -> Creature -> Creature
|
||||||
@@ -120,48 +120,88 @@ flockACC w cr = fromMaybe cr $ do
|
|||||||
else negate r *.* horDir
|
else negate r *.* horDir
|
||||||
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
||||||
|
|
||||||
|
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 _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
|
Just p
|
||||||
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
|
| otherwise ->
|
||||||
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
|
& crActionPlan . apStrategy .~ Search
|
||||||
|
& crIntention . mvToPoint .~ Nothing
|
||||||
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
_ -> True
|
||||||
|
aimi tid = do
|
||||||
|
tcr <- w ^? cWorld . lWorld . creatures . ix tid
|
||||||
|
Aiming <- tcr ^? crStance . posture
|
||||||
|
let txy = tcr ^. crPos . _xy
|
||||||
|
cxy = cr ^. crPos . _xy
|
||||||
|
0 <- cr ^? crType . dodgeCooldown
|
||||||
|
guard $ hasLOS cxy txy w
|
||||||
|
&& abs (nearZeroAngle (tcr^.crDir - argV (cxy - txy))) < 0.3
|
||||||
|
return (txy, tcr ^. crDir)
|
||||||
|
|
||||||
chaseCritMv :: World -> Creature -> Creature
|
chaseCritMv :: World -> Creature -> Creature
|
||||||
chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||||
WarningCry -> cr
|
WarningCry -> cr
|
||||||
MeleeStrike -> cr
|
|
||||||
CloseToMelee cid
|
CloseToMelee cid
|
||||||
| VocReady == (cr ^. crVocalization) ->
|
| VocReady == (cr ^. crVocalization) ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction
|
& crActionPlan . apAction
|
||||||
.:~ ImpulsesList
|
.~ ImpulsesList
|
||||||
( [Bark soundid] :
|
( [Bark soundid] :
|
||||||
replicate numjits [RandomImpulse thejitter]
|
replicate numjits [RandomImpulse thejitter]
|
||||||
++ [[ChangeStrategy (CloseToMelee cid)]]
|
++ [[ChangeStrategy (CloseToMelee cid)]]
|
||||||
)
|
) NoAction
|
||||||
& resetCrVocCoolDown w
|
& resetCrVocCoolDown w
|
||||||
& crActionPlan . apStrategy .~ WarningCry
|
& crActionPlan . apStrategy .~ WarningCry
|
||||||
where
|
where
|
||||||
thejitter = RandImpulseCircMove 3
|
thejitter = RandImpulseCircMove 3
|
||||||
soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
|
soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
|
||||||
numjits = fst $ randomR (15, 25) (_randGen w)
|
numjits = fst $ randomR (15, 25) (_randGen w)
|
||||||
|
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
Just p
|
Just p
|
||||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
cr & crActionPlan . apAction .~ [PathTo p (DoImpulses [ChangeStrategy Wander])]
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
& crActionPlan . apStrategy .~ WatchAndWait
|
& crActionPlan . apStrategy .~ WatchAndWait
|
||||||
& crIntention . mvToPoint .~ Nothing
|
& crIntention . mvToPoint .~ Nothing
|
||||||
_ -> viewTarget w cr
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
hoverCritMv :: World -> Creature -> Creature
|
hoverCritMv :: World -> Creature -> Creature
|
||||||
hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
hoverCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||||
WarningCry -> cr
|
WarningCry -> cr
|
||||||
MeleeStrike -> cr
|
CloseToMelee _ | ma <- cr ^? crActionPlan . apAction , notpath ma -> cr
|
||||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||||
Just p
|
Just p
|
||||||
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
| dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) ->
|
||||||
cr & crActionPlan . apAction .~ [PathTo p (DoImpulses [ChangeStrategy Wander])]
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
cr & crActionPlan . apAction .~ bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
|
||||||
& crActionPlan . apStrategy .~ WatchAndWait
|
& crActionPlan . apStrategy .~ WatchAndWait
|
||||||
& crIntention . mvToPoint .~ Nothing
|
& crIntention . mvToPoint .~ Nothing
|
||||||
_ -> viewTarget w cr
|
_ -> viewTarget w cr
|
||||||
|
where
|
||||||
|
notpath = \case
|
||||||
|
Just NoAction -> False
|
||||||
|
Just PathTo {} -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
--goToTarget :: World -> Creature -> Creature
|
--goToTarget :: World -> Creature -> Creature
|
||||||
--goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
--goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
||||||
@@ -173,23 +213,25 @@ viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
|
|||||||
Just p
|
Just p
|
||||||
| hasLOSIndirect p (cr ^. crPos . _xy) w ->
|
| hasLOSIndirect p (cr ^. crPos . _xy) w ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction .~ [TurnToPoint p]
|
& crActionPlan . apAction .~ TurnToPoint p
|
||||||
& crIntention . viewPoint .~ Nothing
|
& crIntention . viewPoint .~ Nothing
|
||||||
& crActionPlan . apStrategy .~ Investigate
|
& crActionPlan . apStrategy .~ Investigate
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr & crActionPlan . apAction %~ replaceNullWith (PathTo p (DoImpulses [ChangeStrategy Wander]))
|
-- cr & crActionPlan . apAction %~ replaceNullWith (PathTo p (DoImpulses [ChangeStrategy Wander]))
|
||||||
|
cr & crActionPlan . apAction .~ PathTo p (DoImpulses [ChangeStrategy Wander])
|
||||||
& crActionPlan . apStrategy .~ Investigate
|
& crActionPlan . apStrategy .~ Investigate
|
||||||
Nothing -> cr
|
Nothing -> cr
|
||||||
|
|
||||||
replaceNullWith :: a -> [a] -> [a]
|
--replaceNullWith :: a -> [a] -> [a]
|
||||||
replaceNullWith x [] = [x]
|
--replaceNullWith x [] = [x]
|
||||||
replaceNullWith _ xs = xs
|
--replaceNullWith _ xs = xs
|
||||||
|
|
||||||
doStrategyActions :: Creature -> Creature
|
doStrategyActions :: Creature -> Creature
|
||||||
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
||||||
Just (StrategyActions strat acs) ->
|
Just (StrategyActions strat acs) ->
|
||||||
cr
|
cr
|
||||||
& crActionPlan . apAction .~ acs
|
-- & crActionPlan . apAction .~ acs
|
||||||
|
& crActionPlan . apAction .~ head acs
|
||||||
& crActionPlan . apStrategy .~ strat
|
& crActionPlan . apStrategy .~ strat
|
||||||
_ -> cr
|
_ -> cr
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ crShape :: CreatureType -> CreatureShape
|
|||||||
crShape = \case
|
crShape = \case
|
||||||
Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3)
|
Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3)
|
||||||
ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3)
|
ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3)
|
||||||
|
CrabCrit {} -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
||||||
HoverCrit {} -> Humanoid (greyN 0.9) (light blue) (greyN 0.3)
|
HoverCrit {} -> Humanoid (greyN 0.9) (light blue) (greyN 0.3)
|
||||||
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3)
|
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3)
|
||||||
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ crDexterity cr = case cr ^. crType of
|
|||||||
AutoCrit -> 46
|
AutoCrit -> 46
|
||||||
BarrelCrit {} -> 0
|
BarrelCrit {} -> 0
|
||||||
LampCrit {} -> 0
|
LampCrit {} -> 0
|
||||||
|
_ -> 46
|
||||||
|
|
||||||
crStrength :: Creature -> Int
|
crStrength :: Creature -> Int
|
||||||
crStrength cr = case cr ^. crType of
|
crStrength cr = case cr ^. crType of
|
||||||
@@ -35,11 +36,13 @@ crStrength cr = case cr ^. crType of
|
|||||||
AutoCrit -> 46
|
AutoCrit -> 46
|
||||||
BarrelCrit {} -> 0
|
BarrelCrit {} -> 0
|
||||||
LampCrit {} -> 0
|
LampCrit {} -> 0
|
||||||
|
_ -> 46
|
||||||
|
|
||||||
crIntelligence :: Creature -> Int
|
crIntelligence :: Creature -> Int
|
||||||
crIntelligence cr = case cr ^. crType of
|
crIntelligence cr = case cr ^. crType of
|
||||||
Avatar { _avIntelligence = x } -> x
|
Avatar { _avIntelligence = x } -> x
|
||||||
ChaseCrit {} -> 20
|
ChaseCrit {} -> 20
|
||||||
|
CrabCrit {} -> 20
|
||||||
HoverCrit {} -> 20
|
HoverCrit {} -> 20
|
||||||
SwarmCrit -> 20
|
SwarmCrit -> 20
|
||||||
AutoCrit -> 20
|
AutoCrit -> 20
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ updateLivingCreature cr =
|
|||||||
ChaseCrit{} -> \w ->
|
ChaseCrit{} -> \w ->
|
||||||
crUpdate cid . performActions cid $
|
crUpdate cid . performActions cid $
|
||||||
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
|
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
|
||||||
|
CrabCrit{} -> \w ->
|
||||||
|
crUpdate cid . performActions cid $
|
||||||
|
over (cWorld . lWorld . creatures . ix cid) (crabCritInternal w) w
|
||||||
AutoCrit {} -> crUpdate cid
|
AutoCrit {} -> crUpdate cid
|
||||||
SwarmCrit {} -> crUpdate cid
|
SwarmCrit {} -> crUpdate cid
|
||||||
HoverCrit {} -> \w ->
|
HoverCrit {} -> \w ->
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ crWarningSounds cr = case cr ^. crType of
|
|||||||
, seagullCry1S
|
, seagullCry1S
|
||||||
, seagullCry2S
|
, seagullCry2S
|
||||||
]
|
]
|
||||||
|
CrabCrit {} -> mempty
|
||||||
HoverCrit {} -> mempty
|
HoverCrit {} -> mempty
|
||||||
SwarmCrit -> mempty
|
SwarmCrit -> mempty
|
||||||
AutoCrit -> mempty
|
AutoCrit -> mempty
|
||||||
@@ -36,6 +37,7 @@ crDeathSounds :: Creature -> DeathType -> [SoundID]
|
|||||||
crDeathSounds cr dt = case cr ^. crType of
|
crDeathSounds cr dt = case cr ^. crType of
|
||||||
Avatar{} -> mempty
|
Avatar{} -> mempty
|
||||||
ChaseCrit{} -> defaultDeathSounds dt
|
ChaseCrit{} -> defaultDeathSounds dt
|
||||||
|
CrabCrit{} -> defaultDeathSounds dt
|
||||||
HoverCrit{} -> hoverDeathSounds dt
|
HoverCrit{} -> hoverDeathSounds dt
|
||||||
SwarmCrit -> mempty
|
SwarmCrit -> mempty
|
||||||
AutoCrit -> mempty
|
AutoCrit -> mempty
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ shootFirstMiss :: Action
|
|||||||
shootFirstMiss =
|
shootFirstMiss =
|
||||||
LeadTarget (V2 30 50)
|
LeadTarget (V2 30 50)
|
||||||
`DoActionThen` DoImpulses [UseItem]
|
`DoActionThen` DoImpulses [UseItem]
|
||||||
`DoActionThen` (WdCrBlfromCrBl CrCanShoot `DoActionWhile` DoActions [LeadTarget (V2 0 0), DoImpulses [UseItem]])
|
-- `DoActionThen` (WdCrBlfromCrBl CrCanShoot `DoActionWhile` DoActions [LeadTarget (V2 0 0), DoImpulses [UseItem]])
|
||||||
`DoActionThen` 20 `WaitThen` holsterWeapon
|
`DoActionThen` 20 `WaitThen` holsterWeapon
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ data ActionPlan
|
|||||||
= Inanimate
|
= Inanimate
|
||||||
| ActionPlan
|
| ActionPlan
|
||||||
{ -- _apImpulse :: [Impulse] -- done per frame
|
{ -- _apImpulse :: [Impulse] -- done per frame
|
||||||
_apAction :: [Action] -- updated per frame, likely persist across frames
|
_apAction :: Action -- updated per frame, likely persist across frames
|
||||||
, _apStrategy :: Strategy -- current strategy
|
, _apStrategy :: Strategy -- current strategy
|
||||||
, _apGoal :: [Goal] -- particular ordered goals
|
, _apGoal :: [Goal] -- particular ordered goals
|
||||||
}
|
}
|
||||||
@@ -68,8 +68,9 @@ data Action
|
|||||||
, _targetSeenAt :: Point2
|
, _targetSeenAt :: Point2
|
||||||
}
|
}
|
||||||
| PathTo { _pathToPoint :: Point2, _pathFailAction :: Action }
|
| PathTo { _pathToPoint :: Point2, _pathFailAction :: Action }
|
||||||
|
| EvadeAim {_enemyPos :: Point2, _enemyDir :: Float, _acTimer :: Int}
|
||||||
| TurnToPoint { _turnToPoint :: Point2 }
|
| TurnToPoint { _turnToPoint :: Point2 }
|
||||||
| ImpulsesList { _impulsesListList :: [[Impulse]] }
|
| ImpulsesList { _impulsesListList :: [[Impulse]], _acAction :: Action }
|
||||||
| DoImpulses { _doImpulsesList :: [Impulse] }
|
| DoImpulses { _doImpulsesList :: [Impulse] }
|
||||||
| WaitThen
|
| WaitThen
|
||||||
{ _waitThenTimer :: Int
|
{ _waitThenTimer :: Int
|
||||||
@@ -98,7 +99,7 @@ data Action
|
|||||||
, _doActionWhileThenCondition :: WdCrBl
|
, _doActionWhileThenCondition :: WdCrBl
|
||||||
, _doActionWhileThenThen :: Action
|
, _doActionWhileThenThen :: Action
|
||||||
}
|
}
|
||||||
| DoActions { _doActionsList :: [Action] }
|
-- | DoActions { _doActionsList :: [Action] }
|
||||||
| DoActionThen
|
| DoActionThen
|
||||||
{ _doActionThenFirst :: Action
|
{ _doActionThenFirst :: Action
|
||||||
, _doActionThenSecond :: Action
|
, _doActionThenSecond :: Action
|
||||||
@@ -140,9 +141,9 @@ data Strategy
|
|||||||
| CloseToMelee {_meleeTarget :: Int}
|
| CloseToMelee {_meleeTarget :: Int}
|
||||||
| StrategyActions Strategy [Action]
|
| StrategyActions Strategy [Action]
|
||||||
| GetTo Point2
|
| GetTo Point2
|
||||||
| Reload
|
-- | Reload
|
||||||
| Flee
|
| Flee
|
||||||
| MeleeStrike
|
-- | MeleeStrike
|
||||||
| Search
|
| Search
|
||||||
deriving (Eq, Ord, Show) --Generic, Flat)
|
deriving (Eq, Ord, Show) --Generic, Flat)
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ data CreatureType
|
|||||||
, _footForward :: FootForward
|
, _footForward :: FootForward
|
||||||
, _strideAmount :: Float
|
, _strideAmount :: Float
|
||||||
}
|
}
|
||||||
|
| CrabCrit {_meleeCooldown :: Int
|
||||||
|
, _footForward :: FootForward
|
||||||
|
, _strideAmount :: Float
|
||||||
|
, _dodgeCooldown :: Int
|
||||||
|
}
|
||||||
| HoverCrit {_meleeCooldown :: Int}
|
| HoverCrit {_meleeCooldown :: Int}
|
||||||
| SwarmCrit
|
| SwarmCrit
|
||||||
| AutoCrit
|
| AutoCrit
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ defaultCreature =
|
|||||||
, _posture = AtEase
|
, _posture = AtEase
|
||||||
}
|
}
|
||||||
, _crVocalization = VocReady
|
, _crVocalization = VocReady
|
||||||
, _crActionPlan = ActionPlan [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
|
, _crActionPlan = ActionPlan NoAction (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
|
||||||
, _crPerception = defaultPerceptionState
|
, _crPerception = defaultPerceptionState
|
||||||
, _crMemory = defaultCreatureMemory
|
, _crMemory = defaultCreatureMemory
|
||||||
, _crFaction = NoFaction
|
, _crFaction = NoFaction
|
||||||
|
|||||||
+17
-2
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Humanoid (
|
module Dodge.Humanoid (
|
||||||
chaseCritInternal,
|
chaseCritInternal,
|
||||||
|
crabCritInternal,
|
||||||
hoverCritInternal,
|
hoverCritInternal,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ chaseCritInternal w cr =
|
|||||||
[ const doStrategyActions
|
[ const doStrategyActions
|
||||||
, overrideMeleeCloseTarget
|
, overrideMeleeCloseTarget
|
||||||
, setViewPos
|
, setViewPos
|
||||||
, setMvPos
|
, setMvPosToTargetCr
|
||||||
, chaseCritMv
|
, chaseCritMv
|
||||||
, perceptionUpdate [0]
|
, perceptionUpdate [0]
|
||||||
, targetYouWhenCognizant
|
, targetYouWhenCognizant
|
||||||
@@ -25,6 +26,20 @@ chaseCritInternal w cr =
|
|||||||
, const (crVocalization %~ updateVocTimer)
|
, const (crVocalization %~ updateVocTimer)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
crabCritInternal :: World -> Creature -> Creature
|
||||||
|
crabCritInternal w =
|
||||||
|
(crVocalization %~ updateVocTimer)
|
||||||
|
. (crType . meleeCooldown %~ max 0 . subtract 1)
|
||||||
|
. (crType . dodgeCooldown %~ max 0 . subtract 1)
|
||||||
|
. searchIfDamaged
|
||||||
|
. targetYouWhenCognizant w
|
||||||
|
. perceptionUpdate [0] w
|
||||||
|
. crabCritMv w
|
||||||
|
. setMvPosToTargetCr w
|
||||||
|
. setViewPos w
|
||||||
|
. overrideMeleeCloseTarget w
|
||||||
|
. doStrategyActions
|
||||||
|
|
||||||
hoverCritInternal :: World -> Creature -> Creature
|
hoverCritInternal :: World -> Creature -> Creature
|
||||||
hoverCritInternal w cr =
|
hoverCritInternal w cr =
|
||||||
foldl'
|
foldl'
|
||||||
@@ -33,7 +48,7 @@ hoverCritInternal w cr =
|
|||||||
[ const doStrategyActions
|
[ const doStrategyActions
|
||||||
, overrideMeleeCloseTarget
|
, overrideMeleeCloseTarget
|
||||||
, setViewPos
|
, setViewPos
|
||||||
, setMvPos
|
, setMvPosToTargetCr
|
||||||
, hoverCritMv
|
, hoverCritMv
|
||||||
, perceptionUpdate [0]
|
, perceptionUpdate [0]
|
||||||
, targetYouWhenCognizant
|
, targetYouWhenCognizant
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ drawCreature w m cr = translateSP (_crPos cr) . rotateSP (_crDir cr) $
|
|||||||
Avatar {} -> basicCrPict m cr
|
Avatar {} -> basicCrPict m cr
|
||||||
SwarmCrit -> basicCrPict m cr
|
SwarmCrit -> basicCrPict m cr
|
||||||
AutoCrit -> basicCrPict m cr
|
AutoCrit -> basicCrPict m cr
|
||||||
|
CrabCrit {} -> noPic $ drawCrabCrit w cr
|
||||||
HoverCrit{} -> noPic $ drawHoverCrit cr
|
HoverCrit{} -> noPic $ drawHoverCrit cr
|
||||||
|
|
||||||
barrelShape :: SPic
|
barrelShape :: SPic
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module Dodge.Room.Tutorial where
|
module Dodge.Room.Tutorial where
|
||||||
|
|
||||||
|
import Dodge.Item.Held.Stick
|
||||||
import Dodge.Creature.ChaseCrit
|
import Dodge.Creature.ChaseCrit
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
@@ -427,6 +428,10 @@ tutLight = do
|
|||||||
)
|
)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
crabRoom :: State LayoutVars Room
|
||||||
|
crabRoom = (putSingleLight =<< roomNgon 6 150)
|
||||||
|
<&> rmPmnts .:~ psPtPl (PS 100 0) (PutCrit crabCrit)
|
||||||
|
|
||||||
loadAmmoTut :: State LayoutVars (MetaTree Room String)
|
loadAmmoTut :: State LayoutVars (MetaTree Room String)
|
||||||
loadAmmoTut = do
|
loadAmmoTut = do
|
||||||
i <- nextLayoutInt
|
i <- nextLayoutInt
|
||||||
@@ -445,14 +450,16 @@ loadAmmoTut = do
|
|||||||
=<< join (takeOne [roomNgon 6 80, roomRectAutoLights 100 100])
|
=<< join (takeOne [roomNgon 6 80, roomRectAutoLights 100 100])
|
||||||
-- =<< join (takeOne [roomNgon 6 80])
|
-- =<< join (takeOne [roomNgon 6 80])
|
||||||
droom <- distributerRoom BulletAmmo (10 ^ (4::Int))
|
droom <- distributerRoom BulletAmmo (10 ^ (4::Int))
|
||||||
ncrits <- takeOne [1,1,2,2,2,3]
|
croom <- crabRoom
|
||||||
croom <- roomCCrits ncrits
|
wep <- takeOne [burstRifle,smg]
|
||||||
return $
|
return $
|
||||||
tToBTree "loadAmmoTest" $
|
tToBTree "loadAmmoTest" $
|
||||||
treePost
|
treePost
|
||||||
[ amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
|
[ croom
|
||||||
|
, door
|
||||||
|
, amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
|
||||||
, triggerDoorRoom i
|
, triggerDoorRoom i
|
||||||
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
|
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt wep)
|
||||||
, triggerDoorRoom j
|
, triggerDoorRoom j
|
||||||
, droom
|
, droom
|
||||||
, door
|
, door
|
||||||
@@ -478,11 +485,13 @@ putSingleLight rm = do
|
|||||||
, (V2 0 y', V2 x y')
|
, (V2 0 y', V2 x y')
|
||||||
]
|
]
|
||||||
return $ rmPmnts .:~ uncurry spanLightI ps
|
return $ rmPmnts .:~ uncurry spanLightI ps
|
||||||
RoomNgon{_rmngonSize = x} -> do
|
RoomNgon{} -> do
|
||||||
y <- takeOne [21, -21]
|
let p = rm ^?! rmPolys . ix 0 . ix 0
|
||||||
return $ rmPmnts .:~ spanLightI (V2 (-x) y) (V2 x y)
|
return $ rmPmnts .:~ spanLightI p (-p)
|
||||||
return . f $ removeLights rm
|
return . f $ removeLights rm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tutHub :: State LayoutVars (MetaTree Room String)
|
tutHub :: State LayoutVars (MetaTree Room String)
|
||||||
tutHub = do
|
tutHub = do
|
||||||
(is, wbp) <- setTreeInts =<< critsRoom 1
|
(is, wbp) <- setTreeInts =<< critsRoom 1
|
||||||
|
|||||||
@@ -41,15 +41,8 @@ tocrs :: (IM.IntMap Creature
|
|||||||
tocrs = uvWorld . cWorld . lWorld . creatures
|
tocrs = uvWorld . cWorld . lWorld . creatures
|
||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u =
|
testStringInit u = u ^.. tocrs . ix 1 . crActionPlan . apStrategy . to show
|
||||||
[ show $ inverseSelNumPos (u ^. uvConfig) invDP
|
<> u ^.. tocrs . ix 1 . crActionPlan . apAction . to show
|
||||||
(u ^. uvWorld . input . mousePos) (u ^. uvWorld . hud . diSections)
|
|
||||||
, show $ do
|
|
||||||
(i',xs) <- IM.lookupMax (u ^. uvWorld . hud . diSections)
|
|
||||||
(j',_) <- xs ^. ssItems . to IM.lookupMax
|
|
||||||
return (i',j')
|
|
||||||
]
|
|
||||||
|
|
||||||
-- where
|
-- where
|
||||||
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
||||||
-- f = fromMaybe 0
|
-- f = fromMaybe 0
|
||||||
|
|||||||
Reference in New Issue
Block a user