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