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