• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Health & mana percent

GOD Wille

Excellent OT User
Joined
Jan 11, 2010
Messages
2,826
Solutions
2
Reaction score
815
Location
Sweden
Is it possible to source edit so the mana bar is percent of mana and life bar is showing percent of life.
 
Yeah idk if it's because limits or what, but this works, but only works when the characters health is under a certain amount, which is pointless, point of using it is because players can't see their actual health.
Any idea how to make it take % of higher amounts?
 
Yeah idk if it's because limits or what, but this works, but only works when the characters health is under a certain amount, which is pointless, point of using it is because players can't see their actual health.
Any idea how to make it take % of higher amounts?
ey,did u succesfully fix the hp/mana percent? if u did msg me :) help me :P and i can send you some money
 
Code:
void ProtocolGame::AddPlayerStats(NetworkMessage_ptr msg)
{
    msg->AddByte(0xA0);
    msg->AddU16((uint16_t)std::ceil(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
    msg->AddU16((uint16_t)100);
    msg->AddU32(uint32_t(player->getFreeCapacity() * 100));
    uint64_t experience = player->getExperience();
    if(experience > 0x7FFFFFFF) // client debugs after 2,147,483,647 exp
        msg->AddU32(0x7FFFFFFF);
    else
        msg->AddU32(experience);
    msg->AddU16(player->getPlayerInfo(PLAYERINFO_LEVEL));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
    msg->AddU16((uint16_t)std::ceil(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA)));
    msg->AddU16((uint16_t)100);
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVEL));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_SOUL));
    msg->AddU16(player->getStaminaMinutes());
}
 
Code:
void ProtocolGame::AddPlayerStats(NetworkMessage_ptr msg)
{
    msg->AddByte(0xA0);
    msg->AddU16((uint16_t)std::ceil(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
    msg->AddU16((uint16_t)100);
    msg->AddU32(uint32_t(player->getFreeCapacity() * 100));
    uint64_t experience = player->getExperience();
    if(experience > 0x7FFFFFFF) // client debugs after 2,147,483,647 exp
        msg->AddU32(0x7FFFFFFF);
    else
        msg->AddU32(experience);
    msg->AddU16(player->getPlayerInfo(PLAYERINFO_LEVEL));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
    msg->AddU16((uint16_t)std::ceil(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA)));
    msg->AddU16((uint16_t)100);
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVEL));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
    msg->AddByte(player->getPlayerInfo(PLAYERINFO_SOUL));
    msg->AddU16(player->getStaminaMinutes());
}
But what if player's max mana is equal to 0? You are dividing by 0 then :-)
 
Back
Top