Mercurial > mm7
annotate Items.cpp @ 462:37090bd974f9
Merge
author | Gloval |
---|---|
date | Sun, 24 Feb 2013 20:47:46 +0400 |
parents | 197461e5acec |
children | f7b91ef98ab2 |
rev | line source |
---|---|
0 | 1 #include <stdlib.h> |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
2 #include <assert.h> |
0 | 3 |
4 #include "Items.h" | |
5 #include "MapInfo.h" | |
6 #include "FrameTableInc.h" | |
7 #include "Allocator.h" | |
461 | 8 #include "GUIWindow.h" |
9 #include "Events2D.h" | |
10 #include "Chest.h" | |
0 | 11 #include "LOD.h" |
12 #include "Monsters.h" | |
13 #include "Party.h" | |
14 #include "FactionTable.h" | |
15 #include "StorylineTextTable.h" | |
189 | 16 #include "texts.h" |
0 | 17 #include "mm7_data.h" |
18 | |
19 | |
20 | |
21 | |
22 | |
23 ItemGen *ptr_50C9A4; | |
24 | |
315 | 25 struct ItemsTable *pItemsTable; // 005D29E0 |
0 | 26 |
27 | |
28 | |
29 | |
30 | |
31 //----- (00439DF3) -------------------------------------------------------- | |
385 | 32 int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP) |
33 { | |
34 *damage_type = 0; | |
35 if ( !uItemID ) | |
36 return 0; | |
37 UpdateTempBonus(pParty->uTimePlayed); | |
38 if (uItemID == 501 ) //Iron Feather -sword | |
39 { | |
40 *damage_type = 1; | |
41 return rand() % 10 + 6; | |
42 } | |
43 if (uItemID == 507 ) //Ghoulsbane -axe | |
44 { | |
45 *damage_type = 0; | |
46 return rand() % 16 + 3; | |
47 } | |
48 if ( uItemID == 510 ) //Ullyses -bow | |
49 { | |
50 *damage_type = 2; | |
51 return rand() % 4 + 9; | |
52 } | |
53 if ( uItemID == 517 ) //Old Nick -dagger | |
54 { | |
55 *damage_type = 8; | |
56 return 8; | |
57 } | |
0 | 58 |
385 | 59 switch (uSpecEnchantmentType) |
60 { | |
61 case 4: //Adds 3-4 points of Cold damage. | |
62 *damage_type = 2; | |
63 return rand() % 2 + 3; | |
64 break; | |
65 case 5: //Adds 6-8 points of Cold damage. | |
66 *damage_type = 2; | |
67 return rand() % 3 + 6; | |
68 break; | |
69 case 6: //Adds 9-12 points of Cold damage. | |
70 *damage_type = 2; | |
71 return rand() % 4 + 9; | |
72 break; | |
73 case 7: //Adds 2-5 points of Electrical damage. | |
74 *damage_type = 1; | |
75 return rand() % 4 + 2; | |
76 break; | |
77 case 8: //Adds 4-10 points of Electrical damage. | |
78 *damage_type = 1; | |
79 return rand() % 7 + 4; | |
80 break; | |
81 case 9: //Adds 6-15 points of Electrical damage. | |
82 *damage_type = 1; | |
83 return rand() % 10 + 6; | |
84 break; | |
85 case 10: //Adds 1-6 points of Fire damage. | |
86 *damage_type = 0; | |
87 return GetDiceResult(1, 6); | |
88 break; | |
89 case 11: //Adds 2-12 points of Fire damage. | |
90 *damage_type = 0; | |
91 return GetDiceResult(2, 6); | |
92 break; | |
93 case 12: //Adds 3-18 points of Fire damage. | |
94 *damage_type = 0; | |
95 return GetDiceResult(3, 6); | |
96 break; | |
97 case 13: //Adds 5 points of Body damage. | |
98 *damage_type = 8; | |
99 return 5; | |
100 break; | |
101 case 14: //Adds 8 points of Body damage. | |
102 *damage_type = 8; | |
103 return 8; | |
104 break; | |
105 case 15: //Adds 12 points of Body damage. | |
106 *damage_type = 8; | |
107 return 12; | |
108 break; | |
109 case 16: //Drain Hit Points from target. | |
110 case 41: //Drain Hit Points from target and Increased Weapon speed. | |
111 *damage_type = 10; | |
112 *draintargetHP = true; | |
113 return 0; | |
114 break; | |
115 case 46: //Adds 10-20 points of Fire damage and +25 Might. | |
116 *damage_type = 0; | |
117 return rand() % 11 + 10; | |
118 break; | |
119 default: | |
120 *damage_type = 0; | |
121 return 0; | |
122 | |
123 } | |
124 | |
125 } | |
0 | 126 |
127 | |
128 //----- (00402F07) -------------------------------------------------------- | |
129 void ItemGen::Reset() | |
130 { | |
377 | 131 this->uHolderPlayer = 0; |
0 | 132 this->uAttributes = 0; |
133 this->uNumCharges = 0; | |
377 | 134 this->uSpecEnchantmentType = 0; |
0 | 135 this->_bonus_strength = 0; |
377 | 136 this->uEncantmentType = 0; |
0 | 137 this->uItemID = 0; |
138 this->uBodyAnchor = 0; | |
139 this->uExpireTime = 0i64; | |
140 } | |
141 | |
142 //----- (00458260) -------------------------------------------------------- | |
143 void ItemGen::UpdateTempBonus(__int64 uTimePlayed) | |
144 { | |
145 unsigned int v2; // eax@1 | |
146 | |
147 v2 = this->uAttributes; | |
148 if ( v2 & ITEM_TEMP_BONUS ) | |
149 { | |
150 if ( uTimePlayed > (signed __int64)this->uExpireTime ) | |
151 { | |
377 | 152 this->uEncantmentType = 0; |
0 | 153 LOBYTE(v2) = v2 & 0xF7; |
377 | 154 this->uSpecEnchantmentType = 0; |
0 | 155 this->uAttributes = v2; |
156 } | |
157 } | |
158 } | |
159 | |
160 //----- (0045814E) -------------------------------------------------------- | |
374 | 161 void ItemsTable::Release() |
0 | 162 { |
163 if ( pMonstersTXT_Raw ) | |
164 pAllocator->FreeChunk(pMonstersTXT_Raw); | |
165 if ( pMonsterPlacementTXT_Raw ) | |
166 pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); | |
167 if ( pSkillDescTXT_Raw ) | |
168 pAllocator->FreeChunk(pSkillDescTXT_Raw); | |
374 | 169 if (pSpcItemsTXT_Raw ) |
170 pAllocator->FreeChunk(pSpcItemsTXT_Raw); | |
171 if ( pStdItemsTXT_Raw ) | |
172 pAllocator->FreeChunk(pStdItemsTXT_Raw); | |
173 if ( pRndItemsTXT_Raw ) | |
174 pAllocator->FreeChunk(pRndItemsTXT_Raw); | |
175 if ( pItemsTXT_Raw ) | |
176 pAllocator->FreeChunk(pItemsTXT_Raw); | |
0 | 177 if ( pHostileTXT_Raw ) |
178 pAllocator->FreeChunk(pHostileTXT_Raw); | |
179 if ( pHistoryTXT_Raw ) | |
180 pAllocator->FreeChunk(pHistoryTXT_Raw); | |
181 if ( pPotionsTXT_Raw ) | |
182 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
183 if ( pPotionNotesTXT_Raw ) | |
184 pAllocator->FreeChunk(pPotionNotesTXT_Raw); | |
374 | 185 pSpcItemsTXT_Raw = NULL; |
186 pSkillDescTXT_Raw = NULL; | |
187 pStdItemsTXT_Raw = NULL; | |
188 pRndItemsTXT_Raw = NULL; | |
189 pItemsTXT_Raw = NULL; | |
190 | |
0 | 191 } |
192 | |
193 | |
194 //----- (00456D84) -------------------------------------------------------- | |
195 void ItemsTable::Initialize() | |
224 | 196 { |
197 int i,j; | |
198 char* test_string; | |
229 | 199 unsigned char c; |
224 | 200 bool break_loop; |
201 unsigned int temp_str_len; | |
202 char* tmp_pos; | |
203 int decode_step; | |
204 int item_counter; | |
205 | |
206 pMapStats = new MapStats; | |
207 pMapStats->Initialize(); | |
208 | |
209 pMonsterStats = new MonsterStats; | |
210 pMonsterStats->Initialize(); | |
211 pMonsterStats->InitializePlacements(); | |
212 | |
213 pSpellStats = new SpellStats; | |
214 pSpellStats->Initialize(); | |
215 | |
216 LoadPotions(); | |
217 LoadPotionNotes(); | |
218 | |
219 pFactionTable = new FactionTable; | |
220 pFactionTable->Initialize(); | |
221 | |
222 pStorylineText = new StorylineText; | |
223 pStorylineText->Initialize(); | |
0 | 224 |
224 | 225 pStdItemsTXT_Raw = NULL; |
226 pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); | |
227 strtok(pStdItemsTXT_Raw, "\r"); | |
228 strtok(NULL, "\r"); | |
229 strtok(NULL, "\r"); | |
230 strtok(NULL, "\r"); | |
231 //Standard Bonuses by Group | |
232 for (i=0;i<24;++i) | |
233 { | |
234 test_string = strtok(NULL, "\r") + 1; | |
235 break_loop = false; | |
236 decode_step=0; | |
237 do | |
238 { | |
239 c = *(unsigned char*)test_string; | |
240 temp_str_len = 0; | |
241 while((c!='\t')&&(c>0)) | |
242 { | |
243 ++temp_str_len; | |
244 c=test_string[temp_str_len]; | |
245 } | |
246 tmp_pos=test_string+temp_str_len; | |
247 if (*tmp_pos == 0) | |
248 break_loop = true; | |
249 *tmp_pos = 0; | |
250 if (temp_str_len) | |
251 { | |
252 switch (decode_step) | |
253 { | |
254 case 0: | |
255 pEnchantments[i].pBonusStat=RemoveQuotes(test_string); | |
256 break; | |
257 case 1: | |
258 pEnchantments[i].pOfName= RemoveQuotes(test_string); | |
259 break; | |
260 default: | |
261 pEnchantments[i].to_item[decode_step-2]=atoi(test_string); | |
262 } | |
263 } | |
264 else | |
265 { | |
266 if (!decode_step) | |
267 break_loop = true; | |
268 } | |
269 ++decode_step; | |
270 test_string=tmp_pos+1; | |
271 } while ((decode_step<11)&&!break_loop); | |
272 } | |
0 | 273 |
224 | 274 memset(&pEnchantmentsSumm, 0, 36); |
275 for(i=0;i<9;++i) | |
276 { | |
277 for (j=0;j<24;++j) | |
278 pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i]; | |
279 } | |
0 | 280 |
224 | 281 //Bonus range for Standard by Level |
282 strtok(NULL, "\r"); | |
283 strtok(NULL, "\r"); | |
284 strtok(NULL, "\r"); | |
285 strtok(NULL, "\r"); | |
286 strtok(NULL, "\r"); | |
287 for(i=0;i<6;++i) //counted from 1 | |
288 { | |
289 test_string = strtok(NULL, "\r") + 1; | |
290 break_loop = false; | |
291 decode_step=0; | |
292 do | |
293 { | |
294 c = *(unsigned char*)test_string; | |
295 temp_str_len = 0; | |
296 while((c!='\t')&&(c>0)) | |
297 { | |
298 ++temp_str_len; | |
299 c=test_string[temp_str_len]; | |
300 } | |
301 tmp_pos=test_string+temp_str_len; | |
302 if (*tmp_pos == 0) | |
303 break_loop = true; | |
304 *tmp_pos = 0; | |
305 if (decode_step==2) | |
306 bonus_ranges[i].minR = atoi(test_string); | |
307 else if (decode_step==3) | |
308 bonus_ranges[i].maxR =atoi(test_string); | |
309 ++decode_step; | |
310 test_string=tmp_pos+1; | |
311 } while ((decode_step<4)&&!break_loop); | |
312 } | |
313 | |
222 | 314 |
224 | 315 pSpcItemsTXT_Raw = 0; |
316 pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); | |
317 strtok(pSpcItemsTXT_Raw, "\r"); | |
318 strtok(NULL, "\r"); | |
319 strtok(NULL, "\r"); | |
320 strtok(NULL, "\r"); | |
321 for (i=0;i<72;++i) | |
322 { | |
323 test_string = strtok(NULL, "\r") + 1; | |
324 break_loop = false; | |
325 decode_step=0; | |
326 do | |
327 { | |
328 c = *(unsigned char*)test_string; | |
329 temp_str_len = 0; | |
330 while((c!='\t')&&(c>0)) | |
331 { | |
332 ++temp_str_len; | |
333 c=test_string[temp_str_len]; | |
334 } | |
335 tmp_pos=test_string+temp_str_len; | |
336 if (*tmp_pos == 0) | |
337 break_loop = true; | |
338 *tmp_pos = 0; | |
339 if (temp_str_len) | |
340 { | |
341 switch (decode_step) | |
342 { | |
343 case 0: | |
344 pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string); | |
345 break; | |
346 case 1: | |
347 pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string); | |
348 break; | |
349 case 14: | |
350 int res; | |
351 res=atoi(test_string); | |
352 if(!res) | |
353 { | |
354 ++test_string; | |
355 while (*test_string==' ')//fix X 2 case | |
356 ++test_string; | |
222 | 357 res=atoi(test_string); |
224 | 358 } |
359 pSpecialEnchantments[i].iValue=res; | |
360 break; | |
361 case 15: | |
362 pSpecialEnchantments[i].iTreasureLevel= tolower(*test_string) - 97;; | |
363 break; | |
364 default: | |
365 pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string); | |
366 } | |
367 } | |
368 else | |
369 { | |
370 if (!decode_step) | |
371 break_loop = true; | |
372 } | |
373 ++decode_step; | |
374 test_string=tmp_pos+1; | |
375 } while ((decode_step<16)&&!break_loop); | |
376 } | |
377 | |
378 pSpecialEnchantments_count = 71; | |
379 memset(&pSpecialEnchantmentsSumm, 0, 96); | |
380 for(i=0;i<12;++i) | |
381 { | |
382 for (j=0;j<pSpecialEnchantments_count;++j) | |
383 pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; | |
384 } | |
222 | 385 |
224 | 386 Initialize2DA(); |
222 | 387 |
224 | 388 pItemsTXT_Raw = NULL; |
389 pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0); | |
390 strtok(pItemsTXT_Raw, "\r"); | |
391 strtok(NULL, "\r"); | |
392 uAllItemsCount = 0; | |
393 item_counter = 0; | |
222 | 394 while (true) |
395 { | |
396 test_string = strtok(NULL, "\r") + 1; | |
397 break_loop = false; | |
398 decode_step=0; | |
399 do | |
400 { | |
401 c = *(unsigned char*)test_string; | |
402 temp_str_len = 0; | |
403 while((c!='\t')&&(c>0)) | |
404 { | |
405 ++temp_str_len; | |
406 c=test_string[temp_str_len]; | |
407 } | |
408 tmp_pos=test_string+temp_str_len; | |
409 if (*tmp_pos == 0) | |
410 break_loop = true; | |
411 *tmp_pos = 0; | |
412 if (temp_str_len) | |
413 { | |
414 switch (decode_step) | |
415 { | |
416 case 0: //Item # | |
417 item_counter=atoi(test_string); | |
418 uAllItemsCount=item_counter; | |
419 break; | |
420 case 1: //Pic File | |
421 pItems[item_counter].pIconName = RemoveQuotes(test_string); | |
422 break; | |
423 case 2: //Name | |
424 pItems[item_counter].pName = RemoveQuotes(test_string); | |
425 break; | |
426 case 3: //Value | |
427 pItems[item_counter].uValue=atoi(test_string); | |
428 break; | |
429 case 4: //Equip Stat | |
430 { | |
431 if ( !_strcmpi(test_string, "weapon") ) | |
432 { | |
365 | 433 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 434 break; |
435 } | |
436 if ( !_strcmpi(test_string, "weapon2") ) | |
437 { | |
365 | 438 pItems[item_counter].uEquipType = EQUIP_TWO_HANDED; |
222 | 439 break; |
440 } | |
441 if ( !_strcmpi(test_string, "weapon1or2") ) | |
442 { | |
365 | 443 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 444 break; |
445 } | |
446 if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow"))) | |
447 { | |
365 | 448 pItems[item_counter].uEquipType = EQUIP_BOW; |
222 | 449 break; |
450 } | |
451 if ( !_strcmpi(test_string, "armor") ) | |
452 { | |
365 | 453 pItems[item_counter].uEquipType = EQUIP_ARMOUR; |
222 | 454 break; |
455 } | |
456 if ( !_strcmpi(test_string, "shield") ) | |
457 { | |
365 | 458 pItems[item_counter].uEquipType = EQUIP_SHIELD; |
222 | 459 break; |
460 } | |
461 if ( !_strcmpi(test_string, "helm") ) | |
462 { | |
365 | 463 pItems[item_counter].uEquipType = EQUIP_HELMET; |
222 | 464 break; |
465 } | |
466 if ( !_strcmpi(test_string, "belt") ) | |
467 { | |
365 | 468 pItems[item_counter].uEquipType = EQUIP_BELT; |
222 | 469 break; |
470 } | |
471 if ( !_strcmpi(test_string, "cloak") ) | |
472 { | |
365 | 473 pItems[item_counter].uEquipType = EQUIP_CLOAK; |
222 | 474 break; |
475 } | |
476 if ( !_strcmpi(test_string, "gauntlets") ) | |
477 { | |
365 | 478 pItems[item_counter].uEquipType = EQUIP_GAUNTLETS; |
222 | 479 break; |
480 } | |
481 if ( !_strcmpi(test_string, "boots") ) | |
482 { | |
365 | 483 pItems[item_counter].uEquipType = EQUIP_BOOTS; |
222 | 484 break; |
485 } | |
486 if ( !_strcmpi(test_string, "ring") ) | |
487 { | |
365 | 488 pItems[item_counter].uEquipType = EQUIP_RING; |
222 | 489 break; |
490 } | |
491 if ( !_strcmpi(test_string, "amulet") ) | |
492 { | |
365 | 493 pItems[item_counter].uEquipType = EQUIP_AMULET; |
222 | 494 break; |
495 } | |
496 if ( !_strcmpi(test_string, "weaponw") ) | |
497 { | |
365 | 498 pItems[item_counter].uEquipType = EQUIP_WAND; |
222 | 499 break; |
500 } | |
501 if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent"))) | |
502 { | |
365 | 503 pItems[item_counter].uEquipType = EQUIP_REAGENT; |
222 | 504 break; |
505 } | |
506 if ( !_strcmpi(test_string, "bottle") ) | |
507 { | |
365 | 508 pItems[item_counter].uEquipType = EQUIP_POTION; |
222 | 509 break; |
510 } | |
511 if ( !_strcmpi(test_string, "sscroll") ) | |
512 { | |
374 | 513 pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL; |
222 | 514 break; |
515 } | |
516 if ( !_strcmpi(test_string, "book") ) | |
517 { | |
365 | 518 pItems[item_counter].uEquipType = EQUIP_BOOK; |
222 | 519 break; |
520 } | |
521 if ( !_strcmpi(test_string, "mscroll") ) | |
522 { | |
374 | 523 pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL; |
222 | 524 break; |
525 } | |
526 if ( !_strcmpi(test_string, "gold") ) | |
527 { | |
365 | 528 pItems[item_counter].uEquipType = EQUIP_GOLD; |
222 | 529 break; |
530 } | |
531 if ( !_strcmpi(test_string, "gem") ) | |
532 { | |
365 | 533 pItems[item_counter].uEquipType = EQUIP_GEM; |
222 | 534 break; |
535 } | |
365 | 536 pItems[item_counter].uEquipType = EQUIP_NONE; |
222 | 537 break; |
538 } | |
539 case 5: //Skill Group | |
540 { | |
541 if ( !_strcmpi(test_string, "staff") ) | |
542 { | |
374 | 543 pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF; |
222 | 544 break; |
545 } | |
546 if ( !_strcmpi(test_string, "sword") ) | |
547 { | |
374 | 548 pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD; |
222 | 549 break; |
550 } | |
551 if ( !_strcmpi(test_string, "dagger") ) | |
552 { | |
374 | 553 pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER; |
222 | 554 break; |
555 } | |
556 if ( !_strcmpi(test_string, "axe") ) | |
557 { | |
374 | 558 pItems[item_counter].uSkillType = PLAYER_SKILL_AXE; |
222 | 559 break; |
560 } | |
561 if ( !_strcmpi(test_string, "spear") ) | |
562 { | |
374 | 563 pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR; |
222 | 564 break; |
565 } | |
566 if ( !_strcmpi(test_string, "bow") ) | |
567 { | |
374 | 568 pItems[item_counter].uSkillType = PLAYER_SKILL_BOW; |
222 | 569 break; |
570 } | |
571 if ( !_strcmpi(test_string, "mace") ) | |
572 { | |
374 | 573 pItems[item_counter].uSkillType = PLAYER_SKILL_MACE; |
222 | 574 break; |
575 } | |
576 if ( !_strcmpi(test_string, "blaster") ) | |
577 { | |
374 | 578 pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER; |
222 | 579 break; |
580 } | |
581 if ( !_strcmpi(test_string, "shield") ) | |
582 { | |
374 | 583 pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD; |
222 | 584 break; |
585 } | |
586 if ( !_strcmpi(test_string, "leather") ) | |
587 { | |
374 | 588 pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER; |
222 | 589 break; |
590 } | |
591 if ( !_strcmpi(test_string, "chain") ) | |
592 { | |
374 | 593 pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN; |
222 | 594 break; |
595 } | |
596 if ( !_strcmpi(test_string, "plate") ) | |
597 { | |
374 | 598 pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE; |
222 | 599 break; |
600 } | |
601 if ( !_strcmpi(test_string, "club") ) | |
602 { | |
374 | 603 pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB; |
222 | 604 break; |
605 } | |
385 | 606 pItems[item_counter].uSkillType = PLAYER_SKILL_MISC; |
222 | 607 break; |
608 } | |
609 case 6: //Mod1 | |
610 { | |
611 int ii; | |
612 char* test_char; | |
613 int tst_len; | |
614 tst_len=strlen(test_string); | |
615 pItems[item_counter].uDamageDice=0; | |
616 pItems[item_counter].uDamageRoll=0; | |
617 test_char=test_string; | |
618 for (ii=0; ii<tst_len; ++ii) | |
619 { | |
620 if (tolower(*test_char)=='d') | |
621 { | |
622 *test_char=0; | |
623 pItems[item_counter].uDamageDice=atoi(test_string); | |
624 pItems[item_counter].uDamageRoll=atoi(test_char+1); | |
625 *test_char='d'; | |
626 break; | |
627 } | |
628 ++test_char; | |
629 } | |
630 test_char=test_string; | |
631 if ((ii==tst_len)&&(tolower(*test_char)=='s')) | |
632 { | |
633 pItems[item_counter].uDamageDice=atoi(test_char+1); | |
634 pItems[item_counter].uDamageRoll=1; | |
635 } | |
636 break; | |
637 } | |
638 case 7: //Mod2 | |
639 pItems[item_counter].uDamageMod=atoi(test_string); | |
640 break; | |
641 case 8: //material | |
642 { | |
643 if ( !_strcmpi(test_string, "artifact") ) | |
644 { | |
377 | 645 pItems[item_counter].uMaterial = MATERIAL_ARTEFACT; |
222 | 646 break; |
647 } | |
648 if ( !_strcmpi(test_string, "relic") ) | |
649 { | |
377 | 650 pItems[item_counter].uMaterial = MATERIAL_RELIC; |
222 | 651 break; |
652 } | |
653 if ( !_strcmpi(test_string, "special") ) | |
654 { | |
377 | 655 pItems[item_counter].uMaterial = MATERIAL_SPECIAL; |
222 | 656 break; |
657 } | |
377 | 658 pItems[item_counter].uMaterial = MATERIAL_COMMON; |
222 | 659 break;} |
660 case 9: //ID/Rep/St | |
661 pItems[item_counter].uItemID_Rep_St=atoi(test_string); | |
662 break; | |
663 case 10: //Not identified name | |
664 pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string); | |
665 break; | |
666 case 11: //Sprite Index | |
667 pItems[item_counter].uSpriteID=atoi(test_string); | |
668 break; | |
669 case 12: //VarA | |
224 | 670 { |
222 | 671 pItems[item_counter]._additional_value=0; |
672 pItems[item_counter]._bonus_type=0; | |
377 | 673 if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) |
222 | 674 { |
224 | 675 for(int ii=0; ii<24; ++ii) |
676 { | |
677 if (stricmp(test_string,pEnchantments[ii].pBonusStat)) | |
678 { | |
679 pItems[item_counter]._bonus_type=ii+1; | |
222 | 680 break; |
224 | 681 } |
682 } | |
683 if (!pItems[item_counter]._bonus_type) | |
684 { | |
685 for(int ii=0; ii<72; ++ii) | |
686 { | |
687 if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) | |
222 | 688 { |
224 | 689 pItems[item_counter]._additional_value=ii+1; |
222 | 690 } |
224 | 691 } |
692 } | |
222 | 693 } |
224 | 694 |
222 | 695 break; |
224 | 696 } |
222 | 697 case 13: //VarB |
377 | 698 if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) |
222 | 699 { |
700 char b_s=atoi(test_string); | |
701 if (b_s) | |
702 pItems[item_counter]._bonus_strength=b_s; | |
703 else | |
704 pItems[item_counter]._bonus_strength=1; | |
705 } | |
706 else | |
707 pItems[item_counter]._bonus_strength=0; | |
708 break; | |
709 case 14: //Equip X | |
710 pItems[item_counter].uEquipX=atoi(test_string); | |
711 break; | |
712 case 15: //Equip Y | |
713 pItems[item_counter].uEquipY=atoi(test_string); | |
714 break; | |
715 case 16: //Notes | |
716 pItems[item_counter].pDescription = RemoveQuotes(test_string); | |
717 break; | |
224 | 718 |
222 | 719 } |
720 } | |
721 else | |
722 { | |
723 if (!decode_step) | |
724 break_loop = true; | |
725 } | |
726 ++decode_step; | |
727 test_string=tmp_pos+1; | |
728 } while ((decode_step<17)&&!break_loop); | |
729 ++item_counter; | |
730 if (item_counter>799) | |
731 break; | |
732 } | |
733 | |
224 | 734 |
735 pRndItemsTXT_Raw = NULL; | |
736 uAllItemsCount = item_counter; | |
737 pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); | |
738 strtok(pRndItemsTXT_Raw, "\r"); | |
739 strtok(NULL, "\r"); | |
740 strtok(NULL, "\r"); | |
741 strtok(NULL, "\r"); | |
742 item_counter = 0; | |
743 while (true) | |
744 { | |
745 test_string = strtok(NULL, "\r") + 1; | |
746 break_loop = false; | |
747 decode_step=0; | |
748 do | |
749 { | |
750 c = *(unsigned char*)test_string; | |
751 temp_str_len = 0; | |
752 while((c!='\t')&&(c>0)) | |
753 { | |
754 ++temp_str_len; | |
755 c=test_string[temp_str_len]; | |
756 } | |
757 tmp_pos=test_string+temp_str_len; | |
758 if (*tmp_pos == 0) | |
759 break_loop = true; | |
760 *tmp_pos = 0; | |
761 if (temp_str_len) | |
762 { | |
763 switch (decode_step) | |
764 { | |
765 case 0: | |
766 item_counter=atoi(test_string); | |
767 break; | |
768 case 2: | |
769 pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string); | |
770 break; | |
771 case 3: | |
772 pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string); | |
773 break; | |
774 case 4: | |
775 pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string); | |
776 break; | |
777 case 5: | |
778 pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string); | |
779 break; | |
780 case 6: | |
781 pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string); | |
782 break; | |
783 case 7: | |
784 pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string); | |
785 break; | |
786 } | |
787 } | |
788 else | |
789 { | |
790 if (!decode_step) | |
791 break_loop = true; | |
792 } | |
793 ++decode_step; | |
794 test_string=tmp_pos+1; | |
795 } while ((decode_step<8)&&!break_loop); | |
796 ++item_counter; | |
797 if (item_counter>618) | |
798 break; | |
799 } | |
800 | |
801 if ( pRndItemsTXT_Raw ) | |
802 { | |
803 pAllocator->FreeChunk(pRndItemsTXT_Raw); | |
804 pRndItemsTXT_Raw = NULL; | |
805 } | |
806 //ChanceByTreasureLvl Summ - anti cheating? | |
807 memset(&uChanceByTreasureLvlSumm, 0, 24); | |
808 for(i=0;i<6;++i) | |
809 { | |
810 for (j=0;j<800;++j) | |
811 uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i]; | |
812 } | |
222 | 813 |
224 | 814 strtok(NULL, "\r"); |
815 strtok(NULL, "\r"); | |
816 strtok(NULL, "\r"); | |
817 strtok(NULL, "\r"); | |
818 strtok(NULL, "\r"); | |
819 for (i=0;i<3;++i) | |
820 { | |
821 test_string = strtok(NULL, "\r") + 1; | |
822 break_loop = false; | |
823 decode_step=0; | |
824 do | |
825 { | |
826 c = *(unsigned char*)test_string; | |
827 temp_str_len = 0; | |
828 while((c!='\t')&&(c>0)) | |
829 { | |
830 ++temp_str_len; | |
831 c=test_string[temp_str_len]; | |
832 } | |
833 tmp_pos=test_string+temp_str_len; | |
834 if (*tmp_pos == 0) | |
835 break_loop = true; | |
836 *tmp_pos = 0; | |
837 if (temp_str_len) | |
838 { | |
839 switch (decode_step) | |
840 { | |
841 case 2: | |
842 switch (i) | |
843 { | |
844 case 0: | |
845 uBonusChanceStandart[0]=atoi(test_string); | |
846 break; | |
847 case 1: | |
848 uBonusChanceSpecial[0]=atoi(test_string); | |
849 break; | |
850 case 2: | |
851 uBonusChanceWpSpecial[0]=atoi(test_string); | |
852 break; | |
853 } | |
854 break; | |
855 case 3: | |
856 switch (i) | |
857 { | |
858 case 0: | |
859 uBonusChanceStandart[1]=atoi(test_string); | |
860 break; | |
861 case 1: | |
862 uBonusChanceSpecial[1]=atoi(test_string); | |
863 break; | |
864 case 2: | |
865 uBonusChanceWpSpecial[1]=atoi(test_string); | |
866 break; | |
867 } | |
868 break; | |
869 case 4: | |
870 switch (i) | |
871 { | |
872 case 0: | |
873 uBonusChanceStandart[2]=atoi(test_string); | |
874 break; | |
875 case 1: | |
876 uBonusChanceSpecial[2]=atoi(test_string); | |
877 break; | |
878 case 2: | |
879 uBonusChanceWpSpecial[2]=atoi(test_string); | |
880 break; | |
881 } | |
882 break; | |
883 case 5: | |
884 switch (i) | |
885 { | |
886 case 0: | |
887 uBonusChanceStandart[3]=atoi(test_string); | |
888 break; | |
889 case 1: | |
890 uBonusChanceSpecial[3]=atoi(test_string); | |
891 break; | |
892 case 2: | |
893 uBonusChanceWpSpecial[3]=atoi(test_string); | |
894 break; | |
895 } | |
896 break; | |
897 case 6: | |
898 switch (i) | |
899 { | |
900 case 0: | |
901 uBonusChanceStandart[4]=atoi(test_string); | |
902 break; | |
903 case 1: | |
904 uBonusChanceSpecial[4]=atoi(test_string); | |
905 break; | |
906 case 2: | |
907 uBonusChanceWpSpecial[4]=atoi(test_string); | |
908 break; | |
909 } | |
910 break; | |
911 case 7: | |
912 switch (i) | |
913 { | |
914 case 0: | |
915 uBonusChanceStandart[5]=atoi(test_string); | |
916 break; | |
917 case 1: | |
918 uBonusChanceSpecial[5]=atoi(test_string); | |
919 break; | |
920 case 2: | |
921 uBonusChanceWpSpecial[5]=atoi(test_string); | |
922 break; | |
923 } | |
924 break; | |
925 } | |
926 } | |
927 else | |
928 { | |
929 if (!decode_step) | |
930 break_loop = true; | |
931 } | |
932 ++decode_step; | |
933 test_string=tmp_pos+1; | |
934 } while ((decode_step<8)&&!break_loop); | |
935 } | |
222 | 936 |
224 | 937 pSkillDescTXT_Raw = NULL; |
938 pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); | |
939 strtok(pSkillDescTXT_Raw, "\r"); | |
940 for (i=0; i<37; ++i) | |
941 { | |
942 test_string = strtok(NULL, "\r") + 1; | |
943 break_loop = false; | |
944 decode_step=0; | |
945 do | |
946 { | |
947 c = *(unsigned char*)test_string; | |
948 temp_str_len = 0; | |
949 while((c!='\t')&&(c>0)) | |
950 { | |
951 ++temp_str_len; | |
952 c=test_string[temp_str_len]; | |
953 } | |
954 tmp_pos=test_string+temp_str_len; | |
955 if (*tmp_pos == 0) | |
956 break_loop = true; | |
957 *tmp_pos = 0; | |
958 if (temp_str_len) | |
959 { | |
960 switch (decode_step) | |
961 { | |
962 case 1: | |
963 pSkillDesc[i] = RemoveQuotes(test_string); | |
964 break; | |
965 case 2: | |
966 pNormalSkillDesc[i] = RemoveQuotes(test_string); | |
967 break; | |
968 case 3: | |
969 pExpertSkillDesc[i] = RemoveQuotes(test_string); | |
970 break; | |
971 case 4: | |
972 pMasterSkillDesc[i] = RemoveQuotes(test_string); | |
973 break; | |
974 case 5: | |
975 pGrandSkillDesc[i] = RemoveQuotes(test_string); | |
976 break; | |
977 } | |
978 } | |
979 else | |
980 { | |
981 if (!decode_step) | |
982 break_loop = true; | |
983 } | |
984 ++decode_step; | |
985 test_string=tmp_pos+1; | |
986 } while ((decode_step<6)&&!break_loop); | |
987 } | |
988 | |
989 pStatsTXT_Raw = 0; | |
990 pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); | |
991 strtok(pStatsTXT_Raw, "\r"); | |
992 for (i=0; i<26; ++i) | |
993 { | |
994 test_string = strtok(NULL, "\r") + 1; | |
995 break_loop = false; | |
996 decode_step=0; | |
997 do | |
998 { | |
999 c = *(unsigned char*)test_string; | |
1000 temp_str_len = 0; | |
1001 while((c!='\t')&&(c>0)) | |
1002 { | |
1003 ++temp_str_len; | |
1004 c=test_string[temp_str_len]; | |
1005 } | |
1006 tmp_pos=test_string+temp_str_len; | |
1007 if (*tmp_pos == 0) | |
1008 break_loop = true; | |
1009 *tmp_pos = 0; | |
1010 if (temp_str_len) | |
1011 { | |
1012 switch (i) | |
1013 { | |
1014 case 0: | |
1015 case 1: | |
1016 case 2: | |
1017 case 3: | |
1018 case 4: | |
1019 case 5: | |
1020 case 6: | |
1021 pAttributeDescriptions[i] = RemoveQuotes(test_string); | |
1022 break; | |
1023 case 7: | |
1024 pHealthPointsAttributeDescription = RemoveQuotes(test_string); | |
1025 break; | |
1026 case 8: | |
1027 pArmourClassAttributeDescription = RemoveQuotes(test_string); | |
1028 break; | |
1029 case 9: | |
1030 pSpellPointsAttributeDescription = RemoveQuotes(test_string); | |
1031 break; | |
1032 case 10: | |
1033 pPlayerConditionAttributeDescription = RemoveQuotes(test_string); | |
1034 break; | |
1035 case 11: | |
1036 pFastSpellAttributeDescription = RemoveQuotes(test_string); | |
1037 break; | |
1038 case 12: | |
1039 pPlayerAgeAttributeDescription = RemoveQuotes(test_string); | |
1040 break; | |
1041 case 13: | |
1042 pPlayerLevelAttributeDescription = RemoveQuotes(test_string); | |
1043 break; | |
1044 case 14: | |
1045 pPlayerExperienceAttributeDescription = RemoveQuotes(test_string); | |
1046 break; | |
1047 case 15: | |
1048 pAttackBonusAttributeDescription = RemoveQuotes(test_string); | |
1049 break; | |
1050 case 16: | |
1051 pAttackDamageAttributeDescription = RemoveQuotes(test_string); | |
1052 break; | |
1053 case 17: | |
1054 pMissleBonusAttributeDescription = RemoveQuotes(test_string); | |
1055 break; | |
1056 case 18: | |
1057 pMissleDamageAttributeDescription = RemoveQuotes(test_string); | |
1058 break; | |
1059 case 19: | |
1060 pFireResistanceAttributeDescription = RemoveQuotes(test_string); | |
1061 break; | |
1062 case 20: | |
1063 pAirResistanceAttributeDescription = RemoveQuotes(test_string); | |
1064 break; | |
1065 case 21: | |
1066 pWaterResistanceAttributeDescription = RemoveQuotes(test_string); | |
1067 break; | |
1068 case 22: | |
1069 pEarthResistanceAttributeDescription = RemoveQuotes(test_string); | |
1070 break; | |
1071 case 23: | |
1072 pMindResistanceAttributeDescription = RemoveQuotes(test_string); | |
1073 break; | |
1074 case 24: | |
1075 pBodyResistanceAttributeDescription = RemoveQuotes(test_string); | |
1076 break; | |
1077 case 25: | |
1078 pSkillPointsAttributeDescription = RemoveQuotes(test_string); | |
1079 break; | |
1080 } | |
1081 } | |
1082 else | |
1083 { | |
1084 if (!decode_step) | |
1085 break_loop = true; | |
1086 } | |
1087 ++decode_step; | |
1088 test_string=tmp_pos+1; | |
1089 } while ((decode_step<2)&&!break_loop); | |
1090 } | |
222 | 1091 |
1092 | |
224 | 1093 pClassTXT_Raw = 0; |
1094 pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); | |
1095 strtok(pClassTXT_Raw, "\r"); | |
1096 for (i=0; i<36; ++i) | |
1097 { | |
1098 test_string = strtok(NULL, "\r") + 1; | |
1099 break_loop = false; | |
1100 decode_step=0; | |
1101 do | |
1102 { | |
1103 c = *(unsigned char*)test_string; | |
1104 temp_str_len = 0; | |
1105 while((c!='\t')&&(c>0)) | |
1106 { | |
1107 ++temp_str_len; | |
1108 c=test_string[temp_str_len]; | |
1109 } | |
1110 tmp_pos=test_string+temp_str_len; | |
1111 if (*tmp_pos == 0) | |
1112 break_loop = true; | |
1113 *tmp_pos = 0; | |
1114 if (temp_str_len) | |
1115 { | |
229 | 1116 //if(i) |
224 | 1117 pClassDescriptions[i]=RemoveQuotes(test_string); |
1118 } | |
1119 else | |
1120 { | |
1121 if (!decode_step) | |
1122 break_loop = true; | |
1123 } | |
1124 ++decode_step; | |
1125 test_string=tmp_pos+1; | |
1126 } while ((decode_step<2)&&!break_loop); | |
1127 } | |
222 | 1128 |
224 | 1129 } |
0 | 1130 |
1131 //----- (00456D17) -------------------------------------------------------- | |
1132 void ItemsTable::SetSpecialBonus(ItemGen *pItem) | |
1133 { | |
385 | 1134 if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) |
0 | 1135 { |
385 | 1136 pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type; |
1137 pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; | |
1138 pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength; | |
0 | 1139 } |
1140 } | |
1141 | |
1142 //----- (00456D43) -------------------------------------------------------- | |
377 | 1143 bool ItemsTable::IsMaterialSpecial(ItemGen *pItem) |
0 | 1144 { |
377 | 1145 return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL; |
0 | 1146 } |
1147 | |
1148 //----- (00456D5E) -------------------------------------------------------- | |
377 | 1149 bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem) |
0 | 1150 { |
385 | 1151 return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL || |
1152 pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC || | |
1153 pItems[pItem->uItemID].uMaterial == MATERIAL_ARTEFACT; | |
0 | 1154 } |
1155 | |
1156 | |
1157 //----- (00453B3C) -------------------------------------------------------- | |
1158 void ItemsTable::LoadPotions() | |
222 | 1159 { |
0 | 1160 |
222 | 1161 CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26 |
1162 char* test_string; | |
1163 unsigned int uRow; | |
1164 unsigned int uColumn; | |
1165 unsigned __int8 potion_value; | |
1166 | |
1167 if ( pPotionsTXT_Raw ) | |
1168 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
1169 pPotionsTXT_Raw = NULL; | |
1170 pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); | |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1171 test_string = strtok(pPotionsTXT_Raw,"\t\r\n"); |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1172 while ( 1 ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1173 { |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1174 if ( !test_string ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1175 { |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1176 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1177 return; |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1178 } |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1179 if ( !strcmp(test_string, "222") ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1180 break; |
222 | 1181 |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1182 test_string = strtok(NULL, "\t\r\n"); |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1183 } |
222 | 1184 while ( 1 ) |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1185 { |
222 | 1186 test_string = strtok(NULL, "\t\r\n"); |
1187 | |
1188 if ( !test_string ) | |
1189 { | |
1190 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1191 return; | |
1192 } | |
1193 if ( !strcmp(test_string, "222") ) | |
1194 break; | |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1195 } |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1196 |
222 | 1197 for (uRow = 0;uRow < 50; ++uRow) |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1198 { |
222 | 1199 int skip_count; |
1200 for (skip_count = 0;skip_count < 6; ++skip_count) | |
1201 { | |
1202 if ( !strtok(NULL, "\r\t\n") ) | |
1203 break; | |
1204 } | |
1205 if ( skip_count != 6 ) | |
1206 break; | |
1207 for (uColumn = 0; uColumn < 50; ++uColumn) | |
1208 { | |
1209 test_string = strtok(NULL, "\r\t\n"); | |
1210 if ( !test_string ) | |
1211 break; | |
1212 potion_value = atoi(test_string); | |
233 | 1213 unsigned char c=*test_string; |
222 | 1214 if ( !potion_value ) |
1215 { | |
1216 if ( tolower(c) == 'e' ) | |
1217 potion_value = atoi(test_string + 1); | |
1218 else | |
1219 potion_value = 0; | |
1220 } | |
1221 this->potion_data[uRow][uColumn]=potion_value; | |
1222 } | |
1223 if ( uColumn != 50 ) | |
1224 break; | |
1225 strtok(NULL, "\r\t\n"); | |
1226 } | |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1227 |
222 | 1228 if ( uRow != 50 ) |
1229 { | |
1230 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); | |
1231 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1232 } | |
1233 if ( pPotionsTXT_Raw ) | |
1234 { | |
1235 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
1236 pPotionsTXT_Raw = 0; | |
1237 } | |
1238 } | |
0 | 1239 |
1240 //----- (00453CE5) -------------------------------------------------------- | |
1241 void ItemsTable::LoadPotionNotes() | |
222 | 1242 { |
1243 | |
1244 CHAR Text[90]; | |
1245 char* test_string; | |
1246 unsigned int uRow; | |
1247 unsigned int uColumn; | |
1248 unsigned __int8 potion_note; | |
1249 | |
1250 if ( pPotionNotesTXT_Raw ) | |
1251 pAllocator->FreeChunk(pPotionNotesTXT_Raw); | |
1252 pPotionNotesTXT_Raw = NULL; | |
1253 pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); | |
1254 test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); | |
1255 while ( 1 ) | |
1256 { | |
1257 if ( !test_string ) | |
1258 { | |
1259 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1260 return; | |
1261 } | |
1262 if ( !strcmp(test_string, "222") ) | |
1263 break; | |
1264 test_string = strtok(NULL, "\t\r\n"); | |
1265 } | |
1266 while ( 1 ) | |
1267 { | |
1268 test_string = strtok(NULL, "\t\r\n"); | |
1269 | |
1270 if ( !test_string ) | |
1271 { | |
1272 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1273 return; | |
1274 } | |
1275 if ( !strcmp(test_string, "222") ) | |
1276 break; | |
1277 } | |
0 | 1278 |
222 | 1279 for (uRow = 0;uRow < 50; ++uRow) |
1280 { | |
1281 int skip_count; | |
1282 for (skip_count = 0;skip_count < 6; ++skip_count) | |
1283 { | |
1284 if ( !strtok(NULL, "\r\t\n") ) | |
1285 break; | |
1286 } | |
1287 if ( skip_count != 6 ) | |
1288 break; | |
1289 for (uColumn = 0; uColumn < 50; ++uColumn) | |
1290 { | |
1291 test_string = strtok(NULL, "\r\t\n"); | |
1292 if ( !test_string ) | |
1293 break; | |
1294 potion_note = atoi(test_string); | |
233 | 1295 unsigned char c=*test_string; |
222 | 1296 if ( !potion_note ) |
1297 { | |
1298 if ( tolower(c) == 'e' ) | |
1299 potion_note = atoi(test_string + 1); | |
1300 else | |
1301 potion_note = 0; | |
1302 } | |
1303 this->potion_note[uRow][uColumn]=potion_note; | |
1304 } | |
1305 if ( uColumn != 50 ) | |
1306 break; | |
1307 strtok(NULL, "\r\t\n"); | |
1308 } | |
1309 if ( uRow != 50 ) | |
1310 { | |
1311 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); | |
1312 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1313 } | |
1314 } | |
0 | 1315 |
1316 | |
1317 //----- (00456442) -------------------------------------------------------- | |
1318 unsigned int ItemGen::GetValue() | |
1319 { | |
1320 ItemGen *v1; // esi@1 | |
1321 unsigned int uBaseValue; // edi@1 | |
1322 int v3; // eax@4 | |
1323 int v4; // esi@5 | |
1324 unsigned int result; // eax@7 | |
1325 | |
1326 v1 = this; | |
1327 uBaseValue = pItemsTable->pItems[this->uItemID].uValue; | |
377 | 1328 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) |
243 | 1329 return uBaseValue; |
377 | 1330 if ( v1->uEncantmentType ) |
0 | 1331 { |
1332 v3 = 100 * v1->_bonus_strength; | |
1333 return uBaseValue + v3; | |
1334 } | |
377 | 1335 v4 = v1->uSpecEnchantmentType; |
0 | 1336 if ( !v4 ) |
1337 { | |
1338 result = uBaseValue; | |
1339 } | |
1340 else | |
1341 { | |
243 | 1342 v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel; |
0 | 1343 if ( (unsigned int)v3 > 0xA ) |
1344 return uBaseValue + v3; | |
1345 result = uBaseValue * v3; | |
1346 } | |
1347 return result; | |
1348 } | |
1349 | |
1350 //----- (00456499) -------------------------------------------------------- | |
1351 const char *ItemGen::GetDisplayName() | |
1352 { | |
366 | 1353 if (Identified()) |
1354 return GetIdentifiedName(); | |
0 | 1355 else |
366 | 1356 return pItemsTable->pItems[uItemID].pUnidentifiedName; |
0 | 1357 } |
1358 | |
1359 //----- (004564B3) -------------------------------------------------------- | |
1360 const char *ItemGen::GetIdentifiedName() | |
1361 { | |
377 | 1362 unsigned __int8 equip_type; |
1363 const char *player_name; | |
1364 const char *nameModificator; | |
1365 const char *format_str; | |
0 | 1366 |
377 | 1367 equip_type = pItemsTable->pItems[uItemID].uEquipType; |
1368 if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) | |
0 | 1369 { |
377 | 1370 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); |
1371 return item__getname_buffer; | |
0 | 1372 } |
377 | 1373 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); |
1374 if ( uItemID == ITEM_LICH_JAR ) //Lich Jar | |
0 | 1375 { |
377 | 1376 if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) |
0 | 1377 { |
377 | 1378 player_name = pPlayers[uHolderPlayer]->pName; |
1379 strlen(player_name); | |
1380 if ( player_name[strlen(player_name) - 1] == 's' ) | |
1381 format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" | |
0 | 1382 else |
377 | 1383 format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar" |
1384 sprintf(item__getname_buffer, format_str, pPlayers[uHolderPlayer]->pName); | |
1385 return item__getname_buffer; | |
0 | 1386 } |
1387 } | |
377 | 1388 if ( !pItemsTable->IsMaterialNonCommon(this) ) |
0 | 1389 { |
377 | 1390 if ( uEncantmentType ) |
0 | 1391 { |
1392 strcat(item__getname_buffer, " "); | |
377 | 1393 nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName; |
0 | 1394 } |
1395 else | |
1396 { | |
377 | 1397 if ( !uSpecEnchantmentType ) |
1398 return item__getname_buffer; | |
1399 if ( uSpecEnchantmentType == 16 //Drain Hit Points from target. | |
1400 || uSpecEnchantmentType == 39 //Double damage vs Demons. | |
1401 || uSpecEnchantmentType == 40 //Double damage vs Dragons | |
1402 || uSpecEnchantmentType == 45 //+5 Speed and Accuracy | |
1403 || uSpecEnchantmentType == 56 //+5 Might and Endurance. | |
1404 || uSpecEnchantmentType == 57 //+5 Intellect and Personality. | |
1405 || uSpecEnchantmentType == 58 //Increased Value. | |
1406 || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills | |
1407 || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills. | |
1408 || uSpecEnchantmentType == 59 //Increased Weapon speed. | |
1409 || uSpecEnchantmentType == 63 //Double Damage vs. Elves. | |
1410 || uSpecEnchantmentType == 64 //Double Damage vs. Undead. | |
1411 || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill. | |
1412 || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class. | |
1413 { //enchantment and name positions inverted! | |
1414 sprintf( item__getname_buffer, "%s %s", | |
1415 pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd, | |
1416 pItemsTable->pItems[uItemID].pName); | |
1417 return item__getname_buffer; | |
0 | 1418 } |
1419 strcat(item__getname_buffer, " "); | |
377 | 1420 nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd; |
0 | 1421 } |
377 | 1422 strcat(item__getname_buffer, nameModificator); |
0 | 1423 } |
377 | 1424 return item__getname_buffer; |
0 | 1425 } |
1426 | |
1427 | |
1428 //----- (00456620) -------------------------------------------------------- | |
385 | 1429 void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item) |
0 | 1430 { |
294 | 1431 |
1432 ItemGen *v4; // esi@1 | |
1433 ItemsTable *v5; // edi@1 | |
0 | 1434 int v6; // ebx@3 |
1435 int *v7; // ecx@33 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1436 //int v8; // eax@34 |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1437 //int v9; // eax@39 |
0 | 1438 int v10; // ebx@43 |
1439 int v11; // ecx@47 | |
1440 unsigned int *v12; // edx@48 | |
1441 unsigned int v13; // eax@49 | |
1442 signed int v14; // ebx@52 | |
1443 int v15; // eax@53 | |
1444 signed int v16; // eax@55 | |
1445 int v17; // ebx@57 | |
1446 int v18; // edx@62 | |
1447 signed int v19; // ebx@70 | |
1448 unsigned __int8 v20; // al@81 | |
1449 int v21; // eax@84 | |
1450 int v22; // ebx@85 | |
1451 int v23; // eax@86 | |
1452 int v24; // ebx@86 | |
1453 int v25; // edx@86 | |
1454 int v26; // edx@89 | |
1455 unsigned int v27; // eax@89 | |
1456 int i; // ebx@89 | |
1457 unsigned int v29; // ecx@90 | |
1458 int v30; // ebx@91 | |
1459 int v31; // eax@91 | |
1460 int v32; // ecx@91 | |
1461 int v33; // eax@91 | |
1462 int v34; // eax@97 | |
1463 unsigned __int8 v35; // sf@97 | |
1464 unsigned __int8 v36; // of@97 | |
1465 int v37; // ebx@98 | |
1466 int v38; // edx@99 | |
1467 signed int v39; // ebx@101 | |
1468 int v40; // ecx@102 | |
1469 char v41; // zf@107 | |
1470 char v42; // al@108 | |
1471 char v43; // al@111 | |
1472 int *v44; // edx@118 | |
1473 int v45; // eax@120 | |
1474 int v46; // edx@120 | |
1475 int *j; // eax@121 | |
1476 unsigned int v48; // ecx@123 | |
1477 int v49; // eax@123 | |
1478 int v50; // eax@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1479 int Dst[800]; // [sp+Ch] [bp-C88h]@33 |
0 | 1480 int v52; // [sp+C8Ch] [bp-8h]@33 |
294 | 1481 int v53; // [sp+C90h] [bp-4h]@1 |
1482 int v54; // [sp+C9Ch] [bp+8h]@3 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1483 //int v55; // [sp+CA0h] [bp+Ch]@34 |
0 | 1484 signed int v56; // [sp+CA0h] [bp+Ch]@55 |
1485 int v57; // [sp+CA0h] [bp+Ch]@62 | |
1486 int *v58; // [sp+CA0h] [bp+Ch]@102 | |
1487 int v59; // [sp+CA0h] [bp+Ch]@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1488 //signed int a2a; // [sp+CA4h] [bp+10h]@33 |
0 | 1489 int a2b; // [sp+CA4h] [bp+10h]@101 |
1490 int a2c; // [sp+CA4h] [bp+10h]@120 | |
1491 | |
294 | 1492 v53 = -1; |
1493 v5 = this; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1494 if (!out_item) |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1495 out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen"); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1496 memset(out_item, 0, sizeof(*out_item)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1497 |
294 | 1498 v4 = out_item; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1499 v6 = treasure_level - 1; |
385 | 1500 v54 = treasure_level - 1; |
1501 if ( uTreasureType ) //generate known treasure type | |
0 | 1502 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1503 ITEM_EQUIP_TYPE requested_equip; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1504 PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; |
385 | 1505 switch (uTreasureType) |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1506 { |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1507 case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1508 case 21: requested_equip = EQUIP_ARMOUR; break; |
385 | 1509 case 22: requested_skill = PLAYER_SKILL_MISC; break; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1510 case 23: requested_skill = PLAYER_SKILL_SWORD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1511 case 24: requested_skill = PLAYER_SKILL_DAGGER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1512 case 25: requested_skill = PLAYER_SKILL_AXE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1513 case 26: requested_skill = PLAYER_SKILL_SPEAR; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1514 case 27: requested_skill = PLAYER_SKILL_BOW; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1515 case 28: requested_skill = PLAYER_SKILL_MACE; break; |
385 | 1516 case 29: requested_skill = PLAYER_SKILL_CLUB; break; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1517 case 30: requested_skill = PLAYER_SKILL_STAFF; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1518 case 31: requested_skill = PLAYER_SKILL_LEATHER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1519 case 32: requested_skill = PLAYER_SKILL_CHAIN; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1520 case 33: requested_skill = PLAYER_SKILL_PLATE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1521 case 34: requested_equip = EQUIP_SHIELD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1522 case 35: requested_equip = EQUIP_HELMET; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1523 case 36: requested_equip = EQUIP_BELT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1524 case 37: requested_equip = EQUIP_CLOAK; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1525 case 38: requested_equip = EQUIP_GAUNTLETS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1526 case 39: requested_equip = EQUIP_BOOTS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1527 case 40: requested_equip = EQUIP_RING; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1528 case 41: requested_equip = EQUIP_AMULET; break; |
295 | 1529 case 42: requested_equip = EQUIP_WAND; break; |
374 | 1530 case 43: requested_equip = EQUIP_SPELL_SCROLL; break; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1531 case 44: requested_equip = EQUIP_POTION; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1532 case 45: requested_equip = EQUIP_REAGENT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1533 case 46: requested_equip = EQUIP_GEM; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1534 default: |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1535 __debugbreak(); // check this condition |
385 | 1536 requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1); |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1537 break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1538 } |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1539 memset(Dst, 0, sizeof(Dst)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1540 v52 = 0; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1541 v7 = Dst; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1542 //a2a = 1; |
385 | 1543 if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed |
0 | 1544 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1545 for (uint i = 1; i < 500; ++i) |
0 | 1546 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1547 if (pItems[i].uEquipType == requested_equip) |
0 | 1548 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1549 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1550 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1551 } |
1552 } | |
1553 } | |
385 | 1554 else //have needed skill |
0 | 1555 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1556 for (uint i = 1; i < 500; ++i) |
0 | 1557 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1558 if (pItems[i].uSkillType == requested_skill) |
0 | 1559 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1560 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1561 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1562 } |
1563 } | |
1564 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1565 |
0 | 1566 v10 = 0; |
1567 if ( v52 ) | |
1568 v10 = rand() % v52; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1569 |
385 | 1570 out_item->uItemID = *Dst; |
1571 if (!out_item->uItemID) | |
1572 out_item->uItemID = 1; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1573 |
385 | 1574 v11 = pItems[out_item->uItemID].uChanceByTreasureLvl[v6]; |
0 | 1575 if ( v11 < v10 ) |
1576 { | |
1577 v12 = (uint *)Dst; | |
1578 do | |
1579 { | |
1580 ++v12; | |
1581 v13 = *v12; | |
385 | 1582 out_item->uItemID = *v12; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1583 v11 += pItems[v13].uChanceByTreasureLvl[v6]; |
0 | 1584 } |
1585 while ( v11 < v10 ); | |
1586 } | |
385 | 1587 |
1588 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | |
1589 {// if it potion set potion spec | |
1590 out_item->uEncantmentType = 0; | |
1591 for (int i=0; i<2; ++i) | |
1592 out_item->uEncantmentType += rand() % 4 + 1; | |
1593 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
0 | 1594 } |
1595 } | |
1596 else | |
1597 { | |
1598 v16 = 0; | |
1599 v56 = 0; | |
1600 do | |
1601 v56 += pParty->field_7BA[v16++]; | |
1602 while ( v16 < 29 ); | |
1603 v17 = rand() % 29; | |
385 | 1604 |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1605 if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) |
0 | 1606 { |
1607 pParty->field_7BA[v17] = 1; | |
385 | 1608 out_item->uAttributes = 0; |
1609 out_item->uItemID = v17 + 500; | |
1610 SetSpecialBonus(out_item); | |
0 | 1611 return; |
1612 } | |
385 | 1613 |
0 | 1614 v57 = 0; |
294 | 1615 v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54]; |
385 | 1616 out_item->uItemID = 0; |
0 | 1617 if ( v18 > 0 ) |
1618 { | |
1619 do | |
385 | 1620 v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; |
0 | 1621 while ( v57 < v18 ); |
1622 } | |
385 | 1623 |
0 | 1624 if ( !v18 ) |
385 | 1625 out_item->uItemID = 1; |
1626 if ( !out_item->uItemID ) | |
1627 out_item->uItemID = 1; | |
1628 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | |
1629 {// if it potion set potion spec | |
1630 out_item->uEncantmentType = 0; | |
1631 for (int i=0; i<2; ++i) | |
1632 out_item->uEncantmentType += rand() % 4 + 1; | |
1633 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
1634 } | |
1635 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
0 | 1636 } |
1637 if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION | |
1638 && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) | |
1639 v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; | |
222 | 1640 if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St ) |
0 | 1641 v4->uAttributes = 0; |
1642 else | |
1643 v4->uAttributes = 1; | |
385 | 1644 if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) |
0 | 1645 { |
385 | 1646 out_item->uSpecEnchantmentType = 0; |
1647 out_item->uEncantmentType = 0; | |
0 | 1648 } |
385 | 1649 v20 = pItems[out_item->uItemID].uEquipType; |
0 | 1650 if ( v20 <= EQUIP_BOW ) |
1651 { | |
294 | 1652 v37 = v5->uBonusChanceWpSpecial[v54]; |
436 | 1653 if ( !v37 ) |
0 | 1654 return; |
1655 v38 = rand() % 100; | |
436 | 1656 v36 = __OFSUB__(v38, v37); |
1657 v35 = v38 - v37 < 0; | |
0 | 1658 } |
1659 else | |
1660 { | |
1661 if ( v20 > EQUIP_AMULET ) | |
1662 { | |
295 | 1663 if ( v20 == EQUIP_WAND ) |
0 | 1664 { |
1665 v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; | |
385 | 1666 out_item->uNumCharges = v21; |
1667 out_item->uMaxCharges = v21; | |
0 | 1668 } |
1669 return; | |
1670 } | |
436 | 1671 v22 = uBonusChanceStandart[v6]; |
1672 if ( !v22 ) | |
0 | 1673 return; |
436 | 1674 v24 = v22; |
385 | 1675 v25 = rand() % 100; |
1676 if ( !uBonusChanceSpecial[v6] && !(v25 < v24)) | |
224 | 1677 return; |
385 | 1678 if ( v25 < v24 || v25 < v24) |
0 | 1679 { |
385 | 1680 v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[v4->uItemID].uEquipType + 3]; |
0 | 1681 v27 = v4->uItemID; |
377 | 1682 v4->uEncantmentType = 0; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1683 for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; |
0 | 1684 i < v26; |
377 | 1685 i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] ) |
0 | 1686 { |
1687 v29 = v4->uItemID; | |
377 | 1688 ++v4->uEncantmentType; |
0 | 1689 } |
377 | 1690 ++v4->uEncantmentType; |
224 | 1691 v30 = 10;// v5->field_116D8[2 * v54 + 12]; |
0 | 1692 v31 = rand(); |
377 | 1693 v32 = v4->uEncantmentType - 1; |
224 | 1694 v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; |
0 | 1695 v4->_bonus_strength = v33; |
1696 if ( v32 == 21 || v32 == 22 || v32 == 23 ) | |
1697 v4->_bonus_strength = v33 >> 1; | |
1698 if ( v4->_bonus_strength <= 0 ) | |
1699 v4->_bonus_strength = 1; | |
1700 return; | |
1701 } | |
224 | 1702 v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24]; |
0 | 1703 v36 = __OFSUB__(v25, v34); |
1704 v35 = v25 - v34 < 0; | |
1705 } | |
1706 if ( !(v35 ^ v36) ) | |
1707 return; | |
1708 memset(&Dst, 0, 0xC80u); | |
1709 v39 = 0; | |
1710 a2b = 0; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1711 if ( pSpecialEnchantments_count > 0 ) |
0 | 1712 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1713 v52 = -16 - (uint)this; |
0 | 1714 v58 = (int *)&Dst; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1715 v40 = (int)&pSpecialEnchantments[1]; |
0 | 1716 do |
1717 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1718 switch ( v6 ) |
0 | 1719 { |
1720 case 2: | |
1721 if ( !*(unsigned char *)v40 ) | |
245 | 1722 { |
1723 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1724 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1725 { | |
1726 v44 = v58; | |
1727 ++v58; | |
1728 *v44 = a2b; | |
1729 } | |
1730 ++a2b; | |
1731 v40 += 28; | |
1732 continue; | |
1733 } | |
0 | 1734 v41 = *(unsigned char *)v40 == 1; |
1735 break; | |
1736 case 3: | |
1737 v43 = *(unsigned char *)v40; | |
1738 if ( !*(unsigned char *)v40 || v43 == 1 ) | |
1739 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1740 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1741 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) |
0 | 1742 { |
1743 v44 = v58; | |
1744 ++v58; | |
1745 *v44 = a2b; | |
1746 } | |
245 | 1747 ++a2b; |
1748 v40 += 28; | |
1749 continue; | |
0 | 1750 } |
1751 v41 = v43 == 2; | |
1752 break; | |
1753 case 4: | |
1754 v42 = *(unsigned char *)v40; | |
1755 if ( *(unsigned char *)v40 == 1 || v42 == 2 ) | |
245 | 1756 { |
1757 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1758 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1759 { | |
1760 v44 = v58; | |
1761 ++v58; | |
1762 *v44 = a2b; | |
1763 } | |
1764 ++a2b; | |
1765 v40 += 28; | |
1766 continue; | |
1767 } | |
0 | 1768 v41 = v42 == 3; |
1769 break; | |
1770 default: | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1771 if ( v6 != 5 ) |
245 | 1772 { |
1773 ++a2b; | |
1774 v40 += 28; | |
1775 continue; | |
1776 } | |
0 | 1777 v41 = *(unsigned char *)v40 == 3; |
1778 break; | |
1779 } | |
1780 if ( v41 ) | |
245 | 1781 { |
1782 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1783 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1784 { | |
1785 v44 = v58; | |
1786 ++v58; | |
1787 *v44 = a2b; | |
1788 } | |
1789 } | |
0 | 1790 LABEL_119: |
1791 ++a2b; | |
1792 v40 += 28; | |
1793 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1794 while ( a2b < pSpecialEnchantments_count ); |
0 | 1795 } |
1796 v45 = rand(); | |
377 | 1797 v4->uSpecEnchantmentType = *(uint *)Dst; |
0 | 1798 v46 = v45 % v39 + 1; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1799 a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); |
0 | 1800 if ( a2c < v46 ) |
1801 { | |
1802 for ( j = (int *)&Dst; ; j = (int *)v59 ) | |
1803 { | |
1804 v48 = v4->uItemID; | |
1805 v49 = (int)(j + 1); | |
1806 v59 = v49; | |
1807 v50 = *(unsigned int *)v49; | |
377 | 1808 v4->uSpecEnchantmentType = v50; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1809 a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); |
0 | 1810 if ( a2c >= v46 ) |
1811 break; | |
1812 } | |
1813 } | |
377 | 1814 ++v4->uSpecEnchantmentType; |
0 | 1815 } |
1816 | |
1817 //----- (004505CC) -------------------------------------------------------- | |
1818 bool ItemGen::GenerateArtifact() | |
1819 { | |
1820 ItemGen *v1; // edi@1 | |
1821 signed int uNumArtifactsNotFound; // esi@1 | |
1822 int v3; // eax@1 | |
1823 bool result; // eax@6 | |
385 | 1824 int artifacts_list[32]; // [sp+8h] [bp-A0h]@3 |
0 | 1825 char Dst[32]; // [sp+88h] [bp-20h]@1 |
1826 | |
1827 auto a2 = this; | |
1828 v1 = a2; | |
385 | 1829 memset(artifacts_list, 0,sizeof(artifacts_list)); |
0 | 1830 uNumArtifactsNotFound = 0; |
385 | 1831 |
1832 for (int i=500;i<529;++i) | |
1833 if ( !pParty->field_3C.pIsArtifactFound[i] ) | |
1834 artifacts_list[uNumArtifactsNotFound++] = i; | |
1835 | |
1836 Reset(); | |
0 | 1837 if ( uNumArtifactsNotFound ) |
1838 { | |
385 | 1839 uItemID = artifacts_list[rand() % uNumArtifactsNotFound]; |
1840 pItemsTable->SetSpecialBonus(this); | |
1841 return true; | |
0 | 1842 } |
1843 else | |
385 | 1844 return false; |
1845 | |
0 | 1846 } |
461 | 1847 //----- (004B8E3D) -------------------------------------------------------- |
1848 void *__cdecl GenerateShopItems() | |
1849 { | |
1850 GUIWindow *v0; // eax@1 | |
1851 signed int v1; // edi@1 | |
1852 signed int v2; // esi@1 | |
1853 int v3; // ecx@3 | |
1854 int v4; // ebx@3 | |
1855 int v5; // ecx@3 | |
1856 bool v6; // ebp@5 | |
1857 int v7; // ecx@5 | |
1858 void *result; // eax@15 | |
1859 signed int v9; // [sp-Ch] [bp-14h]@7 | |
1860 | |
1861 v0 = window_SpeakInHouse; | |
1862 v1 = 0; | |
1863 v2 = (signed int)window_SpeakInHouse->ptr_1C; | |
1864 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) | |
1865 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) | |
1866 { | |
1867 while ( v2 > 14 ) | |
1868 { | |
1869 if ( v2 <= 28 ) | |
1870 { | |
1871 v6 = v1 > 3; | |
1872 v7 = v6 + 2 * v2 - 30; | |
1873 v2 = (signed int)v0->ptr_1C; | |
1874 v4 = word_4F0498[5 * v7]; | |
1875 __debugbreak(); | |
1876 //things happen around word_4F0400 actually | |
1877 //v5 = *(short *)&aTooManyStation[2 * (5 * (v6 + 2 * v2) + rand() % 4) + 10]; | |
1878 goto LABEL_13; | |
1879 } | |
1880 if ( v2 <= 41 ) | |
1881 { | |
1882 v4 = word_4F0576[v2]; | |
1883 v9 = 22; //misc | |
1884 goto LABEL_12; | |
1885 } | |
1886 if ( v2 <= 53 ) | |
1887 { | |
1888 if ( v1 >= 6 ) | |
1889 { | |
1890 v4 = word_4F0578[v2]; | |
1891 v9 = 45; //reagent | |
1892 LABEL_12: | |
1893 v5 = v9; | |
1894 LABEL_13: | |
1895 pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]); | |
1896 v0 = window_SpeakInHouse; | |
1897 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1; //identified | |
1898 goto LABEL_14; | |
1899 } | |
1900 auto _t = (ItemGen *)&pParty->field_777C[v2][v1]; | |
1901 _t->Reset(); | |
1902 v0 = window_SpeakInHouse; | |
1903 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220; //potion bottle | |
1904 } | |
1905 LABEL_14: | |
1906 v2 = (signed int)v0->ptr_1C; | |
1907 ++v1; | |
1908 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v0->ptr_1C]] ) | |
1909 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v0->ptr_1C - 1].uType] ) | |
1910 goto LABEL_15; | |
1911 } | |
1912 v3 = 5 * v2; | |
1913 v2 = (signed int)v0->ptr_1C; | |
1914 v4 = word_4F0404[v3 - 4]; | |
1915 v5 = word_4F0404[5 * v2 + rand() % 4 - 2]; | |
1916 goto LABEL_13; | |
1917 } | |
1918 LABEL_15: | |
1919 result = v0->ptr_1C; | |
1920 *(int *)&pParty->field_16154[4 * (int)result] = 0; | |
1921 return result; | |
1922 } | |
1923 | |
1924 //----- (004B8F94) -------------------------------------------------------- | |
1925 void sub_4B8F94() | |
1926 { | |
1927 GUIWindow *v0; // edi@1 | |
1928 signed int v1; // ebp@1 | |
1929 int v2; // ebx@1 | |
1930 signed int v3; // esi@1 | |
1931 int v4; // eax@3 | |
1932 int v5; // ebx@3 | |
1933 int v6; // ecx@3 | |
1934 bool v7; // eax@5 | |
1935 bool v8; // ST1C_4@5 | |
1936 int v9; // eax@5 | |
1937 int v10; // eax@10 | |
1938 void *result; // eax@15 | |
1939 signed int v12; // [sp-4h] [bp-18h]@7 | |
1940 | |
1941 v0 = window_SpeakInHouse; | |
1942 v1 = 0; | |
1943 v2 = (int)&window_SpeakInHouse->ptr_1C; | |
1944 v3 = (signed int)window_SpeakInHouse->ptr_1C; | |
1945 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) | |
1946 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) | |
1947 { | |
1948 while ( v3 > 14 ) | |
1949 { | |
1950 if ( v3 <= 28 ) | |
1951 { | |
1952 v7 = v1 > 3; | |
1953 v8 = v7; | |
1954 v9 = 5 * (v7 + 2 * v3 - 30); | |
1955 v3 = (signed int)v0->ptr_1C; | |
1956 v5 = word_4F06D8[v9]; | |
1957 v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4]; | |
1958 goto LABEL_13; | |
1959 } | |
1960 if ( v3 <= 41 ) | |
1961 { | |
1962 v5 = word_4F07B6[v3]; | |
1963 v12 = 22; | |
1964 goto LABEL_12; | |
1965 } | |
1966 if ( v3 <= 53 ) | |
1967 { | |
1968 if ( v1 >= 6 ) | |
1969 { | |
1970 v5 = word_4F07B6[v3 + 1]; | |
1971 v12 = 44; | |
1972 LABEL_12: | |
1973 v6 = v12; | |
1974 LABEL_13: | |
1975 pItemsTable->GenerateItem(v5, v6,&pParty->Recipes_Item[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]); | |
1976 v0 = window_SpeakInHouse; | |
1977 v2 = (int)&window_SpeakInHouse->ptr_1C; | |
1978 // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1; | |
1979 pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1; | |
1980 goto LABEL_14; | |
1981 } | |
1982 // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]; | |
1983 auto _a =&pParty->Recipes_Item[v3][v1]; | |
1984 _a->Reset(); | |
1985 // v2 = (int)&v0->ptr_1C; | |
1986 //v10 = rand(); | |
1987 // v0 = window_SpeakInHouse; | |
1988 // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740; | |
1989 pParty->Recipes_Item[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740; | |
1990 } | |
1991 LABEL_14: | |
1992 v3 = *(int *)v2; | |
1993 ++v1; | |
1994 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] ) | |
1995 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[*(int *)v2 - 1].uType] ) | |
1996 goto LABEL_15; | |
1997 } | |
1998 v4 = 5 * v3; | |
1999 v3 = (signed int)v0->ptr_1C; | |
2000 v5 = word_4F063E[v4]; | |
2001 v6 = word_4F063E[5 * v3 + rand() % 4 + 1]; | |
2002 goto LABEL_13; | |
2003 } | |
2004 LABEL_15: | |
2005 result = v0->ptr_1C; | |
2006 pParty->field_16154[(int)v0->ptr_1C] = 0; | |
2007 } | |
2008 | |
2009 | |
2010 //----- (00450218) -------------------------------------------------------- | |
2011 void __cdecl sub_450218_prolly_generate_chests_loot() | |
2012 { | |
2013 unsigned int v0; // eax@1 | |
2014 Chest *v1; // ebx@1 | |
2015 MapInfo *v2; // esi@1 | |
2016 ItemGen *v3; // ebx@2 | |
2017 int v4; // ebp@4 | |
2018 int v5; // edi@4 | |
2019 int v6; // esi@4 | |
2020 int v7; // eax@4 | |
2021 signed int v8; // esi@4 | |
2022 int v9; // edx@4 | |
2023 int v10; // esi@8 | |
2024 int v11; // ebp@25 | |
2025 int v12; // esi@25 | |
2026 signed int v13; // ebp@27 | |
2027 ItemGen *v14; // edi@28 | |
2028 signed int v15; // edx@32 | |
2029 signed __int64 v16; // qtt@32 | |
2030 int v17; // esi@34 | |
2031 signed int v18; // [sp+10h] [bp-18h]@1 | |
2032 int v19; // [sp+14h] [bp-14h]@4 | |
2033 MapInfo *v20; // [sp+18h] [bp-10h]@1 | |
2034 Chest *v21; // [sp+1Ch] [bp-Ch]@1 | |
2035 int v22; // [sp+20h] [bp-8h]@26 | |
2036 signed int v23; // [sp+24h] [bp-4h]@2 | |
2037 | |
2038 v18 = rand() % 100; | |
2039 v0 = pMapStats->GetMapInfo(pCurrentMapName); | |
2040 v1 = pChests; | |
2041 v2 = &pMapStats->pInfos[v0]; | |
2042 v21 = pChests; | |
2043 v20 = &pMapStats->pInfos[v0]; | |
2044 do | |
2045 { | |
2046 v3 = v1->mm7__vector_pItems; | |
2047 v23 = 140; | |
2048 do | |
2049 { | |
2050 if ( (v3->uItemID & 0x80000000u) == 0 ) | |
2051 goto LABEL_56; | |
2052 v4 = rand() % 5 + 1; | |
2053 v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; | |
2054 v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; | |
2055 v7 = rand(); | |
2056 v8 = v6 - v5 + 1; | |
2057 v9 = v5 + v7 % v8; | |
2058 v19 = v5 + v7 % v8; | |
2059 if ( v9 < 7 ) | |
2060 { | |
2061 if ( v18 < 20 ) | |
2062 { | |
2063 v3->Reset(); | |
2064 goto LABEL_25; | |
2065 } | |
2066 if ( v18 < 60 ) | |
2067 { | |
2068 v10 = 0; | |
2069 v3->Reset(); | |
2070 if ( v19 == 1 ) | |
2071 { | |
2072 v10 = rand() % 51 + 50; | |
2073 } | |
2074 else | |
2075 { | |
2076 if ( v19 != 2 ) | |
2077 { | |
2078 if ( v19 == 3 ) | |
2079 { | |
2080 v10 = rand() % 301 + 200; | |
2081 } | |
2082 else | |
2083 { | |
2084 if ( v19 != 4 ) | |
2085 { | |
2086 if ( v19 == 5 ) | |
2087 { | |
2088 v10 = rand() % 1001 + 1000; | |
2089 LABEL_15: | |
2090 v3->uItemID = 199; | |
2091 } | |
2092 else | |
2093 { | |
2094 if ( v19 == 6 ) | |
2095 { | |
2096 v10 = rand() % 3001 + 2000; | |
2097 goto LABEL_15; | |
2098 } | |
2099 } | |
2100 LABEL_23: | |
2101 v3->SetIdentified(); | |
2102 v3->uSpecEnchantmentType = v10; | |
2103 LABEL_25: | |
2104 v11 = v4 - 1; | |
2105 v12 = 0; | |
2106 if ( v11 > 0 ) | |
2107 { | |
2108 v22 = v11; | |
2109 while ( 1 ) | |
2110 { | |
2111 v13 = v12; | |
2112 if ( v12 >= 140 ) | |
2113 goto LABEL_52; | |
2114 v14 = &v21->mm7__vector_pItems[v12]; | |
2115 while ( v14->uItemID ) | |
2116 { | |
2117 ++v13; | |
2118 ++v14; | |
2119 if ( v13 >= 140 ) | |
2120 goto LABEL_52; | |
2121 } | |
2122 v16 = rand(); | |
2123 v15 = v16 % 100; | |
2124 v18 = v16 % 100; | |
2125 if ( v15 < 20 ) | |
2126 goto LABEL_52; | |
2127 if ( v15 >= 60 ) | |
2128 { | |
2129 pItemsTable->GenerateItem(v19, 0, v14); | |
2130 goto LABEL_51; | |
2131 } | |
2132 v17 = 0; | |
2133 v14->Reset(); | |
2134 if ( v19 == 1 ) | |
2135 { | |
2136 v17 = rand() % 51 + 50; | |
2137 goto LABEL_48; | |
2138 } | |
2139 if ( v19 == 2 ) | |
2140 { | |
2141 v17 = rand() % 101 + 100; | |
2142 LABEL_48: | |
2143 v14->uItemID = 197; | |
2144 goto LABEL_49; | |
2145 } | |
2146 if ( v19 == 3 ) | |
2147 { | |
2148 v17 = rand() % 301 + 200; | |
2149 goto LABEL_44; | |
2150 } | |
2151 if ( v19 == 4 ) | |
2152 { | |
2153 v17 = rand() % 501 + 500; | |
2154 LABEL_44: | |
2155 v14->uItemID = 198; | |
2156 goto LABEL_49; | |
2157 } | |
2158 if ( v19 == 5 ) | |
2159 break; | |
2160 if ( v19 == 6 ) | |
2161 { | |
2162 v17 = rand() % 3001 + 2000; | |
2163 LABEL_41: | |
2164 v14->uItemID = 199; | |
2165 } | |
2166 LABEL_49: | |
2167 v14->uSpecEnchantmentType = v17; | |
2168 LABEL_51: | |
2169 v12 = v13 + 1; | |
2170 LABEL_52: | |
2171 --v22; | |
2172 if ( !v22 ) | |
2173 goto LABEL_55; | |
2174 } | |
2175 v17 = rand() % 1001 + 1000; | |
2176 goto LABEL_41; | |
2177 } | |
2178 goto LABEL_55; | |
2179 } | |
2180 v10 = rand() % 501 + 500; | |
2181 } | |
2182 v3->uItemID = 198; | |
2183 goto LABEL_23; | |
2184 } | |
2185 v10 = rand() % 101 + 100; | |
2186 } | |
2187 v3->uItemID = 197; | |
2188 goto LABEL_23; | |
2189 } | |
2190 pItemsTable->GenerateItem(v9, 0, v3); | |
2191 goto LABEL_25; | |
2192 } | |
2193 v3->GenerateArtifact(); | |
2194 LABEL_55: | |
2195 v2 = v20; | |
2196 LABEL_56: | |
2197 ++v3; | |
2198 --v23; | |
2199 } | |
2200 while ( v23 ); | |
2201 v1 = v21 + 1; | |
2202 ++v21; | |
2203 } | |
2204 while ( (signed int)v21 < (signed int)&uNumChests ); | |
2205 } | |
2206 | |
2207 | |
2208 | |
2209 | |
0 | 2210 // 4505CC: using guessed type int var_A0[32]; |