Experience Problem - Roll Over
Moderator: Nizari
Experience Problem - Roll Over
Hey Guys,
In my mod its possible to find experience potions which simply add experience to your character.
If you drink enough of these potions you will level, providing your experience is over the cap for the next level.
Example:
Level 1
0 Experience
500 to Next Level
Potion of Xp
Adds 500 Experience
Level 1
500 Experience
500 to Next Level
Kill a monster - Bing level 2.
The problem has arisen where players can drink more and more experience potions after they hit level 99. Initially this does nothing but once you go over the EXP Cap of 4,294,967,295 you now roll over on to a new experience table. Guess what this means; you can now regain more stats and skills. This means players are in effect able to have as many stats/skills as they please.
Does anybody have any methods that could rectify this problem?
My initial thoughts are changing the hard exp cap of 4,294,967,295 to something absolutely stupid/unreachable; meaning it would be almost impossible to achieve this.
In my mod its possible to find experience potions which simply add experience to your character.
If you drink enough of these potions you will level, providing your experience is over the cap for the next level.
Example:
Level 1
0 Experience
500 to Next Level
Potion of Xp
Adds 500 Experience
Level 1
500 Experience
500 to Next Level
Kill a monster - Bing level 2.
The problem has arisen where players can drink more and more experience potions after they hit level 99. Initially this does nothing but once you go over the EXP Cap of 4,294,967,295 you now roll over on to a new experience table. Guess what this means; you can now regain more stats and skills. This means players are in effect able to have as many stats/skills as they please.
Does anybody have any methods that could rectify this problem?
My initial thoughts are changing the hard exp cap of 4,294,967,295 to something absolutely stupid/unreachable; meaning it would be almost impossible to achieve this.
Re: Experience Problem - Roll Over
Unless you intend on recoding how the game handles experience, you can't.Kieran" wrote: My initial thoughts are changing the hard exp cap of 4,294,967,295 to something absolutely stupid/unreachable; meaning it would be almost impossible to achieve this.
You can use a formula with a conditional and make the potion give 0 exp if they are at the level cap, however you can still overflow if your potion can give more experience than the difference between the cap and their current exp. Solving this isn't too hard either, just add a bit more math to the conditional (in pseduo formula):
Code: Select all
(max_lvl_exp - current_exp < exp_add) ? max(max_lvl_exp - current_exp - 1, 0) : exp_add
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
Re: Experience Problem - Roll Over
Thanks Nec,Necrolis" wrote:Unless you intend on recoding how the game handles experience, you can't.Kieran" wrote: My initial thoughts are changing the hard exp cap of 4,294,967,295 to something absolutely stupid/unreachable; meaning it would be almost impossible to achieve this.
You can use a formula with a conditional and make the potion give 0 exp if they are at the level cap, however you can still overflow if your potion can give more experience than the difference between the cap and their current exp. Solving this isn't too hard either, just add a bit more math to the conditional (in pseduo formula):Code: Select all
(max_lvl_exp - current_exp < exp_add) ? max(max_lvl_exp - current_exp - 1, 0) : exp_add
I think my original "solution" was somewhat of a mash keys and hope solution rather than anything thought out and logical.
In terms of overflowing the difference;
The experience potion gives 50 million. If somebody was to theoretically drink a large number of these at say level 98 (not the max level in the formula) prior to killing a monster and securing the level to 99; could this still result in the overflow?
Re: Experience Problem - Roll Over
Yes, cause you can overflow the current experience stat and have it wrap back around to zero.
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
Re: Experience Problem - Roll Over
Oh how I hate blizzardNecrolis" wrote:Yes, cause you can overflow the current experience stat and have it wrap back around to zero.
Looks like these experience pots have to be removed!
Re: Experience Problem - Roll Over
All you are doing is adding 500xp per use using simple text editing? This can be easily solved with a conditional formula like Necrolis stated above.
stat('level'.base)<99?500:0
Just place this in the calc column and boom no more Xp potions at level 99.
It reads:
If stat 'level' is less than 99, grant 500, else 0.
stat('level'.base)<99?500:0
Just place this in the calc column and boom no more Xp potions at level 99.
It reads:
If stat 'level' is less than 99, grant 500, else 0.
Re: Experience Problem - Roll Over
Thanks mate it's more the problem that at any level below that a player could still drink a ton of them pre level 99 and loop over in to the next xp table.Black_Eternity" wrote:All you are doing is adding 500xp per use using simple text editing? This can be easily solved with a conditional formula like Necrolis stated above.
stat('level'.base)<99?500:0
Just place this in the calc column and boom no more Xp potions at level 99.
It reads:
If stat 'level' is less than 99, grant 500, else 0.
Re: Experience Problem - Roll Over
Then add stat('experience'.base)<###? To the equation.
### being the max Xp
I would actually put less than max so you can't use an Xp pot to get there.
### being the max Xp
I would actually put less than max so you can't use an Xp pot to get there.
Re: Experience Problem - Roll Over
Oh dam thanks bro that would work!Black_Eternity" wrote:Then add stat('experience'.base)<###? To the equation.
### being the max Xp
I would actually put less than max so you can't use an Xp pot to get there.
Edit:
Not sure what I'm doing wrong but the formula just adds 1 no matter my level/experience
Stat1
experience
Calc1
stat('experience'.base)<3600000000?50000000:0
This is for an experience potion to add 50mil worth of xp. I have tried with lower numbers and nothing seems to change. Have I missed something obvious? I probably shouldn't be doing this at almost 2am my time
pSpell I'm using is 4
I tried running from 1-10 just to see if the pSpell mattters. Most make them unusable however 3/4 add 1 experience no matter how I work this calculation
Edit\2
Resolved.
(stat('experience'.base)<2000)?(500:0)
Missed a few brackets. Lowered the numbers for quicker tests!
Edit\3
Another problem unfortunately.
It appears that the max number I can put in for the experience number is 2.1billion (2,147,483,647) rather than 3.6billion (just over level 99).
From scanning around the keep this appears to be the max number for stats although from other peoples experience this seems to exclude experience as it can go as high as 4,294,967,295. (twice the value - 32 bits?)
I wonder if its the actual stat command at the start of the formula that is causing the limitation? (thinking aloud)
Anybody have any problem with this in the past?
Re: Experience Problem - Roll Over
Tried to add this via a pot without any calc besides a blank number and i can also have 2.1bil max.
Re: Experience Problem - Roll Over
Just so I know I'm making 100% sense out of it:J'P" wrote:Tried to add this via a pot without any calc besides a blank number and i can also have 2.1bil max.
My calc field is:
(stat('experience'.base)<3,600,000,000)?(50,000,000:0)
Which if I am correct should read as:
If current experience is less than 3,600,000,000 add 50,000,000 else add 0
================================================
Note I am not adding more than 2.1B experience; simply 50M
================================================
If I work it based on:
(stat('experience'.base)<2,147,483,647)?(50,000,000:0) then it works correctly.
If I step up to:
(stat('experience'.base<2,147,483,648)?(50,000,000:0) then it does not work.
=================================================
This is extremely confusing as the most experience you can hold is 4,294,967,294.
For some reason the calc field does not recognise any number above 2,147,483,647.
Re: Experience Problem - Roll Over
Ok tried this and it working.
pspell: 4
stat1: experience
calc1: (stat('experience'.base) < 3600000000) ? (50000000 : 0)
pspell: 4
stat1: experience
calc1: (stat('experience'.base) < 3600000000) ? (50000000 : 0)
Re: Experience Problem - Roll Over
Nothing is different apart from spaces?J'P" wrote:Ok tried this and it working.
pspell: 4
stat1: experience
calc1: (stat('experience'.base) < 3600000000) ? (50000000 : 0)
Likewise it doesn't work for me.
I'm using 1.13c if it matters which I doubt.
Re: Experience Problem - Roll Over
Try deleting your bin files. Also try moving the parenthesis a bit.
((stat('experience'.base)<3600000000)?50000000:0)
Spaces don't matter, the game doesn't acknowledge them in calc fields.
((stat('experience'.base)<3600000000)?50000000:0)
Spaces don't matter, the game doesn't acknowledge them in calc fields.
Re: Experience Problem - Roll Over
I tried the bin files that didn't work either, I'll try that shortly and report back. Some strange going onsBlack_Eternity" wrote:Try deleting your bin files. Also try moving the parenthesis a bit.
((stat('experience'.base)<3600000000)?50000000:0)
Spaces don't matter, the game doesn't acknowledge them in calc fields.
Re: Experience Problem - Roll Over
Can u may post ur ISC line for experience to see if there is a different?
Re: Experience Problem - Roll Over
I thought the same from ISC so I just replaced it with a clean version as I haven't made any changes in this area.
I've just come away from PC but the number 32 is in the important parts I remember that much! I'll post the full line shortly.
I've just come away from PC but the number 32 is in the important parts I remember that much! I'll post the full line shortly.
Re: Experience Problem - Roll Over
And there's why....Integer overflows. Game stores every temporary result in a signed dword (-2147483648…2147483647). And if the number doesn’t lie in these bounds, we get a rollover (e.g. “2147483647/1000000000” equals 2, but “2147483648/1000000000” equals -2). After calculating the final result game engine tries to store it in the appropriate variable. But the problem is that its size may be less than dword, so we’re likely to get a rollover then. Consult ISC for determining exact stat size or simply make some experiments
Haven't had time to explore if this is changeable.
Re: Experience Problem - Roll Over
This is as I posted above mate; however experience is set to using 32 bits rather than 16 bits hence how it can hold a value of 4.2B.Black_Eternity" wrote:And there's why....Integer overflows. Game stores every temporary result in a signed dword (-2147483648…2147483647). And if the number doesn’t lie in these bounds, we get a rollover (e.g. “2147483647/1000000000” equals 2, but “2147483648/1000000000” equals -2). After calculating the final result game engine tries to store it in the appropriate variable. But the problem is that its size may be less than dword, so we’re likely to get a rollover then. Consult ISC for determining exact stat size or simply make some experiments
Haven't had time to explore if this is changeable.
This is my lines from ItemStatCosts
Stat: Experience
ID: 13
SendBits: 32
Saved: 1
CSvSigned: 0
CSvBits: 32
Divide: 1024
Eol: 0
Rest are blank
Re: Experience Problem - Roll Over
Let me reiterate...
Yes experience can hold 32 bits, that's fine. The game works as intended. ISC is for storing stats to the savefile and for stat lists.
The problem here is, when doing math in the game, the "temporary" result can not exceed 2147483647. Like shown and tested.
Yes experience can hold 32 bits, that's fine. The game works as intended. ISC is for storing stats to the savefile and for stat lists.
The problem here is, when doing math in the game, the "temporary" result can not exceed 2147483647. Like shown and tested.
Last edited by HarvestWombs on Tue May 02, 2017 3:00 pm, edited 1 time in total.
Re: Experience Problem - Roll Over
I see.Black_Eternity" wrote:Let me reiterate...
Yes experience can hold 32 bits, that's fine. The game works as intended.
The problem here is, when doing math in the game, the "temporary" result can not exceed 2147483647. Like shown and tested.
It look's like I am back to square one! Although I certainly do thank you for your help thus far.
Re: Experience Problem - Roll Over
My only other solution to try and make this work is,
Taking the single use potion concept, and increase the limit to what ever need be, making them extremely rare, or costing large amounts of gold. So the player can never get enough to multi stack.
Taking the single use potion concept, and increase the limit to what ever need be, making them extremely rare, or costing large amounts of gold. So the player can never get enough to multi stack.
Re: Experience Problem - Roll Over
Im wondering because it worked for me as stated above. Maybe it is a problem because you are modding for classic? I've also tried this in a clean 1.13 mod and it also worked, so i can't say whats the problem here.
Re: Experience Problem - Roll Over
If you have a clean version up with 1.13 feel free to try on classic. I tried on expansion and nothing.J'P" wrote:Im wondering because it worked for me as stated above. Maybe it is a problem because you are modding for classic? I've also tried this in a clean 1.13 mod and it also worked, so i can't say whats the problem here.
What is interesting is that at level 95 and above these work fine as my current experience is above 2.5billion!
Worst case scenario is that I limit them to be used above level 95. Somewhat goes against my concept but I guess its better than nothing.
Appreciate the help guys
Re: Experience Problem - Roll Over
Funny, had a character in the directory wich was 95 lol, thats why it worked, but i may have a idea for you. You can do it softcoded.
Set Level 95 to 2147483648 experience.
Create 2 Pots.
1st Pot have a limit of 2147483647 and is available at level 1.
2nd Pot have a limit of 3600000000 (or whatever) and is available at level 95.
Now you could do 2 things.
1.) Let pot1 drop everywhere and pot2 only in the end areas (maybe with a bigger amount of exp gain?) to make them worth.
2.) Let only pot1 drop and put some "hint" of it, that you have to cube it at level 95 e.g. with a healpot, so pot1 + hpot = pot2. You can also restrict this recipe to only work at level 95 or higher tho.
For myself, i would the 2nd version or limit this pot to levels < 95.
Set Level 95 to 2147483648 experience.
Create 2 Pots.
1st Pot have a limit of 2147483647 and is available at level 1.
2nd Pot have a limit of 3600000000 (or whatever) and is available at level 95.
Now you could do 2 things.
1.) Let pot1 drop everywhere and pot2 only in the end areas (maybe with a bigger amount of exp gain?) to make them worth.
2.) Let only pot1 drop and put some "hint" of it, that you have to cube it at level 95 e.g. with a healpot, so pot1 + hpot = pot2. You can also restrict this recipe to only work at level 95 or higher tho.
For myself, i would the 2nd version or limit this pot to levels < 95.