@@ -389,6 +389,7 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
389
389
390
390
// starts counting walk
391
391
m_walking = true ;
392
+ m_walkSteps = std::max<int >(++m_walkSteps, 1 );
392
393
m_walkTimer.restart ();
393
394
m_walkedPixels = 0 ;
394
395
@@ -644,12 +645,12 @@ void Creature::nextWalkUpdate()
644
645
645
646
if (!m_walking) return ;
646
647
647
- // schedules next update
648
- auto self = static_self_cast<Creature>();
649
- m_walkUpdateEvent = g_dispatcher.scheduleEvent ([self] {
648
+ auto action = [self = static_self_cast<Creature>()] {
650
649
self->m_walkUpdateEvent = nullptr ;
651
650
self->nextWalkUpdate ();
652
- }, m_stepCache.walkDuration );
651
+ };
652
+
653
+ m_walkUpdateEvent = isLocalPlayer () ? g_dispatcher.addEvent (action) : g_dispatcher.scheduleEvent (action, m_stepCache.walkDuration );
653
654
}
654
655
655
656
void Creature::updateWalk (const bool isPreWalking)
@@ -666,7 +667,7 @@ void Creature::updateWalk(const bool isPreWalking)
666
667
updateWalkingTile ();
667
668
668
669
if (m_walkedPixels == g_gameConfig.getSpriteSize ()) {
669
- if (isPreWalking) resetWalkAnimationPhase (true );
670
+ if (isPreWalking) resetWalkAnimationPhase (false );
670
671
else terminateWalk ();
671
672
}
672
673
}
@@ -694,6 +695,15 @@ void Creature::terminateWalk()
694
695
m_walkOffset = {};
695
696
m_walking = false ;
696
697
698
+ if (isLocalPlayer () && !static_self_cast<LocalPlayer>()->isAutoWalking () && getWalkSteps () > 1 ) {
699
+ g_dispatcher.addEvent ([] {
700
+ g_dispatcher.deferEvent ([] {
701
+ if (g_game.getLocalPlayer ())
702
+ g_game.walk (g_game.getLocalPlayer ()->getNextWalkDir ());
703
+ });
704
+ });
705
+ }
706
+
697
707
resetWalkAnimationPhase (true );
698
708
}
699
709
@@ -705,6 +715,7 @@ void Creature::resetWalkAnimationPhase(bool toSchedule) {
705
715
706
716
const auto self = static_self_cast<Creature>();
707
717
m_walkFinishAnimEvent = g_dispatcher.scheduleEvent ([self] {
718
+ self->m_walkSteps = 0 ;
708
719
self->m_walkAnimationPhase = 0 ;
709
720
self->m_walkFinishAnimEvent = nullptr ;
710
721
}, g_game.getServerBeat ());
@@ -944,7 +955,11 @@ uint16_t Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
944
955
stepDuration = ((stepDuration + serverBeat - 1 ) / serverBeat) * serverBeat;
945
956
}
946
957
947
- m_stepCache.duration = stepDuration + 10 ;
958
+ if (isLocalPlayer () && stepDuration <= 100 )
959
+ stepDuration += 10 ;
960
+
961
+ m_stepCache.duration = stepDuration;
962
+
948
963
m_stepCache.walkDuration = std::min<int >(stepDuration / g_gameConfig.getSpriteSize (), DrawPool::FPS60);
949
964
m_stepCache.diagonalDuration = stepDuration *
950
965
(g_game.getClientVersion () > 810 || g_gameConfig.isForcingNewWalkingFormula ()
0 commit comments