Fix battle filter, fix walk issue, try logout when force exit
This commit is contained in:
parent
56817a8678
commit
b5cb4e2c93
|
@ -170,7 +170,7 @@ end
|
||||||
|
|
||||||
function onCreatureAppear(creature)
|
function onCreatureAppear(creature)
|
||||||
local player = g_game.getLocalPlayer()
|
local player = g_game.getLocalPlayer()
|
||||||
if creature ~= player and creature:getPosition().z == player:getPosition().z then
|
if creature ~= player and creature:getPosition().z == player:getPosition().z and doCreatureFitFilters(creature) then
|
||||||
addCreature(creature)
|
addCreature(creature)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -131,6 +131,7 @@ function tryExit()
|
||||||
local cancelButton = exitWindow:getChildById('buttonCancel')
|
local cancelButton = exitWindow:getChildById('buttonCancel')
|
||||||
|
|
||||||
local exitFunc = function()
|
local exitFunc = function()
|
||||||
|
logout() -- try logout anyway
|
||||||
forceExit()
|
forceExit()
|
||||||
end
|
end
|
||||||
local logoutFunc = function()
|
local logoutFunc = function()
|
||||||
|
|
|
@ -48,6 +48,7 @@ Creature::Creature() : Thing()
|
||||||
m_direction = Otc::South;
|
m_direction = Otc::South;
|
||||||
m_walkAnimationPhase = 0;
|
m_walkAnimationPhase = 0;
|
||||||
m_walkedPixels = 0;
|
m_walkedPixels = 0;
|
||||||
|
m_walkStepDuration = 0;
|
||||||
m_walkTurnDirection = Otc::InvalidDirection;
|
m_walkTurnDirection = Otc::InvalidDirection;
|
||||||
m_skull = Otc::SkullNone;
|
m_skull = Otc::SkullNone;
|
||||||
m_shield = Otc::ShieldNone;
|
m_shield = Otc::ShieldNone;
|
||||||
|
@ -265,6 +266,7 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
|
||||||
m_walking = true;
|
m_walking = true;
|
||||||
m_walkTimer.restart();
|
m_walkTimer.restart();
|
||||||
m_walkedPixels = 0;
|
m_walkedPixels = 0;
|
||||||
|
m_walkStepDuration = getStepDuration();
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -349,7 +351,7 @@ void Creature::updateWalkAnimation(int totalPixelsWalked)
|
||||||
int footAnimPhases = getAnimationPhases() - 1;
|
int footAnimPhases = getAnimationPhases() - 1;
|
||||||
if(totalPixelsWalked == 32 || footAnimPhases == 0)
|
if(totalPixelsWalked == 32 || footAnimPhases == 0)
|
||||||
m_walkAnimationPhase = 0;
|
m_walkAnimationPhase = 0;
|
||||||
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= getStepDuration() / 4 ) {
|
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= m_walkStepDuration / 4 ) {
|
||||||
m_footStep++;
|
m_footStep++;
|
||||||
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
|
||||||
m_footStepDrawn = false;
|
m_footStepDrawn = false;
|
||||||
|
@ -413,14 +415,13 @@ void Creature::nextWalkUpdate()
|
||||||
m_walkUpdateEvent = g_dispatcher.scheduleEvent([self] {
|
m_walkUpdateEvent = g_dispatcher.scheduleEvent([self] {
|
||||||
self->m_walkUpdateEvent = nullptr;
|
self->m_walkUpdateEvent = nullptr;
|
||||||
self->nextWalkUpdate();
|
self->nextWalkUpdate();
|
||||||
}, getStepDuration() / 32);
|
}, m_walkStepDuration / 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::updateWalk()
|
void Creature::updateWalk()
|
||||||
{
|
{
|
||||||
int stepDuration = getStepDuration();
|
float walkTicksPerPixel = m_walkStepDuration / 32;
|
||||||
float walkTicksPerPixel = stepDuration / 32;
|
|
||||||
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||||
|
|
||||||
// needed for paralyze effect
|
// needed for paralyze effect
|
||||||
|
@ -432,7 +433,7 @@ void Creature::updateWalk()
|
||||||
updateWalkingTile();
|
updateWalkingTile();
|
||||||
|
|
||||||
// terminate walk
|
// terminate walk
|
||||||
if(m_walking && m_walkTimer.ticksElapsed() >= stepDuration)
|
if(m_walking && m_walkTimer.ticksElapsed() >= m_walkStepDuration)
|
||||||
terminateWalk();
|
terminateWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@ protected:
|
||||||
// walk related
|
// walk related
|
||||||
int m_walkAnimationPhase;
|
int m_walkAnimationPhase;
|
||||||
int m_walkedPixels;
|
int m_walkedPixels;
|
||||||
|
int m_walkStepDuration;
|
||||||
uint m_footStep;
|
uint m_footStep;
|
||||||
Timer m_walkTimer;
|
Timer m_walkTimer;
|
||||||
Timer m_footTimer;
|
Timer m_footTimer;
|
||||||
|
|
|
@ -67,11 +67,11 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// last walk is not done yet
|
// last walk is not done yet
|
||||||
if(m_walkTimer.ticksElapsed() < getStepDuration())
|
if(m_walkTimer.ticksElapsed() < m_walkStepDuration)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk
|
// 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() >= getStepDuration() + PREWALK_TIMEOUT;
|
bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration + PREWALK_TIMEOUT;
|
||||||
|
|
||||||
// avoid doing more walks than wanted when receiving a lot of walks from server
|
// avoid doing more walks than wanted when receiving a lot of walks from server
|
||||||
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
|
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
|
||||||
|
@ -178,8 +178,7 @@ void LocalPlayer::updateWalkOffset(int totalPixelsWalked)
|
||||||
|
|
||||||
void LocalPlayer::updateWalk()
|
void LocalPlayer::updateWalk()
|
||||||
{
|
{
|
||||||
int stepDuration = getStepDuration();
|
float walkTicksPerPixel = m_walkStepDuration / 32.0f;
|
||||||
float walkTicksPerPixel = stepDuration / 32.0f;
|
|
||||||
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||||
|
|
||||||
// update walk animation and offsets
|
// update walk animation and offsets
|
||||||
|
@ -188,7 +187,7 @@ void LocalPlayer::updateWalk()
|
||||||
updateWalkingTile();
|
updateWalkingTile();
|
||||||
|
|
||||||
// terminate walk only when client and server side walk are complated
|
// terminate walk only when client and server side walk are complated
|
||||||
if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= stepDuration)
|
if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration)
|
||||||
terminateWalk();
|
terminateWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue