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