• 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!

How to set NPC walkInterval to 1000?

tylerdurden

New Member
Joined
Jan 10, 2022
Messages
17
Reaction score
1
hello i make old tibia and i cannot manage npc to walk like in old tibia. they walked fast like every second. now they walk slow. now they walk like 2 seconds because walkinterval is 2000 but if i set walkinterval to 1000 it doesnt work. i dont want speed only time between moves so walk interval
sorry my english i so bad :(
 
Last edited:
Hmmm...
In TFS you can not set walk interval to and below 1000 milisecons because I believe it is related to onThink function in npc.cpp. It's quite bugged because of this fact as you can only set the NPC speed tobe greater than 1000. It also results in movin slower. If you set walkInterval to let's say 5000, the speed of your character will not only be 5000 miliseconds but also wait 5000 before making next step.

You would have to set your own "if" instruction to execute "addEventWalk" below 1 second in void Npc::eek:nThink and then in bool Npc::getNextStep to execute every 2 second, so it means in real 1 seconds as onThink executed walkEvent and getNextStep executed walking after 1 seconds. So it looks like 1 second.

I no longer use TFS but I would try something like this:
C++:
change to:
bool Npc::getNextStep(Direction& dir, uint32_t& flags)
{

    if (Creature::getNextStep(dir, flags)) {
        return true;
    }

    if (walkTicks == 0) {
        return false;
    }

    if (focusCreature != 0) {
        return false;
    }

    int time_passed = getTimeSinceLastMove();

    if (time_passed >= 2000) // + step duration?
    {
        return getRandomStep(dir);

    }  
    //return getRandomStep(dir);

}

and change to:

C++:
void Npc::onThink(uint32_t interval)
{
    Creature::onThink(interval);

    if (npcEventHandler) {
        npcEventHandler->onThink();
    }

    int time_passed = getTimeSinceLastMove();

    if (!isIdle && time_passed < 1000) // or step duration?
    {
        addEventWalk();
    }
}

Let me know if it works I havent got time now to test it. I am on my phone on holiday
 
Last edited by a moderator:
Send me the tallbar files with formulas because I need to pay attention to the the ground speed etc. I know that even Nostalrius got it wrong. My brain is too small now. Im drunk af under a palm tree.
 
Last edited by a moderator:
monster.cpp:
bool Monster::getNextStep(Direction& direction, uint32_t& flags){

if (!followCreature || !hasFollowPath)
if (getTimeSinceLastMove() > 800) { // minotaur walks constantly on desert, snow etc but stops for a moment on tiles like black marble floor etc
getRandomStep(getPosition(), direction);
}
}

Note: NPC and monsters walk faster in new Tibia aswell. It's not just about old Tibia. The Forgottenserver is bugged.
 

Attachments

  • minotaur walk 4.gif
    minotaur walk 4.gif
    891 KB · Views: 31 · VirusTotal
  • minotaur walk 5.gif
    minotaur walk 5.gif
    2.6 MB · Views: 30 · VirusTotal
  • minotaur walk 7.gif
    minotaur walk 7.gif
    361.6 KB · Views: 31 · VirusTotal
Last edited by a moderator:
bool Monster::getNextStep(Direction& direction, uint32_t& flags) {

bool result = false;
if (listWalkDir.empty() && (!followCreature || !hasFollowPath)) {
if (getTimeSinceLastMove() >= 800)
{
randomStepping = true;
result = getRandomStep(getPosition(), direction);
}
}
else if (followCreature || !listWalkDir.empty())
{
randomStepping = false;
result = Creature::getNextStep(direction, flags);
if (result) {
flags |= FLAG_PATHFINDING;
}
else {
if (ignoreFieldDamage) {
ignoreFieldDamage = false;
updateMapCache();
}

if (attackedCreature && attackedCreature == followCreature) {
if (isFleeing()) {
result = getDanceStep(getPosition(), direction, false, false);
}
else if (mType->info.staticAttackChance < static_cast<uint32_t>(uniform_random(1, 100))) {
result = getDanceStep(getPosition(), direction);
}
}
}
}

return result;
}

its not working because function returns every result variable and skips getTimeSinceLastMove... :(
 
Last edited:
Hmmm...
In TFS you can not set walk interval to and below 1000 milisecons because I believe it is related to onThink function in npc.cpp. It's quite bugged because of this fact as you can only set the NPC speed tobe greater than 1000. It also results in movin slower. If you set walkInterval to let's say 5000, the speed of your character will not only be 5000 miliseconds but also wait 5000 before making next step.

You would have to set your own "if" instruction to execute "addEventWalk" below 1 second in void Npc::eek:nThink and then in bool Npc::getNextStep to execute every 2 second, so it means in real 1 seconds as onThink executed walkEvent and getNextStep executed walking after 1 seconds. So it looks like 1 second.

I no longer use TFS but I would try something like this:
C++:
change to:
bool Npc::getNextStep(Direction& dir, uint32_t& flags)
{

    if (Creature::getNextStep(dir, flags)) {
        return true;
    }

    if (walkTicks == 0) {
        return false;
    }

    if (focusCreature != 0) {
        return false;
    }

    int time_passed = getTimeSinceLastMove();

    if (time_passed >= 2000) // + step duration?
    {
        return getRandomStep(dir);

    } 
    //return getRandomStep(dir);

}

and change to:

C++:
void Npc::onThink(uint32_t interval)
{
    Creature::onThink(interval);

    if (npcEventHandler) {
        npcEventHandler->onThink();
    }

    int time_passed = getTimeSinceLastMove();

    if (!isIdle && time_passed < 1000) // or step duration?
    {
        addEventWalk();
    }
}

Let me know if it works I havent got time now to test it. I am on my phone on holid


omg man now is like tibiantis thanks man i love you!!!!!!!!!!!!!!!!!

/edit its bugged ;[
Could you guys share the working code pls?
 
What happens if you do this:
C++:
int64_t Creature::getEventStepTicks(bool onlyDelay) const
{
    if (const Npc* npc = getNpc()) {
        return 2000;
    }

    int64_t ret = getWalkDelay();
    if (ret <= 0) {
        int64_t stepDuration = getStepDuration();
        if (onlyDelay && stepDuration > 0) {
            ret = 1;
        } else {
            ret = stepDuration * lastStepCost;
        }
    }
    
    return ret;
}
 
What happens if you do this:
C++:
int64_t Creature::getEventStepTicks(bool onlyDelay) const
{
    if (const Npc* npc = getNpc()) {
        return 2000;
    }

    int64_t ret = getWalkDelay();
    if (ret <= 0) {
        int64_t stepDuration = getStepDuration();
        if (onlyDelay && stepDuration > 0) {
            ret = 1;
        } else {
            ret = stepDuration * lastStepCost;
        }
    }
 
    return ret;
}
Gonna test when I get home, I tested the code of glapa93 and it does not works, npcs doesn't walk at all

@ond should i replace this code without the editions of @glapa93 ?

@ond works good, thank you. could you do something similar for monsters ?
 
Last edited:
onThink calls addEventWalk every second or so, so maybe just change

C++:
if (!walkingToSpawn && (!followCreature || !hasFollowPath) && (!isSummon() || !isMasterInRange)) {
    if (getTimeSinceLastMove() >= 1000) {
        randomStepping = true;
        //choose a random direction
        result = getRandomStep(getPosition(), direction);
    }

to

C++:
    if (!walkingToSpawn && (!followCreature || !hasFollowPath) && (!isSummon() || !isMasterInRange)) {
        randomStepping = true;
        //choose a random direction
        result = getRandomStep(getPosition(), direction);
 
onThink calls addEventWalk every second or so, so maybe just change

C++:
if (!walkingToSpawn && (!followCreature || !hasFollowPath) && (!isSummon() || !isMasterInRange)) {
    if (getTimeSinceLastMove() >= 1000) {
        randomStepping = true;
        //choose a random direction
        result = getRandomStep(getPosition(), direction);
    }

to

C++:
    if (!walkingToSpawn && (!followCreature || !hasFollowPath) && (!isSummon() || !isMasterInRange)) {
        randomStepping = true;
        //choose a random direction
        result = getRandomStep(getPosition(), direction);
they move faster now ! thanks!
 
Post automatically merged:

The code for monster's doesn't work. They walk like crazy and dont stop even for a millisecond despite the stepduration.
Here videos:
 

Attachments

Last edited:
It works differently in ots than how it "should" work.
Anyway, try this lol

C++:
int64_t Creature::getEventStepTicks(bool onlyDelay) const
{
    if (const Npc* npc = getNpc()) {
        return 2000;
    }
    
    if (const Monster* monster = getMonster()) {
        if (!hasFollowPath) {
            return 1000;
        }   
    }

    int64_t ret = getWalkDelay();
    if (ret <= 0) {
        int64_t stepDuration = getStepDuration();
        if (onlyDelay && stepDuration > 0) {
            ret = 1;
        } else {
            ret = stepDuration * lastStepCost;
        }
    }
    
    return ret;
}
 
Back
Top