hakai_no_tenshi,Feb 28 2003, 07:03 AM Wrote:Cool, that's a first step in the right direction. :D I just wish someone would keep a repository of all these things in one place. It's sad when people like Jamella and John Doe keep their work secret and becomes lost knowledge. Do you think you got that comment from the source code that Jamella posted? I'd really like a copy of it if *anyone* has it.
Jarulf: I'll go hunt for the item generation posts. Thanks. I really hope to have Classi decoded. Unfortunately, there is only one seed in 1.03- and two seeds in 1.04+ ... I'm not quite sure how this works. Here is one post that had some info but nothing I could I could really work with :( I just wish I knew where to start. I'll send nutzzy99 an email and see what he says.
--T
I don't really keep things secret, I post things for people to understand the game though not posting what would basically be copies of the code.
The most important things to remember about item generation is that it is basically done by a stream of random values, of which the first is saved with the item (when there are two one is actually only used for a few things like ammount of items in stack, exact DR and so on, the other is used for ALL magical properties and quality determination, I supose in old versions it was simply just one used for all things).
So you really only need to figure out what random values are rolled for for an item.
First off (this is from memory), the game use the seed to determine the quality of the item (I think the quality is actually saved with the item, but it still goes through it to get to the correct seed used for the magical properties.
This is done more or less as today. You need to use the correct txt table to get the correct values for each quality of the specific game version you work with. Then calculate a number. This is more or less:
Number = Val - mlvl/divisor
I think for some qualities the divisor was not used though, not sure.
The game then do a Rnd[Number] and if the result was 0, that quality was picked, otherwise the game proceeded to the quality (rare was done before set in those old versions).
As soon as a quality was picked, the game proceeded to the actual code, specific for each quality (it is possible that for 1.03 and older that the game did the DR and suich inbetween here, no idea).
So you need seperate code for each quality.
For magic items the game was now to pick a prefix. First there is a random roll (with 50/50 chance that is a Rnd[2]) if it exists. Then the game build a list of all affixes possible and do a Rnd[number of possible affixes] to pick one. Then it do the same for suffix. Note, even if no prefix was picked and a suffix is needed, it still roll for it. It just discards the result if a suffix is needed. Then pick a suffix.
For rare items it is pretty much the same. First though, two random rolls are made to pick prefix and suffix NAMES. Again, you need to use the ingame data fileds to build the proper list of possible ones based on item types and pick on. Next it rolls for number of affixes.
The for EACH affix, it loops up to 250 times (I think) until an affix is actually chose in the loop then the loop stop. First it make another 50/50 roll to see if it is a prefix or suffix (remember, max three of each though, but I think it still rolled for it even if it then forced picked the other).
Next it picks a prefix or suffix in the exact same way as for a magical item. It DO roll the 50/50 chance but discards it since it is a forced pick when the item is rare. Build the list and pick one affix at random. Next it needs to check if the affix's group allready had an affix picked, if so it loop arround otherwise it pick that affix.
Uniques and sets are quite straight forward, pick one at random (for sets I believe I detelaied the procedure and how it made some sets more common in one post) but for uniques it is no need since it pick the first one not yet in existance in a game. Now, to recreate the item, you should allready find the exact set/unique number in the save file so no need to do anything I think.
Now if I recall correctly, each affix is added to the item AS IT IS PICKED. So you need to insert code that use a rnadom number to determine any possible random value of the affix's property. Some affixes has multiple properties by the way.
After all this the item should be almost done I think. But for some item types it pick the specific +spell properties. That is quite a compliacted thing that I really can't reember detailed enough to explain here. I think it as well is detailied very well in some post (a bit later in time, perhaps during fall 2000) and it should probably be enough to figure out how the seed is used, that is what random rolls are done.
Hope this helps soke. I guess you have to try a bit and see when you get it correctly.
There are three types of people in the world. Those who can count and those who can't.