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