Feature Health And Mana Percent [TFS 1.2]

Shadow_

Active Member
Joined
Jun 2, 2018
Messages
348
Best answers
9
Reaction score
72
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

Well-Known 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

Excellent OT User
Joined
Jan 14, 2009
Messages
69
Best answers
1
Reaction score
3
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
 
Top