• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Slow Character Walk in certain speeds

bertosso

Member
Joined
Apr 27, 2024
Messages
13
Solutions
1
Reaction score
5
Location
Brasil
Twitch
bertosso
YouTube
KBertosso
Hello,

I have a problem that at certain speeds the character does not walk properly, here is a video representing the bug, when walking with the character at his normal speed he walks a little stuck, when i put boh and time ring that make the char have a higher speed he walks normally, I looked for other speed bugs on the forum and tried some things but without success.

TFS 1.4.2

 
Solution
Hello,

I have a problem that at certain speeds the character does not walk properly, here is a video representing the bug, when walking with the character at his normal speed he walks a little stuck, when i put boh and time ring that make the char have a higher speed he walks normally, I looked for other speed bugs on the forum and tried some things but without success.

TFS 1.4.2

The reason is pretty simple, the stepDuration sent to the client is different from the real step duration executed by the serverSide, if i remember correctly there was like a minimum value for that or something that caused that stuck on speed its not correctly in sync

the delay is server side as it stucks, so you sent the...
Hello,

I have a problem that at certain speeds the character does not walk properly, here is a video representing the bug, when walking with the character at his normal speed he walks a little stuck, when i put boh and time ring that make the char have a higher speed he walks normally, I looked for other speed bugs on the forum and tried some things but without success.

TFS 1.4.2

The reason is pretty simple, the stepDuration sent to the client is different from the real step duration executed by the serverSide, if i remember correctly there was like a minimum value for that or something that caused that stuck on speed its not correctly in sync

the delay is server side as it stucks, so you sent the clientSide a value that might be lower than the real step duration so inside the memory the player didn't arrive to the position desired, but on client view you arrived, you take action for another move, game scheduler schedules this call as there is already a move into action


(Im not sure as long as i didn't check files)
 
Solution
I'm trying some things based on what you said but without success, I'll leave what shows for me if i search for stepduration on my server and client files

LUA:
Client OLD • src\client\creature.cpp:
  155:         int footDelay = (getStepDuration(true)) / 3;
  158:             (int)m_stepDuration, (int)getStepDuration(true), getStepDuration(false), (int)m_walkedPixels, (int)m_walkTimer.ticksElapsed(),
  487:     uint16 footDelay = getStepDuration(true);
  489:         footDelay = ((getStepDuration(true) + 20) / (g_game.getFeature(Otc::GameFasterAnimations) ? footAnimPhases * 2 : footAnimPhases));
  589:          std::max(getStepDuration(true) / std::max(g_app.getFps(), 1), 1) : (float)getStepDuration() / g_sprites.spriteSize()
  595:     float walkTicksPerPixel = ((float)(getStepDuration(true) + (g_game.getFeature(Otc::GameNewUpdateWalk) ? 0 : 10))) / (float)g_sprites.spriteSize();
  610:     if (!isLocalPlayer() && m_walking && m_walkTimer.ticksElapsed() >= getStepDuration())
  876: uint16 Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
  928:     if (isServerWalking() && g_game.getFeature(Otc::GameNewWalking) && m_stepDuration > 0) // just use server value
  930:         interval = m_stepDuration;

Client OLD • src\client\creature.h:
  118:     uint16 getStepDuration(bool ignoreDiagonal = false, Otc::Direction dir = Otc::InvalidDirection);
  122:     float getStepProgress() { return m_walkTimer.ticksElapsed() / getStepDuration(); }
  123:     int getStepTicksLeft() { return getStepDuration() - m_walkTimer.ticksElapsed(); }
  146:     void allowAppearWalk(uint16_t stepSpeed) { m_allowAppearWalk = true; m_stepDuration = stepSpeed; }
  275:     uint16 m_stepDuration = 0;

Client OLD • src\client\localplayer.cpp:
   83:     if (m_walking && (m_walkTimer.ticksElapsed() < getStepDuration()) && !isAutoWalking() && !isServerWalking())
  100:         if (m_walkTimer.ticksElapsed() >= getStepDuration() + 300)
  227:         m_walkTimer.adjust(-(getStepDuration() + 50));
  372:     if (m_walking && m_walkTimer.ticksElapsed() >= getStepDuration()) {

Client OLD • src\client\luafunctions_client.cpp:
  525:     g_lua.bindClassMemberFunction<Creature>("getStepDuration", &Creature::getStepDuration);

Client OLD • src\client\protocolgameparse.cpp:
  1236:     uint16_t stepDuration = 0;
  1238:         stepDuration = msg->getU16();
  1251:     creature->allowAppearWalk(stepDuration);

home • src\creature.cpp:
   102:     int64_t stepDuration = getStepDuration(dir);
   103:     return stepDuration - (ct - lastStep);
   114:     int64_t stepDuration = getStepDuration() * lastStepCost;
   115:     return stepDuration - (ct - lastStep);
  1393: int64_t Creature::getStepDuration(Direction dir) const
  1395:     int64_t stepDuration = getStepDuration();
  1397:         stepDuration *= 1.5;
  1399:     return stepDuration;
  1402: int64_t Creature::getStepDuration() const
  1432:     int64_t stepDuration = std::ceil(duration / 50) * 50;
  1436:         stepDuration *= 2;
  1439:     return stepDuration;
  1446:         int64_t stepDuration = getStepDuration();
  1447:         if (onlyDelay && stepDuration > 0) {
  1450:             ret = stepDuration * lastStepCost;

home • src\creature.h:
  184:         int64_t getStepDuration(Direction dir) const;
  185:         int64_t getStepDuration() const;

home • src\monster.cpp:
  1354:         if (stepDuration < 2) {
  1355:             stepDuration++;
  1357:     } else if (stepDuration > 0) {
  1358:         stepDuration--;

home • src\monster.h:
  161:             return stepDuration >= 1;
  193:         int32_t stepDuration = 0;

home • src\player.cpp:
  1331:     //setNextAction(OTSYS_TIME() + getStepDuration(dir));

home • src\protocolgame.cpp:
  3245:     msg.add<uint16_t>(creature->getStepDuration());
Post automatically merged:

Changed my creature.cpp to this and it got better, but still dont feel 100% right

LUA:
int64_t Creature::getStepDuration() const
{
    if(isRemoved()) {
        return 0;
    }

    uint32_t groundSpeed;
    int32_t stepSpeed = getStepSpeed();

    Item* ground = tile->getGround();
    if (ground) {
        groundSpeed = Item::items[ground->getID()].speed;
        if (groundSpeed == 0) {
            groundSpeed = 150;
        }
    } else {
        groundSpeed = 150;
    }

    int64_t stepDuration = (1000 * groundSpeed) / stepSpeed;

    const Monster* monster = getMonster();
    if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) {
        stepDuration *= 3;
    }

    return stepDuration;
}
 
Last edited:
The reason is pretty simple, the stepDuration sent to the client is different from the real step duration executed by the serverSide, if i remember correctly there was like a minimum value for that or something that caused that stuck on speed its not correctly in sync

the delay is server side as it stucks, so you sent the clientSide a value that might be lower than the real step duration so inside the memory the player didn't arrive to the position desired, but on client view you arrived, you take action for another move, game scheduler schedules this call as there is already a move into action


(Im not sure as long as i didn't check files)

I managed to solve the manual walking by adding g_game.enableFeature(GameSlowerManualWalking) on features.lua from client.
Marked your answer as solution since it put me in the right way to fix it, i was completely lost before.

Now the walk is bad only when map clicking, found others posts with people with same problem gonna try what they said there to see if it gets fixed aswell.

Thanks for your help
 
Back
Top