Fix regression in walk paralyze
This commit is contained in:
parent
b5cb4e2c93
commit
10c564f90e
|
@ -572,6 +572,7 @@ void Application::registerLuaFunctions()
|
|||
g_lua.registerClass<UIVerticalLayout, UIBoxLayout>();
|
||||
g_lua.bindClassStaticFunction<UIVerticalLayout>("create", [](UIWidgetPtr parent){ return UIVerticalLayoutPtr(new UIVerticalLayout(parent)); } );
|
||||
g_lua.bindClassMemberFunction<UIVerticalLayout>("setAlignBottom", &UIVerticalLayout::setAlignBottom);
|
||||
g_lua.bindClassMemberFunction<UIVerticalLayout>("isAlignBottom", &UIVerticalLayout::isAlignBottom);
|
||||
|
||||
// UIHorizontalLayout
|
||||
g_lua.registerClass<UIHorizontalLayout, UIBoxLayout>();
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
void applyStyle(const OTMLNodePtr& styleNode);
|
||||
|
||||
void setAlignBottom(bool aliginBottom) { m_alignBottom = aliginBottom; update(); }
|
||||
bool isAlignBottom() { return m_alignBottom; }
|
||||
|
||||
bool isUIVerticalLayout() { return true; }
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ Creature::Creature() : Thing()
|
|||
m_direction = Otc::South;
|
||||
m_walkAnimationPhase = 0;
|
||||
m_walkedPixels = 0;
|
||||
m_walkStepDuration = 0;
|
||||
m_walkTurnDirection = Otc::InvalidDirection;
|
||||
m_skull = Otc::SkullNone;
|
||||
m_shield = Otc::ShieldNone;
|
||||
|
@ -258,6 +257,7 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
|
|||
|
||||
// get walk direction
|
||||
m_lastStepDirection = oldPos.getDirectionFromPosition(newPos);
|
||||
m_lastStepPosition = newPos;
|
||||
|
||||
// set current walking direction
|
||||
setDirection(m_lastStepDirection);
|
||||
|
@ -266,7 +266,6 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
|
|||
m_walking = true;
|
||||
m_walkTimer.restart();
|
||||
m_walkedPixels = 0;
|
||||
m_walkStepDuration = getStepDuration();
|
||||
|
||||
// no direction need to be changed when the walk ends
|
||||
m_walkTurnDirection = Otc::InvalidDirection;
|
||||
|
@ -351,7 +350,7 @@ void Creature::updateWalkAnimation(int totalPixelsWalked)
|
|||
int footAnimPhases = getAnimationPhases() - 1;
|
||||
if(totalPixelsWalked == 32 || footAnimPhases == 0)
|
||||
m_walkAnimationPhase = 0;
|
||||
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= m_walkStepDuration / 4 ) {
|
||||
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= getStepDuration() / 4 ) {
|
||||
m_footStep++;
|
||||
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
||||
m_footStepDrawn = false;
|
||||
|
@ -415,13 +414,14 @@ void Creature::nextWalkUpdate()
|
|||
m_walkUpdateEvent = g_dispatcher.scheduleEvent([self] {
|
||||
self->m_walkUpdateEvent = nullptr;
|
||||
self->nextWalkUpdate();
|
||||
}, m_walkStepDuration / 32);
|
||||
}, getStepDuration() / 32);
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::updateWalk()
|
||||
{
|
||||
float walkTicksPerPixel = m_walkStepDuration / 32;
|
||||
int stepDuration = getStepDuration();
|
||||
float walkTicksPerPixel = stepDuration / 32;
|
||||
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||
|
||||
// needed for paralyze effect
|
||||
|
@ -433,7 +433,7 @@ void Creature::updateWalk()
|
|||
updateWalkingTile();
|
||||
|
||||
// terminate walk
|
||||
if(m_walking && m_walkTimer.ticksElapsed() >= m_walkStepDuration)
|
||||
if(m_walking && m_walkTimer.ticksElapsed() >= stepDuration)
|
||||
terminateWalk();
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,11 @@ Point Creature::getDrawOffset()
|
|||
int Creature::getStepDuration()
|
||||
{
|
||||
int groundSpeed = 0;
|
||||
const TilePtr& tile = getTile();
|
||||
|
||||
Position tilePos = m_lastStepPosition;
|
||||
if(!tilePos.isValid())
|
||||
tilePos = m_position;
|
||||
const TilePtr& tile = g_map.getTile(tilePos);
|
||||
if(tile)
|
||||
groundSpeed = tile->getGroundSpeed();
|
||||
|
||||
|
|
|
@ -139,7 +139,6 @@ protected:
|
|||
// walk related
|
||||
int m_walkAnimationPhase;
|
||||
int m_walkedPixels;
|
||||
int m_walkStepDuration;
|
||||
uint m_footStep;
|
||||
Timer m_walkTimer;
|
||||
Timer m_footTimer;
|
||||
|
@ -151,6 +150,7 @@ protected:
|
|||
Point m_walkOffset;
|
||||
Otc::Direction m_walkTurnDirection;
|
||||
Otc::Direction m_lastStepDirection;
|
||||
Position m_lastStepPosition;
|
||||
Position m_oldPosition;
|
||||
};
|
||||
|
||||
|
|
|
@ -66,12 +66,16 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
|||
if(m_walkLockExpiration != 0 && g_clock.millis() < m_walkLockExpiration)
|
||||
return false;
|
||||
|
||||
// paralyzed
|
||||
if(m_speed == 0)
|
||||
return false;
|
||||
|
||||
// last walk is not done yet
|
||||
if(m_walkTimer.ticksElapsed() < m_walkStepDuration)
|
||||
if(m_walkTimer.ticksElapsed() < getStepDuration())
|
||||
return false;
|
||||
|
||||
// prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk
|
||||
bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration + PREWALK_TIMEOUT;
|
||||
bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= getStepDuration() + PREWALK_TIMEOUT;
|
||||
|
||||
// avoid doing more walks than wanted when receiving a lot of walks from server
|
||||
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
|
||||
|
@ -178,7 +182,8 @@ void LocalPlayer::updateWalkOffset(int totalPixelsWalked)
|
|||
|
||||
void LocalPlayer::updateWalk()
|
||||
{
|
||||
float walkTicksPerPixel = m_walkStepDuration / 32.0f;
|
||||
int stepDuration = getStepDuration();
|
||||
float walkTicksPerPixel = stepDuration / 32.0f;
|
||||
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||
|
||||
// update walk animation and offsets
|
||||
|
@ -186,8 +191,8 @@ void LocalPlayer::updateWalk()
|
|||
updateWalkOffset(totalPixelsWalked);
|
||||
updateWalkingTile();
|
||||
|
||||
// terminate walk only when client and server side walk are complated
|
||||
if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration)
|
||||
// terminate walk only when client and server side walk are completed
|
||||
if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= stepDuration)
|
||||
terminateWalk();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue