A Softcoded Approach to Expanding ItemStatCost.txt

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

Post Reply
User avatar
Cypress
Posts: 31
Joined: Fri Dec 01, 2017 2:08 am

A Softcoded Approach to Expanding ItemStatCost.txt

Post by Cypress » Mon Jul 08, 2019 2:35 pm

I've been working on my mod and came to realize that I would need upwards of thousands of new stats to create a functional and expansive system by which NPC conversations and events can be controlled by player stats. To circumvent the inherent limits of itemstatcost.txt, I had to come up with a method to create multipurpose stats, or sub-stats. This method will work with any dummy calc stats (i.e. stats that are functional only in that they are read in calculations, such as a stat that would give additional minions to a specific summon or would be read by a skill and increase damage).

The methodology behind my approach is to create formulae that filter out specific parts or digits of the stat, thereby turning a single stat functionally into multiple sub-stats.

As an example, let us suppose I wanted to create sub-stats that control the number of valkyries, decoys, necroskeletons, wolves, bears, vines and spirits. Instead of creating 7 stats to control each, I will use one 32-bit stat, which for the purposes of this method must be within the values of 1000000000 to 3999999999, or the entire formula will potentially under or overroll into oblivion. Given these limits, we can turn each digit into its own sub-stat, or multiple digits into a single sub-stat, or whatever else you can manage to create a filter for (I am using base 10 filters mainly because it is easier to understand and apply).

So for the ones-digit, I will assign valkyries, to the tens-digit decoys, to the hundreds-digit necroskeletons, to the thousands-digit wolves, to the ten-thousands-digit bears, to the hundred-thousands-digit vines, and to the millions-digit spirits. This means that the limit of each of these sub-stats will be 10 values (0 to 9) except for the billionth-digit (which has limits of 1 to 3). So in the summon limits column of skills.txt, all I'd need to do is filter out the digit I desire. This is entirely possible thanks to the way the calculations truncate numbers after each step. These are the formulae I derived for reading each digit, with X being the value of the stat that the sub-stats come from:

Digit 10=x/1-(x/10)*10 (digit 10 meaning the last digit or the ones-digit)
Digit 09=x/10-(x/100)*10
Digit 08=x/100-(x/1000)*10
Digit 07=x/1000-(x/10000)*10
Digit 06=x/10000-(x/100000)*10
Digit 05=x/100000-(x/1000000)*10
Digit 04=x/1000000-(x/10000000)*10
Digit 03=x/10000000-(x/100000000)*10
Digit 02=x/100000000-(x/1000000000)*10
Digit 01=x/1000000000

So let us suppose I found a variety of items, with my helmet giving me three spirits (+30000000), my body armor giving me seven valkyries (+7) and my boots giving me 5 bears and 6 vines (+650000). The total value of this stat on the player will be 1003650007 (remember that the player must have the highest digit value of at least 1, otherwise the formula might end up reading a different digit). The summon limit calculation for each summon will then be:

Spirit: 1003650007/1000-(1003650007/10000)*10 = +3
Bear: 1003650007/10000-(1003650007/100000)*10 = +5
Vines: 1003650007/100000-(1003650007/1000000)*10 = +6
Valkyrie: 1003650007/1-(1003650007/10)*10 = +7

A problem of this method is that giving too much of a sub-stat, instead of simply wrapping back around, will instead overflow into the next digit, giving you summons or whatever sub-stat that should not be given. As such, it will require somewhat careful application so that the player will not accidentally obtain too much of a given sub-stat.

User avatar
Psycrono7
Posts: 73
Joined: Tue Nov 05, 2013 10:42 pm

Re: A Softcoded Approach to Expanding ItemStatCost.txt

Post by Psycrono7 » Sun Jul 28, 2019 12:11 am

What about life/mana/stamina values? They roll-over at 8388607...
Image
Miniguns Assault!

User avatar
Cypress
Posts: 31
Joined: Fri Dec 01, 2017 2:08 am

Re: A Softcoded Approach to Expanding ItemStatCost.txt

Post by Cypress » Sun Jul 28, 2019 1:48 am

Psycrono7 wrote:
Sun Jul 28, 2019 12:11 am
What about life/mana/stamina values? They roll-over at 8388607...
If you are using a stat with a roll-over at 8388607, then the minimum value must be 1000000 and the value must not be greater than 7999999. You would also only use the formulae up to digit 7, since the digits past that do not exist (or produce your own formulae to read whatever parts of the stat that you want to use).

However, I would not recommend using stats that can do things by themselves, as giving the player that much life, stamina and mana at minimum would most likely be gamebreaking. Unless you intend to give it to monsters, in which case mana and stamina would be OK to massively inflate since they don't actually use those stats. This method works most ideally with stats that have the sole purpose of being read by calculation columns.

Post Reply

Return to “General Mod Making”