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

Experience stages

nanduzenho

Member
Joined
Mar 21, 2021
Messages
187
Solutions
1
Reaction score
15
GitHub
nanduzenho
Good morning, when I set the exp to 0.5x the player doesn't get exp, only when I set it to 1x, but I want to put stages below 1x
I'm using TFS 1.3
XML:
<?xml version="1.0" encoding="UTF-8"?>
<stages>
    <config enabled="1" />
    <stage minlevel="8" maxlevel="100" multiplier="50" />
    <stage minlevel="101" maxlevel="150" multiplier="40" />
    <stage minlevel="151" maxlevel="160" multiplier="30" />
    <stage minlevel="161" maxlevel="170" multiplier="20" />
    <stage minlevel="171" maxlevel="180" multiplier="10" />
    <stage minlevel="181" maxlevel="190" multiplier="1" />
    <stage minlevel="191" maxlevel="200" multiplier="0.7" />
    <stage minlevel="201" maxlevel="300" multiplier="0.6" />
    <stage minlevel="301" multiplier="0.5" />
</stages>
 
Dunno if it works but in game.cpp find function
Lua:
bool Game::loadExperienceStages()
And set every variable's value:
Code:
mul = 1.0f
defStageMultiplier = 1.0f;
to the lowest value you will use:
Code:
mul = 0.5f
defStageMultiplier = 0.5f;
so maybe you will be able to use values: 0.5, 0.6, 0.7 etc

I use 0.3.6, so notice that there might be different names, but the idea is to set the value from 1.0f to lower.
Then compile and check.
 
Dunno if it works but in game.cpp find function
Lua:
bool Game::loadExperienceStages()
And set every variable's value:
Code:
mul = 1.0f
defStageMultiplier = 1.0f;
to the lowest value you will use:
Code:
mul = 0.5f
defStageMultiplier = 0.5f;
so maybe you will be able to use values: 0.5, 0.6, 0.7 etc

I use 0.3.6, so notice that there might be different names, but the idea is to set the value from 1.0f to lower.
Then compile and check.
How do I change?

Lua:
bool Game::loadExperienceStages()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("data/XML/stages.xml");
    if (!result) {
        printXMLError("Error - Game::loadExperienceStages", "data/XML/stages.xml", result);
        return false;
    }

    for (auto stageNode : doc.child("stages").children()) {
        if (strcasecmp(stageNode.name(), "config") == 0) {
            stagesEnabled = stageNode.attribute("enabled").as_bool();
        } else {
            uint32_t minLevel, maxLevel, multiplier;

            pugi::xml_attribute minLevelAttribute = stageNode.attribute("minlevel");
            if (minLevelAttribute) {
                minLevel = pugi::cast<uint32_t>(minLevelAttribute.value());
            } else {
                minLevel = 1;
            }

            pugi::xml_attribute maxLevelAttribute = stageNode.attribute("maxlevel");
            if (maxLevelAttribute) {
                maxLevel = pugi::cast<uint32_t>(maxLevelAttribute.value());
            } else {
                maxLevel = 0;
                lastStageLevel = minLevel;
                useLastStageLevel = true;
            }

            pugi::xml_attribute multiplierAttribute = stageNode.attribute("multiplier");
            if (multiplierAttribute) {
                multiplier = pugi::cast<uint32_t>(multiplierAttribute.value());
            } else {
                multiplier = 1;
            }

            if (useLastStageLevel) {
                stages[lastStageLevel] = multiplier;
            } else {
                for (uint32_t i = minLevel; i <= maxLevel; ++i) {
                    stages[i] = multiplier;
                }
            }
        }
    }
    return true;
}
 
As I expected its different. Bro Loney gave us the hint.
uint32_t is type of integer, we need float numbers.
Change the line(34 in your post):
Lua:
multiplier = pugi::cast<uint32_t>(multiplierAttribute.value());
to:
Code:
multiplier = pugi::cast<float>(multiplierAttribute.value());
And probably this:
then in data/events/scripts/player.lua

look for that function

function Player: onGainExperience(source, exp, rawExp)
...
exp = exp * 0.1 <-- add this line at the end!!!!
return exp
end
Dunno if it enough
 
Last edited:
As I expected its different. Bro Loney gave us the hint.
uint32_t is type of integer, we need float numbers.
Change the line(34 in your post):
Lua:
multiplier = pugi::cast<uint32_t>(multiplierAttribute.value());
to:
Code:
multiplier = pugi::cast<float>(multiplierAttribute.value());
And probably this:

Dunno if it enough
didn't work = /
 
Back
Top