Experience Problem - Roll Over

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Experience Problem - Roll Over

Post by Kieran » Fri Apr 28, 2017 10:38 pm

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.

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Re: Experience Problem - Roll Over

Post by Necrolis » Fri Apr 28, 2017 10:48 pm

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.
Unless you intend on recoding how the game handles experience, you can't.

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
Image
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

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Fri Apr 28, 2017 11:10 pm

Necrolis" wrote:
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.
Unless you intend on recoding how the game handles experience, you can't.

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
Thanks Nec,

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?

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Re: Experience Problem - Roll Over

Post by Necrolis » Sat Apr 29, 2017 3:07 am

Yes, cause you can overflow the current experience stat and have it wrap back around to zero.
Image
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

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Sun Apr 30, 2017 5:39 pm

Necrolis" wrote:Yes, cause you can overflow the current experience stat and have it wrap back around to zero.
Oh how I hate blizzard :mrgreen:

Looks like these experience pots have to be removed!

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Sun Apr 30, 2017 7:19 pm

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.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Sun Apr 30, 2017 9:43 pm

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.
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.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Sun Apr 30, 2017 11:24 pm

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.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Mon May 01, 2017 7:39 pm

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.
Oh dam thanks bro that would work!

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 :roll:

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?

User avatar
SpiKe.
Forum Tech Support
Champion of the Light
Posts: 280
Joined: Thu Jul 28, 2011 5:25 pm
Location: Germany
Germany

Re: Experience Problem - Roll Over

Post by SpiKe. » Mon May 01, 2017 8:11 pm

Tried to add this via a pot without any calc besides a blank number and i can also have 2.1bil max.

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Mon May 01, 2017 8:33 pm

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.
Just so I know I'm making 100% sense out of it:

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.

User avatar
SpiKe.
Forum Tech Support
Champion of the Light
Posts: 280
Joined: Thu Jul 28, 2011 5:25 pm
Location: Germany
Germany

Re: Experience Problem - Roll Over

Post by SpiKe. » Mon May 01, 2017 8:44 pm

Ok tried this and it working.

pspell: 4
stat1: experience
calc1: (stat('experience'.base) < 3600000000) ? (50000000 : 0)

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Mon May 01, 2017 9:47 pm

J'P" wrote:Ok tried this and it working.

pspell: 4
stat1: experience
calc1: (stat('experience'.base) < 3600000000) ? (50000000 : 0)
Nothing is different apart from spaces?

Likewise it doesn't work for me.

I'm using 1.13c if it matters which I doubt.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Mon May 01, 2017 9:58 pm

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.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Mon May 01, 2017 10:03 pm

Black_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.
I tried the bin files that didn't work either, I'll try that shortly and report back. Some strange going ons :cry:

User avatar
SpiKe.
Forum Tech Support
Champion of the Light
Posts: 280
Joined: Thu Jul 28, 2011 5:25 pm
Location: Germany
Germany

Re: Experience Problem - Roll Over

Post by SpiKe. » Mon May 01, 2017 10:05 pm

Can u may post ur ISC line for experience to see if there is a different?

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Mon May 01, 2017 10:16 pm

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.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Mon May 01, 2017 11:57 pm

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
And there's why....
Haven't had time to explore if this is changeable.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Tue May 02, 2017 2:41 pm

Black_Eternity" wrote:
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
And there's why....
Haven't had time to explore if this is changeable.
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.

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

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Tue May 02, 2017 2:56 pm

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.
Last edited by HarvestWombs on Tue May 02, 2017 3:00 pm, edited 1 time in total.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Tue May 02, 2017 3:00 pm

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.
I see.

It look's like I am back to square one! Although I certainly do thank you for your help thus far.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Experience Problem - Roll Over

Post by HarvestWombs » Tue May 02, 2017 3:03 pm

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.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
SpiKe.
Forum Tech Support
Champion of the Light
Posts: 280
Joined: Thu Jul 28, 2011 5:25 pm
Location: Germany
Germany

Re: Experience Problem - Roll Over

Post by SpiKe. » Tue May 02, 2017 3:34 pm

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.

User avatar
Kieran
Senior Moderator
Angel
Posts: 617
Joined: Mon Oct 22, 2007 9:46 am
Location: England
Great Britain

Hand-picked

Re: Experience Problem - Roll Over

Post by Kieran » Tue May 02, 2017 3:40 pm

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.
If you have a clean version up with 1.13 feel free to try on classic. I tried on expansion and nothing.

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

User avatar
SpiKe.
Forum Tech Support
Champion of the Light
Posts: 280
Joined: Thu Jul 28, 2011 5:25 pm
Location: Germany
Germany

Re: Experience Problem - Roll Over

Post by SpiKe. » Tue May 02, 2017 4:48 pm

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.

Return to “General Mod Making”