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

C++ Old elevation parcel block [TFS 1.2] tibia 10.98

helviio

Member
Joined
Apr 30, 2019
Messages
53
Solutions
2
Reaction score
12

Used Distro : Github

Tibia Version : 1098

good morning good afternoon or good night.​

alright? Hope all is well =D​

c'mon... I'm trying to create a 10.98 server and I'm trying to add this to my server​

but I'm not getting​

however I don't understand much about sources and I've even been researching how to do it but I didn't get success... after a lot of frustrated attempts I came to ask for help! I thank you for your precious time!​



My Tibia TFS 1.2 10.98



how i would like it to stay

 
Last edited:
Hello,
You need to do it in internalMoveCreature functions in game.cpp also you need to calculate the height of items on tile and check if tile contains an item with height and calculate it height.
Here's my cheap* example "how to do it"
If you read it I bet you can similarly adapt to your engine.

game.cpp , : Game::internalMoveCreature(Creature& creature, Tile& toTile, uint32_t flags /= 0/)
C++:
    //height check
    const Position& creaturePos = creature.getPosition();
    const Position& toPos = toTile.getPosition();
    if((creaturePos.z >= toPos.z) && (toTile.getHeight() - creature.getTile()->getHeight() >= 2)) {
        return RETURNVALUE_NOTPOSSIBLE;
    }
game.cpp , : Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags /= 0/)
C++:
ReturnValue Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags /*= 0*/)
{
    const Position& currentPos = creature->getPosition();
    Position destPos = getNextPosition(direction, currentPos);

    bool diagonalMovement = (direction & DIRECTION_DIAGONAL_MASK) != 0;
    if (creature->getPlayer() && !diagonalMovement) {
        //try go up
        if (currentPos.z != 8 && creature->getTile()->hasHeight(3)) {
            Tile* tmpTile = map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID)) {
                    flags |= FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;

                    if (!tmpTile->hasFlag(TILESTATE_FLOORCHANGE)) {
                        destPos.z--;
                    }
                }
            }
        } else {
            //try go down
            Tile* tmpTile = map.getTile(destPos.x, destPos.y, destPos.z);
            if (currentPos.z != 7 && (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID)))) {
                tmpTile = map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->hasHeight(3)) {
                    flags |= FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;
                    destPos.z++;
                }
            }
        }
    }

    Tile* toTile = map.getTile(destPos);
    if (!toTile) {
        return RETURNVALUE_NOTPOSSIBLE;
    }
    return internalMoveCreature(*creature, *toTile, flags);
}
tile.cpp
C++:
bool Tile::hasHeight(uint32_t n) const
{
    uint32_t height = 0;

    if (ground) {
        if (ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }

        if (n == height) {
            return true;
        }
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }

            if (n == height) {
                return true;
            }
        }
    }
    return false;
}

int16_t Tile::getHeight() const
{
    int32_t height = 0;
    if(ground) {
        if(ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }
    }
 
    if(const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }
        }
    }
 
    return height;
}
tile.h
C++:
        bool hasHeight(uint32_t n) const;
        int16_t getHeight() const;

* (disclaimer : the code is old and could be better (specially used type of variables), but I want to quickly just show you one of the possible ways)
 
Last edited:
Hello,
You need to do it in internalMoveCreature functions in game.cpp also you need to calculate the height of items on tile and check if tile contains an item with height and calculate it height.
Here's my cheap* example "how to do it"
If you read it I bet you can similarly adapt to your engine.

game.cpp , : Game::internalMoveCreature(Creature& creature, Tile& toTile, uint32_t flags /= 0/)
C++:
    //height check
    const Position& creaturePos = creature.getPosition();
    const Position& toPos = toTile.getPosition();
    if((creaturePos.z >= toPos.z) && (toTile.getHeight() - creature.getTile()->getHeight() >= 2)) {
        return RETURNVALUE_NOTPOSSIBLE;
    }
game.cpp , : Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags /= 0/)
C++:
ReturnValue Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags /*= 0*/)
{
    const Position& currentPos = creature->getPosition();
    Position destPos = getNextPosition(direction, currentPos);

    bool diagonalMovement = (direction & DIRECTION_DIAGONAL_MASK) != 0;
    if (creature->getPlayer() && !diagonalMovement) {
        //try go up
        if (currentPos.z != 8 && creature->getTile()->hasHeight(3)) {
            Tile* tmpTile = map.getTile(currentPos.x, currentPos.y, currentPos.getZ() - 1);
            if (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID))) {
                tmpTile = map.getTile(destPos.x, destPos.y, destPos.getZ() - 1);
                if (tmpTile && tmpTile->getGround() && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID)) {
                    flags |= FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;

                    if (!tmpTile->hasFlag(TILESTATE_FLOORCHANGE)) {
                        destPos.z--;
                    }
                }
            }
        } else {
            //try go down
            Tile* tmpTile = map.getTile(destPos.x, destPos.y, destPos.z);
            if (currentPos.z != 7 && (tmpTile == nullptr || (tmpTile->getGround() == nullptr && !tmpTile->hasFlag(TILESTATE_BLOCKSOLID)))) {
                tmpTile = map.getTile(destPos.x, destPos.y, destPos.z + 1);
                if (tmpTile && tmpTile->hasHeight(3)) {
                    flags |= FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;
                    destPos.z++;
                }
            }
        }
    }

    Tile* toTile = map.getTile(destPos);
    if (!toTile) {
        return RETURNVALUE_NOTPOSSIBLE;
    }
    return internalMoveCreature(*creature, *toTile, flags);
}
tile.cpp
C++:
bool Tile::hasHeight(uint32_t n) const
{
    uint32_t height = 0;

    if (ground) {
        if (ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }

        if (n == height) {
            return true;
        }
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }

            if (n == height) {
                return true;
            }
        }
    }
    return false;
}

int16_t Tile::getHeight() const
{
    int32_t height = 0;
    if(ground) {
        if(ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }
    }
 
    if(const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }
        }
    }
 
    return height;
}
tile.h
C++:
        bool hasHeight(uint32_t n) const;
        int16_t getHeight() const;

* (disclaimer : the code is old and could be better (specially used type of variables), but I want to quickly just show you one of the possible ways)

thank you very much for your explanation! I'm grateful I'll study a little about what you sent me!
 
Back
Top