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