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

Solved C++ Question about formula

Acubens

Old Penguin
Joined
May 6, 2008
Messages
1,261
Solutions
13
Reaction score
184
Location
Venezuela
I wanna get exp from low level players, but i can't make it work, i change the formula one, two, alot times and sometimes i dont get exp from high level players, this the normal function without changes.

Code:
uint64_t Player::getGainedExperience(Creature* attacker) const
{
    if (g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED && g_config.getNumber(ConfigManager::RATE_EXPERIENCE_PVP) > 0)
    {
        Player* attackerPlayer = attacker->getPlayer();

        if(attackerPlayer && attackerPlayer != this && skillLoss)
        {
                /*Formula
                a = attackers level * 0.9
                b = victims level
                c = victims experience

                y = (1 - (a / b)) * 0.05 * c
                */

                uint32_t a = (int32_t)std::floor(attackerPlayer->getLevel() * 0.9);
                uint32_t b = getLevel();
                uint64_t c = getExperience();


                uint64_t result = std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker) * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c));
                return result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE_PVP);
        }
    }

    return 0;
}

Distro used: OTHire 0.0.2

What changes is needed in the formula? i can't get work it >.< thanks in advance.

@Ezzz
 
Code:
uint64_t result = std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker) * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c));
return result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE_PVP);
to
Code:
return (c / 3 * getDamageRatio(attacker));
 
Back
Top