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

Shadow_

Intermediate OT User
Joined
Jun 2, 2018
Messages
546
Best answers
19
Reaction score
139
Location
Cairo, Egypt
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 :


Credits to : @Crypton3

 
Last edited:

adriez

New Member
Joined
Aug 14, 2011
Messages
73
Best answers
0
Reaction score
0
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 :


Credits to : @Crypton3



Old pic didn't work
 

paola92

New Member
Joined
Jan 14, 2009
Messages
98
Best answers
1
Reaction score
4
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
 

TomBartezz

Member
Joined
May 29, 2016
Messages
159
Best answers
0
Reaction score
14
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 %?
 
Top