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

monsters gives wrong exp

elkingahmed

New Member
Joined
May 31, 2012
Messages
116
Reaction score
2
my ots stage rate is 120,000 when i kill a monster with exp (40,000,000,000) i get very low exp anyone know why ? are there any maximum of the Exp received ?
 
i'm not aware of that version, do you have the source files or the link to where you got the engine and/or it's sources?
i'm assuming the problem is that the monster exp is still uint32_t which would cause an integer overflow if your numbers are that big, meaning the value wraps around to 0 once the value gets high enough then starts counting again which would result in your experience being lower than it should be
but i can't check if that's the case if i don't have the sources for the engine you're using
 
so what should i change to ?

the value from experience="xxxx" in your monster xml file is being read into an integer (maximum value is 2,147,483,647, you have 40,000,000,000)
because of that, your value will wrap around back to -2,147,483,648 multiple times and keep counting from there until it counts out 40,000,000,000
by the end the final value will be 1,345,294,336
your final experience value after stages * that value will be 161,435,320,320,000 which is significantly less than what you would expect (4,800,000,000,000,000), note that this doesn't overflow because the value type the calculation is stored in is uint64_t which holds up to about 18 quintillion
what you need to do is find this in monsters.cpp
C++:
if(readXMLInteger(root, "experience", intValue)){
mType->experience = intValue;
}
and replace it with this
C++:
uint64_t ullValue = 0;
if(readXMLInteger64(root, "experience", ullValue)) {
mType->experience = ullValue;
}
 
the value from experience="xxxx" in your monster xml file is being read into an integer (maximum value is 2,147,483,647, you have 40,000,000,000)
because of that, your value will wrap around back to -2,147,483,648 multiple times and keep counting from there until it counts out 40,000,000,000
by the end the final value will be 1,345,294,336
your final experience value after stages * that value will be 161,435,320,320,000 which is significantly less than what you would expect (4,800,000,000,000,000), note that this doesn't overflow because the value type the calculation is stored in is uint64_t which holds up to about 18 quintillion
what you need to do is find this in monsters.cpp
C++:
if(readXMLInteger(root, "experience", intValue)){
mType->experience = intValue;
}
and replace it with this
C++:
uint64_t ullValue = 0;
if(readXMLInteger64(root, "experience", ullValue)) {
mType->experience = ullValue;
}
tried and nothing changed
 
tried and nothing changed
you recompiled and replaced the exe?
if it doesn't change then debug it yourself by using print to check if the values are correct
for example add
C++:
std::cout << mType->name << " experience: " << ullValue << '\n';
above
C++:
mType->experience = ullValue;
if it's correct, look in player.cpp at Player::addExperience and check print out that value
 
you recompiled and replaced the exe?
if it doesn't change then debug it yourself by using print to check if the values are correct
for example add
C++:
std::cout << mType->name << " experience: " << ullValue << '\n';
above
C++:
mType->experience = ullValue;
if it's correct, look in player.cpp at Player::addExperience and check print out that value
worked
btw can you help me setting my max level to 777,777 ?
i've read gesior tutorial but looks like there are something not found in my tfs
this is my level formula
Code:
 static uint64_t getExpForLevel(int32_t level)
       {
           return (uint64_t)std::ceil((double)(50 * level * level * level)/3 - (100 * level * level) + ((850 * level) / 3) - 200);
       }
 
create a new thread for that, although i specifically can't help with that
i remember i also tried to use that formula and never had success
 
well thanks
i've faced another big from the monsters :/
once i kill 2 monsters the tfs crash
if you're using visual studio you can debug the exe with that once it gives you the option on the window where it says "theforgottenserver.exe has stopped working"
it'll point you to the exact line where it crashed and give more details
if you can get to that window, screenshot it and post it here
 
Back
Top