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