Mercurial > mm7
annotate Items.cpp @ 366:85edec9da96b
_4B910F_shop_interaction
author | Nomad |
---|---|
date | Fri, 22 Feb 2013 01:36:54 +0200 |
parents | 0f35f908547f |
children | c606cabd7cbf |
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 | |
315 | 22 struct ItemsTable *pItemsTable; // 005D29E0 |
0 | 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 { | |
365 | 496 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 497 break; |
498 } | |
499 if ( !_strcmpi(test_string, "weapon2") ) | |
500 { | |
365 | 501 pItems[item_counter].uEquipType = EQUIP_TWO_HANDED; |
222 | 502 break; |
503 } | |
504 if ( !_strcmpi(test_string, "weapon1or2") ) | |
505 { | |
365 | 506 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 507 break; |
508 } | |
509 if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow"))) | |
510 { | |
365 | 511 pItems[item_counter].uEquipType = EQUIP_BOW; |
222 | 512 break; |
513 } | |
514 if ( !_strcmpi(test_string, "armor") ) | |
515 { | |
365 | 516 pItems[item_counter].uEquipType = EQUIP_ARMOUR; |
222 | 517 break; |
518 } | |
519 if ( !_strcmpi(test_string, "shield") ) | |
520 { | |
365 | 521 pItems[item_counter].uEquipType = EQUIP_SHIELD; |
222 | 522 break; |
523 } | |
524 if ( !_strcmpi(test_string, "helm") ) | |
525 { | |
365 | 526 pItems[item_counter].uEquipType = EQUIP_HELMET; |
222 | 527 break; |
528 } | |
529 if ( !_strcmpi(test_string, "belt") ) | |
530 { | |
365 | 531 pItems[item_counter].uEquipType = EQUIP_BELT; |
222 | 532 break; |
533 } | |
534 if ( !_strcmpi(test_string, "cloak") ) | |
535 { | |
365 | 536 pItems[item_counter].uEquipType = EQUIP_CLOAK; |
222 | 537 break; |
538 } | |
539 if ( !_strcmpi(test_string, "gauntlets") ) | |
540 { | |
365 | 541 pItems[item_counter].uEquipType = EQUIP_GAUNTLETS; |
222 | 542 break; |
543 } | |
544 if ( !_strcmpi(test_string, "boots") ) | |
545 { | |
365 | 546 pItems[item_counter].uEquipType = EQUIP_BOOTS; |
222 | 547 break; |
548 } | |
549 if ( !_strcmpi(test_string, "ring") ) | |
550 { | |
365 | 551 pItems[item_counter].uEquipType = EQUIP_RING; |
222 | 552 break; |
553 } | |
554 if ( !_strcmpi(test_string, "amulet") ) | |
555 { | |
365 | 556 pItems[item_counter].uEquipType = EQUIP_AMULET; |
222 | 557 break; |
558 } | |
559 if ( !_strcmpi(test_string, "weaponw") ) | |
560 { | |
365 | 561 pItems[item_counter].uEquipType = EQUIP_WAND; |
222 | 562 break; |
563 } | |
564 if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent"))) | |
565 { | |
365 | 566 pItems[item_counter].uEquipType = EQUIP_REAGENT; |
222 | 567 break; |
568 } | |
569 if ( !_strcmpi(test_string, "bottle") ) | |
570 { | |
365 | 571 pItems[item_counter].uEquipType = EQUIP_POTION; |
222 | 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 { | |
365 | 581 pItems[item_counter].uEquipType = EQUIP_BOOK; |
222 | 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 { | |
365 | 591 pItems[item_counter].uEquipType = EQUIP_GOLD; |
222 | 592 break; |
593 } | |
594 if ( !_strcmpi(test_string, "gem") ) | |
595 { | |
365 | 596 pItems[item_counter].uEquipType = EQUIP_GEM; |
222 | 597 break; |
598 } | |
365 | 599 pItems[item_counter].uEquipType = EQUIP_NONE; |
222 | 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 { | |
366 | 1420 if (Identified()) |
1421 return GetIdentifiedName(); | |
0 | 1422 else |
366 | 1423 return pItemsTable->pItems[uItemID].pUnidentifiedName; |
0 | 1424 } |
1425 | |
1426 //----- (004564B3) -------------------------------------------------------- | |
1427 const char *ItemGen::GetIdentifiedName() | |
1428 { | |
1429 ItemGen *v1; // esi@1 | |
1430 unsigned int v2; // eax@1 | |
1431 unsigned __int8 v3; // cl@1 | |
1432 char *v4; // edi@4 | |
1433 char v5; // al@6 | |
1434 const char *v6; // esi@8 | |
1435 int v7; // eax@15 | |
1436 const char *v9; // [sp-Ch] [bp-14h]@14 | |
1437 const char *v10; // [sp-8h] [bp-10h]@4 | |
1438 char *v11; // [sp-4h] [bp-Ch]@4 | |
1439 | |
1440 v1 = this; | |
1441 v2 = this->uItemID; | |
1442 v3 = pItemsTable->pItems[v2].uEquipType; | |
1443 if ( v3 >= EQUIP_REAGENT && (v3 <= EQUIP_POTION || v3 == EQUIP_GOLD) ) | |
1444 { | |
1445 v11 = pItemsTable->pItems[v2].pName; | |
1446 v4 = item__getname_buffer; | |
1447 v10 = "%s"; | |
1448 sprintf(v4, v10, v11); | |
1449 return v4; | |
1450 } | |
1451 v4 = item__getname_buffer; | |
1452 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName); | |
1453 if ( v1->uItemID == 601 ) | |
1454 { | |
1455 v5 = v1->field_1A; | |
1456 if ( (unsigned __int8)v5 >= 1u ) | |
1457 { | |
1458 if ( (unsigned __int8)v5 <= 4u ) | |
1459 { | |
1460 v6 = pPlayers[(unsigned __int8)v5]->pName; | |
1461 strlen(pPlayers[(unsigned __int8)v5]->pName); | |
1462 v11 = (char *)v6; | |
1463 if ( v6[strlen(v6) - 1] == 115 ) | |
1464 v10 = pGlobalTXT_LocalizationStrings[655]; | |
1465 else | |
1466 v10 = pGlobalTXT_LocalizationStrings[654]; | |
243 | 1467 sprintf(v4, v10, v11); |
1468 return v4; | |
0 | 1469 } |
1470 } | |
1471 } | |
1472 if ( !pItemsTable->_456D5E_is_some_material(v1) ) | |
1473 { | |
1474 if ( v1->_bonus_type ) | |
1475 { | |
1476 strcat(item__getname_buffer, " "); | |
1477 v9 = (const char *)*((unsigned int *)&pItemsTable->pItems[799].uEquipType + 5 * v1->_bonus_type); | |
1478 } | |
1479 else | |
1480 { | |
1481 v7 = v1->uAdditionalValue; | |
1482 if ( !v7 ) | |
1483 return v4; | |
1484 if ( v7 == 16 | |
1485 || v7 == 39 | |
1486 || v7 == 40 | |
1487 || v7 == 45 | |
1488 || v7 == 56 | |
1489 || v7 == 57 | |
1490 || v7 == 58 | |
1491 || v7 == 60 | |
1492 || v7 == 61 | |
1493 || v7 == 59 | |
1494 || v7 == 63 | |
1495 || v7 == 64 | |
1496 || v7 == 67 | |
1497 || v7 == 68 ) | |
1498 { | |
1499 sprintf( | |
1500 item__getname_buffer, | |
1501 "%s %s", | |
243 | 1502 pItemsTable->pSpecialEnchantments[v7].pBonusStatement, |
0 | 1503 pItemsTable->pItems[v1->uItemID].pName); |
1504 return v4; | |
1505 } | |
1506 strcat(item__getname_buffer, " "); | |
243 | 1507 v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement; |
0 | 1508 } |
1509 strcat(item__getname_buffer, v9); | |
1510 } | |
1511 return v4; | |
1512 } | |
1513 | |
1514 | |
1515 //----- (00456620) -------------------------------------------------------- | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1516 void ItemsTable::GenerateItem(int treasure_level, int a3, ItemGen *out_item) |
0 | 1517 { |
294 | 1518 |
1519 ItemGen *v4; // esi@1 | |
1520 ItemsTable *v5; // edi@1 | |
0 | 1521 int v6; // ebx@3 |
1522 int *v7; // ecx@33 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1523 //int v8; // eax@34 |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1524 //int v9; // eax@39 |
0 | 1525 int v10; // ebx@43 |
1526 int v11; // ecx@47 | |
1527 unsigned int *v12; // edx@48 | |
1528 unsigned int v13; // eax@49 | |
1529 signed int v14; // ebx@52 | |
1530 int v15; // eax@53 | |
1531 signed int v16; // eax@55 | |
1532 int v17; // ebx@57 | |
1533 int v18; // edx@62 | |
1534 signed int v19; // ebx@70 | |
1535 unsigned __int8 v20; // al@81 | |
1536 int v21; // eax@84 | |
1537 int v22; // ebx@85 | |
1538 int v23; // eax@86 | |
1539 int v24; // ebx@86 | |
1540 int v25; // edx@86 | |
1541 int v26; // edx@89 | |
1542 unsigned int v27; // eax@89 | |
1543 int i; // ebx@89 | |
1544 unsigned int v29; // ecx@90 | |
1545 int v30; // ebx@91 | |
1546 int v31; // eax@91 | |
1547 int v32; // ecx@91 | |
1548 int v33; // eax@91 | |
1549 int v34; // eax@97 | |
1550 unsigned __int8 v35; // sf@97 | |
1551 unsigned __int8 v36; // of@97 | |
1552 int v37; // ebx@98 | |
1553 int v38; // edx@99 | |
1554 signed int v39; // ebx@101 | |
1555 int v40; // ecx@102 | |
1556 char v41; // zf@107 | |
1557 char v42; // al@108 | |
1558 char v43; // al@111 | |
1559 int *v44; // edx@118 | |
1560 int v45; // eax@120 | |
1561 int v46; // edx@120 | |
1562 int *j; // eax@121 | |
1563 unsigned int v48; // ecx@123 | |
1564 int v49; // eax@123 | |
1565 int v50; // eax@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1566 int Dst[800]; // [sp+Ch] [bp-C88h]@33 |
0 | 1567 int v52; // [sp+C8Ch] [bp-8h]@33 |
294 | 1568 int v53; // [sp+C90h] [bp-4h]@1 |
1569 int v54; // [sp+C9Ch] [bp+8h]@3 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1570 //int v55; // [sp+CA0h] [bp+Ch]@34 |
0 | 1571 signed int v56; // [sp+CA0h] [bp+Ch]@55 |
1572 int v57; // [sp+CA0h] [bp+Ch]@62 | |
1573 int *v58; // [sp+CA0h] [bp+Ch]@102 | |
1574 int v59; // [sp+CA0h] [bp+Ch]@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1575 //signed int a2a; // [sp+CA4h] [bp+10h]@33 |
0 | 1576 int a2b; // [sp+CA4h] [bp+10h]@101 |
1577 int a2c; // [sp+CA4h] [bp+10h]@120 | |
1578 | |
294 | 1579 v53 = -1; |
1580 v5 = this; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1581 if (!out_item) |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1582 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
|
1583 memset(out_item, 0, sizeof(*out_item)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1584 |
294 | 1585 v4 = out_item; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1586 v6 = treasure_level - 1; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1587 //v54 = treasure_level - 1; |
0 | 1588 if ( a3 ) |
1589 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1590 ITEM_EQUIP_TYPE requested_equip; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1591 PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1592 switch (a3) |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1593 { |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1594 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
|
1595 case 21: requested_equip = EQUIP_ARMOUR; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1596 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
|
1597 case 23: requested_skill = PLAYER_SKILL_SWORD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1598 case 24: requested_skill = PLAYER_SKILL_DAGGER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1599 case 25: requested_skill = PLAYER_SKILL_AXE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1600 case 26: requested_skill = PLAYER_SKILL_SPEAR; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1601 case 27: requested_skill = PLAYER_SKILL_BOW; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1602 case 28: requested_skill = PLAYER_SKILL_MACE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1603 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
|
1604 case 30: requested_skill = PLAYER_SKILL_STAFF; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1605 case 31: requested_skill = PLAYER_SKILL_LEATHER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1606 case 32: requested_skill = PLAYER_SKILL_CHAIN; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1607 case 33: requested_skill = PLAYER_SKILL_PLATE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1608 case 34: requested_equip = EQUIP_SHIELD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1609 case 35: requested_equip = EQUIP_HELMET; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1610 case 36: requested_equip = EQUIP_BELT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1611 case 37: requested_equip = EQUIP_CLOAK; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1612 case 38: requested_equip = EQUIP_GAUNTLETS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1613 case 39: requested_equip = EQUIP_BOOTS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1614 case 40: requested_equip = EQUIP_RING; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1615 case 41: requested_equip = EQUIP_AMULET; break; |
295 | 1616 case 42: requested_equip = EQUIP_WAND; break; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1617 case 43: requested_equip = EQUIP_F; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1618 case 44: requested_equip = EQUIP_POTION; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1619 case 45: requested_equip = EQUIP_REAGENT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1620 case 46: requested_equip = EQUIP_GEM; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1621 default: |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1622 __debugbreak(); // check this condition |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1623 requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1624 break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1625 } |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1626 memset(Dst, 0, sizeof(Dst)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1627 v52 = 0; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1628 v7 = Dst; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1629 //a2a = 1; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1630 if (requested_skill == PLAYER_SKILL_INVALID) |
0 | 1631 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1632 for (uint i = 1; i < 500; ++i) |
0 | 1633 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1634 if (pItems[i].uEquipType == requested_equip) |
0 | 1635 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1636 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1637 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1638 } |
1639 } | |
1640 } | |
1641 else | |
1642 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1643 for (uint i = 1; i < 500; ++i) |
0 | 1644 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1645 if (pItems[i].uSkillType == requested_skill) |
0 | 1646 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1647 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1648 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1649 } |
1650 } | |
1651 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1652 |
0 | 1653 v10 = 0; |
1654 if ( v52 ) | |
1655 v10 = rand() % v52; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1656 |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1657 v4->uItemID = *Dst; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1658 if (!v4->uItemID) |
0 | 1659 v4->uItemID = 1; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1660 |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1661 v11 = pItems[v4->uItemID].uChanceByTreasureLvl[v6]; |
0 | 1662 if ( v11 < v10 ) |
1663 { | |
1664 v12 = (uint *)Dst; | |
1665 do | |
1666 { | |
1667 ++v12; | |
1668 v13 = *v12; | |
1669 v4->uItemID = *v12; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1670 v11 += pItems[v13].uChanceByTreasureLvl[v6]; |
0 | 1671 } |
1672 while ( v11 < v10 ); | |
1673 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1674 if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) |
0 | 1675 { |
1676 v4->_bonus_type = 0; | |
1677 v14 = 2; | |
1678 do | |
1679 { | |
1680 v4->_bonus_type += rand() % 4 + 1; | |
1681 v15 = v4->_bonus_type; | |
1682 --v14; | |
1683 } | |
1684 while ( v14 ); | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1685 v4->_bonus_type = v15 * treasure_level; |
0 | 1686 } |
1687 } | |
1688 else | |
1689 { | |
1690 v16 = 0; | |
1691 v56 = 0; | |
1692 do | |
1693 v56 += pParty->field_7BA[v16++]; | |
1694 while ( v16 < 29 ); | |
1695 v17 = rand() % 29; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1696 if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) |
0 | 1697 { |
1698 pParty->field_7BA[v17] = 1; | |
1699 v4->uAttributes = 0; | |
1700 v4->uItemID = v17 + 500; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1701 SetSpecialBonus(v4); |
0 | 1702 return; |
1703 } | |
1704 v57 = 0; | |
294 | 1705 v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54]; |
0 | 1706 v4->uItemID = 0; |
1707 if ( v18 > 0 ) | |
1708 { | |
1709 do | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1710 v57 += pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[v6]; |
0 | 1711 while ( v57 < v18 ); |
1712 } | |
1713 if ( !v18 ) | |
1714 v4->uItemID = 1; | |
1715 if ( !v4->uItemID ) | |
1716 v4->uItemID = 1; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1717 if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE) |
0 | 1718 { |
1719 v4->_bonus_type = 0; | |
1720 v19 = 2; | |
1721 do | |
1722 { | |
1723 v4->_bonus_type += rand() % 4 + 1; | |
1724 v15 = v4->_bonus_type; | |
1725 --v19; | |
1726 } | |
1727 while ( v19 ); | |
245 | 1728 v4->_bonus_type = v15 * treasure_level; |
0 | 1729 } |
1730 } | |
1731 if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION | |
1732 && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) | |
1733 v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; | |
222 | 1734 if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St ) |
0 | 1735 v4->uAttributes = 0; |
1736 else | |
1737 v4->uAttributes = 1; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1738 if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION ) |
0 | 1739 { |
1740 v4->uAdditionalValue = 0; | |
1741 v4->_bonus_type = 0; | |
1742 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1743 v20 = pItems[v4->uItemID].uEquipType; |
0 | 1744 if ( v20 <= EQUIP_BOW ) |
1745 { | |
294 | 1746 v37 = v5->uBonusChanceWpSpecial[v54]; |
0 | 1747 if ( !*(unsigned int *)v37 ) |
1748 return; | |
1749 v38 = rand() % 100; | |
1750 v36 = __OFSUB__(v38, *(unsigned int *)v37); | |
1751 v35 = v38 - *(unsigned int *)v37 < 0; | |
1752 } | |
1753 else | |
1754 { | |
1755 if ( v20 > EQUIP_AMULET ) | |
1756 { | |
295 | 1757 if ( v20 == EQUIP_WAND ) |
0 | 1758 { |
1759 v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; | |
1760 v4->uNumCharges = v21; | |
1761 v4->uMaxCharges = v21; | |
1762 } | |
1763 return; | |
1764 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1765 v22 = (int)&uBonusChanceStandart[v6]; |
0 | 1766 if ( !*(unsigned int *)v22 ) |
1767 return; | |
1768 v23 = rand(); | |
1769 v24 = *(unsigned int *)v22; | |
1770 v25 = v23 % 100; | |
245 | 1771 if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24)) |
224 | 1772 return; |
245 | 1773 if ( v25 < v24 || v23 % 100 < v24) |
0 | 1774 { |
224 | 1775 v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType]; |
0 | 1776 v27 = v4->uItemID; |
1777 v4->_bonus_type = 0; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1778 for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; |
0 | 1779 i < v26; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1780 i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] ) |
0 | 1781 { |
1782 v29 = v4->uItemID; | |
1783 ++v4->_bonus_type; | |
1784 } | |
1785 ++v4->_bonus_type; | |
224 | 1786 v30 = 10;// v5->field_116D8[2 * v54 + 12]; |
0 | 1787 v31 = rand(); |
1788 v32 = v4->_bonus_type - 1; | |
224 | 1789 v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; |
0 | 1790 v4->_bonus_strength = v33; |
1791 if ( v32 == 21 || v32 == 22 || v32 == 23 ) | |
1792 v4->_bonus_strength = v33 >> 1; | |
1793 if ( v4->_bonus_strength <= 0 ) | |
1794 v4->_bonus_strength = 1; | |
1795 return; | |
1796 } | |
224 | 1797 v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24]; |
0 | 1798 v36 = __OFSUB__(v25, v34); |
1799 v35 = v25 - v34 < 0; | |
1800 } | |
1801 if ( !(v35 ^ v36) ) | |
1802 return; | |
1803 memset(&Dst, 0, 0xC80u); | |
1804 v39 = 0; | |
1805 a2b = 0; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1806 if ( pSpecialEnchantments_count > 0 ) |
0 | 1807 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1808 v52 = -16 - (uint)this; |
0 | 1809 v58 = (int *)&Dst; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1810 v40 = (int)&pSpecialEnchantments[1]; |
0 | 1811 do |
1812 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1813 switch ( v6 ) |
0 | 1814 { |
1815 case 2: | |
1816 if ( !*(unsigned char *)v40 ) | |
245 | 1817 { |
1818 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1819 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1820 { | |
1821 v44 = v58; | |
1822 ++v58; | |
1823 *v44 = a2b; | |
1824 } | |
1825 ++a2b; | |
1826 v40 += 28; | |
1827 continue; | |
1828 } | |
0 | 1829 v41 = *(unsigned char *)v40 == 1; |
1830 break; | |
1831 case 3: | |
1832 v43 = *(unsigned char *)v40; | |
1833 if ( !*(unsigned char *)v40 || v43 == 1 ) | |
1834 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1835 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
|
1836 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) |
0 | 1837 { |
1838 v44 = v58; | |
1839 ++v58; | |
1840 *v44 = a2b; | |
1841 } | |
245 | 1842 ++a2b; |
1843 v40 += 28; | |
1844 continue; | |
0 | 1845 } |
1846 v41 = v43 == 2; | |
1847 break; | |
1848 case 4: | |
1849 v42 = *(unsigned char *)v40; | |
1850 if ( *(unsigned char *)v40 == 1 || v42 == 2 ) | |
245 | 1851 { |
1852 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1853 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1854 { | |
1855 v44 = v58; | |
1856 ++v58; | |
1857 *v44 = a2b; | |
1858 } | |
1859 ++a2b; | |
1860 v40 += 28; | |
1861 continue; | |
1862 } | |
0 | 1863 v41 = v42 == 3; |
1864 break; | |
1865 default: | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1866 if ( v6 != 5 ) |
245 | 1867 { |
1868 ++a2b; | |
1869 v40 += 28; | |
1870 continue; | |
1871 } | |
0 | 1872 v41 = *(unsigned char *)v40 == 3; |
1873 break; | |
1874 } | |
1875 if ( v41 ) | |
245 | 1876 { |
1877 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1878 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1879 { | |
1880 v44 = v58; | |
1881 ++v58; | |
1882 *v44 = a2b; | |
1883 } | |
1884 } | |
0 | 1885 LABEL_119: |
1886 ++a2b; | |
1887 v40 += 28; | |
1888 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1889 while ( a2b < pSpecialEnchantments_count ); |
0 | 1890 } |
1891 v45 = rand(); | |
1892 v4->uAdditionalValue = *(uint *)Dst; | |
1893 v46 = v45 % v39 + 1; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1894 a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); |
0 | 1895 if ( a2c < v46 ) |
1896 { | |
1897 for ( j = (int *)&Dst; ; j = (int *)v59 ) | |
1898 { | |
1899 v48 = v4->uItemID; | |
1900 v49 = (int)(j + 1); | |
1901 v59 = v49; | |
1902 v50 = *(unsigned int *)v49; | |
1903 v4->uAdditionalValue = v50; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1904 a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); |
0 | 1905 if ( a2c >= v46 ) |
1906 break; | |
1907 } | |
1908 } | |
1909 ++v4->uAdditionalValue; | |
1910 } | |
1911 | |
1912 //----- (004505CC) -------------------------------------------------------- | |
1913 bool ItemGen::GenerateArtifact() | |
1914 { | |
1915 ItemGen *v1; // edi@1 | |
1916 signed int uNumArtifactsNotFound; // esi@1 | |
1917 int v3; // eax@1 | |
1918 bool result; // eax@6 | |
1919 int v5[32]; // [sp+8h] [bp-A0h]@3 | |
1920 char Dst[32]; // [sp+88h] [bp-20h]@1 | |
1921 | |
1922 auto a2 = this; | |
1923 v1 = a2; | |
1924 memset(Dst, 0, 0x20u); | |
1925 uNumArtifactsNotFound = 0; | |
1926 v3 = 500; | |
1927 do | |
1928 { | |
1929 if ( !pParty->field_3C.pIsArtifactFound[v3] ) | |
1930 v5[uNumArtifactsNotFound++] = v3; | |
1931 ++v3; | |
1932 } | |
1933 while ( v3 < 529 ); | |
1934 v1->Reset(); | |
1935 if ( uNumArtifactsNotFound ) | |
1936 { | |
1937 v1->uItemID = v5[rand() % uNumArtifactsNotFound]; | |
1938 pItemsTable->SetSpecialBonus(v1); | |
1939 result = 1; | |
1940 } | |
1941 else | |
1942 { | |
1943 result = 0; | |
1944 } | |
1945 return result; | |
1946 } | |
1947 // 4505CC: using guessed type int var_A0[32]; |