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