Work on crab feet
This commit is contained in:
@@ -44,6 +44,8 @@ crabCrit = defaultCreature
|
|||||||
, _footForward = LeftForward
|
, _footForward = LeftForward
|
||||||
, _strideAmount = 0
|
, _strideAmount = 0
|
||||||
, _dodgeCooldown = 0
|
, _dodgeCooldown = 0
|
||||||
|
, _lFootPos = 0
|
||||||
|
, _rFootPos = 0
|
||||||
}
|
}
|
||||||
& crFaction .~ ColorFaction red
|
& crFaction .~ ColorFaction red
|
||||||
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
& crPerception . cpVision . viFOV .~ FloatFOV pi
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ followImpulse cid w = \case
|
|||||||
( crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) . (crType . meleeCooldown .~ 20)
|
( crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) . (crType . meleeCooldown .~ 20)
|
||||||
)
|
)
|
||||||
MeleeL cid' ->
|
MeleeL cid' ->
|
||||||
hitCrl cid' $
|
hitCrd (-pi/2) cid' $
|
||||||
crup
|
crup
|
||||||
-- ( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ 10 *.* normalizeV (posFromID cid' -.- cpos))
|
-- ( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ 10 *.* normalizeV (posFromID cid' -.- cpos))
|
||||||
-- .
|
-- .
|
||||||
(crType . meleeCooldownL .~ 20)
|
(crType . meleeCooldownL .~ 20)
|
||||||
-- )
|
-- )
|
||||||
MeleeR cid' ->
|
MeleeR cid' ->
|
||||||
hitCrr cid' $
|
hitCrd (pi/2) cid' $
|
||||||
crup
|
crup
|
||||||
--( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ (-10) *.* normalizeV (posFromID cid' -.- cpos)) .
|
--( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ (-10) *.* normalizeV (posFromID cid' -.- cpos)) .
|
||||||
(crType . meleeCooldownR .~ 20)
|
(crType . meleeCooldownR .~ 20)
|
||||||
@@ -87,13 +87,8 @@ followImpulse cid w = \case
|
|||||||
hitCr i =
|
hitCr i =
|
||||||
cWorld . lWorld . creatures . ix i . crDamage
|
cWorld . lWorld . creatures . ix i . crDamage
|
||||||
.:~ Blunt 100 (posFromID i) (posFromID i - cpos)
|
.:~ Blunt 100 (posFromID i) (posFromID i - cpos)
|
||||||
hitCrl i =
|
hitCrd a i =
|
||||||
cWorld . lWorld . creatures . ix i . crDamage
|
cWorld . lWorld . creatures . ix i . crDamage
|
||||||
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
|
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
|
||||||
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir - pi/2))
|
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + a))
|
||||||
]
|
|
||||||
hitCrr i =
|
|
||||||
cWorld . lWorld . creatures . ix i . crDamage
|
|
||||||
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
|
|
||||||
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + pi/2))
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -160,17 +160,30 @@ feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
|||||||
|
|
||||||
crabFeet :: Creature -> Shape
|
crabFeet :: Creature -> Shape
|
||||||
{-# INLINE crabFeet #-}
|
{-# INLINE crabFeet #-}
|
||||||
crabFeet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
crabFeet cr =
|
||||||
(Just sa,Just LeftForward) -> sh (f sa)
|
uncurryV translateSHxy rpos afoot
|
||||||
(Just sa,Just RightForward) -> sh (-f sa)
|
<> uncurryV translateSHxy (f (V2 0 10) rpos) afoot
|
||||||
_ -> sh 0
|
<> uncurryV translateSHxy lpos afoot
|
||||||
|
<> uncurryV translateSHxy (f (V2 0 (-10)) lpos) afoot
|
||||||
|
-- <> uncurryV translateSHxy (rotateV cdir $ cr ^?! crType . lFootPos - cxy) afoot
|
||||||
|
-- <> uncurryV translateSHxy (rotateV cdir $ cxy - cr ^?! crType . lFootPos) afoot
|
||||||
|
-- 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
|
where
|
||||||
sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
|
rpos = rot ( cr ^?! crType . rFootPos - cxy)
|
||||||
aFoot = upperPrismPolyST 10 $ polyCirc 3 2
|
rot = rotateV cdir
|
||||||
|
lpos = rot ( cr ^?! crType . lFootPos - cxy)
|
||||||
|
f p q = q + 2 *^ (p - q)
|
||||||
|
cdir = -cr ^. crDir
|
||||||
|
cxy = cr ^. crPos . _xy
|
||||||
|
-- sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
|
||||||
|
afoot = upperPrismPolyST 10 $ polyCirc 3 2
|
||||||
off = 10
|
off = 10
|
||||||
sLen = strideLength cr
|
sLen = strideLength cr
|
||||||
-- 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)
|
||||||
|
|
||||||
deadFeet :: Creature -> Shape
|
deadFeet :: Creature -> Shape
|
||||||
{-# INLINE deadFeet #-}
|
{-# INLINE deadFeet #-}
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ data CreatureType
|
|||||||
, _footForward :: FootForward
|
, _footForward :: FootForward
|
||||||
, _strideAmount :: Float
|
, _strideAmount :: Float
|
||||||
, _dodgeCooldown :: Int
|
, _dodgeCooldown :: Int
|
||||||
|
, _lFootPos :: Point2
|
||||||
|
, _rFootPos :: Point2
|
||||||
}
|
}
|
||||||
| HoverCrit {_meleeCooldown :: Int}
|
| HoverCrit {_meleeCooldown :: Int}
|
||||||
| SwarmCrit
|
| SwarmCrit
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ tutAnoTree = do
|
|||||||
foldMTRS
|
foldMTRS
|
||||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||||
, corDoor
|
, corDoor
|
||||||
, chasmSpitTerminal
|
-- , chasmSpitTerminal
|
||||||
, corDoor
|
-- , corDoor
|
||||||
, loadAmmoTut
|
, loadAmmoTut
|
||||||
, corDoor
|
, corDoor
|
||||||
, chasmSpitTerminal
|
, chasmSpitTerminal
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ tocrs :: (IM.IntMap Creature
|
|||||||
tocrs = uvWorld . cWorld . lWorld . creatures
|
tocrs = uvWorld . cWorld . lWorld . creatures
|
||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u = u ^.. tocrs . ix 1 . crActionPlan . apStrategy . to show
|
testStringInit u = u ^.. tocrs . ix 3 . crPos . _xy . to show
|
||||||
<> u ^.. tocrs . ix 1 . crActionPlan . apAction . to show
|
<> u ^.. tocrs . ix 3 . crType . lFootPos . to show
|
||||||
|
<> u ^.. tocrs . ix 3 . crType . rFootPos . to show
|
||||||
-- where
|
-- where
|
||||||
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
||||||
-- f = fromMaybe 0
|
-- f = fromMaybe 0
|
||||||
|
|||||||
+9
-1
@@ -375,9 +375,17 @@ updateCreatureStrides = cWorld . lWorld . creatures . each %~ updateCreatureStri
|
|||||||
|
|
||||||
updateCreatureStride :: Creature -> Creature
|
updateCreatureStride :: Creature -> Creature
|
||||||
updateCreatureStride cr
|
updateCreatureStride cr
|
||||||
| Walking <- cr ^. crStance . carriage = cr & crType . strideAmount +~ d
|
| Walking <- cr ^. crStance . carriage
|
||||||
|
, CrabCrit {} <- cr ^. crType
|
||||||
|
= cr & crType . lFootPos %~ f (g 10)
|
||||||
|
& crType . rFootPos %~ f (g (-10))
|
||||||
|
| Walking <- cr ^. crStance . carriage
|
||||||
|
, isJust $ cr ^? crType . strideAmount = cr & crType . strideAmount +~ d
|
||||||
| otherwise = cr
|
| otherwise = cr
|
||||||
where
|
where
|
||||||
|
f p q | distance p q > 10 = p - 9 *^ signorm (q - p)
|
||||||
|
| otherwise = q
|
||||||
|
g x = cr ^. crPos . _xy + x *^ vNormal (unitVectorAtAngle (cr ^. crDir))
|
||||||
s = 2 * fromMaybe 1 (crMvType cr ^? mvSpeed)
|
s = 2 * fromMaybe 1 (crMvType cr ^? mvSpeed)
|
||||||
-- d = min s . norm $ cr ^. crPos - cr ^. crOldPos
|
-- d = min s . norm $ cr ^. crPos - cr ^. crOldPos
|
||||||
d = max 0 . min s $ dotV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle (cr ^. crMvDir))
|
d = max 0 . min s $ dotV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle (cr ^. crMvDir))
|
||||||
|
|||||||
Reference in New Issue
Block a user