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