• 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+ Match character movement duration to diagonal movement cooldown.

kubiczi123

RoFT- First and last memb
Joined
Dec 30, 2011
Messages
135
Reaction score
31
Location
Poland
Hey. Im in search of improving the UX of player movement.
Currently the character moves diagonally very fast, then has to wait.
Is there a way to sync the character movement speed with the movement cooldown? (As in, you can walk right again after the diagonal movement animation is done)
Post automatically merged:

Alright nevermind...
Already found it.
client/src/creature.cpp
C++:
void Creature::updateWalk(const bool isPreWalking)
{
    const float walkTicksPerPixel = getStepDuration(true) / static_cast<float>(g_gameConfig.getSpriteSize());
    const int totalPixelsWalked = std::min<int>(m_walkTimer.ticksElapsed() / walkTicksPerPixel, g_gameConfig.getSpriteSize());
    // needed for paralyze effect
    m_walkedPixels = std::max<int>(m_walkedPixels, totalPixelsWalked);
    updateWalkAnimation();
    updateWalkOffset(m_walkedPixels);
    updateWalkingTile();
    if (m_walkedPixels == g_gameConfig.getSpriteSize()) {
        if (isPreWalking) resetWalkAnimationPhase(true);
        else terminateWalk();
    }
}

Simply change the "true" in getStepDuration() to "false".
C++:
uint16_t Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
 
If you couldn't use the method above, it might be that yours is OTClientV8 Kondra. In that case, follow this tutorial as an alternative.

Step 1: Modify the creature.cpp file in the OTClientV8 Kondra source code.

In the creature.cpp file, search for:

C++:
getStepDuration(true)

Replace all occurrences with:

C++:
getStepDuration()

Then, search for:

C++:
interval *= factor;

Change it to:

C++:
interval *= 1.5;

---

Step 2: Modify the localplayer.cpp file in the OTClientV8 Kondra source code.

In the localplayer.cpp file, search for:

C++:
getStepDuration(true)

Replace all occurrences with:

C++:
getStepDuration()

---

Step 3: Modify the creature.cpp file in the Server source code.

In the creature.cpp file in the Server source code, search for:

C++:
// extra diagonal cost
lastStepCost = 3;

Replace it with:

C++:
// extra diagonal cost
lastStepCost = 1.5;

Then, search for:

C++:
if ((dir & DIRECTION_MASK_DIAGONAL) != 0) {
    stepDuration *= 3;
}

Replace it with:

C++:
if ((dir & DIRECTION_MASK_DIAGONAL) != 0) {
    stepDuration *= 1.5;
}

---

Note:

The value 1.5 controls the speed. If you want to increase or decrease the speed, simply change this value accordingly.
 
Last edited:
Back
Top