Fix enemy stride/footsteps
This commit is contained in:
@@ -5,7 +5,7 @@ module Dodge.Creature.ChaseCrit (
|
||||
) where
|
||||
|
||||
--import Dodge.Data.Equipment.Misc
|
||||
--import Control.Lens
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
--import Dodge.Item.Equipment
|
||||
@@ -27,12 +27,11 @@ invisibleChaseCrit =
|
||||
chaseCrit :: Creature
|
||||
chaseCrit =
|
||||
defaultCreature
|
||||
{ _crName = "chaseCrit"
|
||||
, _crHP = HP 150
|
||||
, _crInv = mempty
|
||||
, _crFaction = ColorFaction green
|
||||
, _crVocalization = chaseCritVocalization
|
||||
}
|
||||
& crName .~ "chaseCrit"
|
||||
& crHP .~ HP 150
|
||||
& crFaction .~ ColorFaction green
|
||||
& crVocalization .~ chaseCritVocalization
|
||||
& crStance . strideLength .~ 30
|
||||
|
||||
chaseCritVocalization :: Vocalization
|
||||
chaseCritVocalization = Vocalization (50, 200) 0
|
||||
|
||||
@@ -45,6 +45,7 @@ followImpulse cr w imp = case imp of
|
||||
Bark sid -> (soundStart (CrMouth cid) cpos sid Nothing, resetCrVocCoolDown w cr)
|
||||
Move p -> crup $ crMvBy p (w ^. cWorld . lWorld) cr
|
||||
MoveForward x -> crup $ crMvForward x (w ^. cWorld . lWorld) cr
|
||||
MoveNoStride p -> crup $ crMvByNoStride p (w ^. cWorld . lWorld) cr
|
||||
Turn a -> crup $ cr & crDir +~ a
|
||||
TurnToward p a -> crup $ creatureTurnToward p a cr
|
||||
TurnTo p -> crup $ creatureTurnTo p cr
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Creature.Impulse.Movement (
|
||||
creatureTurnTowardDir,
|
||||
crMvAbsolute,
|
||||
crMvBy,
|
||||
crMvByNoStride,
|
||||
crMvForward,
|
||||
creatureTurnTo,
|
||||
) where
|
||||
@@ -26,6 +27,14 @@ crMvBy ::
|
||||
Creature
|
||||
crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
|
||||
|
||||
crMvByNoStride ::
|
||||
-- | Movement translation vector, will be made relative to creature direction
|
||||
Point2 ->
|
||||
LWorld ->
|
||||
Creature ->
|
||||
Creature
|
||||
crMvByNoStride p lw cr = crMvAbsoluteNoStride lw (rotateV (_crDir cr) p) cr
|
||||
|
||||
crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature
|
||||
crMvAbsolute lw p' cr =
|
||||
advanceStepCounter (magV p) cr
|
||||
@@ -34,6 +43,11 @@ crMvAbsolute lw p' cr =
|
||||
where
|
||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||
|
||||
crMvAbsoluteNoStride :: LWorld -> Point2 -> Creature -> Creature
|
||||
crMvAbsoluteNoStride lw p' cr = cr & crPos . _xy +~ p
|
||||
where
|
||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||
|
||||
strengthFactor :: Int -> Float
|
||||
strengthFactor i
|
||||
| i > 50 = 1
|
||||
|
||||
@@ -10,7 +10,7 @@ import Sound.Data
|
||||
|
||||
updateWalkCycle :: Int -> World -> World
|
||||
updateWalkCycle cid w
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
, Walking x ff <- cr ^. crStance . carriage
|
||||
, x >= cr ^. crStance . strideLength =
|
||||
w
|
||||
|
||||
@@ -47,6 +47,7 @@ updateCreature' cr =
|
||||
LampCrit{} -> updateLampoid cr
|
||||
BarrelCrit bt -> updateBarreloid bt cr
|
||||
AvatarDead -> id
|
||||
ChaseCrit {} -> crUpdate updateHumanoid cr
|
||||
_ -> crUpdate updateHumanoid cr
|
||||
|
||||
{- | this seems to work, but I am not sure about the ordering:
|
||||
|
||||
Reference in New Issue
Block a user