uint64_t Player::getGainedExperience(Creature* attacker) const
{
if (g_config.getBoolean(ConfigManager::EXPERIENCE_FROM_PLAYERS)) {
Player* attackerPlayer = attacker->getPlayer();
if (attackerPlayer && attackerPlayer != this && skillLoss && std::abs(static_cast<int32_t>(attackerPlayer->getLevel() - level)) <= g_config.getNumber(ConfigManager::EXP_FROM_PLAYERS_LEVEL_RANGE)) {
return std::max<uint64_t>(0, std::floor(getLostExperience() * getDamageRatio(attacker) * g_config.getNumber(ConfigManager::EXP_ENFO_PLAYER)));
}
}
return 0;
}
return exp
return exp / 100
Describe the solution you have found so others can do itthanks for the help. I had to change the code a little, but it works fine
floating[EXP_ENFO_PLAYER] = getGlobalFloat(L, "expenfo", 0.75);
int32_t ConfigManager::getNumber(integer_config_t _what) const
{
if (_what >= LAST_INTEGER_CONFIG) {
std::cout << "[Warning - ConfigManager::getNumber] Accessing invalid index: " << _what << std::endl;
return 0;
}
return integer[_what];
}
float ConfigManager::getFloat(floating_config_t _what) const
{
if (_what >= LAST_FLOATING_CONFIG) {
std::cout << "[Warning - ConfigManager::getFloat] Accessing invalid index: " << _what << std::endl;
return 0.0f;
}
return floating[_what];
}
int32_t ConfigManager::getGlobalNumber(lua_State* L, const char* identifier, const int32_t _default)
{
lua_getglobal(L, identifier);
if (!lua_isnumber(L, -1)) {
return _default;
}
int32_t val = lua_tonumber(L, -1);
lua_pop(L, 1);
return val;
}
float ConfigManager::getGlobalFloat(lua_State* L, const char* identifier, const float defaultValue)
{
lua_getglobal(L, identifier);
if (!lua_isnumber(L, -1)) {
lua_pop(L, 1);
return defaultValue;
}
float val = lua_tonumber(L, -1);
lua_pop(L, 1);
return val;
}
LAST_INTEGER_CONFIG /* this must be the last one */
};
enum floating_config_t {
EXP_ENFO_PLAYER,
LAST_FLOATING_CONFIG
};
bool getBoolean(boolean_config_t _what) const;
float getFloat(floating_config_t _what) const;
static int32_t getGlobalNumber(lua_State* L, const char* identifier, const int32_t _default = 0);
float getGlobalFloat(lua_State* L, const char* identifier, const float defaultValue = 0.0f);
bool boolean[LAST_BOOLEAN_CONFIG];
float floating[LAST_FLOATING_CONFIG];