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