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