FANDOM


This is what blog posts are, right?

So, item generation. Quite complex procedure that devolves into a few gosubs, vars and much headache. Here I will describe results of my continuing attemps to uncover mechanic behind all this. I don't understand what I'm doing about quarter of time, so there can be and probably will be mistakes.

  1. deffunc itemcreate int prm_518, int prm_519, int prm_520, int prm_521, int prm_522

Here, prm_519 is ID of item (it'll get written into inv.s1 on offset 12, or var_99(3, id)), prm_520 is x coordinate, and prm_521 is y coordinate. prm_518 and prm_522... do something.

In the start, nothing important happens before moving on to label_1897.

label_1897

For most of equipment, if rnd(5000) is less than your luck, var_580, responsible for quality, will increase by 1, but no more than 5 (godly quality).

After that, game will search for free space in array of items. If there's none, something will get deleted with message

Too many item data! Some items in this area are destroyed.

After that, free space will get cleared for new item. Then game'll assign X and Y coordinates, located at var_99(5, id) and var_99(6, id) (offsets 20 and 24).

After that, game will go to label_0527, responsible for addition of base data (item type, price, material, description, charges...) depending on ID, and return back.

If quality is 6 (Special), the name of item will get written in art.txt (for oracle spell).

After, the game will assign amount of charges (for certain items), color of dye, type of skillbook, amount of gold, enchantment in cores of nefia, and other little fluff.

From there we go on to label_1896:

label_1896

Most items here have a chance to be cursed (1/13, with additional 1/4 chance to be doomed for... certain stuff? TODO: find out) or blessed (1/12 chance). Special items are always uncursed.

After that, equipment gets a material!

var_621(0, 0) = bronze (12), iron (34), mica (21), coral (33)
var_621(0, 1) = metal (10), silver (25), glass (5), obsidian (20)
var_621(0, 2) = steel (9), platinum (26), perl (22), mithril (7)
var_621(0, 3) = chrome (30), crystal (11), emerald (23), adamantium (31)
var_621(0, 4) = titanium (29), diamond (13), rubynus (15), ether (8)

var_622(0, 0) = cloth (3), silk (2), paper (16), bone (18)
var_622(0, 1) = leather (1), scale (4), glass (5), obsidian (20)
var_622(0, 2) = chain (19), platinum (26), perl (22), mithril (7)
var_622(0, 3) = zylon (27), gold (32), spirit cloth (14), dragon scale (24)
var_622(0, 4) = dawn cloth (17), griffon scale (28), rubynus (15), ether (8)

TODO: understand what this means, convert IDs into names.

As you can see, this is array of materials. For each 15 levels of creature (or 10 of current object level, it depends on dungeon level or on something else, depending on source TODO: find out what) you essentialy get new 'tier' (or row) of equipment unlocked.

Special rules for material kits: they get additional roll on 'quality' and in 1/3 chance pull material from first array.

Furniture have equal chance to get material from either array.

Some of the equipment will get materials mostly from first array, some - from second, with 1/10 chance of getting material from other array. (Note: items with material id 1000 take material mainly from first array, while items with id 1001 take mainly from second array. Lightsabers always generate ether, while rocks and stones are always metal)


Id Name Material 955 sox" 1001
633 panty" 1001
557 vindale cloak" 1001
556 seven league boots" 1001
520 wing" 1001
471 charm" 1001
469 talisman" 1001
463 feather hat" 1001
462 cloak" 1001
461 armored cloak" 1001
457 tight boots" 1001
456 boots" 1001
455 shoes" 1001
447 light gloves" 1001
445 gloves" 1001
444 bulletproof jacket" 1001
443 breast plate" 1001
442 coat" 1001
441 light mail" 1001
440 pope robe" 1001
67 decorative amulet" 1001
66 girdle" 1001
65 light cloak" 1001
13 decorative ring" 1001
9 decorated gloves" 1001
8 robe" 1001
6 fairy hat" 1001
5 magic hat" 1001
973 magnum" 1000
956 whip" 1000
954 chainsickle" 1000
953 ballista" 1000
938 claw" 1000
937 repeating bow" 1000
817 sniper rifle" 1000
788 skull bow" 1000
781 kitchen knife" 1000
735 scythe" 1000
714 grenade" 1000
713 shuriken" 1000
664 speed ring" 1000
558 aurora ring" 1000
552 feather" 1000
513 energy cell" 1000
512 laser gun" 1000
496 shot gun" 1000
483 bolt" 1000
482 crossbow" 1000
477 engagement ring" 1000
476 ring" 1000
475 armored ring" 1000
474 composite ring" 1000
473 engagement amulet" 1000
472 bejeweled amulet" 1000
470 neck guard" 1000
468 peridot" 1000
467 composite helm" 1000
466 helm" 1000
465 knight helm" 1000
464 heavy helm" 1000
460 plate girdle" 1000
459 composite girdle" 1000
458 armored boots" 1000
454 tower shield" 1000
453 kite shield" 1000
452 large shield" 1000
451 shield" 1000
450 round shield" 1000
449 small shield" 1000
448 composite gauntlets" 1000
446 plate gauntlets" 1000
439 chain mail" 1000
438 composite mail" 1000
437 ring mail" 1000
436 plate mail" 1000
435 banded mail" 1000
266 wakizashi" 1000
235 halberd" 1000
234 bardish" 1000
232 claymore" 1000
231 machine gun" 1000
230 short bow" 1000
229 long staff" 1000
228 trident" 1000
227 hammer" 1000
226 battle axe" 1000
225 scimitar" 1000
224 katana" 1000
213 spear" 1000
212 staff" 1000
211 sickle" 1000
62 bullet" 1000
61 arrow" 1000
60 pistol" 1000
59 knight shield" 1000
58 long bow" 1000
12 composite boots" 1000
11 heavy boots" 1000
10 thick gauntlets" 1000
7 breastplate" 1000
4 club" 1000
3 hand axe" 1000
2 dagger" 1000
1 long sword" 1000

Another roll will determine tier (or row) from which you get the material.

Depending on random, you'll get:

Rarest materials from last column (5% chance)

Materials from third column (20% chance)

Materials from second column (30% chance)

Materials from first column (45% chance)

After all THAT, there's still flat 1/25 chance to get 'raw' material.


Furniture with material cloth, paper, mica and silk have their material changed to wood automatically.

Then, PV, DV, damage\hit rolls are modified, depending on material and quality (and random). Enchantments from material\base item (including static arts, they get enchantments now) are applied after.

We then go on to *label_0308, where random enhantments are generated. Items with quality 2 or less immedietly return back.

Blood rod

Bloody Tears

Ivy Spine

whip

Vice Staff

Drake Rod

Zwiebel

Vital flayer

Solar Cane

Elemental Staff

Staff of Insanity

long staff

staff

These items have 5 independent rolls (1/10 chance) to recieve:

Enchances your spells;

Increases your Magic by x;

Improves your Casting by x (if rolled, next rolls won't happen);

Increases your Mana by x (if rolled, next roll won't happen);

Improves your Magic Device by x;

Now, items with quality lesser than 4 (thats 3, Great quality) recieve either rnd(rnd(5) + 1) + 1 random normal (rank 4-) enchantments, or random ego:

Of silence: Improves Stealth, prevents teleport;

Of resist blind: immunity to blindness;

Of resist confusion: immunity to confusion;

Of fire: resistance to fire and\or fire damage;

Of cold: resistance to cold and\or cold damage

Of lightning: resistance to lightning and\or lightning damage

Of night: resistance to darkness and\or darkness damage

Of illusion: resistance to mind and\or mind damage

Of Poison: resistance to poison and\or posion damage

Of hell: resistance to nether and\or netherdamage

Of sound: resistance to sound and\or sound damage

Of nerve: resistance to nerveand\or nerve damage

Of chaos: resistance to chaos and\or chaos damage

Of magic: resistance to magic and\or magic damage

Of healing: Improves Healing

Of resist paralysis: immunity to paralysis;

Of resist fear: immunity to fear;

Of resist sleep: immunity to sleep;

Of defender: resistances to fire, cold and lightning

Items with ego also have two separate chances (1/2 and 1/4) to recieve random enchantment.

If item is of quality 5 (or 4 if rnd(10) rolls 0), game will give one enchantment of any rank, including rank 99. If it's a weapon, an additional rnd(100) roll will roll (sorry). If it rolls 0, the weapon becomes living, and returns immediately, not recieving any further enchantments.

Now, random will determine amount of enchantments on item given. It's

rnd(rnd(rnd(10) + 1) + 3) + 3 (3-14) for miracle quality or

rnd(rnd(rnd(10) + 1) + 3) + 6 (6-17?) for godly quality

If item is weapon and has more than 11 enchantments, it has 1/10 chance to recieve additional enchantment (up to rank 99), and become eternal force weapon.

After that, normal random enchantments are added.

For special items: 0-2 enchantments are added to preexisting, always up to rank 4.

If the item is cursed or doomed, it'll recieve another random normal enchantment with 1.25 (or 1.5 if doomed) strength, then will attempt 1 + (1 if doomed) + rnd(2) times to add either 'weaken your resistance' (1.5 times strength) or 'weaken your skill' (2.5 times strength) enchantments with 1/3 chance each, or random -1 rank if both rolls don't succeed.

flt

This is good function. Doesn't actually do anything for generetion directly, but passes quality values to variables responsible.

If none values are passed to function, generates them using object level of floor (DL+floor?), and base quality level 2, then passes them.

calcfixlv int prm_495

This function is responsible for determining the quality level of item before generation.

The var_574 (result) starts at prm_495, with default of 2.

Most sources provide base level 2, but some sources:

Salary (3, with chance of getting 4 (1/6 if you take the Apprentice Quartermaster feat, 2/6 if you improve it to Expert Quartermaster))

Chests (first item has 3)

Treasure balls (3)

Rare treasure balls (4)

Bejeweled chest (3, with first item having 1/4 chance to have 4)

Performance rewards (3 with varying chance to get 4)

Quest rewards (starts at 2, with 1/2 chance to be 3, with additional 1/12 chance to be 4).

(2 - good, 3 - great, 4 - miracle, just in case)

I seem to stray slightly. Erm...

So, the base level. Then, function performs 3 different rolls, they have:

1/35, 1/40, 1/45 chance to increase quality OR

2/35, 2/40, 2/45 chance to reduce it.

Then, if quality is below 1, it changes to 1 and

if above 5, becomes 5.

randomenc()

Done; this function forms an array of possible enchantments, then rolls one of them. The contents of this array (id's and weights, if I read it right) are formed depending on rank (no more than what is passed) and on types allowed. The types are in array below; because every single item has it, I truncated it, leaving only base weapon\armor types. If I forgot something, tell in comments. For example, enchantment 9, aka 'can be loaded with', can be recieved only by type 25000, or ammo (it also has absolutely crazy weight compared to others).

Id's of enchantments with no limitations: 21, 45, 46, 47, 56, 59, 3, 6, 23, 1, 22, 25, 2, 24, 26, 27, 28, 48, 32, 33, 42, 8 (enchantment itself is free, but actual invoke is limited to weapons. Melee weapons can't get Draw Shadow, and ranged can't get Decapitation (randomly)).


var_596
Id Name 'Type'
1 long sword" 10000
2 dagger" 10000
3 hand axe" 10000
4 club" 10000
211 sickle" 10000
212 staff" 10000
213 spear" 10000
224 katana" 10000
225 scimitar" 10000
226 battle axe" 10000
227 hammer" 10000
228 trident" 10000
229 long staff" 10000
232 claymore" 10000
234 bardish" 10000
235 halberd" 10000
266 wakizashi" 10000
735 scythe" 10000
759 lightsabre" 10000
781 kitchen knife" 10000
954 chainsickle" 10000
956 whip" 10000
5 magic hat" 12000
6 fairy hat" 12000
463 feather hat" 12000
464 heavy helm" 12000
465 knight helm" 12000
466 helm" 12000
467 composite helm" 12000
59 knight shield" 14000
449 small shield" 14000
450 round shield" 14000
451 shield" 14000
452 large shield" 14000
453 kite shield" 14000
454 tower shield" 14000
938 claw" 14000
7 breastplate" 16000
8 robe" 16000
435 banded mail" 16000
436 plate mail" 16000
437 ring mail" 16000
438 composite mail" 16000
439 chain mail" 16000
440 pope robe" 16000
441 light mail" 16000
442 coat" 16000
443 breast plate" 16000
444 bulletproof jacket" 16000
11 heavy boots" 18000
12 composite boots" 18000
455 shoes" 18000
456 boots" 18000
457 tight boots" 18000
458 armored boots" 18000
556 seven league boots" 18000
66 girdle" 19000
459 composite girdle" 19000
460 plate girdle" 19000
65 light cloak" 20000
461 armored cloak" 20000
462 cloak" 20000
520 wing" 20000
552 feather" 20000
557 vindale cloak" 20000
9 decorated gloves" 22000
10 thick gauntlets" 22000
445 gloves" 22000
446 plate gauntlets" 22000
447 light gloves" 22000
448 composite gauntlets" 22000
58 long bow" 24000
60 pistol" 24000
210 stone" 24000
230 short bow" 24000
231 machine gun" 24000
482 crossbow" 24000
496 shot gun" 24000
512 laser gun" 24000
633 panty" 24000
713 shuriken" 24000
714 grenade" 24000
788 skull bow" 24000
817 sniper rifle" 24000
937 repeating bow" 24000
939 rock" 24000
953 ballista" 24000
61 arrow" 25000
62 bullet" 25000
483 bolt" 25000
513 energy cell" 25000
973 magnum" 25000
13 decorative ring" 32000
474 composite ring" 32000
475 armored ring" 32000
476 ring" 32000
477 engagement ring" 32000
558 aurora ring" 32000
664 speed ring" 32000
67 decorative amulet" 34000
468 peridot" 34000
469 talisman" 34000
470 neck guard" 34000
471 charm" 34000
472 bejeweled amulet" 34000
473 engagement amulet" 34000

Table of enchantments. The item type needs to fit to one of types listed in table to be eligble to recieve enchantment. If type1 is 0, the enchantment is available to any item.

Enchantments
Id Rank ?? Weight? Type1 Type2 Type3
21 -1 50 75 0
45 -1 50 100 0
46 -1 50 100 0
47 -1 50 50 0
56 0 200 30 0
59 0 200 30 0
3 0 120 4500 0
6 0 120 4500 0
7 1 120 300 10000 24000
9 1 120 50000 25000
23 1 120 400 0
1 1 120 3000 0
22 1 150 150 0
25 1 120 400 0
2 2 150 2500 0
24 2 120 300 0
26 1 120 600 0
27 1 120 600 0
28 2 120 500 0
29 3 200 25 18000
30 3 200 25 20000
31 2 200 40 32000
48 1 120 300 0
50 3 180 150 32000 34000
51 3 180 150 32000 34000
32 1 130 250 0
55 3 130 40 19000 34000
33 3 160 200 0
34 3 170 250 10000
57 2 170 200 10000 24000
58 2 170 200 10000 24000
52 1 140 100 14000
53 2 160 80 14000
54 3 180 250 14000 16000
35 2 170 100 12000 32000
44 99 300 10000 10000 34000
42 99 300 2000 0
36 99 450 1000 10000 24000
38 99 450 1000 10000 24000
37 99 100 1000 10000 24000
39 99 500 500 10000 22000
40 99 550 500 10000 24000
41 99 300 1500 0
43 99 150 2000 0
8 99 300 15000 0
49 100 120 300 60000
60 100 120 300 60000
61 2 170 150 10000 24000
62 3 180 250 14000 20000
63 100 120 5000 10000
64 99 300 5000 16000 12000 19000
65 99 500 1500 10000 20000 14000
66 99 550 1500 18000 24000 22000
67 100 170 150 10000 24000
68 3 170 300 16000 12000 22000

Unfortunately, actual random lies within function exrand_rnd, which is located in exrand.dll. I couldn't find any documentation regarding it.

randomencp()

This function is responsible for generating random enchantment power.

It is simply a few rolls, the first being rnd(rnd(500) + 1)) + 1, with additional rnd(51) with 1/5 chance (or always, if you activated secret treasure of Ehekatl). Max power thus is 550.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.