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

C++ Experience boost show in skill window

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
Hello folks, I'm trying change the Xp Gain Rate in the skills window when the player buy the experience boost in the store ...
so, the offer in the store will give a storage to the player and it will be handled in creatureEvents in onGainExperience
then I want to update the values and handle with that as the Tibia Global
1- the boost will decay only if you are hunting
2- update the value exp gain rate when the time is over
3- update the value when the player buy the exp boost
I find in protocolgame.cpp
Code:
msg.add<uint16_t>(100); // base xp gain rate
msg.add<uint16_t>(0); // xp voucher
msg.add<uint16_t>(0); // low level bonus
msg.add<uint16_t>(0); // xp boost
msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)
How I can handle with that?
 
Solution
yes ...
then I remove the lines:
  1. msg.add<uint16_t>(100); // base xp gain rate
  2. msg.add<uint16_t>(0); // xp voucher
  3. msg.add<uint16_t>(0); // low level bonus
  4. msg.add<uint16_t>(0); // xp boost
  5. msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)
and create a code that check the player level and the stamina, so, if the player is level 50 or less he will gain 50% of rate and if the player have more than 40 hours of stamina he will gain more 50% the final rate will be 225%
he has 100% then win 50% more for level 50
the gain rate will be 150%
then the player win more 50% because of the stamina
50% of 150% is 75%
so the final will be 225% gain rate
here works fine my code :)

C++:
if (player->getLevel() <= 50) {...
still 100% the gain rate, lol.. it fuc* me, I write a code that update the rate at lvl 50, and with the stamina e-e
 
yes ...
then I remove the lines:
  1. msg.add<uint16_t>(100); // base xp gain rate
  2. msg.add<uint16_t>(0); // xp voucher
  3. msg.add<uint16_t>(0); // low level bonus
  4. msg.add<uint16_t>(0); // xp boost
  5. msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)
and create a code that check the player level and the stamina, so, if the player is level 50 or less he will gain 50% of rate and if the player have more than 40 hours of stamina he will gain more 50% the final rate will be 225%
he has 100% then win 50% more for level 50
the gain rate will be 150%
then the player win more 50% because of the stamina
50% of 150% is 75%
so the final will be 225% gain rate
here works fine my code :)

C++:
if (player->getLevel() <= 50) {
        msg.add<uint16_t>(50); // low level bonus
    }
    else {
        msg.add<uint16_t>(0); // low level bonus
    }
 
Last edited by a moderator:
Solution
srly? you open a thread asking for something.
someone(myself) give you a link where is the solution.
you comment nothing only saying "here work fine"
and you marked yourself as best answer?
where is the code to add the bonus to low levels?
if the link that i posted help you, why you no post something useful to the community?
for that when the people here on otland need to find someting only find empty threads. with comments like :

"here works fine my code :)"
 
well, the link don't work, so I try by my self and get it working, of course editing the event onGainExperience
if you don't know how check level and stamina you have serious problems
Code:
if (player->getLevel() <= 50) {
        msg.add<uint16_t>(50); // low level bonus
    }
    else {
        msg.add<uint16_t>(0); // low level bonus
    }
and of course that I'll mark my own answer as the best because I have done it alone.

edit: the link don't work for me, it don't help me with anything
 
C++:
    float valueExp = getExpBaseRate(0, SKILL_EXPERIENCE_GAIN_STAMINA, SKILL_EXPERIENCE_GAIN_VOUNCHER, SKILL_EXPERIENCE_GAIN_LOWLEVEL, SKILL_EXPERIENCE_GAIN_BASERATE);
    msg.add<uint16_t>(std::floor(valueExp));
    msg.add<uint16_t>(0); // disable for formula valueExp
    msg.add<uint16_t>(0); // disable for formula valueExp
    msg.add<uint16_t>(0); // disable for formula valueExp
    msg.add<uint16_t>(100);
 
Stamina bonus.
Code:
if (player->getStaminaMinutes() > 2400) {
        msg.add<uint16_t>(150);
    } else {
        msg.add<uint16_t>(100);
    }
 
I changed my source code and my problem was solved.
Code:
uint16_t staminaXpBoost = 100;
change to:
Code:
uint16_t staminaXpBoost = 150;
 
Last edited:
I changed my source code and my problem was solved.
Code:
uint16_t staminaXpBoost = 100;
change to:
Code:
uint16_t staminaXpBoost = 150;
Ofc you can do it like this, but its redundant to have function to set stamina xp boost when it is always 150 and 100 without happy hour :p

Btw. this way it will not count the normal stamina, when stamina is < 40. (1x not 1,5x)
It will always be 150 in your skill window.
 
@Theamax yes you are right :p I left others lines, only changed this once int just like this
Code:
        uint16_t baseXpGain = 100;
        uint16_t voucherXpBoost = 0;
        uint16_t grindingXpBoost = 0;
        uint16_t storeXpBoost = 0;
        uint16_t staminaXpBoost = 150;
        int16_t lastDepotId = -1;
Tested on malucoo's datapack (otxserver) and works normal stamina and happy hour :) but I had to recompile to make it available
 
Back
Top