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