Skip to content

Feature: Support floating points for more precise XP buffs #9

Description

@bhavinamin

Describe your feature request or suggestion in detail

Currently this module only supports integers for the xp multipliers. Putting in a floating point number such as 1.25 for a 25% XP increase will return invalid in the server console and will revert to the conf defaults. By supporting floating point, we can fine-tune XP rates more precisely.

I fixed this in my own local install with the code block below and tested it successfully, was just too lazy to fork and pull request.

Describe a possible solution to your feature or suggestion in detail

Basically we do the math in float then cast back to int.

void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
    {
        float rate = 1.00;
        if (sConfigMgr->GetOption<bool>("Dynamic.XP.Rate", true))
        {
            if (player->GetLevel() <= 9)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.1-9", 1.00);
            else if (player->GetLevel() <= 19)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.10-19", 1.00);
            else if (player->GetLevel() <= 29)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.20-29", 1.00);
            else if (player->GetLevel() <= 39)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.30-39", 1.00);
            else if (player->GetLevel() <= 49)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.40-49", 1.00);
            else if (player->GetLevel() <= 59)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.50-59", 1.00);
            else if (player->GetLevel() <= 69)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.60-69", 1.00);
            else if (player->GetLevel() <= 79)
                rate = sConfigMgr->GetOption<float>("Dynamic.XP.Rate.70-79", 1.00);
        }

        amount = uint32(std::round(amount * rate));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions