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