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