Fix old bug #149
This commit is contained in:
parent
e900a7679a
commit
fa8971498f
|
@ -313,6 +313,12 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
|
||||||
m_walkTimer.restart();
|
m_walkTimer.restart();
|
||||||
m_walkedPixels = 0;
|
m_walkedPixels = 0;
|
||||||
|
|
||||||
|
if(m_walkFinishAnimEvent) {
|
||||||
|
m_walkFinishAnimEvent->cancel();
|
||||||
|
m_walkFinishAnimEvent = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// no direction need to be changed when the walk ends
|
// no direction need to be changed when the walk ends
|
||||||
m_walkTurnDirection = Otc::InvalidDirection;
|
m_walkTurnDirection = Otc::InvalidDirection;
|
||||||
|
|
||||||
|
@ -452,14 +458,27 @@ void Creature::updateWalkAnimation(int totalPixelsWalked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int footAnimPhases = getAnimationPhases() - 1;
|
int footAnimPhases = getAnimationPhases() - 1;
|
||||||
if(totalPixelsWalked == 32 || footAnimPhases == 0)
|
int footDelay = getStepDuration(true) / 3;
|
||||||
|
if(footAnimPhases == 0)
|
||||||
m_walkAnimationPhase = 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_footStep++;
|
||||||
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
||||||
m_footStepDrawn = false;
|
m_footStepDrawn = false;
|
||||||
m_footTimer.restart();
|
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<Creature>();
|
||||||
|
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)
|
void Creature::updateWalkOffset(int totalPixelsWalked)
|
||||||
|
@ -813,7 +832,11 @@ int Creature::getStepDuration(bool ignoreDiagonal)
|
||||||
|
|
||||||
Point Creature::getDisplacement()
|
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()
|
int Creature::getDisplacementX()
|
||||||
|
|
|
@ -176,6 +176,7 @@ protected:
|
||||||
stdext::boolean<false> m_allowAppearWalk;
|
stdext::boolean<false> m_allowAppearWalk;
|
||||||
stdext::boolean<false> m_footStepDrawn;
|
stdext::boolean<false> m_footStepDrawn;
|
||||||
ScheduledEventPtr m_walkUpdateEvent;
|
ScheduledEventPtr m_walkUpdateEvent;
|
||||||
|
ScheduledEventPtr m_walkFinishAnimEvent;
|
||||||
EventPtr m_disappearEvent;
|
EventPtr m_disappearEvent;
|
||||||
Point m_walkOffset;
|
Point m_walkOffset;
|
||||||
Otc::Direction m_walkTurnDirection;
|
Otc::Direction m_walkTurnDirection;
|
||||||
|
|
|
@ -211,7 +211,7 @@ bool LocalPlayer::autoWalk(const Position& destination)
|
||||||
m_lastAutoWalkPosition = m_position.translatedToDirections(limitedPath).back();
|
m_lastAutoWalkPosition = m_position.translatedToDirections(limitedPath).back();
|
||||||
|
|
||||||
for(auto pos : m_position.translatedToDirections(limitedPath)) {
|
for(auto pos : m_position.translatedToDirections(limitedPath)) {
|
||||||
g_map.getOrCreateTile(pos)->overwriteMinimapColor(16);
|
g_map.getOrCreateTile(pos)->overwriteMinimapColor(215);
|
||||||
g_map.notificateTileUpdate(pos);
|
g_map.notificateTileUpdate(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,9 @@ void LocalPlayer::onPositionChange(const Position& newPos, const Position& oldPo
|
||||||
{
|
{
|
||||||
Creature::onPositionChange(newPos, oldPos);
|
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);
|
autoWalk(m_autoWalkDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue