diff --git a/src/client/creature.cpp b/src/client/creature.cpp index f6d708f7..13988123 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -313,6 +313,12 @@ void Creature::walk(const Position& oldPos, const Position& newPos) m_walkTimer.restart(); m_walkedPixels = 0; + if(m_walkFinishAnimEvent) { + m_walkFinishAnimEvent->cancel(); + m_walkFinishAnimEvent = nullptr; + } + + // no direction need to be changed when the walk ends m_walkTurnDirection = Otc::InvalidDirection; @@ -452,14 +458,27 @@ void Creature::updateWalkAnimation(int totalPixelsWalked) return; int footAnimPhases = getAnimationPhases() - 1; - if(totalPixelsWalked == 32 || footAnimPhases == 0) + int footDelay = getStepDuration(true) / 3; + if(footAnimPhases == 0) m_walkAnimationPhase = 0; - else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= getStepDuration(true) / 4 ) { + else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= footDelay && totalPixelsWalked < 32) { m_footStep++; m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases); m_footStepDrawn = false; m_footTimer.restart(); + } else if(m_walkAnimationPhase == 0 && totalPixelsWalked < 32) { + m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases); + } + + if(totalPixelsWalked == 32 && !m_walkFinishAnimEvent) { + auto self = static_self_cast(); + m_walkFinishAnimEvent = g_dispatcher.scheduleEvent([self] { + if(!self->m_walking || self->m_walkTimer.ticksElapsed() >= self->getStepDuration(true)) + self->m_walkAnimationPhase = 0; + self->m_walkFinishAnimEvent = nullptr; + }, std::min(footDelay, 200)); } + } void Creature::updateWalkOffset(int totalPixelsWalked) @@ -813,7 +832,11 @@ int Creature::getStepDuration(bool ignoreDiagonal) Point Creature::getDisplacement() { - return Point(getDisplacementX(), getDisplacementY()); + if(m_outfit.getCategory() == ThingCategoryEffect) + return Point(8, 8); + else if(m_outfit.getCategory() == ThingCategoryItem) + return Point(0, 0); + return Thing::getDisplacement(); } int Creature::getDisplacementX() diff --git a/src/client/creature.h b/src/client/creature.h index 7084e6cf..dbe3cfc1 100644 --- a/src/client/creature.h +++ b/src/client/creature.h @@ -176,6 +176,7 @@ protected: stdext::boolean m_allowAppearWalk; stdext::boolean m_footStepDrawn; ScheduledEventPtr m_walkUpdateEvent; + ScheduledEventPtr m_walkFinishAnimEvent; EventPtr m_disappearEvent; Point m_walkOffset; Otc::Direction m_walkTurnDirection; diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index 2715dcf3..0cc4884a 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -211,7 +211,7 @@ bool LocalPlayer::autoWalk(const Position& destination) m_lastAutoWalkPosition = m_position.translatedToDirections(limitedPath).back(); for(auto pos : m_position.translatedToDirections(limitedPath)) { - g_map.getOrCreateTile(pos)->overwriteMinimapColor(16); + g_map.getOrCreateTile(pos)->overwriteMinimapColor(215); g_map.notificateTileUpdate(pos); } @@ -300,7 +300,9 @@ void LocalPlayer::onPositionChange(const Position& newPos, const Position& oldPo { Creature::onPositionChange(newPos, oldPos); - if(m_autoWalkDestination.isValid() && newPos == m_lastAutoWalkPosition) + if(newPos == m_autoWalkDestination) + stopAutoWalk(); + else if(m_autoWalkDestination.isValid() && newPos == m_lastAutoWalkPosition) autoWalk(m_autoWalkDestination); }