Monster dash
Monsters appear to be dashing when approaching the target, check recording: https://i.gyazo.com/276e94b77add6042f7c0d1663645bb64.mp4 This appear only on OTClient. When pushing a creature around me they move smoothly, NPCs also have fine movement.
When pushing a creature diagonally they lag, check recording: https://i.gyazo.com/412d93e4a799cdc93fd098c04001d7e2.mp4 This only OTClient (using 7.4 spr)
Is there a quickfix for this?
I using OTX3. (7.72)
This reproduce inclusive on tfs 1.3 - 10.99
fix?
@mattyx14
Why closed?
Let me give you a hint, this is connected to Creature::updateWalkAnimation. It works like a clockwork, you should find the right formula, it's basically trial and error or check the decompiled flash for the code and find out ;)
Best Wishes, Okke
I fixed the player walk animation in this function, it's almost like real tibia, but don't know what to do to fix monsters animation/dash
void Creature::updateWalkAnimation(int totalPixelsWalked)
{
// update outfit animation
if(m_outfit.getCategory() != ThingCategoryCreature)
return;
int footAnimPhases = getAnimationPhases() - 1; //returns 8 for player
float footDelay = getStepDuration(true) / footAnimPhases; //varies with the ground
// since mount is a different outfit we need to get the mount animation phases
if(m_outfit.getMount() != 0) {
ThingType *type = g_things.rawGetThingType(m_outfit.getMount(), m_outfit.getCategory());
footAnimPhases = type->getAnimationPhases() - 1;
footDelay = getStepDuration(true) / footAnimPhases;
}
if (totalPixelsWalked >= 32 && !m_walkFinishAnimEvent) {
m_footStep = 0; //
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<int>(footDelay, 200));
}
if (footAnimPhases == 0) {
m_walkAnimationPhase = 0;
}
else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= footDelay && totalPixelsWalked < 32) {
m_footStep++;
m_walkAnimationPhase = (m_footStep % footAnimPhases);
m_footStepDrawn = false;
m_footTimer.restart();
}
else if(m_walkAnimationPhase == 0 && totalPixelsWalked < 32) {
m_walkAnimationPhase = (m_footStep % footAnimPhases);
}
}
Thanks for the contribution, Gustavo.
The next hint for the animation / dash part: check speed factor on the function Creature::getStepDuration.
Best WIshes, Okke
Factor is only used for diagonal movements, setting it to 1 or 1.5f solves the laggy diagonal issue on 10.98 / TFS 1.3. Thanks for the tip!
But the dashing problem is the most annoying and I still don't know how to fix
Players that click on map also look like dashing.
My guess is that this is a problem drawing things that aren't the local player. Maybe client is receiving these packets wrong or delayed, I dont know...
Edit: maybe around here, in tile.cpp:
// creatures
if(drawFlags & Otc::DrawCreatures) {
if(animate) {
for(const CreaturePtr& creature : m_walkingCreatures) {
creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor,
dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate, lightView);
}
}
for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
const ThingPtr& thing = *it;
if(!thing->isCreature())
continue;
CreaturePtr creature = thing->static_self_cast<Creature>();
if(creature && (!creature->isWalking() || !animate))
creature->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
}
}
Made a super slow motion to show the exaclty dashing issue: https://streamable.com/2xek1 going from up to down and comparing with real gif and sprites https://streamable.com/wmv6e going from right to left https://ezgif.com/split/ezgif-1-1c80fb2cf982.gif gif and sprites
I really wanna fix this, does anyone have any tips?