Mercurial > mm7
annotate Items.cpp @ 493:59649750a054
Merge
author | Gloval |
---|---|
date | Thu, 28 Feb 2013 01:39:18 +0400 |
parents | 4bd56919f075 |
children | 214d9d47cf1f |
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" | |
461 | 8 #include "GUIWindow.h" |
9 #include "Events2D.h" | |
10 #include "Chest.h" | |
0 | 11 #include "LOD.h" |
12 #include "Monsters.h" | |
13 #include "Party.h" | |
14 #include "FactionTable.h" | |
15 #include "StorylineTextTable.h" | |
189 | 16 #include "texts.h" |
0 | 17 #include "mm7_data.h" |
18 | |
19 | |
20 | |
463 | 21 struct ITEM_VARIATION |
22 { | |
23 unsigned __int16 treasure_level; | |
24 unsigned __int16 item_class[4]; | |
25 }; | |
26 | |
27 | |
28 char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; | |
29 | |
30 ITEM_VARIATION shopWeap_variation_ord[15] ={ | |
31 { 0, { 0, 0, 0, 0 }}, | |
32 { 1, { 23, 27, 20, 20 }}, | |
33 { 1, { 23, 24, 28, 20 }}, | |
34 { 2, { 23, 24, 25, 20 }}, | |
35 { 2, { 27, 27, 26, 26 }}, | |
36 { 4, { 24, 30, 25, 27 }}, | |
37 { 4, { 24, 30, 25, 27 }}, | |
38 { 3, { 30, 24, 20, 20 }}, | |
39 { 2, { 20, 20, 20, 20 }}, | |
40 { 3, { 27, 27, 26, 26 }}, | |
41 { 3, { 28, 28, 25, 25 }}, | |
42 { 2, { 23, 23, 24, 24 }}, | |
43 { 3, { 23, 23, 26, 26 }}, | |
44 { 2, { 30, 26, 26, 26 }}, | |
45 { 2, { 28, 25, 28, 29 }}}; | |
46 | |
470 | 47 ITEM_VARIATION shopArmr_variation_ord[28] ={ |
463 | 48 { 1, { 35, 35, 38, 38 }}, |
49 { 1, { 31, 31, 31, 34 }}, | |
50 { 1, { 35, 35, 38, 38 }}, | |
51 { 1, { 31, 31, 32, 34 }}, | |
52 { 2, { 35, 35, 38, 38 }}, | |
53 { 2, { 31, 32, 32, 33 }}, | |
54 { 2, { 35, 35, 38, 38 }}, | |
55 { 2, { 31, 31, 32, 32 }}, | |
56 { 4, { 35, 35, 38, 38 }}, | |
57 { 4, { 31, 32, 33, 34 }}, | |
58 { 4, { 35, 35, 38, 38 }}, | |
59 { 4, { 31, 32, 33, 34 }}, | |
60 { 3, { 35, 35, 38, 38 }}, | |
61 { 3, { 31, 31, 31, 31 }}, | |
62 { 2, { 35, 35, 38, 38 }}, | |
63 { 2, { 31, 32, 34, 34 }}, | |
64 { 3, { 35, 35, 38, 38 }}, | |
65 { 3, { 31, 31, 32, 32 }}, | |
66 { 3, { 35, 35, 38, 38 }}, | |
67 { 3, { 32, 32, 32, 33 }}, | |
68 { 3, { 35, 35, 38, 38 }}, | |
69 { 3, { 31, 31, 31, 32 }}, | |
70 { 3, { 35, 35, 38, 38 }}, | |
71 { 3, { 33, 31, 32, 34 }}, | |
72 { 3, { 35, 35, 38, 38 }}, | |
73 { 3, { 33, 31, 32, 34 }}, | |
74 { 4, { 35, 35, 38, 38 }}, | |
75 { 4, { 33, 31, 32, 34 }}}; | |
76 | |
77 | |
78 | |
79 unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; | |
470 | 80 unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; |
463 | 81 |
82 ITEM_VARIATION shopWeap_variation_spc[15]={ | |
83 { 0, { 0, 0, 0, 0 }}, | |
470 | 84 { 2, { 25, 30, 20, 20}}, |
85 { 2, { 23, 24, 28, 20}}, | |
86 { 3, { 23, 24, 25, 20}}, | |
87 { 3, { 27, 27, 26, 26}}, | |
88 { 5, { 23, 26, 28, 27}}, | |
89 { 5, { 23, 26, 28, 27}}, | |
90 { 4, { 30, 24, 20, 20}}, | |
91 { 3, { 20, 20, 20, 20}}, | |
92 { 4, { 27, 27, 26, 26}}, | |
93 { 4, { 28, 28, 25, 25}}, | |
94 { 4, { 23, 23, 24, 24}}, | |
95 { 4, { 24, 24, 27, 20}}, | |
96 { 4, { 30, 26, 26, 26}}, | |
97 { 4, { 28, 25, 28, 29}}}; | |
463 | 98 |
470 | 99 ITEM_VARIATION shopArmr_variation_spc[28]={ |
100 { 2, { 35, 35, 38, 38 }}, | |
101 { 2, { 31, 31, 31, 34 }}, | |
102 { 2, { 35, 35, 38, 38 }}, | |
103 { 2, { 31, 31, 32, 34 }}, | |
104 { 3, { 35, 35, 38, 38 }}, | |
105 { 3, { 31, 32, 32, 33 }}, | |
106 { 3, { 35, 35, 38, 38 }}, | |
107 { 3, { 31, 31, 32, 32 }}, | |
108 { 5, { 35, 35, 38, 38 }}, | |
109 { 5, { 31, 32, 33, 34 }}, | |
110 { 5, { 35, 35, 38, 38 }}, | |
111 { 5, { 31, 32, 33, 34 }}, | |
112 { 4, { 35, 35, 38, 38 }}, | |
113 { 4, { 31, 31, 31, 31 }}, | |
114 { 3, { 35, 35, 38, 38 }}, | |
115 { 3, { 31, 32, 34, 34 }}, | |
116 { 4, { 35, 35, 38, 38 }}, | |
117 { 4, { 31, 31, 32, 33 }}, | |
118 { 4, { 35, 35, 38, 38 }}, | |
119 { 4, { 32, 32, 33, 34 }}, | |
120 { 4, { 35, 35, 38, 38 }}, | |
121 { 4, { 31, 31, 31, 32 }}, | |
122 { 4, { 35, 35, 38, 38 }}, | |
123 { 4, { 32, 32, 32, 32 }}, | |
124 { 4, { 35, 35, 38, 38 }}, | |
125 { 4, { 34, 34, 34, 34 }}, | |
126 { 5, { 35, 35, 38, 38 }}, | |
127 { 5, { 33, 33, 33, 33 }} | |
128 }; | |
463 | 129 |
470 | 130 unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; |
131 unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; | |
0 | 132 |
475 | 133 int sub_4BE571(int a1, int *a2, int a3, int a4); |
0 | 134 |
135 ItemGen *ptr_50C9A4; | |
136 | |
315 | 137 struct ItemsTable *pItemsTable; // 005D29E0 |
0 | 138 |
139 | |
140 | |
141 | |
142 | |
143 //----- (00439DF3) -------------------------------------------------------- | |
385 | 144 int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP) |
145 { | |
146 *damage_type = 0; | |
147 if ( !uItemID ) | |
148 return 0; | |
149 UpdateTempBonus(pParty->uTimePlayed); | |
150 if (uItemID == 501 ) //Iron Feather -sword | |
151 { | |
152 *damage_type = 1; | |
153 return rand() % 10 + 6; | |
154 } | |
155 if (uItemID == 507 ) //Ghoulsbane -axe | |
156 { | |
157 *damage_type = 0; | |
158 return rand() % 16 + 3; | |
159 } | |
160 if ( uItemID == 510 ) //Ullyses -bow | |
161 { | |
162 *damage_type = 2; | |
163 return rand() % 4 + 9; | |
164 } | |
165 if ( uItemID == 517 ) //Old Nick -dagger | |
166 { | |
167 *damage_type = 8; | |
168 return 8; | |
169 } | |
0 | 170 |
385 | 171 switch (uSpecEnchantmentType) |
172 { | |
173 case 4: //Adds 3-4 points of Cold damage. | |
174 *damage_type = 2; | |
175 return rand() % 2 + 3; | |
176 break; | |
177 case 5: //Adds 6-8 points of Cold damage. | |
178 *damage_type = 2; | |
179 return rand() % 3 + 6; | |
180 break; | |
181 case 6: //Adds 9-12 points of Cold damage. | |
182 *damage_type = 2; | |
183 return rand() % 4 + 9; | |
184 break; | |
185 case 7: //Adds 2-5 points of Electrical damage. | |
186 *damage_type = 1; | |
187 return rand() % 4 + 2; | |
188 break; | |
189 case 8: //Adds 4-10 points of Electrical damage. | |
190 *damage_type = 1; | |
191 return rand() % 7 + 4; | |
192 break; | |
193 case 9: //Adds 6-15 points of Electrical damage. | |
194 *damage_type = 1; | |
195 return rand() % 10 + 6; | |
196 break; | |
197 case 10: //Adds 1-6 points of Fire damage. | |
198 *damage_type = 0; | |
199 return GetDiceResult(1, 6); | |
200 break; | |
201 case 11: //Adds 2-12 points of Fire damage. | |
202 *damage_type = 0; | |
203 return GetDiceResult(2, 6); | |
204 break; | |
205 case 12: //Adds 3-18 points of Fire damage. | |
206 *damage_type = 0; | |
207 return GetDiceResult(3, 6); | |
208 break; | |
209 case 13: //Adds 5 points of Body damage. | |
210 *damage_type = 8; | |
211 return 5; | |
212 break; | |
213 case 14: //Adds 8 points of Body damage. | |
214 *damage_type = 8; | |
215 return 8; | |
216 break; | |
217 case 15: //Adds 12 points of Body damage. | |
218 *damage_type = 8; | |
219 return 12; | |
220 break; | |
221 case 16: //Drain Hit Points from target. | |
222 case 41: //Drain Hit Points from target and Increased Weapon speed. | |
223 *damage_type = 10; | |
224 *draintargetHP = true; | |
225 return 0; | |
226 break; | |
227 case 46: //Adds 10-20 points of Fire damage and +25 Might. | |
228 *damage_type = 0; | |
229 return rand() % 11 + 10; | |
230 break; | |
231 default: | |
232 *damage_type = 0; | |
233 return 0; | |
234 | |
235 } | |
236 | |
237 } | |
0 | 238 |
239 | |
240 //----- (00402F07) -------------------------------------------------------- | |
241 void ItemGen::Reset() | |
242 { | |
377 | 243 this->uHolderPlayer = 0; |
0 | 244 this->uAttributes = 0; |
245 this->uNumCharges = 0; | |
377 | 246 this->uSpecEnchantmentType = 0; |
0 | 247 this->_bonus_strength = 0; |
377 | 248 this->uEncantmentType = 0; |
0 | 249 this->uItemID = 0; |
250 this->uBodyAnchor = 0; | |
251 this->uExpireTime = 0i64; | |
252 } | |
253 | |
254 //----- (00458260) -------------------------------------------------------- | |
255 void ItemGen::UpdateTempBonus(__int64 uTimePlayed) | |
256 { | |
463 | 257 if ( this->uAttributes & ITEM_TEMP_BONUS ) |
0 | 258 { |
259 if ( uTimePlayed > (signed __int64)this->uExpireTime ) | |
260 { | |
377 | 261 this->uEncantmentType = 0; |
262 this->uSpecEnchantmentType = 0; | |
463 | 263 this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS); |
0 | 264 } |
265 } | |
266 } | |
267 | |
268 //----- (0045814E) -------------------------------------------------------- | |
374 | 269 void ItemsTable::Release() |
0 | 270 { |
271 if ( pMonstersTXT_Raw ) | |
272 pAllocator->FreeChunk(pMonstersTXT_Raw); | |
273 if ( pMonsterPlacementTXT_Raw ) | |
274 pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); | |
275 if ( pSkillDescTXT_Raw ) | |
276 pAllocator->FreeChunk(pSkillDescTXT_Raw); | |
374 | 277 if (pSpcItemsTXT_Raw ) |
278 pAllocator->FreeChunk(pSpcItemsTXT_Raw); | |
279 if ( pStdItemsTXT_Raw ) | |
280 pAllocator->FreeChunk(pStdItemsTXT_Raw); | |
281 if ( pRndItemsTXT_Raw ) | |
282 pAllocator->FreeChunk(pRndItemsTXT_Raw); | |
283 if ( pItemsTXT_Raw ) | |
284 pAllocator->FreeChunk(pItemsTXT_Raw); | |
0 | 285 if ( pHostileTXT_Raw ) |
286 pAllocator->FreeChunk(pHostileTXT_Raw); | |
287 if ( pHistoryTXT_Raw ) | |
288 pAllocator->FreeChunk(pHistoryTXT_Raw); | |
289 if ( pPotionsTXT_Raw ) | |
290 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
291 if ( pPotionNotesTXT_Raw ) | |
292 pAllocator->FreeChunk(pPotionNotesTXT_Raw); | |
374 | 293 pSpcItemsTXT_Raw = NULL; |
294 pSkillDescTXT_Raw = NULL; | |
295 pStdItemsTXT_Raw = NULL; | |
296 pRndItemsTXT_Raw = NULL; | |
297 pItemsTXT_Raw = NULL; | |
298 | |
0 | 299 } |
300 | |
301 | |
302 //----- (00456D84) -------------------------------------------------------- | |
303 void ItemsTable::Initialize() | |
224 | 304 { |
305 int i,j; | |
306 char* test_string; | |
229 | 307 unsigned char c; |
224 | 308 bool break_loop; |
309 unsigned int temp_str_len; | |
310 char* tmp_pos; | |
311 int decode_step; | |
312 int item_counter; | |
313 | |
314 pMapStats = new MapStats; | |
315 pMapStats->Initialize(); | |
316 | |
317 pMonsterStats = new MonsterStats; | |
318 pMonsterStats->Initialize(); | |
319 pMonsterStats->InitializePlacements(); | |
320 | |
321 pSpellStats = new SpellStats; | |
322 pSpellStats->Initialize(); | |
323 | |
324 LoadPotions(); | |
325 LoadPotionNotes(); | |
326 | |
327 pFactionTable = new FactionTable; | |
328 pFactionTable->Initialize(); | |
329 | |
330 pStorylineText = new StorylineText; | |
331 pStorylineText->Initialize(); | |
0 | 332 |
224 | 333 pStdItemsTXT_Raw = NULL; |
334 pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); | |
335 strtok(pStdItemsTXT_Raw, "\r"); | |
336 strtok(NULL, "\r"); | |
337 strtok(NULL, "\r"); | |
338 strtok(NULL, "\r"); | |
339 //Standard Bonuses by Group | |
340 for (i=0;i<24;++i) | |
341 { | |
342 test_string = strtok(NULL, "\r") + 1; | |
343 break_loop = false; | |
344 decode_step=0; | |
345 do | |
346 { | |
347 c = *(unsigned char*)test_string; | |
348 temp_str_len = 0; | |
349 while((c!='\t')&&(c>0)) | |
350 { | |
351 ++temp_str_len; | |
352 c=test_string[temp_str_len]; | |
353 } | |
354 tmp_pos=test_string+temp_str_len; | |
355 if (*tmp_pos == 0) | |
356 break_loop = true; | |
357 *tmp_pos = 0; | |
358 if (temp_str_len) | |
359 { | |
360 switch (decode_step) | |
361 { | |
362 case 0: | |
363 pEnchantments[i].pBonusStat=RemoveQuotes(test_string); | |
364 break; | |
365 case 1: | |
366 pEnchantments[i].pOfName= RemoveQuotes(test_string); | |
367 break; | |
368 default: | |
369 pEnchantments[i].to_item[decode_step-2]=atoi(test_string); | |
370 } | |
371 } | |
372 else | |
373 { | |
374 if (!decode_step) | |
375 break_loop = true; | |
376 } | |
377 ++decode_step; | |
378 test_string=tmp_pos+1; | |
379 } while ((decode_step<11)&&!break_loop); | |
380 } | |
0 | 381 |
224 | 382 memset(&pEnchantmentsSumm, 0, 36); |
383 for(i=0;i<9;++i) | |
384 { | |
385 for (j=0;j<24;++j) | |
386 pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i]; | |
387 } | |
0 | 388 |
224 | 389 //Bonus range for Standard by Level |
390 strtok(NULL, "\r"); | |
391 strtok(NULL, "\r"); | |
392 strtok(NULL, "\r"); | |
393 strtok(NULL, "\r"); | |
394 strtok(NULL, "\r"); | |
395 for(i=0;i<6;++i) //counted from 1 | |
396 { | |
397 test_string = strtok(NULL, "\r") + 1; | |
398 break_loop = false; | |
399 decode_step=0; | |
400 do | |
401 { | |
402 c = *(unsigned char*)test_string; | |
403 temp_str_len = 0; | |
404 while((c!='\t')&&(c>0)) | |
405 { | |
406 ++temp_str_len; | |
407 c=test_string[temp_str_len]; | |
408 } | |
409 tmp_pos=test_string+temp_str_len; | |
410 if (*tmp_pos == 0) | |
411 break_loop = true; | |
412 *tmp_pos = 0; | |
413 if (decode_step==2) | |
414 bonus_ranges[i].minR = atoi(test_string); | |
415 else if (decode_step==3) | |
416 bonus_ranges[i].maxR =atoi(test_string); | |
417 ++decode_step; | |
418 test_string=tmp_pos+1; | |
419 } while ((decode_step<4)&&!break_loop); | |
420 } | |
421 | |
222 | 422 |
224 | 423 pSpcItemsTXT_Raw = 0; |
424 pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); | |
425 strtok(pSpcItemsTXT_Raw, "\r"); | |
426 strtok(NULL, "\r"); | |
427 strtok(NULL, "\r"); | |
428 strtok(NULL, "\r"); | |
429 for (i=0;i<72;++i) | |
430 { | |
431 test_string = strtok(NULL, "\r") + 1; | |
432 break_loop = false; | |
433 decode_step=0; | |
434 do | |
435 { | |
436 c = *(unsigned char*)test_string; | |
437 temp_str_len = 0; | |
438 while((c!='\t')&&(c>0)) | |
439 { | |
440 ++temp_str_len; | |
441 c=test_string[temp_str_len]; | |
442 } | |
443 tmp_pos=test_string+temp_str_len; | |
444 if (*tmp_pos == 0) | |
445 break_loop = true; | |
446 *tmp_pos = 0; | |
447 if (temp_str_len) | |
448 { | |
449 switch (decode_step) | |
450 { | |
451 case 0: | |
452 pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string); | |
453 break; | |
454 case 1: | |
455 pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string); | |
456 break; | |
457 case 14: | |
458 int res; | |
459 res=atoi(test_string); | |
460 if(!res) | |
461 { | |
462 ++test_string; | |
463 while (*test_string==' ')//fix X 2 case | |
464 ++test_string; | |
222 | 465 res=atoi(test_string); |
224 | 466 } |
467 pSpecialEnchantments[i].iValue=res; | |
468 break; | |
469 case 15: | |
470 pSpecialEnchantments[i].iTreasureLevel= tolower(*test_string) - 97;; | |
471 break; | |
472 default: | |
473 pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string); | |
474 } | |
475 } | |
476 else | |
477 { | |
478 if (!decode_step) | |
479 break_loop = true; | |
480 } | |
481 ++decode_step; | |
482 test_string=tmp_pos+1; | |
483 } while ((decode_step<16)&&!break_loop); | |
484 } | |
485 | |
486 pSpecialEnchantments_count = 71; | |
487 memset(&pSpecialEnchantmentsSumm, 0, 96); | |
488 for(i=0;i<12;++i) | |
489 { | |
490 for (j=0;j<pSpecialEnchantments_count;++j) | |
491 pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; | |
492 } | |
222 | 493 |
224 | 494 Initialize2DA(); |
222 | 495 |
224 | 496 pItemsTXT_Raw = NULL; |
497 pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0); | |
498 strtok(pItemsTXT_Raw, "\r"); | |
499 strtok(NULL, "\r"); | |
500 uAllItemsCount = 0; | |
501 item_counter = 0; | |
222 | 502 while (true) |
503 { | |
504 test_string = strtok(NULL, "\r") + 1; | |
505 break_loop = false; | |
506 decode_step=0; | |
507 do | |
508 { | |
509 c = *(unsigned char*)test_string; | |
510 temp_str_len = 0; | |
511 while((c!='\t')&&(c>0)) | |
512 { | |
513 ++temp_str_len; | |
514 c=test_string[temp_str_len]; | |
515 } | |
516 tmp_pos=test_string+temp_str_len; | |
517 if (*tmp_pos == 0) | |
518 break_loop = true; | |
519 *tmp_pos = 0; | |
520 if (temp_str_len) | |
521 { | |
522 switch (decode_step) | |
523 { | |
524 case 0: //Item # | |
525 item_counter=atoi(test_string); | |
526 uAllItemsCount=item_counter; | |
527 break; | |
528 case 1: //Pic File | |
529 pItems[item_counter].pIconName = RemoveQuotes(test_string); | |
530 break; | |
531 case 2: //Name | |
532 pItems[item_counter].pName = RemoveQuotes(test_string); | |
533 break; | |
534 case 3: //Value | |
535 pItems[item_counter].uValue=atoi(test_string); | |
536 break; | |
537 case 4: //Equip Stat | |
538 { | |
539 if ( !_strcmpi(test_string, "weapon") ) | |
540 { | |
365 | 541 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 542 break; |
543 } | |
544 if ( !_strcmpi(test_string, "weapon2") ) | |
545 { | |
365 | 546 pItems[item_counter].uEquipType = EQUIP_TWO_HANDED; |
222 | 547 break; |
548 } | |
549 if ( !_strcmpi(test_string, "weapon1or2") ) | |
550 { | |
365 | 551 pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; |
222 | 552 break; |
553 } | |
554 if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow"))) | |
555 { | |
365 | 556 pItems[item_counter].uEquipType = EQUIP_BOW; |
222 | 557 break; |
558 } | |
559 if ( !_strcmpi(test_string, "armor") ) | |
560 { | |
365 | 561 pItems[item_counter].uEquipType = EQUIP_ARMOUR; |
222 | 562 break; |
563 } | |
564 if ( !_strcmpi(test_string, "shield") ) | |
565 { | |
365 | 566 pItems[item_counter].uEquipType = EQUIP_SHIELD; |
222 | 567 break; |
568 } | |
569 if ( !_strcmpi(test_string, "helm") ) | |
570 { | |
365 | 571 pItems[item_counter].uEquipType = EQUIP_HELMET; |
222 | 572 break; |
573 } | |
574 if ( !_strcmpi(test_string, "belt") ) | |
575 { | |
365 | 576 pItems[item_counter].uEquipType = EQUIP_BELT; |
222 | 577 break; |
578 } | |
579 if ( !_strcmpi(test_string, "cloak") ) | |
580 { | |
365 | 581 pItems[item_counter].uEquipType = EQUIP_CLOAK; |
222 | 582 break; |
583 } | |
584 if ( !_strcmpi(test_string, "gauntlets") ) | |
585 { | |
365 | 586 pItems[item_counter].uEquipType = EQUIP_GAUNTLETS; |
222 | 587 break; |
588 } | |
589 if ( !_strcmpi(test_string, "boots") ) | |
590 { | |
365 | 591 pItems[item_counter].uEquipType = EQUIP_BOOTS; |
222 | 592 break; |
593 } | |
594 if ( !_strcmpi(test_string, "ring") ) | |
595 { | |
365 | 596 pItems[item_counter].uEquipType = EQUIP_RING; |
222 | 597 break; |
598 } | |
599 if ( !_strcmpi(test_string, "amulet") ) | |
600 { | |
365 | 601 pItems[item_counter].uEquipType = EQUIP_AMULET; |
222 | 602 break; |
603 } | |
604 if ( !_strcmpi(test_string, "weaponw") ) | |
605 { | |
365 | 606 pItems[item_counter].uEquipType = EQUIP_WAND; |
222 | 607 break; |
608 } | |
609 if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent"))) | |
610 { | |
365 | 611 pItems[item_counter].uEquipType = EQUIP_REAGENT; |
222 | 612 break; |
613 } | |
614 if ( !_strcmpi(test_string, "bottle") ) | |
615 { | |
365 | 616 pItems[item_counter].uEquipType = EQUIP_POTION; |
222 | 617 break; |
618 } | |
619 if ( !_strcmpi(test_string, "sscroll") ) | |
620 { | |
374 | 621 pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL; |
222 | 622 break; |
623 } | |
624 if ( !_strcmpi(test_string, "book") ) | |
625 { | |
365 | 626 pItems[item_counter].uEquipType = EQUIP_BOOK; |
222 | 627 break; |
628 } | |
629 if ( !_strcmpi(test_string, "mscroll") ) | |
630 { | |
374 | 631 pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL; |
222 | 632 break; |
633 } | |
634 if ( !_strcmpi(test_string, "gold") ) | |
635 { | |
365 | 636 pItems[item_counter].uEquipType = EQUIP_GOLD; |
222 | 637 break; |
638 } | |
639 if ( !_strcmpi(test_string, "gem") ) | |
640 { | |
365 | 641 pItems[item_counter].uEquipType = EQUIP_GEM; |
222 | 642 break; |
643 } | |
365 | 644 pItems[item_counter].uEquipType = EQUIP_NONE; |
222 | 645 break; |
646 } | |
647 case 5: //Skill Group | |
648 { | |
649 if ( !_strcmpi(test_string, "staff") ) | |
650 { | |
374 | 651 pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF; |
222 | 652 break; |
653 } | |
654 if ( !_strcmpi(test_string, "sword") ) | |
655 { | |
374 | 656 pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD; |
222 | 657 break; |
658 } | |
659 if ( !_strcmpi(test_string, "dagger") ) | |
660 { | |
374 | 661 pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER; |
222 | 662 break; |
663 } | |
664 if ( !_strcmpi(test_string, "axe") ) | |
665 { | |
374 | 666 pItems[item_counter].uSkillType = PLAYER_SKILL_AXE; |
222 | 667 break; |
668 } | |
669 if ( !_strcmpi(test_string, "spear") ) | |
670 { | |
374 | 671 pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR; |
222 | 672 break; |
673 } | |
674 if ( !_strcmpi(test_string, "bow") ) | |
675 { | |
374 | 676 pItems[item_counter].uSkillType = PLAYER_SKILL_BOW; |
222 | 677 break; |
678 } | |
679 if ( !_strcmpi(test_string, "mace") ) | |
680 { | |
374 | 681 pItems[item_counter].uSkillType = PLAYER_SKILL_MACE; |
222 | 682 break; |
683 } | |
684 if ( !_strcmpi(test_string, "blaster") ) | |
685 { | |
374 | 686 pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER; |
222 | 687 break; |
688 } | |
689 if ( !_strcmpi(test_string, "shield") ) | |
690 { | |
374 | 691 pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD; |
222 | 692 break; |
693 } | |
694 if ( !_strcmpi(test_string, "leather") ) | |
695 { | |
374 | 696 pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER; |
222 | 697 break; |
698 } | |
699 if ( !_strcmpi(test_string, "chain") ) | |
700 { | |
374 | 701 pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN; |
222 | 702 break; |
703 } | |
704 if ( !_strcmpi(test_string, "plate") ) | |
705 { | |
374 | 706 pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE; |
222 | 707 break; |
708 } | |
709 if ( !_strcmpi(test_string, "club") ) | |
710 { | |
374 | 711 pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB; |
222 | 712 break; |
713 } | |
385 | 714 pItems[item_counter].uSkillType = PLAYER_SKILL_MISC; |
222 | 715 break; |
716 } | |
717 case 6: //Mod1 | |
718 { | |
719 int ii; | |
720 char* test_char; | |
721 int tst_len; | |
722 tst_len=strlen(test_string); | |
723 pItems[item_counter].uDamageDice=0; | |
724 pItems[item_counter].uDamageRoll=0; | |
725 test_char=test_string; | |
726 for (ii=0; ii<tst_len; ++ii) | |
727 { | |
728 if (tolower(*test_char)=='d') | |
729 { | |
730 *test_char=0; | |
731 pItems[item_counter].uDamageDice=atoi(test_string); | |
732 pItems[item_counter].uDamageRoll=atoi(test_char+1); | |
733 *test_char='d'; | |
734 break; | |
735 } | |
736 ++test_char; | |
737 } | |
738 test_char=test_string; | |
739 if ((ii==tst_len)&&(tolower(*test_char)=='s')) | |
740 { | |
741 pItems[item_counter].uDamageDice=atoi(test_char+1); | |
742 pItems[item_counter].uDamageRoll=1; | |
743 } | |
744 break; | |
745 } | |
746 case 7: //Mod2 | |
747 pItems[item_counter].uDamageMod=atoi(test_string); | |
748 break; | |
749 case 8: //material | |
750 { | |
751 if ( !_strcmpi(test_string, "artifact") ) | |
752 { | |
377 | 753 pItems[item_counter].uMaterial = MATERIAL_ARTEFACT; |
222 | 754 break; |
755 } | |
756 if ( !_strcmpi(test_string, "relic") ) | |
757 { | |
377 | 758 pItems[item_counter].uMaterial = MATERIAL_RELIC; |
222 | 759 break; |
760 } | |
761 if ( !_strcmpi(test_string, "special") ) | |
762 { | |
377 | 763 pItems[item_counter].uMaterial = MATERIAL_SPECIAL; |
222 | 764 break; |
765 } | |
377 | 766 pItems[item_counter].uMaterial = MATERIAL_COMMON; |
222 | 767 break;} |
768 case 9: //ID/Rep/St | |
769 pItems[item_counter].uItemID_Rep_St=atoi(test_string); | |
770 break; | |
771 case 10: //Not identified name | |
772 pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string); | |
773 break; | |
774 case 11: //Sprite Index | |
775 pItems[item_counter].uSpriteID=atoi(test_string); | |
776 break; | |
777 case 12: //VarA | |
224 | 778 { |
222 | 779 pItems[item_counter]._additional_value=0; |
780 pItems[item_counter]._bonus_type=0; | |
377 | 781 if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) |
222 | 782 { |
224 | 783 for(int ii=0; ii<24; ++ii) |
784 { | |
785 if (stricmp(test_string,pEnchantments[ii].pBonusStat)) | |
786 { | |
787 pItems[item_counter]._bonus_type=ii+1; | |
222 | 788 break; |
224 | 789 } |
790 } | |
791 if (!pItems[item_counter]._bonus_type) | |
792 { | |
793 for(int ii=0; ii<72; ++ii) | |
794 { | |
795 if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) | |
222 | 796 { |
224 | 797 pItems[item_counter]._additional_value=ii+1; |
222 | 798 } |
224 | 799 } |
800 } | |
222 | 801 } |
224 | 802 |
222 | 803 break; |
224 | 804 } |
222 | 805 case 13: //VarB |
377 | 806 if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) |
222 | 807 { |
808 char b_s=atoi(test_string); | |
809 if (b_s) | |
810 pItems[item_counter]._bonus_strength=b_s; | |
811 else | |
812 pItems[item_counter]._bonus_strength=1; | |
813 } | |
814 else | |
815 pItems[item_counter]._bonus_strength=0; | |
816 break; | |
817 case 14: //Equip X | |
818 pItems[item_counter].uEquipX=atoi(test_string); | |
819 break; | |
820 case 15: //Equip Y | |
821 pItems[item_counter].uEquipY=atoi(test_string); | |
822 break; | |
823 case 16: //Notes | |
824 pItems[item_counter].pDescription = RemoveQuotes(test_string); | |
825 break; | |
224 | 826 |
222 | 827 } |
828 } | |
829 else | |
830 { | |
831 if (!decode_step) | |
832 break_loop = true; | |
833 } | |
834 ++decode_step; | |
835 test_string=tmp_pos+1; | |
836 } while ((decode_step<17)&&!break_loop); | |
837 ++item_counter; | |
838 if (item_counter>799) | |
839 break; | |
840 } | |
841 | |
224 | 842 |
843 pRndItemsTXT_Raw = NULL; | |
844 uAllItemsCount = item_counter; | |
845 pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); | |
846 strtok(pRndItemsTXT_Raw, "\r"); | |
847 strtok(NULL, "\r"); | |
848 strtok(NULL, "\r"); | |
849 strtok(NULL, "\r"); | |
850 item_counter = 0; | |
851 while (true) | |
852 { | |
853 test_string = strtok(NULL, "\r") + 1; | |
854 break_loop = false; | |
855 decode_step=0; | |
856 do | |
857 { | |
858 c = *(unsigned char*)test_string; | |
859 temp_str_len = 0; | |
860 while((c!='\t')&&(c>0)) | |
861 { | |
862 ++temp_str_len; | |
863 c=test_string[temp_str_len]; | |
864 } | |
865 tmp_pos=test_string+temp_str_len; | |
866 if (*tmp_pos == 0) | |
867 break_loop = true; | |
868 *tmp_pos = 0; | |
869 if (temp_str_len) | |
870 { | |
871 switch (decode_step) | |
872 { | |
873 case 0: | |
874 item_counter=atoi(test_string); | |
875 break; | |
876 case 2: | |
877 pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string); | |
878 break; | |
879 case 3: | |
880 pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string); | |
881 break; | |
882 case 4: | |
883 pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string); | |
884 break; | |
885 case 5: | |
886 pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string); | |
887 break; | |
888 case 6: | |
889 pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string); | |
890 break; | |
891 case 7: | |
892 pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string); | |
893 break; | |
894 } | |
895 } | |
896 else | |
897 { | |
898 if (!decode_step) | |
899 break_loop = true; | |
900 } | |
901 ++decode_step; | |
902 test_string=tmp_pos+1; | |
903 } while ((decode_step<8)&&!break_loop); | |
904 ++item_counter; | |
905 if (item_counter>618) | |
906 break; | |
907 } | |
908 | |
909 if ( pRndItemsTXT_Raw ) | |
910 { | |
911 pAllocator->FreeChunk(pRndItemsTXT_Raw); | |
912 pRndItemsTXT_Raw = NULL; | |
913 } | |
914 //ChanceByTreasureLvl Summ - anti cheating? | |
915 memset(&uChanceByTreasureLvlSumm, 0, 24); | |
916 for(i=0;i<6;++i) | |
917 { | |
918 for (j=0;j<800;++j) | |
919 uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i]; | |
920 } | |
222 | 921 |
224 | 922 strtok(NULL, "\r"); |
923 strtok(NULL, "\r"); | |
924 strtok(NULL, "\r"); | |
925 strtok(NULL, "\r"); | |
926 strtok(NULL, "\r"); | |
927 for (i=0;i<3;++i) | |
928 { | |
929 test_string = strtok(NULL, "\r") + 1; | |
930 break_loop = false; | |
931 decode_step=0; | |
932 do | |
933 { | |
934 c = *(unsigned char*)test_string; | |
935 temp_str_len = 0; | |
936 while((c!='\t')&&(c>0)) | |
937 { | |
938 ++temp_str_len; | |
939 c=test_string[temp_str_len]; | |
940 } | |
941 tmp_pos=test_string+temp_str_len; | |
942 if (*tmp_pos == 0) | |
943 break_loop = true; | |
944 *tmp_pos = 0; | |
945 if (temp_str_len) | |
946 { | |
947 switch (decode_step) | |
948 { | |
949 case 2: | |
950 switch (i) | |
951 { | |
952 case 0: | |
953 uBonusChanceStandart[0]=atoi(test_string); | |
954 break; | |
955 case 1: | |
956 uBonusChanceSpecial[0]=atoi(test_string); | |
957 break; | |
958 case 2: | |
959 uBonusChanceWpSpecial[0]=atoi(test_string); | |
960 break; | |
961 } | |
962 break; | |
963 case 3: | |
964 switch (i) | |
965 { | |
966 case 0: | |
967 uBonusChanceStandart[1]=atoi(test_string); | |
968 break; | |
969 case 1: | |
970 uBonusChanceSpecial[1]=atoi(test_string); | |
971 break; | |
972 case 2: | |
973 uBonusChanceWpSpecial[1]=atoi(test_string); | |
974 break; | |
975 } | |
976 break; | |
977 case 4: | |
978 switch (i) | |
979 { | |
980 case 0: | |
981 uBonusChanceStandart[2]=atoi(test_string); | |
982 break; | |
983 case 1: | |
984 uBonusChanceSpecial[2]=atoi(test_string); | |
985 break; | |
986 case 2: | |
987 uBonusChanceWpSpecial[2]=atoi(test_string); | |
988 break; | |
989 } | |
990 break; | |
991 case 5: | |
992 switch (i) | |
993 { | |
994 case 0: | |
995 uBonusChanceStandart[3]=atoi(test_string); | |
996 break; | |
997 case 1: | |
998 uBonusChanceSpecial[3]=atoi(test_string); | |
999 break; | |
1000 case 2: | |
1001 uBonusChanceWpSpecial[3]=atoi(test_string); | |
1002 break; | |
1003 } | |
1004 break; | |
1005 case 6: | |
1006 switch (i) | |
1007 { | |
1008 case 0: | |
1009 uBonusChanceStandart[4]=atoi(test_string); | |
1010 break; | |
1011 case 1: | |
1012 uBonusChanceSpecial[4]=atoi(test_string); | |
1013 break; | |
1014 case 2: | |
1015 uBonusChanceWpSpecial[4]=atoi(test_string); | |
1016 break; | |
1017 } | |
1018 break; | |
1019 case 7: | |
1020 switch (i) | |
1021 { | |
1022 case 0: | |
1023 uBonusChanceStandart[5]=atoi(test_string); | |
1024 break; | |
1025 case 1: | |
1026 uBonusChanceSpecial[5]=atoi(test_string); | |
1027 break; | |
1028 case 2: | |
1029 uBonusChanceWpSpecial[5]=atoi(test_string); | |
1030 break; | |
1031 } | |
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<8)&&!break_loop); | |
1043 } | |
222 | 1044 |
224 | 1045 pSkillDescTXT_Raw = NULL; |
1046 pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); | |
1047 strtok(pSkillDescTXT_Raw, "\r"); | |
1048 for (i=0; i<37; ++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 (decode_step) | |
1069 { | |
1070 case 1: | |
1071 pSkillDesc[i] = RemoveQuotes(test_string); | |
1072 break; | |
1073 case 2: | |
1074 pNormalSkillDesc[i] = RemoveQuotes(test_string); | |
1075 break; | |
1076 case 3: | |
1077 pExpertSkillDesc[i] = RemoveQuotes(test_string); | |
1078 break; | |
1079 case 4: | |
1080 pMasterSkillDesc[i] = RemoveQuotes(test_string); | |
1081 break; | |
1082 case 5: | |
1083 pGrandSkillDesc[i] = RemoveQuotes(test_string); | |
1084 break; | |
1085 } | |
1086 } | |
1087 else | |
1088 { | |
1089 if (!decode_step) | |
1090 break_loop = true; | |
1091 } | |
1092 ++decode_step; | |
1093 test_string=tmp_pos+1; | |
1094 } while ((decode_step<6)&&!break_loop); | |
1095 } | |
1096 | |
1097 pStatsTXT_Raw = 0; | |
1098 pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); | |
1099 strtok(pStatsTXT_Raw, "\r"); | |
1100 for (i=0; i<26; ++i) | |
1101 { | |
1102 test_string = strtok(NULL, "\r") + 1; | |
1103 break_loop = false; | |
1104 decode_step=0; | |
1105 do | |
1106 { | |
1107 c = *(unsigned char*)test_string; | |
1108 temp_str_len = 0; | |
1109 while((c!='\t')&&(c>0)) | |
1110 { | |
1111 ++temp_str_len; | |
1112 c=test_string[temp_str_len]; | |
1113 } | |
1114 tmp_pos=test_string+temp_str_len; | |
1115 if (*tmp_pos == 0) | |
1116 break_loop = true; | |
1117 *tmp_pos = 0; | |
1118 if (temp_str_len) | |
1119 { | |
1120 switch (i) | |
1121 { | |
1122 case 0: | |
1123 case 1: | |
1124 case 2: | |
1125 case 3: | |
1126 case 4: | |
1127 case 5: | |
1128 case 6: | |
1129 pAttributeDescriptions[i] = RemoveQuotes(test_string); | |
1130 break; | |
1131 case 7: | |
1132 pHealthPointsAttributeDescription = RemoveQuotes(test_string); | |
1133 break; | |
1134 case 8: | |
1135 pArmourClassAttributeDescription = RemoveQuotes(test_string); | |
1136 break; | |
1137 case 9: | |
1138 pSpellPointsAttributeDescription = RemoveQuotes(test_string); | |
1139 break; | |
1140 case 10: | |
1141 pPlayerConditionAttributeDescription = RemoveQuotes(test_string); | |
1142 break; | |
1143 case 11: | |
1144 pFastSpellAttributeDescription = RemoveQuotes(test_string); | |
1145 break; | |
1146 case 12: | |
1147 pPlayerAgeAttributeDescription = RemoveQuotes(test_string); | |
1148 break; | |
1149 case 13: | |
1150 pPlayerLevelAttributeDescription = RemoveQuotes(test_string); | |
1151 break; | |
1152 case 14: | |
1153 pPlayerExperienceAttributeDescription = RemoveQuotes(test_string); | |
1154 break; | |
1155 case 15: | |
1156 pAttackBonusAttributeDescription = RemoveQuotes(test_string); | |
1157 break; | |
1158 case 16: | |
1159 pAttackDamageAttributeDescription = RemoveQuotes(test_string); | |
1160 break; | |
1161 case 17: | |
1162 pMissleBonusAttributeDescription = RemoveQuotes(test_string); | |
1163 break; | |
1164 case 18: | |
1165 pMissleDamageAttributeDescription = RemoveQuotes(test_string); | |
1166 break; | |
1167 case 19: | |
1168 pFireResistanceAttributeDescription = RemoveQuotes(test_string); | |
1169 break; | |
1170 case 20: | |
1171 pAirResistanceAttributeDescription = RemoveQuotes(test_string); | |
1172 break; | |
1173 case 21: | |
1174 pWaterResistanceAttributeDescription = RemoveQuotes(test_string); | |
1175 break; | |
1176 case 22: | |
1177 pEarthResistanceAttributeDescription = RemoveQuotes(test_string); | |
1178 break; | |
1179 case 23: | |
1180 pMindResistanceAttributeDescription = RemoveQuotes(test_string); | |
1181 break; | |
1182 case 24: | |
1183 pBodyResistanceAttributeDescription = RemoveQuotes(test_string); | |
1184 break; | |
1185 case 25: | |
1186 pSkillPointsAttributeDescription = RemoveQuotes(test_string); | |
1187 break; | |
1188 } | |
1189 } | |
1190 else | |
1191 { | |
1192 if (!decode_step) | |
1193 break_loop = true; | |
1194 } | |
1195 ++decode_step; | |
1196 test_string=tmp_pos+1; | |
1197 } while ((decode_step<2)&&!break_loop); | |
1198 } | |
222 | 1199 |
1200 | |
224 | 1201 pClassTXT_Raw = 0; |
1202 pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); | |
1203 strtok(pClassTXT_Raw, "\r"); | |
1204 for (i=0; i<36; ++i) | |
1205 { | |
1206 test_string = strtok(NULL, "\r") + 1; | |
1207 break_loop = false; | |
1208 decode_step=0; | |
1209 do | |
1210 { | |
1211 c = *(unsigned char*)test_string; | |
1212 temp_str_len = 0; | |
1213 while((c!='\t')&&(c>0)) | |
1214 { | |
1215 ++temp_str_len; | |
1216 c=test_string[temp_str_len]; | |
1217 } | |
1218 tmp_pos=test_string+temp_str_len; | |
1219 if (*tmp_pos == 0) | |
1220 break_loop = true; | |
1221 *tmp_pos = 0; | |
1222 if (temp_str_len) | |
1223 { | |
229 | 1224 //if(i) |
224 | 1225 pClassDescriptions[i]=RemoveQuotes(test_string); |
1226 } | |
1227 else | |
1228 { | |
1229 if (!decode_step) | |
1230 break_loop = true; | |
1231 } | |
1232 ++decode_step; | |
1233 test_string=tmp_pos+1; | |
1234 } while ((decode_step<2)&&!break_loop); | |
1235 } | |
222 | 1236 |
224 | 1237 } |
0 | 1238 |
1239 //----- (00456D17) -------------------------------------------------------- | |
1240 void ItemsTable::SetSpecialBonus(ItemGen *pItem) | |
1241 { | |
385 | 1242 if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) |
0 | 1243 { |
385 | 1244 pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type; |
1245 pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; | |
1246 pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength; | |
0 | 1247 } |
1248 } | |
1249 | |
1250 //----- (00456D43) -------------------------------------------------------- | |
377 | 1251 bool ItemsTable::IsMaterialSpecial(ItemGen *pItem) |
0 | 1252 { |
377 | 1253 return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL; |
0 | 1254 } |
1255 | |
1256 //----- (00456D5E) -------------------------------------------------------- | |
377 | 1257 bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem) |
0 | 1258 { |
385 | 1259 return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL || |
1260 pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC || | |
1261 pItems[pItem->uItemID].uMaterial == MATERIAL_ARTEFACT; | |
0 | 1262 } |
1263 | |
1264 | |
1265 //----- (00453B3C) -------------------------------------------------------- | |
1266 void ItemsTable::LoadPotions() | |
222 | 1267 { |
0 | 1268 |
222 | 1269 CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26 |
1270 char* test_string; | |
1271 unsigned int uRow; | |
1272 unsigned int uColumn; | |
1273 unsigned __int8 potion_value; | |
1274 | |
1275 if ( pPotionsTXT_Raw ) | |
1276 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
1277 pPotionsTXT_Raw = NULL; | |
1278 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
|
1279 test_string = strtok(pPotionsTXT_Raw,"\t\r\n"); |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1280 while ( 1 ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1281 { |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1282 if ( !test_string ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1283 { |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1284 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
|
1285 return; |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1286 } |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1287 if ( !strcmp(test_string, "222") ) |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1288 break; |
222 | 1289 |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1290 test_string = strtok(NULL, "\t\r\n"); |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1291 } |
222 | 1292 while ( 1 ) |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1293 { |
222 | 1294 test_string = strtok(NULL, "\t\r\n"); |
1295 | |
1296 if ( !test_string ) | |
1297 { | |
1298 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1299 return; | |
1300 } | |
1301 if ( !strcmp(test_string, "222") ) | |
1302 break; | |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1303 } |
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1304 |
222 | 1305 for (uRow = 0;uRow < 50; ++uRow) |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1306 { |
222 | 1307 int skip_count; |
1308 for (skip_count = 0;skip_count < 6; ++skip_count) | |
1309 { | |
1310 if ( !strtok(NULL, "\r\t\n") ) | |
1311 break; | |
1312 } | |
1313 if ( skip_count != 6 ) | |
1314 break; | |
1315 for (uColumn = 0; uColumn < 50; ++uColumn) | |
1316 { | |
1317 test_string = strtok(NULL, "\r\t\n"); | |
1318 if ( !test_string ) | |
1319 break; | |
1320 potion_value = atoi(test_string); | |
233 | 1321 unsigned char c=*test_string; |
222 | 1322 if ( !potion_value ) |
1323 { | |
1324 if ( tolower(c) == 'e' ) | |
1325 potion_value = atoi(test_string + 1); | |
1326 else | |
1327 potion_value = 0; | |
1328 } | |
1329 this->potion_data[uRow][uColumn]=potion_value; | |
1330 } | |
1331 if ( uColumn != 50 ) | |
1332 break; | |
1333 strtok(NULL, "\r\t\n"); | |
1334 } | |
193
821fd955c379
fixed potion data parsing. Somehow 3d render was affected
Gloval
parents:
189
diff
changeset
|
1335 |
222 | 1336 if ( uRow != 50 ) |
1337 { | |
1338 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); | |
1339 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1340 } | |
1341 if ( pPotionsTXT_Raw ) | |
1342 { | |
1343 pAllocator->FreeChunk(pPotionsTXT_Raw); | |
1344 pPotionsTXT_Raw = 0; | |
1345 } | |
1346 } | |
0 | 1347 |
1348 //----- (00453CE5) -------------------------------------------------------- | |
1349 void ItemsTable::LoadPotionNotes() | |
222 | 1350 { |
1351 | |
1352 CHAR Text[90]; | |
1353 char* test_string; | |
1354 unsigned int uRow; | |
1355 unsigned int uColumn; | |
1356 unsigned __int8 potion_note; | |
1357 | |
1358 if ( pPotionNotesTXT_Raw ) | |
1359 pAllocator->FreeChunk(pPotionNotesTXT_Raw); | |
1360 pPotionNotesTXT_Raw = NULL; | |
1361 pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); | |
1362 test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); | |
1363 while ( 1 ) | |
1364 { | |
1365 if ( !test_string ) | |
1366 { | |
1367 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1368 return; | |
1369 } | |
1370 if ( !strcmp(test_string, "222") ) | |
1371 break; | |
1372 test_string = strtok(NULL, "\t\r\n"); | |
1373 } | |
1374 while ( 1 ) | |
1375 { | |
1376 test_string = strtok(NULL, "\t\r\n"); | |
1377 | |
1378 if ( !test_string ) | |
1379 { | |
1380 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1381 return; | |
1382 } | |
1383 if ( !strcmp(test_string, "222") ) | |
1384 break; | |
1385 } | |
0 | 1386 |
222 | 1387 for (uRow = 0;uRow < 50; ++uRow) |
1388 { | |
1389 int skip_count; | |
1390 for (skip_count = 0;skip_count < 6; ++skip_count) | |
1391 { | |
1392 if ( !strtok(NULL, "\r\t\n") ) | |
1393 break; | |
1394 } | |
1395 if ( skip_count != 6 ) | |
1396 break; | |
1397 for (uColumn = 0; uColumn < 50; ++uColumn) | |
1398 { | |
1399 test_string = strtok(NULL, "\r\t\n"); | |
1400 if ( !test_string ) | |
1401 break; | |
1402 potion_note = atoi(test_string); | |
233 | 1403 unsigned char c=*test_string; |
222 | 1404 if ( !potion_note ) |
1405 { | |
1406 if ( tolower(c) == 'e' ) | |
1407 potion_note = atoi(test_string + 1); | |
1408 else | |
1409 potion_note = 0; | |
1410 } | |
1411 this->potion_note[uRow][uColumn]=potion_note; | |
1412 } | |
1413 if ( uColumn != 50 ) | |
1414 break; | |
1415 strtok(NULL, "\r\t\n"); | |
1416 } | |
1417 if ( uRow != 50 ) | |
1418 { | |
1419 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); | |
1420 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); | |
1421 } | |
1422 } | |
0 | 1423 |
1424 | |
1425 //----- (00456442) -------------------------------------------------------- | |
1426 unsigned int ItemGen::GetValue() | |
463 | 1427 { |
1428 unsigned int uBaseValue; // edi@1 | |
1429 unsigned int bonus; | |
0 | 1430 |
463 | 1431 uBaseValue = pItemsTable->pItems[this->uItemID].uValue; |
1432 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) | |
1433 return uBaseValue; | |
1434 if (uEncantmentType ) | |
1435 return uBaseValue + 100 * _bonus_strength;; | |
1436 if (uSpecEnchantmentType ) | |
1437 { | |
1438 bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel; | |
1439 if ( bonus > 10 ) | |
1440 return uBaseValue + bonus; | |
1441 else | |
1442 return uBaseValue * bonus; | |
1443 } | |
1444 return uBaseValue; | |
1445 } | |
0 | 1446 |
1447 //----- (00456499) -------------------------------------------------------- | |
1448 const char *ItemGen::GetDisplayName() | |
1449 { | |
366 | 1450 if (Identified()) |
1451 return GetIdentifiedName(); | |
0 | 1452 else |
366 | 1453 return pItemsTable->pItems[uItemID].pUnidentifiedName; |
0 | 1454 } |
1455 | |
1456 //----- (004564B3) -------------------------------------------------------- | |
1457 const char *ItemGen::GetIdentifiedName() | |
1458 { | |
377 | 1459 unsigned __int8 equip_type; |
1460 const char *player_name; | |
1461 const char *nameModificator; | |
1462 const char *format_str; | |
0 | 1463 |
377 | 1464 equip_type = pItemsTable->pItems[uItemID].uEquipType; |
1465 if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) | |
0 | 1466 { |
377 | 1467 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); |
1468 return item__getname_buffer; | |
0 | 1469 } |
377 | 1470 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); |
1471 if ( uItemID == ITEM_LICH_JAR ) //Lich Jar | |
0 | 1472 { |
377 | 1473 if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) |
0 | 1474 { |
377 | 1475 player_name = pPlayers[uHolderPlayer]->pName; |
1476 strlen(player_name); | |
1477 if ( player_name[strlen(player_name) - 1] == 's' ) | |
1478 format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" | |
0 | 1479 else |
377 | 1480 format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar" |
1481 sprintf(item__getname_buffer, format_str, pPlayers[uHolderPlayer]->pName); | |
1482 return item__getname_buffer; | |
0 | 1483 } |
1484 } | |
377 | 1485 if ( !pItemsTable->IsMaterialNonCommon(this) ) |
0 | 1486 { |
377 | 1487 if ( uEncantmentType ) |
0 | 1488 { |
1489 strcat(item__getname_buffer, " "); | |
377 | 1490 nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName; |
0 | 1491 } |
1492 else | |
1493 { | |
377 | 1494 if ( !uSpecEnchantmentType ) |
1495 return item__getname_buffer; | |
1496 if ( uSpecEnchantmentType == 16 //Drain Hit Points from target. | |
1497 || uSpecEnchantmentType == 39 //Double damage vs Demons. | |
1498 || uSpecEnchantmentType == 40 //Double damage vs Dragons | |
1499 || uSpecEnchantmentType == 45 //+5 Speed and Accuracy | |
1500 || uSpecEnchantmentType == 56 //+5 Might and Endurance. | |
1501 || uSpecEnchantmentType == 57 //+5 Intellect and Personality. | |
1502 || uSpecEnchantmentType == 58 //Increased Value. | |
1503 || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills | |
1504 || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills. | |
1505 || uSpecEnchantmentType == 59 //Increased Weapon speed. | |
1506 || uSpecEnchantmentType == 63 //Double Damage vs. Elves. | |
1507 || uSpecEnchantmentType == 64 //Double Damage vs. Undead. | |
1508 || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill. | |
1509 || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class. | |
1510 { //enchantment and name positions inverted! | |
1511 sprintf( item__getname_buffer, "%s %s", | |
1512 pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd, | |
1513 pItemsTable->pItems[uItemID].pName); | |
1514 return item__getname_buffer; | |
0 | 1515 } |
1516 strcat(item__getname_buffer, " "); | |
377 | 1517 nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd; |
0 | 1518 } |
377 | 1519 strcat(item__getname_buffer, nameModificator); |
0 | 1520 } |
377 | 1521 return item__getname_buffer; |
0 | 1522 } |
1523 | |
1524 | |
1525 //----- (00456620) -------------------------------------------------------- | |
385 | 1526 void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item) |
0 | 1527 { |
294 | 1528 |
1529 ItemGen *v4; // esi@1 | |
1530 ItemsTable *v5; // edi@1 | |
0 | 1531 int v6; // ebx@3 |
1532 int *v7; // ecx@33 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1533 //int v8; // eax@34 |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1534 //int v9; // eax@39 |
0 | 1535 int v10; // ebx@43 |
1536 int v11; // ecx@47 | |
1537 unsigned int *v12; // edx@48 | |
1538 unsigned int v13; // eax@49 | |
1539 signed int v14; // ebx@52 | |
1540 int v15; // eax@53 | |
1541 signed int v16; // eax@55 | |
1542 int v17; // ebx@57 | |
1543 int v18; // edx@62 | |
1544 signed int v19; // ebx@70 | |
1545 unsigned __int8 v20; // al@81 | |
1546 int v21; // eax@84 | |
1547 int v22; // ebx@85 | |
1548 int v23; // eax@86 | |
1549 int v24; // ebx@86 | |
1550 int v25; // edx@86 | |
1551 int v26; // edx@89 | |
1552 unsigned int v27; // eax@89 | |
1553 int i; // ebx@89 | |
1554 unsigned int v29; // ecx@90 | |
1555 int v30; // ebx@91 | |
1556 int v31; // eax@91 | |
1557 int v32; // ecx@91 | |
1558 int v33; // eax@91 | |
1559 int v34; // eax@97 | |
1560 unsigned __int8 v35; // sf@97 | |
1561 unsigned __int8 v36; // of@97 | |
1562 int v37; // ebx@98 | |
1563 int v38; // edx@99 | |
1564 signed int v39; // ebx@101 | |
1565 int v40; // ecx@102 | |
1566 char v41; // zf@107 | |
1567 char v42; // al@108 | |
1568 char v43; // al@111 | |
1569 int *v44; // edx@118 | |
1570 int v45; // eax@120 | |
1571 int v46; // edx@120 | |
1572 int *j; // eax@121 | |
1573 unsigned int v48; // ecx@123 | |
1574 int v49; // eax@123 | |
1575 int v50; // eax@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1576 int Dst[800]; // [sp+Ch] [bp-C88h]@33 |
0 | 1577 int v52; // [sp+C8Ch] [bp-8h]@33 |
294 | 1578 int v53; // [sp+C90h] [bp-4h]@1 |
1579 int v54; // [sp+C9Ch] [bp+8h]@3 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1580 //int v55; // [sp+CA0h] [bp+Ch]@34 |
0 | 1581 signed int v56; // [sp+CA0h] [bp+Ch]@55 |
1582 int v57; // [sp+CA0h] [bp+Ch]@62 | |
1583 int *v58; // [sp+CA0h] [bp+Ch]@102 | |
1584 int v59; // [sp+CA0h] [bp+Ch]@123 | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1585 //signed int a2a; // [sp+CA4h] [bp+10h]@33 |
0 | 1586 int a2b; // [sp+CA4h] [bp+10h]@101 |
1587 int a2c; // [sp+CA4h] [bp+10h]@120 | |
1588 | |
294 | 1589 v53 = -1; |
1590 v5 = this; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1591 if (!out_item) |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1592 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
|
1593 memset(out_item, 0, sizeof(*out_item)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1594 |
294 | 1595 v4 = out_item; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1596 v6 = treasure_level - 1; |
385 | 1597 v54 = treasure_level - 1; |
1598 if ( uTreasureType ) //generate known treasure type | |
0 | 1599 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1600 ITEM_EQUIP_TYPE requested_equip; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1601 PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; |
385 | 1602 switch (uTreasureType) |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1603 { |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1604 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
|
1605 case 21: requested_equip = EQUIP_ARMOUR; break; |
385 | 1606 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
|
1607 case 23: requested_skill = PLAYER_SKILL_SWORD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1608 case 24: requested_skill = PLAYER_SKILL_DAGGER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1609 case 25: requested_skill = PLAYER_SKILL_AXE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1610 case 26: requested_skill = PLAYER_SKILL_SPEAR; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1611 case 27: requested_skill = PLAYER_SKILL_BOW; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1612 case 28: requested_skill = PLAYER_SKILL_MACE; break; |
385 | 1613 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
|
1614 case 30: requested_skill = PLAYER_SKILL_STAFF; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1615 case 31: requested_skill = PLAYER_SKILL_LEATHER; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1616 case 32: requested_skill = PLAYER_SKILL_CHAIN; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1617 case 33: requested_skill = PLAYER_SKILL_PLATE; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1618 case 34: requested_equip = EQUIP_SHIELD; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1619 case 35: requested_equip = EQUIP_HELMET; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1620 case 36: requested_equip = EQUIP_BELT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1621 case 37: requested_equip = EQUIP_CLOAK; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1622 case 38: requested_equip = EQUIP_GAUNTLETS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1623 case 39: requested_equip = EQUIP_BOOTS; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1624 case 40: requested_equip = EQUIP_RING; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1625 case 41: requested_equip = EQUIP_AMULET; break; |
295 | 1626 case 42: requested_equip = EQUIP_WAND; break; |
374 | 1627 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
|
1628 case 44: requested_equip = EQUIP_POTION; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1629 case 45: requested_equip = EQUIP_REAGENT; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1630 case 46: requested_equip = EQUIP_GEM; break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1631 default: |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1632 __debugbreak(); // check this condition |
385 | 1633 requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1); |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1634 break; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1635 } |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1636 memset(Dst, 0, sizeof(Dst)); |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1637 v52 = 0; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1638 v7 = Dst; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1639 //a2a = 1; |
385 | 1640 if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed |
0 | 1641 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1642 for (uint i = 1; i < 500; ++i) |
0 | 1643 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1644 if (pItems[i].uEquipType == requested_equip) |
0 | 1645 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1646 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1647 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1648 } |
1649 } | |
1650 } | |
385 | 1651 else //have needed skill |
0 | 1652 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1653 for (uint i = 1; i < 500; ++i) |
0 | 1654 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1655 if (pItems[i].uSkillType == requested_skill) |
0 | 1656 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1657 *v7++ = i; |
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1658 v52 += pItems[i].uChanceByTreasureLvl[v6]; |
0 | 1659 } |
1660 } | |
1661 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1662 |
0 | 1663 v10 = 0; |
1664 if ( v52 ) | |
1665 v10 = rand() % v52; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1666 |
385 | 1667 out_item->uItemID = *Dst; |
1668 if (!out_item->uItemID) | |
1669 out_item->uItemID = 1; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1670 |
385 | 1671 v11 = pItems[out_item->uItemID].uChanceByTreasureLvl[v6]; |
0 | 1672 if ( v11 < v10 ) |
1673 { | |
1674 v12 = (uint *)Dst; | |
1675 do | |
1676 { | |
1677 ++v12; | |
1678 v13 = *v12; | |
385 | 1679 out_item->uItemID = *v12; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1680 v11 += pItems[v13].uChanceByTreasureLvl[v6]; |
0 | 1681 } |
1682 while ( v11 < v10 ); | |
1683 } | |
385 | 1684 |
1685 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | |
1686 {// if it potion set potion spec | |
1687 out_item->uEncantmentType = 0; | |
1688 for (int i=0; i<2; ++i) | |
1689 out_item->uEncantmentType += rand() % 4 + 1; | |
1690 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
0 | 1691 } |
1692 } | |
1693 else | |
1694 { | |
1695 v16 = 0; | |
1696 v56 = 0; | |
1697 do | |
484 | 1698 v56 += pParty->pIsArtifactFound[v16++]; |
0 | 1699 while ( v16 < 29 ); |
1700 v17 = rand() % 29; | |
385 | 1701 |
484 | 1702 if ( v6 == 5 && rand() % 100 < 5 && !pParty->pIsArtifactFound[v17] && v56 < 13 ) |
0 | 1703 { |
484 | 1704 pParty->pIsArtifactFound[v17] = 1; |
385 | 1705 out_item->uAttributes = 0; |
1706 out_item->uItemID = v17 + 500; | |
1707 SetSpecialBonus(out_item); | |
0 | 1708 return; |
1709 } | |
385 | 1710 |
0 | 1711 v57 = 0; |
294 | 1712 v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54]; |
385 | 1713 out_item->uItemID = 0; |
0 | 1714 if ( v18 > 0 ) |
1715 { | |
1716 do | |
385 | 1717 v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; |
0 | 1718 while ( v57 < v18 ); |
1719 } | |
385 | 1720 |
0 | 1721 if ( !v18 ) |
385 | 1722 out_item->uItemID = 1; |
1723 if ( !out_item->uItemID ) | |
1724 out_item->uItemID = 1; | |
1725 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | |
1726 {// if it potion set potion spec | |
1727 out_item->uEncantmentType = 0; | |
1728 for (int i=0; i<2; ++i) | |
1729 out_item->uEncantmentType += rand() % 4 + 1; | |
1730 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
1731 } | |
1732 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; | |
0 | 1733 } |
1734 if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION | |
484 | 1735 && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) |
0 | 1736 v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; |
222 | 1737 if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St ) |
0 | 1738 v4->uAttributes = 0; |
1739 else | |
1740 v4->uAttributes = 1; | |
385 | 1741 if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) |
0 | 1742 { |
385 | 1743 out_item->uSpecEnchantmentType = 0; |
1744 out_item->uEncantmentType = 0; | |
0 | 1745 } |
385 | 1746 v20 = pItems[out_item->uItemID].uEquipType; |
0 | 1747 if ( v20 <= EQUIP_BOW ) |
1748 { | |
294 | 1749 v37 = v5->uBonusChanceWpSpecial[v54]; |
436 | 1750 if ( !v37 ) |
0 | 1751 return; |
1752 v38 = rand() % 100; | |
436 | 1753 v36 = __OFSUB__(v38, v37); |
1754 v35 = v38 - v37 < 0; | |
0 | 1755 } |
1756 else | |
1757 { | |
1758 if ( v20 > EQUIP_AMULET ) | |
1759 { | |
295 | 1760 if ( v20 == EQUIP_WAND ) |
0 | 1761 { |
1762 v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; | |
385 | 1763 out_item->uNumCharges = v21; |
1764 out_item->uMaxCharges = v21; | |
0 | 1765 } |
1766 return; | |
1767 } | |
436 | 1768 v22 = uBonusChanceStandart[v6]; |
1769 if ( !v22 ) | |
0 | 1770 return; |
436 | 1771 v24 = v22; |
385 | 1772 v25 = rand() % 100; |
1773 if ( !uBonusChanceSpecial[v6] && !(v25 < v24)) | |
224 | 1774 return; |
385 | 1775 if ( v25 < v24 || v25 < v24) |
0 | 1776 { |
385 | 1777 v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[v4->uItemID].uEquipType + 3]; |
0 | 1778 v27 = v4->uItemID; |
377 | 1779 v4->uEncantmentType = 0; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1780 for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; |
0 | 1781 i < v26; |
377 | 1782 i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] ) |
0 | 1783 { |
1784 v29 = v4->uItemID; | |
377 | 1785 ++v4->uEncantmentType; |
0 | 1786 } |
377 | 1787 ++v4->uEncantmentType; |
224 | 1788 v30 = 10;// v5->field_116D8[2 * v54 + 12]; |
0 | 1789 v31 = rand(); |
377 | 1790 v32 = v4->uEncantmentType - 1; |
224 | 1791 v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; |
0 | 1792 v4->_bonus_strength = v33; |
1793 if ( v32 == 21 || v32 == 22 || v32 == 23 ) | |
1794 v4->_bonus_strength = v33 >> 1; | |
1795 if ( v4->_bonus_strength <= 0 ) | |
1796 v4->_bonus_strength = 1; | |
1797 return; | |
1798 } | |
224 | 1799 v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24]; |
0 | 1800 v36 = __OFSUB__(v25, v34); |
1801 v35 = v25 - v34 < 0; | |
1802 } | |
1803 if ( !(v35 ^ v36) ) | |
1804 return; | |
1805 memset(&Dst, 0, 0xC80u); | |
1806 v39 = 0; | |
1807 a2b = 0; | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1808 if ( pSpecialEnchantments_count > 0 ) |
0 | 1809 { |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1810 v52 = -16 - (uint)this; |
0 | 1811 v58 = (int *)&Dst; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1812 v40 = (int)&pSpecialEnchantments[1]; |
0 | 1813 do |
1814 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1815 switch ( v6 ) |
0 | 1816 { |
1817 case 2: | |
1818 if ( !*(unsigned char *)v40 ) | |
245 | 1819 { |
1820 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1821 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1822 { | |
1823 v44 = v58; | |
1824 ++v58; | |
1825 *v44 = a2b; | |
1826 } | |
1827 ++a2b; | |
1828 v40 += 28; | |
1829 continue; | |
1830 } | |
0 | 1831 v41 = *(unsigned char *)v40 == 1; |
1832 break; | |
1833 case 3: | |
1834 v43 = *(unsigned char *)v40; | |
1835 if ( !*(unsigned char *)v40 || v43 == 1 ) | |
1836 { | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1837 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
|
1838 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) |
0 | 1839 { |
1840 v44 = v58; | |
1841 ++v58; | |
1842 *v44 = a2b; | |
1843 } | |
245 | 1844 ++a2b; |
1845 v40 += 28; | |
1846 continue; | |
0 | 1847 } |
1848 v41 = v43 == 2; | |
1849 break; | |
1850 case 4: | |
1851 v42 = *(unsigned char *)v40; | |
1852 if ( *(unsigned char *)v40 == 1 || v42 == 2 ) | |
245 | 1853 { |
1854 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1855 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1856 { | |
1857 v44 = v58; | |
1858 ++v58; | |
1859 *v44 = a2b; | |
1860 } | |
1861 ++a2b; | |
1862 v40 += 28; | |
1863 continue; | |
1864 } | |
0 | 1865 v41 = v42 == 3; |
1866 break; | |
1867 default: | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1868 if ( v6 != 5 ) |
245 | 1869 { |
1870 ++a2b; | |
1871 v40 += 28; | |
1872 continue; | |
1873 } | |
0 | 1874 v41 = *(unsigned char *)v40 == 3; |
1875 break; | |
1876 } | |
1877 if ( v41 ) | |
245 | 1878 { |
1879 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); | |
1880 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) | |
1881 { | |
1882 v44 = v58; | |
1883 ++v58; | |
1884 *v44 = a2b; | |
1885 } | |
1886 } | |
0 | 1887 LABEL_119: |
1888 ++a2b; | |
1889 v40 += 28; | |
1890 } | |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1891 while ( a2b < pSpecialEnchantments_count ); |
0 | 1892 } |
1893 v45 = rand(); | |
377 | 1894 v4->uSpecEnchantmentType = *(uint *)Dst; |
0 | 1895 v46 = v45 % v39 + 1; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1896 a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); |
0 | 1897 if ( a2c < v46 ) |
1898 { | |
1899 for ( j = (int *)&Dst; ; j = (int *)v59 ) | |
1900 { | |
1901 v48 = v4->uItemID; | |
1902 v49 = (int)(j + 1); | |
1903 v59 = v49; | |
1904 v50 = *(unsigned int *)v49; | |
377 | 1905 v4->uSpecEnchantmentType = v50; |
228
46ae2602aceb
Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents:
224
diff
changeset
|
1906 a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); |
0 | 1907 if ( a2c >= v46 ) |
1908 break; | |
1909 } | |
1910 } | |
377 | 1911 ++v4->uSpecEnchantmentType; |
0 | 1912 } |
1913 | |
1914 //----- (004505CC) -------------------------------------------------------- | |
1915 bool ItemGen::GenerateArtifact() | |
1916 { | |
1917 signed int uNumArtifactsNotFound; // esi@1 | |
463 | 1918 int artifacts_list[32]; |
0 | 1919 |
385 | 1920 memset(artifacts_list, 0,sizeof(artifacts_list)); |
0 | 1921 uNumArtifactsNotFound = 0; |
385 | 1922 |
1923 for (int i=500;i<529;++i) | |
484 | 1924 if ( !pParty->pIsArtifactFound[i-500] ) |
385 | 1925 artifacts_list[uNumArtifactsNotFound++] = i; |
1926 | |
1927 Reset(); | |
0 | 1928 if ( uNumArtifactsNotFound ) |
1929 { | |
385 | 1930 uItemID = artifacts_list[rand() % uNumArtifactsNotFound]; |
1931 pItemsTable->SetSpecialBonus(this); | |
1932 return true; | |
0 | 1933 } |
1934 else | |
385 | 1935 return false; |
1936 | |
0 | 1937 } |
461 | 1938 //----- (004B8E3D) -------------------------------------------------------- |
463 | 1939 void GenerateStandartShopItems() |
1940 { | |
1941 signed int item_count; | |
1942 signed int shop_index; | |
1943 int treasure_lvl; | |
1944 int item_class; | |
1945 int mdf; | |
1946 | |
1947 shop_index = (signed int)window_SpeakInHouse->ptr_1C; | |
1948 if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) | |
1949 { | |
1950 for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) | |
1951 { | |
1952 if (shop_index<=14) //weapon shop | |
1953 { | |
1954 treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level; | |
1955 item_class =shopWeap_variation_ord[shop_index].item_class[rand() % 4]; | |
1956 } | |
1957 else if (shop_index<=28) //armor shop | |
1958 { | |
1959 mdf =0; | |
1960 if (item_count > 3) | |
1961 ++mdf;// rechek offsets | |
1962 treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level; | |
1963 item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4]; | |
1964 } | |
1965 else if (shop_index<=41) //magic shop | |
1966 { | |
1967 treasure_lvl = shopMagic_treasure_lvl[shop_index-28]; | |
1968 item_class = 22; //misc | |
1969 } | |
1970 else if (shop_index<=53) //alchemist shop | |
1971 { | |
1972 if (item_count<6) | |
1973 { | |
1974 pParty->StandartItemsInShops[shop_index][item_count].Reset(); | |
1975 pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle | |
1976 continue; | |
1977 } | |
1978 else | |
1979 { | |
1980 treasure_lvl = shopAlch_treasure_lvl[shop_index-41]; | |
1981 item_class = 45; //reagent | |
1982 } | |
1983 } | |
1984 pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]); | |
1985 pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified | |
1986 } | |
1987 } | |
1988 pParty->InTheShopFlags[shop_index] = 0; | |
1989 } | |
1990 | |
1991 //----- (004B8F94) -------------------------------------------------------- | |
1992 void GenerateSpecialShopItems() | |
461 | 1993 { |
463 | 1994 signed int item_count; |
1995 signed int shop_index; | |
1996 int treasure_lvl; | |
1997 int item_class; | |
1998 int mdf; | |
1999 | |
2000 shop_index = (signed int)window_SpeakInHouse->ptr_1C; | |
2001 if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) | |
2002 { | |
2003 for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) | |
2004 { | |
2005 if (shop_index<=14) //weapon shop | |
2006 { | |
2007 treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level; | |
2008 item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4]; | |
2009 } | |
2010 else if (shop_index<=28) //armor shop | |
2011 { | |
2012 mdf =0; | |
2013 if (item_count > 3) | |
2014 ++mdf; | |
470 | 2015 treasure_lvl = shopArmr_variation_spc[2*(shop_index-15)+mdf].treasure_level; |
2016 item_class =shopArmr_variation_spc[2*(shop_index-15)+mdf].item_class[rand() % 4]; | |
463 | 2017 } |
2018 else if (shop_index<=41) //magic shop | |
2019 { | |
2020 treasure_lvl = shopMagicSpc_treasure_lvl[shop_index-28]; | |
2021 item_class = 22; //misc | |
2022 } | |
2023 else if (shop_index<=53) //alchemist shop | |
2024 { | |
2025 if (item_count<6) | |
2026 { | |
470 | 2027 pParty->SpecialItemsInShops[shop_index][item_count].Reset(); |
2028 pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool | |
463 | 2029 continue; |
2030 } | |
2031 else | |
2032 { | |
470 | 2033 treasure_lvl = shopAlchSpc_treasure_lvl[shop_index-41]; |
463 | 2034 item_class = 44; //potion |
2035 } | |
2036 } | |
470 | 2037 pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShops[shop_index][item_count]); |
2038 pParty->SpecialItemsInShops[shop_index][item_count].SetIdentified(); //identified | |
463 | 2039 } |
2040 } | |
2041 pParty->InTheShopFlags[shop_index] = 0; | |
461 | 2042 } |
2043 | |
2044 | |
463 | 2045 //----- (00450218) -------------------------------------------------------- |
2046 void __cdecl sub_450218_prolly_generate_chests_loot() | |
2047 { | |
2048 unsigned int v0; // eax@1 | |
2049 Chest *v1; // ebx@1 | |
2050 MapInfo *v2; // esi@1 | |
2051 ItemGen *v3; // ebx@2 | |
2052 int v4; // ebp@4 | |
2053 int v5; // edi@4 | |
2054 int v6; // esi@4 | |
2055 int v7; // eax@4 | |
2056 signed int v8; // esi@4 | |
2057 int v9; // edx@4 | |
2058 int v10; // esi@8 | |
2059 int v11; // ebp@25 | |
2060 int v12; // esi@25 | |
2061 signed int v13; // ebp@27 | |
2062 ItemGen *v14; // edi@28 | |
2063 signed int v15; // edx@32 | |
2064 signed __int64 v16; // qtt@32 | |
2065 int v17; // esi@34 | |
2066 signed int v18; // [sp+10h] [bp-18h]@1 | |
2067 int v19; // [sp+14h] [bp-14h]@4 | |
2068 MapInfo *v20; // [sp+18h] [bp-10h]@1 | |
2069 Chest *v21; // [sp+1Ch] [bp-Ch]@1 | |
2070 int v22; // [sp+20h] [bp-8h]@26 | |
2071 signed int v23; // [sp+24h] [bp-4h]@2 | |
461 | 2072 |
463 | 2073 v18 = rand() % 100; |
2074 v0 = pMapStats->GetMapInfo(pCurrentMapName); | |
2075 v1 = pChests; | |
2076 v2 = &pMapStats->pInfos[v0]; | |
2077 v21 = pChests; | |
2078 v20 = &pMapStats->pInfos[v0]; | |
2079 do | |
461 | 2080 { |
463 | 2081 v3 = v1->mm7__vector_pItems; |
2082 v23 = 140; | |
461 | 2083 do |
2084 { | |
463 | 2085 if ( (v3->uItemID & 0x80000000u) == 0 ) |
2086 goto LABEL_56; | |
2087 v4 = rand() % 5 + 1; | |
2088 v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; | |
2089 v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; | |
2090 v7 = rand(); | |
2091 v8 = v6 - v5 + 1; | |
2092 v9 = v5 + v7 % v8; | |
2093 v19 = v5 + v7 % v8; | |
2094 if ( v9 < 7 ) | |
461 | 2095 { |
463 | 2096 if ( v18 < 20 ) |
2097 { | |
2098 v3->Reset(); | |
2099 goto LABEL_25; | |
2100 } | |
2101 if ( v18 < 60 ) | |
461 | 2102 { |
463 | 2103 v10 = 0; |
2104 v3->Reset(); | |
2105 if ( v19 == 1 ) | |
461 | 2106 { |
463 | 2107 v10 = rand() % 51 + 50; |
461 | 2108 } |
463 | 2109 else |
461 | 2110 { |
463 | 2111 if ( v19 != 2 ) |
461 | 2112 { |
463 | 2113 if ( v19 == 3 ) |
461 | 2114 { |
463 | 2115 v10 = rand() % 301 + 200; |
2116 } | |
2117 else | |
2118 { | |
2119 if ( v19 != 4 ) | |
461 | 2120 { |
463 | 2121 if ( v19 == 5 ) |
2122 { | |
2123 v10 = rand() % 1001 + 1000; | |
2124 LABEL_15: | |
2125 v3->uItemID = 199; | |
2126 } | |
2127 else | |
2128 { | |
2129 if ( v19 == 6 ) | |
2130 { | |
2131 v10 = rand() % 3001 + 2000; | |
2132 goto LABEL_15; | |
2133 } | |
2134 } | |
2135 LABEL_23: | |
2136 v3->SetIdentified(); | |
2137 v3->uSpecEnchantmentType = v10; | |
2138 LABEL_25: | |
2139 v11 = v4 - 1; | |
2140 v12 = 0; | |
2141 if ( v11 > 0 ) | |
461 | 2142 { |
463 | 2143 v22 = v11; |
2144 while ( 1 ) | |
461 | 2145 { |
463 | 2146 v13 = v12; |
2147 if ( v12 >= 140 ) | |
2148 goto LABEL_52; | |
2149 v14 = &v21->mm7__vector_pItems[v12]; | |
2150 while ( v14->uItemID ) | |
2151 { | |
2152 ++v13; | |
2153 ++v14; | |
2154 if ( v13 >= 140 ) | |
2155 goto LABEL_52; | |
2156 } | |
2157 v16 = rand(); | |
2158 v15 = v16 % 100; | |
2159 v18 = v16 % 100; | |
2160 if ( v15 < 20 ) | |
2161 goto LABEL_52; | |
2162 if ( v15 >= 60 ) | |
2163 { | |
2164 pItemsTable->GenerateItem(v19, 0, v14); | |
2165 goto LABEL_51; | |
2166 } | |
2167 v17 = 0; | |
2168 v14->Reset(); | |
2169 if ( v19 == 1 ) | |
2170 { | |
2171 v17 = rand() % 51 + 50; | |
2172 goto LABEL_48; | |
2173 } | |
2174 if ( v19 == 2 ) | |
2175 { | |
2176 v17 = rand() % 101 + 100; | |
2177 LABEL_48: | |
2178 v14->uItemID = 197; | |
2179 goto LABEL_49; | |
2180 } | |
2181 if ( v19 == 3 ) | |
2182 { | |
2183 v17 = rand() % 301 + 200; | |
2184 goto LABEL_44; | |
2185 } | |
2186 if ( v19 == 4 ) | |
2187 { | |
2188 v17 = rand() % 501 + 500; | |
2189 LABEL_44: | |
2190 v14->uItemID = 198; | |
2191 goto LABEL_49; | |
2192 } | |
2193 if ( v19 == 5 ) | |
2194 break; | |
461 | 2195 if ( v19 == 6 ) |
2196 { | |
463 | 2197 v17 = rand() % 3001 + 2000; |
2198 LABEL_41: | |
2199 v14->uItemID = 199; | |
461 | 2200 } |
463 | 2201 LABEL_49: |
2202 v14->uSpecEnchantmentType = v17; | |
2203 LABEL_51: | |
2204 v12 = v13 + 1; | |
2205 LABEL_52: | |
2206 --v22; | |
2207 if ( !v22 ) | |
2208 goto LABEL_55; | |
461 | 2209 } |
463 | 2210 v17 = rand() % 1001 + 1000; |
2211 goto LABEL_41; | |
461 | 2212 } |
463 | 2213 goto LABEL_55; |
461 | 2214 } |
463 | 2215 v10 = rand() % 501 + 500; |
461 | 2216 } |
463 | 2217 v3->uItemID = 198; |
2218 goto LABEL_23; | |
461 | 2219 } |
463 | 2220 v10 = rand() % 101 + 100; |
461 | 2221 } |
463 | 2222 v3->uItemID = 197; |
2223 goto LABEL_23; | |
461 | 2224 } |
463 | 2225 pItemsTable->GenerateItem(v9, 0, v3); |
2226 goto LABEL_25; | |
461 | 2227 } |
463 | 2228 v3->GenerateArtifact(); |
2229 LABEL_55: | |
2230 v2 = v20; | |
2231 LABEL_56: | |
2232 ++v3; | |
2233 --v23; | |
461 | 2234 } |
463 | 2235 while ( v23 ); |
2236 v1 = v21 + 1; | |
2237 ++v21; | |
461 | 2238 } |
463 | 2239 while ( (signed int)v21 < (signed int)&uNumChests ); |
2240 } | |
461 | 2241 |
2242 | |
2243 | |
2244 | |
463 | 2245 // 4505CC: using guessed type int var_A0[32]; |
2246 //----- (004B3703) -------------------------------------------------------- | |
473 | 2247 void FillAviableSkillsToTeach( int _this ) |
2248 { | |
2249 char *v30; // ecx@65 | |
2250 unsigned int v29; // edx@56 | |
2251 int v15; // ecx@19 | |
2252 int v33; // [sp-4h] [bp-2Ch]@23 | |
2253 int v34; // [sp-4h] [bp-2Ch]@43 | |
2254 int v21; // ecx@34 | |
2255 int v35[5]; // [sp+Ch] [bp-1Ch]@8 | |
2256 int v37=0; // [sp+24h] [bp-4h]@1* | |
2257 int i=0; | |
2258 | |
2259 dword_F8B1DC = 0; | |
2260 | |
2261 switch (_this) | |
463 | 2262 { |
473 | 2263 case 1: //shop weapon |
2264 for (int i=0; i<2; ++i) | |
2265 { | |
2266 for (int j=0; j<4; ++j) | |
2267 { | |
2268 if ( i ) | |
2269 v21 = shopWeap_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; | |
2270 else | |
2271 v21 = shopWeap_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; | |
463 | 2272 |
473 | 2273 switch (v21) |
463 | 2274 { |
473 | 2275 case 23: v34 = 37; break; |
2276 case 24: v34 = 38; break; | |
2277 case 25: v34 = 39; break; | |
2278 case 26: v34 = 40; break; | |
2279 case 27: v34 = 41; break; | |
2280 case 28: v34 = 42; break; | |
2281 case 30: v34 = 36; break; | |
2282 default: | |
2283 continue; | |
2284 } | |
2285 v37 = sub_4BE571(v34, v35, v37, 5); | |
463 | 2286 } |
2287 } | |
473 | 2288 break; |
2289 case 2: //shop armor | |
2290 | |
2291 for (int i=0; i<2; ++i) | |
463 | 2292 { |
473 | 2293 for (int j=0; j<2; ++j) |
463 | 2294 { |
473 | 2295 for (int k=0; k<4; ++k) |
463 | 2296 { |
473 | 2297 if ( i ) |
2298 v15 = shopArmr_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; | |
2299 else | |
2300 v15 = shopArmr_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; | |
2301 switch (v15) | |
463 | 2302 { |
473 | 2303 case 31: v33 = 45; break; |
2304 case 32: v33 = 46; break; | |
2305 case 33: v33 = 47; break; | |
2306 case 34: v33 = 44; break; | |
2307 default: | |
2308 continue; | |
463 | 2309 } |
473 | 2310 v37 = sub_4BE571(v33, v35, v37, 5); |
463 | 2311 } |
2312 } | |
2313 } | |
473 | 2314 break; |
2315 case 3: //shop magic | |
2316 v37 = 2; | |
2317 v35[0] = 57; | |
2318 v35[1] = 59; | |
2319 break; | |
2320 case 4: //shop alchemist | |
2321 v37 = 2; | |
2322 v35[0] = 71; | |
2323 v35[1] = 68; | |
2324 break; | |
2325 case 21: //tavern | |
2326 v37 = 3; | |
2327 v35[0] = 70; | |
2328 v35[1] = 65; | |
2329 v35[2] = 62; | |
2330 break; | |
2331 case 23: //temple | |
2332 v37 = 3; | |
2333 v35[0] = 67; | |
2334 v35[1] = 66; | |
2335 v35[2] = 58; | |
2336 break; | |
2337 case 30: ///trainig | |
2338 v37 = 2; | |
2339 v35[0] = 69; | |
2340 v35[1] = 60; | |
2341 break; | |
2342 } | |
2343 for(i=0;i<v37;++i) | |
2344 { | |
2345 v29=v35[i]; | |
2346 switch(v29) | |
463 | 2347 { |
473 | 2348 case 40 :v30 = pSkillNames[4]; break; |
2349 case 5 : v30 = pSkillNames[23]; break; | |
2350 case 36 :v30 = pSkillNames[0]; break; | |
2351 case 37 :v30 = pSkillNames[1]; break; | |
2352 case 38 :v30 = pSkillNames[2]; break; | |
2353 case 39 :v30 = pSkillNames[3]; break; | |
2354 case 41 :v30 = pSkillNames[5]; break; | |
2355 case 42 :v30 = pSkillNames[6]; break; | |
2356 case 44 :v30 = pSkillNames[8]; break; | |
2357 case 45 :v30 = pSkillNames[9]; break; | |
2358 case 46 :v30 = pSkillNames[10]; break; | |
2359 case 47 :v30 = pSkillNames[11]; break; | |
2360 case 66 :v30 = pSkillNames[30]; break; | |
2361 case 57 :v30 = pSkillNames[21]; break; | |
2362 case 58 :v30 = pSkillNames[22]; break; | |
2363 case 60 :v30 = pSkillNames[24]; break; | |
2364 case 62 :v30 = pSkillNames[26]; break; | |
2365 case 65 :v30 = pSkillNames[29]; break; | |
2366 case 67:v30 = pSkillNames[31]; break; | |
2367 case 68:v30 = pSkillNames[32]; break; | |
2368 case 69:v30 = pSkillNames[33]; break; | |
2369 case 70:v30 = pSkillNames[34]; break; | |
2370 case 71:v30 = pSkillNames[35]; break; | |
2371 default: | |
463 | 2372 v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!" |
2373 } | |
473 | 2374 pShopOptions[dword_F8B1DC] = v30; |
2375 ++dword_F8B1DC; | |
2376 CreateButtonInColumn(i+1, v29); | |
463 | 2377 } |
473 | 2378 pDialogueWindow->_41D08F(i, 1, 0, 2); |
2379 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; | |
2380 } | |
475 | 2381 |
2382 //----- (004BE571) -------------------------------------------------------- | |
2383 int sub_4BE571(int a1, int *a2, int a3, int a4) | |
2384 { | |
2385 int result; // eax@1 | |
2386 int i; // esi@3 | |
2387 | |
2388 result = a3; | |
2389 if ( a3 < a4 ) | |
2390 { | |
2391 for ( i = 0; i < a3; ++i ) | |
2392 { | |
2393 if ( a1 == a2[i] ) | |
2394 break; | |
2395 } | |
2396 if ( i == a3 ) | |
2397 { | |
2398 a2[a3] = a1; | |
2399 result = a3 + 1; | |
2400 } | |
2401 return result; | |
2402 } | |
2403 else | |
2404 { | |
2405 return a4; | |
2406 } | |
2407 } | |
2408 | |
2409 |