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

Walking/Flying delay?

xaii

Member
Joined
Nov 17, 2018
Messages
42
Reaction score
5
Hey guys i have another problem, i recorded video to show whats going on.


When I walk normally without using the !up command where it takes us a level up, probably in the Z axis if I'm not mistaken, the walking animation seems smooth, however, if I use the !up command and go up a level, I automatically have such a delay as in the video.


Distribution. PokeDash by Pota 1.0, TFS 1.2
 
Last edited:
Yes, we know everything from your Pokemon distro without any sources/scripts. So... let me run my imagination and open my brain...
I think it's due to creating "invisible tile" or whatever you using for "flying". I bet in this (your Pokemon) engine flying work like creating Tile in front of character when you trying to move (and removing previously created tile if you already "land" on newly created Tile).
Probably tile speed is 0 when u trying to move or something is 0 and server is not allowing you to pass frequently.
 
Yes, we know everything from your Pokemon distro without any sources/scripts. So... let me run my imagination and open my brain...
I think it's due to creating "invisible tile" or whatever you using for "flying". I bet in this (your Pokemon) engine flying work like creating Tile in front of character when you trying to move (and removing previously created tile if you already "land" on newly created Tile).
Probably tile speed is 0 when u trying to move or something is 0 and server is not allowing you to pass frequently.
Sorry
Distribution TFS 1.2 PokeDash By Pota 1.0 -10.98

There is a Fly.lua
Lua:
local prohibitedItems = {}

function onSay(player, words)
    if words == "!up" and player:getStorageValue(storageDive) > 0 then
        local nextPosition = player:getPosition():moveUpstairs()
        local tile = Tile(nextPosition)
        if tile and isInArray(waterIds, tile:getGround():getId()) and hasSummons(player) and MonsterType(player:getSummon():getName()):isSurfable() > 0 then
            player:setStorageValue(storageDive, -1)
            player:removeCondition(CONDITION_OUTFIT)
            player:teleportTo(nextPosition, false)
        else
            player:sendCancelMessage("You need a surfable pokemon to go up.")
        end
        return true
    end

    if not player:isOnFly() then
        player:sendCancelMessage("You are not flying.")
        return false
    end
    local last = player:getStorageValue(storageDelay)
    local interval = 1
    if last+interval > os.time() then
        player:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    end
 
    if words == "!up" then
        local ret = player:flyUp()
        if ret == false then
            player:sendCancelMessage("You can not fly up.")
        else
            player:activateFly()
            player:setStorageValue(storageDelay, os.time())
        end
    elseif words == "!down" then
        local ret = player:flyDown()
        if ret == false then
            player:sendCancelMessage("You can not fly down.")
        else
            player:deactivateFly()
            player:setStorageValue(storageDelay, os.time())
        end
    end
    return false
end

--function onSay(player, words, param)
--    if player:getStorageValue(storageFly) ~= 1 then return false end
--    local position = player:getPosition()
--    position.z = position.z - 1   
--    local destTile = Tile(position)
--    if not destTile then
--        Game.createTile(position)
--        Game.createItem(8426, 1, position)
--        player:teleportTo(position)
--    end   
--    position:createFlyFloor()
--    player:teleportTo(position)
--    player:flyUp()
--    return false
--end

I'll put the scripts that have been modified by Pota here.

flyevent.lua

Lua:
function onMove(creature, toPosition, fromPosition)

    local player = Player(creature:getId())

    if player:isOnFly() then

--    if toPosition.x > 2080 or toPosition.x < 209 or toPosition.y > 2342 or toPosition.y < 611 then

--        player:teleportTo(fromPosition, false)

--        fromPosition:sendMagicEffect(CONST_ME_POFF)

--        return false

--    end





        local fromTile = Tile(fromPosition)

        local fromItem = fromTile:getItemById(flyFloor)

        if fromItem then

            fromItem:remove()

        end

--    local toTile = Tile(toPosition)

--    if toTile then

--        local ground = toTile:getGround()

--        if ground then

--            player:unregisterEvent("FlyEvent")

--            print("unregister onmove")

--            return true

--        end

--    end

        toPosition:createFlyFloor()

    end

    return true

end


Tile.cpp


Lua:
void Tile::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link /*= LINK_OWNER*/)
{
    SpectatorVec list;
    g_game.map.getSpectators(list, getPosition(), true, true);
    for (Creature* spectator : list) {
        spectator->getPlayer()->postAddNotification(thing, oldParent, index, LINK_NEAR);
    }

    //add a reference to this item, it may be deleted after being added (mailbox for example)
    Creature* creature = thing->getCreature();
    Item* item;
    if (creature) {
        creature->incrementReferenceCounter();
        item = nullptr;
    } else {
        item = thing->getItem();
        if (item) {
            item->incrementReferenceCounter();
        }
    }

    if (link == LINK_OWNER) { //pota
        //calling movement scripts
        bool postScript = false;

        if (creature) {
            postScript = g_moveEvents->onCreatureMove(creature, this, MOVE_EVENT_STEP_IN);
        } else if (item) {
            g_moveEvents->onItemMove(item, this, true);
        }

        if (hasFlag(TILESTATE_TELEPORT)) {
            if (postScript) {
                Teleport* teleport = getTeleportItem();
                if (teleport) {
                    teleport->addThing(thing);
                }
            }
        } else if (hasFlag(TILESTATE_TRASHHOLDER)) {
            TrashHolder* trashholder = getTrashHolder();
            if (trashholder) {
                trashholder->addThing(thing);
            }
        } else if (hasFlag(TILESTATE_MAILBOX)) {
            Mailbox* mailbox = getMailbox();
            if (mailbox) {
                mailbox->addThing(thing);
            }
        }
    }

    //release the reference to this item onces we are finished
    if (creature) {
        g_game.ReleaseCreature(creature);
    } else if (item) {
        g_game.ReleaseItem(item);
    }
}

Creature.cpp

Lua:
void Creature::onCreatureMove(Creature* creature, const Tile* newTile, const Position& newPos,
                              const Tile* oldTile, const Position& oldPos, bool teleport)
{
    if (creature == this) {
        lastStep = OTSYS_TIME();
        lastStepCost = 1;

        if (!teleport) {
            if (oldPos.z != newPos.z) {
                //floor change extra cost
                lastStepCost = 1;
            } else if (Position::getDistanceX(newPos, oldPos) >= 1 && Position::getDistanceY(newPos, oldPos) >= 1) {
                //diagonal extra cost
                lastStepCost = 1;
            }
        } else {
            stopEventWalk();
        }

        if (!summons.empty()) { //pota
            //check if any of our summons is out of range (+/- 2 floors or 30 tiles away)
            std::forward_list<Creature*> despawnList;
            for (Creature* summon : summons) {
                if (summon->hasCondition(CONDITION_MOVING)) { //pota
                    summon->removeCondition(CONDITION_MOVING);
                }

                const Position& pos = summon->getPosition();
                //added
                Tile* destTile = g_game.map.getTile(newPos);

                if (Position::getDistanceZ(newPos, pos) > 0 || (std::max<int32_t>(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) > 12)) {
                    //changed,
                    //before:despawnList.push_front(summon);
                    g_game.map.moveCreature(*summon, *destTile);                   
                    //added
                    g_game.addMagicEffect(pos, CONST_ME_TELEPORT);
                }
            }

Lua:
bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)
{
    if (myPos.z <= 7) {
        //we are on ground level or above (7 -> 0)
        //view is from 7 -> 0
        if (pos.z > 7) {
            return false;
        }
    } else if (myPos.z >= 8) {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if (Position::getDistanceZ(myPos, pos) > 2) {
            return false;
        }
    }

    const int_fast32_t offsetz = myPos.getZ() - pos.getZ();
    return (pos.getX() >= myPos.getX() - Map::maxViewportX + offsetz) && (pos.getX() <= myPos.getX() + Map::maxViewportX + offsetz) //pota
        && (pos.getY() >= myPos.getY() - Map::maxViewportY + offsetz) && (pos.getY() <= myPos.getY() + Map::maxViewportY + offsetz);
}


actions.cpp
Lua:
ReturnValue Actions::canUseFar(const Creature* creature, const Position& toPos, bool checkLineOfSight, bool checkFloor)
{
    if (toPos.x == 0xFFFF) {
        return RETURNVALUE_NOERROR;
    }

    const Position& creaturePos = creature->getPosition();
    if (checkFloor && creaturePos.z != toPos.z) {
        return creaturePos.z > toPos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS;
    }

    if (!Position::areInRange<10, 5>(toPos, creaturePos)) { //pota
        return RETURNVALUE_TOOFARAWAY;
    }

    if (checkLineOfSight && !g_game.canThrowObjectTo(creaturePos, toPos)) {
        return RETURNVALUE_CANNOTTHROW;
    }

    return RETURNVALUE_NOERROR;
}
 
From OTS point of view:
Only tiles that are on map (.otbm) - has ground item - are allocated in memory (RAM) of server.
Only tiles that are in memory are walkable (has ground item = has walk speed).

Only way to make it smooth walking on empty tile, would be to add 'walkable invisible ground items' to all tiles on map - giiigabytes of RAM to fill whole map with walkable items on all tiles.
Someone did some hack in your engine/Lua to make it create new Tiles in front of players or around players.
Only function that sounds like that hack is toPosition:createFlyFloor().
Find function createFlyFloor and post it contents.

Do you use some command to walk around after !up or just walk by arrows?
 
From OTS point of view:
Only tiles that are on map (.otbm) - has ground item - are allocated in memory (RAM) of server.
Only tiles that are in memory are walkable (has ground item = has walk speed).

Only way to make it smooth walking on empty tile, would be to add 'walkable invisible ground items' to all tiles on map - giiigabytes of RAM to fill whole map with walkable items on all tiles.
Someone did some hack in your engine/Lua to make it create new Tiles in front of players or around players.
Only function that sounds like that hack is toPosition:createFlyFloor().
Find function createFlyFloor and post it contents.

Do you use some command to walk around after !up or just walk by arrows?
Only WASD/arrows
 
Only WASD/arrows
Find function createFlyFloor and post it contents or link to place where you did download that server source/datapack.

EDIT:
I've found it:
Lua:
function Position:createFlyFloor()
local toTile = Tile(self)
if not toTile or not toTile:getItems() or not toTile:getGround() then
      doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
Game.createItem(flyFloor, 1, self)
end
   return true
end
and flyFloor item ID is 460 (invisible floor).
 
Last edited:
Find function createFlyFloor and post it contents or link to place where you did download that server source/datapack.

EDIT:
I've found it:
Lua:
function Position:createFlyFloor()
local toTile = Tile(self)
if not toTile or not toTile:getItems() or not toTile:getGround() then
      doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
Game.createItem(flyFloor, 1, self)
end
   return true
end
and flyFloor item ID is 460 (invisible floor).
Daamn, so it works thanks to "side effect", execution of area combat creates this tile (so area spells effects can be placed on some non existing tiles):


C++:
    Tile* tile = g_game.map.getTile(targetPos);
    if (!tile) {
        tile = new StaticTile(targetPos.x, targetPos.y, targetPos.z);
        g_game.map.setTile(targetPos, tile);
    }


Fun, fun:
fun.gif
 
Last edited:
Back
Top