diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index fec8dc843..a05128566 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -62,9 +62,10 @@ crUpdate f = foldCr [ doDamage -- these two , checkDeath -- must be in this order 24/7/22 - , internalCreatureUpdate - , f +-- , internalCreatureUpdate , footstepSideEffect + , f +-- , footstepSideEffect -- , updateInv -- upInv must be called before invSideEff 22.05.23 , invRootItemEffs , invSideEff @@ -425,9 +426,9 @@ updateMovement cr | isFrictionless cr = over crPos (+.+ momentum) cr | otherwise = cr & crStance %~ updateWalkCycle where - momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr) + momentum' = 0.98 *.* (_crPos cr - _crOldPos cr) momentum - | magV momentum' > 1 = 1 *.* normalizeV momentum' + | magV momentum' > 1 = normalizeV momentum' | otherwise = momentum' isFrictionless :: Creature -> Bool diff --git a/src/Dodge/Creature/State/WalkCycle.hs b/src/Dodge/Creature/State/WalkCycle.hs index 09674316d..380c6fe42 100644 --- a/src/Dodge/Creature/State/WalkCycle.hs +++ b/src/Dodge/Creature/State/WalkCycle.hs @@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase #-} + module Dodge.Creature.State.WalkCycle ( updateWalkCycle, footstepSideEffect, @@ -11,30 +12,27 @@ import Sound.Data updateWalkCycle :: Stance -> Stance updateWalkCycle s = case s ^. carriage of - Walking x ff | x > maxStride -> s & carriage .~ Walking 0 (normalGait ff) + Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff) _ -> s - where - maxStride = s ^. strideLength normalGait :: FootForward -> FootForward -normalGait = \case +normalGait = \case LeftForward -> RightForward WasLeftForward -> RightForward RightForward -> LeftForward WasRightForward -> LeftForward footstepSideEffect :: Creature -> World -> World -footstepSideEffect cr = case cr ^. crStance . carriage of +footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance) updateWalkCycle . + case cr ^. crStance . carriage of Walking x ff - | x > maxStride -> + | x > cr ^. crStance . strideLength -> soundMultiFrom [FootstepSound i | i <- [0 .. 10]] (cr ^. crPos) (chooseFootSound ff) Nothing _ -> id - where - maxStride = _strideLength (_crStance cr) chooseFootSound :: FootForward -> SoundID chooseFootSound LeftForward = foot1S