- Joined
- Oct 7, 2018
- Messages
- 137
- Solutions
- 4
- Reaction score
- 95
Hello!
Show health & mana in percentage, also configurable to show when reach client limit.
Read and change values below as desired.
config.lua in limits
src/configmanager.cpp - ConfigManager::load()
src/configmanager.h - enum bool_config_t
src/protocolgame.cpp - AddPlayerStats
CHANGE
TO
CHANGE
TO
Thank you.
Show health & mana in percentage, also configurable to show when reach client limit.
Read and change values below as desired.
config.lua in limits
LUA:
healthInPercentage = false
HealthPercentAfterClientLimit = false
manaInPercentage = false
manaPercentAfterClientLimit = false
src/configmanager.cpp - ConfigManager::load()
Code:
m_confBool[HEALTH_IN_PERCENTAGE] = getGlobalBool("healthInPercentage", false);
m_confBool[HEALTH_PERCENTAGE_AFTER_CLIENT_LIMIT] = getGlobalBool("HealthPercentAfterClientLimit", false);
m_confBool[MANA_IN_PERCENTAGE] = getGlobalBool("manaInPercentage", false);
m_confBool[MANA_PERCENTAGE_AFTER_CLIENT_LIMIT] = getGlobalBool("manaPercentAfterClientLimit", false);
src/configmanager.h - enum bool_config_t
Code:
HEALTH_IN_PERCENTAGE,
HEALTH_PERCENTAGE_AFTER_CLIENT_LIMIT,
MANA_IN_PERCENTAGE,
MANA_PERCENTAGE_AFTER_CLIENT_LIMIT,
src/protocolgame.cpp - AddPlayerStats
CHANGE
Code:
msg->put<uint16_t>(player->getHealth());
msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));
Code:
int32_t health = player->getHealth();
int32_t maxHealth = player->getPlayerInfo(PLAYERINFO_MAXHEALTH);
bool healthInPercent = g_config.getBool(ConfigManager::HEALTH_IN_PERCENTAGE);
bool healthAfterClientLimit = g_config.getBool(ConfigManager::HEALTH_PERCENTAGE_AFTER_CLIENT_LIMIT);
msg->put<uint16_t>(uint16_t(maxHealth > 0 && healthInPercent ? (maxHealth <= 65535 && healthAfterClientLimit ? health : (health * 100 / maxHealth)) : health));
msg->put<uint16_t>(uint16_t(maxHealth > 0 && healthInPercent ? (maxHealth <= 65535 && healthAfterClientLimit ? maxHealth : 100) : maxHealth));
CHANGE
Code:
msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA));
msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA));
Code:
int32_t mana = player->getPlayerInfo(PLAYERINFO_MANA);
int32_t maxMana = player->getPlayerInfo(PLAYERINFO_MAXMANA);
bool manaInPercent = g_config.getBool(ConfigManager::MANA_IN_PERCENTAGE);
bool manaAfterClientLimit = g_config.getBool(ConfigManager::MANA_PERCENTAGE_AFTER_CLIENT_LIMIT);
msg->put<uint16_t>(uint16_t(maxMana > 0 && manaInPercent ? (maxMana <= 65535 && manaAfterClientLimit ? mana : (mana * 100 / maxMana)) : mana));
msg->put<uint16_t>(uint16_t(maxMana > 0 && manaInPercent ? (maxMana <= 65535 && manaAfterClientLimit ? maxMana : 100) : maxMana));
Thank you.