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

Feature Health And Mana Percent [TFS 1.2]

S

Shadow_

Guest
Hello Otland members,
I have just finished it so i found no problem to share it with you all because the old one is not working on new tfs versions ( i used it to make it working on tfs 1.2 )
anyway lets start.

First Step (1/3):Open protocolgame.cpp and find this (Should be close to line 2885) :
Code:
    msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));

change it with this (1.2 Users):
Code:
    if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }
1.3 Users :
C++:
    if (player->getMaxHealth() > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getHealth() * 100 / player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }
Second Step (2/3) : find this :
Code:
    msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));

change it with this(1.2 Users) :
Code:
    if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }
1.3 :
C++:
    if (player->getMaxMana() > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getMana() * 100 / player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }
Third Step (3/3) : Compile your TFS and have fun with the new future!
How to compile : otland/forgottenserver
More Details about compiling : Compiling TFS 1.0/1.1 latest source. 64 and 32 bits. Pics and lots of explanation.

Start tibia to find out that your mana and health are now like this :
gngxno


Credits to : @Crypton3

2yxhpxi.png
 
Last edited by a moderator:
Hello Otland members,
I have just finished it so i found no problem to share it with you all because the old one is not working on new tfs versions ( i used it to make it working on tfs 1.2 )
anyway lets start.

First Step (1/3):Open protocolgame.cpp and find this (Should be close to line 2885) :
Code:
    msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));

change it with this :
Code:
    if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }

Second Step (2/3) : find this :
Code:
    msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));

change it with this :
Code:
    if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }

Third Step (3/3) : Compile your TFS and have fun with the new future!
How to compile : otland/forgottenserver
More Details about compiling : Compiling TFS 1.0/1.1 latest source. 64 and 32 bits. Pics and lots of explanation.

Start tibia to find out that your mana and health are now like this :
gngxno


Credits to : @Crypton3

2yxhpxi.png


Old pic didn't work
 
Is it possible to add character "%" after 100 as text? Just for information that HP and MANA is displayed in percents. Please see screen below.

Capture.JPG
 
Will this work for tfs 1.3 without compiling if I compiled already prior to reading this thread? And Is it also possible to make the monster show damage %?
 
Back
Top