annotate Items.cpp @ 314:6a7607a1bd04

use item in inventory fixed
author zipi
date Tue, 19 Feb 2013 22:09:58 +0000
parents af7e848d6def
children 2a09e1d6fc8f
rev   line source
0
Ritor1
parents:
diff changeset
1 #include <stdlib.h>
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
2 #include <assert.h>
0
Ritor1
parents:
diff changeset
3
Ritor1
parents:
diff changeset
4 #include "Items.h"
Ritor1
parents:
diff changeset
5 #include "MapInfo.h"
Ritor1
parents:
diff changeset
6 #include "FrameTableInc.h"
Ritor1
parents:
diff changeset
7 #include "Allocator.h"
Ritor1
parents:
diff changeset
8 #include "LOD.h"
Ritor1
parents:
diff changeset
9 #include "Monsters.h"
Ritor1
parents:
diff changeset
10 #include "Party.h"
Ritor1
parents:
diff changeset
11 #include "FactionTable.h"
Ritor1
parents:
diff changeset
12 #include "StorylineTextTable.h"
189
038a4d09406f new texts file, fix text rendender error
Gloval
parents: 0
diff changeset
13 #include "texts.h"
0
Ritor1
parents:
diff changeset
14 #include "mm7_data.h"
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20 ItemGen *ptr_50C9A4;
Ritor1
parents:
diff changeset
21
Ritor1
parents:
diff changeset
22 struct ItemsTable *pItemsTable;
Ritor1
parents:
diff changeset
23
Ritor1
parents:
diff changeset
24
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28 //----- (00439DF3) --------------------------------------------------------
Ritor1
parents:
diff changeset
29 int ItemGen::_439DF3_get_additional_damage(int *a2, int *a3)
Ritor1
parents:
diff changeset
30 {
Ritor1
parents:
diff changeset
31 int *v3; // edi@1
Ritor1
parents:
diff changeset
32 ItemGen *v4; // ebx@1
Ritor1
parents:
diff changeset
33 signed int v5; // esi@1
Ritor1
parents:
diff changeset
34 unsigned int v7; // ecx@5
Ritor1
parents:
diff changeset
35 signed int v8; // ebx@7
Ritor1
parents:
diff changeset
36 int v9; // edx@22
Ritor1
parents:
diff changeset
37 int v10; // eax@24
Ritor1
parents:
diff changeset
38 int v11; // edx@25
Ritor1
parents:
diff changeset
39 int v12; // ebx@28
Ritor1
parents:
diff changeset
40 int v13; // ebx@29
Ritor1
parents:
diff changeset
41 int v14; // ebx@30
Ritor1
parents:
diff changeset
42 int v15; // ebx@31
Ritor1
parents:
diff changeset
43 int v16; // ebx@32
Ritor1
parents:
diff changeset
44 signed int v17; // [sp-4h] [bp-10h]@24
Ritor1
parents:
diff changeset
45
Ritor1
parents:
diff changeset
46 auto a1 = this;
Ritor1
parents:
diff changeset
47 v3 = a2;
Ritor1
parents:
diff changeset
48 v4 = a1;
Ritor1
parents:
diff changeset
49 v5 = 0;
Ritor1
parents:
diff changeset
50 *a2 = 0;
Ritor1
parents:
diff changeset
51 if ( !a1->uItemID )
Ritor1
parents:
diff changeset
52 return 0;
Ritor1
parents:
diff changeset
53 UpdateTempBonus(pParty->uTimePlayed);
Ritor1
parents:
diff changeset
54 if ( v4->uItemID == 501 )
Ritor1
parents:
diff changeset
55 {
Ritor1
parents:
diff changeset
56 *v3 = 1;
Ritor1
parents:
diff changeset
57 v10 = rand();
Ritor1
parents:
diff changeset
58 v17 = 10;
Ritor1
parents:
diff changeset
59 return v10 % v17 + 6;
Ritor1
parents:
diff changeset
60 }
Ritor1
parents:
diff changeset
61 if ( v4->uItemID == 507 )
Ritor1
parents:
diff changeset
62 {
Ritor1
parents:
diff changeset
63 *v3 = 0;
Ritor1
parents:
diff changeset
64 v11 = rand() % 16;
Ritor1
parents:
diff changeset
65 return v11 + 3;
Ritor1
parents:
diff changeset
66 }
Ritor1
parents:
diff changeset
67 v7 = 3;
Ritor1
parents:
diff changeset
68 if ( v4->uItemID == 510 )
Ritor1
parents:
diff changeset
69 {
Ritor1
parents:
diff changeset
70 *v3 = 2;
Ritor1
parents:
diff changeset
71 v9 = rand() % 4;
Ritor1
parents:
diff changeset
72 return v9 + 9;
Ritor1
parents:
diff changeset
73 }
Ritor1
parents:
diff changeset
74 if ( v4->uItemID == 517 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
75 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
76 v5 = 8;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
77 *v3 = v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
78 return v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
79 }
0
Ritor1
parents:
diff changeset
80 v8 = v4->uAdditionalValue;
Ritor1
parents:
diff changeset
81 if ( v8 > 46 )
Ritor1
parents:
diff changeset
82 {
Ritor1
parents:
diff changeset
83 v5 = 0;
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
84 *v3 = v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
85 return v5;
0
Ritor1
parents:
diff changeset
86 }
Ritor1
parents:
diff changeset
87 if ( v8 == 46 )
Ritor1
parents:
diff changeset
88 {
Ritor1
parents:
diff changeset
89 *v3 = 0;
Ritor1
parents:
diff changeset
90 return rand() % 11 + 10;
Ritor1
parents:
diff changeset
91 }
Ritor1
parents:
diff changeset
92 if ( v8 > 11 )
Ritor1
parents:
diff changeset
93 {
Ritor1
parents:
diff changeset
94 v12 = v8 - 12;
Ritor1
parents:
diff changeset
95 if ( !v12 )
Ritor1
parents:
diff changeset
96 {
Ritor1
parents:
diff changeset
97 *v3 = 0;
Ritor1
parents:
diff changeset
98 return GetDiceResult(v7, 6u);
Ritor1
parents:
diff changeset
99 }
Ritor1
parents:
diff changeset
100 v13 = v12 - 1;
Ritor1
parents:
diff changeset
101 if ( !v13 )
Ritor1
parents:
diff changeset
102 {
Ritor1
parents:
diff changeset
103 *v3 = 8;
Ritor1
parents:
diff changeset
104 return 5;
Ritor1
parents:
diff changeset
105 }
Ritor1
parents:
diff changeset
106 v14 = v13 - 1;
Ritor1
parents:
diff changeset
107 if ( v14 )
Ritor1
parents:
diff changeset
108 {
Ritor1
parents:
diff changeset
109 v15 = v14 - 1;
Ritor1
parents:
diff changeset
110 if ( v15 )
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 v16 = v15 - 1;
Ritor1
parents:
diff changeset
113 if ( !v16 || v16 == 25 )
Ritor1
parents:
diff changeset
114 {
Ritor1
parents:
diff changeset
115 *v3 = 10;
Ritor1
parents:
diff changeset
116 *a3 = 1;
Ritor1
parents:
diff changeset
117 return v5;
Ritor1
parents:
diff changeset
118 }
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
119 v5 = 0;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
120 *v3 = v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
121 return v5;
0
Ritor1
parents:
diff changeset
122 }
Ritor1
parents:
diff changeset
123 *v3 = 2;
Ritor1
parents:
diff changeset
124 return 12;
Ritor1
parents:
diff changeset
125 }
Ritor1
parents:
diff changeset
126 v5 = 8;
Ritor1
parents:
diff changeset
127 *v3 = v5;
Ritor1
parents:
diff changeset
128 return v5;
Ritor1
parents:
diff changeset
129 }
Ritor1
parents:
diff changeset
130 if ( v8 == 11 )
Ritor1
parents:
diff changeset
131 {
Ritor1
parents:
diff changeset
132 *v3 = 0;
Ritor1
parents:
diff changeset
133 v7 = 2;
Ritor1
parents:
diff changeset
134 return GetDiceResult(v7, 6u);
Ritor1
parents:
diff changeset
135 }
Ritor1
parents:
diff changeset
136 if ( v8 == 4 )
Ritor1
parents:
diff changeset
137 {
Ritor1
parents:
diff changeset
138 *v3 = 2;
Ritor1
parents:
diff changeset
139 v11 = rand() % 2;
Ritor1
parents:
diff changeset
140 return v11 + 3;
Ritor1
parents:
diff changeset
141 }
Ritor1
parents:
diff changeset
142 if ( v8 == 5 )
Ritor1
parents:
diff changeset
143 {
Ritor1
parents:
diff changeset
144 *v3 = 2;
Ritor1
parents:
diff changeset
145 v10 = rand();
Ritor1
parents:
diff changeset
146 v17 = 3;
Ritor1
parents:
diff changeset
147 return v10 % v17 + 6;
Ritor1
parents:
diff changeset
148 }
Ritor1
parents:
diff changeset
149 if ( v8 == 6 )
Ritor1
parents:
diff changeset
150 {
Ritor1
parents:
diff changeset
151 *v3 = 2;
Ritor1
parents:
diff changeset
152 v9 = rand() % 4;
Ritor1
parents:
diff changeset
153 return v9 + 9;
Ritor1
parents:
diff changeset
154 }
Ritor1
parents:
diff changeset
155 if ( v8 == 7 )
Ritor1
parents:
diff changeset
156 {
Ritor1
parents:
diff changeset
157 *v3 = 1;
Ritor1
parents:
diff changeset
158 return rand() % 4 + 2;
Ritor1
parents:
diff changeset
159 }
Ritor1
parents:
diff changeset
160 if ( v8 == 8 )
Ritor1
parents:
diff changeset
161 {
Ritor1
parents:
diff changeset
162 *v3 = 1;
Ritor1
parents:
diff changeset
163 return rand() % 7 + 4;
Ritor1
parents:
diff changeset
164 }
Ritor1
parents:
diff changeset
165 if ( v8 == 9 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
166 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
167 *v3 = 1;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
168 v10 = rand();
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
169 v17 = 10;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
170 return v10 % v17 + 6;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
171 }
0
Ritor1
parents:
diff changeset
172 if ( v8 != 10 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
173 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
174 v5 = 0;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
175 *v3 = v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
176 return v5;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
177 }
0
Ritor1
parents:
diff changeset
178 *v3 = 0;
Ritor1
parents:
diff changeset
179 v7 = 1;
Ritor1
parents:
diff changeset
180 return GetDiceResult(v7, 6u);
Ritor1
parents:
diff changeset
181 }
Ritor1
parents:
diff changeset
182
Ritor1
parents:
diff changeset
183
Ritor1
parents:
diff changeset
184 //----- (00402F07) --------------------------------------------------------
Ritor1
parents:
diff changeset
185 void ItemGen::Reset()
Ritor1
parents:
diff changeset
186 {
Ritor1
parents:
diff changeset
187 this->field_1A = 0;
Ritor1
parents:
diff changeset
188 this->uAttributes = 0;
Ritor1
parents:
diff changeset
189 this->uNumCharges = 0;
Ritor1
parents:
diff changeset
190 this->uAdditionalValue = 0;
Ritor1
parents:
diff changeset
191 this->_bonus_strength = 0;
Ritor1
parents:
diff changeset
192 this->_bonus_type = 0;
Ritor1
parents:
diff changeset
193 this->uItemID = 0;
Ritor1
parents:
diff changeset
194 this->uBodyAnchor = 0;
Ritor1
parents:
diff changeset
195 this->uExpireTime = 0i64;
Ritor1
parents:
diff changeset
196 }
Ritor1
parents:
diff changeset
197
Ritor1
parents:
diff changeset
198 //----- (00458260) --------------------------------------------------------
Ritor1
parents:
diff changeset
199 void ItemGen::UpdateTempBonus(__int64 uTimePlayed)
Ritor1
parents:
diff changeset
200 {
Ritor1
parents:
diff changeset
201 unsigned int v2; // eax@1
Ritor1
parents:
diff changeset
202
Ritor1
parents:
diff changeset
203 v2 = this->uAttributes;
Ritor1
parents:
diff changeset
204 if ( v2 & ITEM_TEMP_BONUS )
Ritor1
parents:
diff changeset
205 {
Ritor1
parents:
diff changeset
206 if ( uTimePlayed > (signed __int64)this->uExpireTime )
Ritor1
parents:
diff changeset
207 {
Ritor1
parents:
diff changeset
208 this->_bonus_type = 0;
Ritor1
parents:
diff changeset
209 LOBYTE(v2) = v2 & 0xF7;
Ritor1
parents:
diff changeset
210 this->uAdditionalValue = 0;
Ritor1
parents:
diff changeset
211 this->uAttributes = v2;
Ritor1
parents:
diff changeset
212 }
Ritor1
parents:
diff changeset
213 }
Ritor1
parents:
diff changeset
214 }
Ritor1
parents:
diff changeset
215
Ritor1
parents:
diff changeset
216 //----- (0045814E) --------------------------------------------------------
Ritor1
parents:
diff changeset
217 char *ItemsTable::Release()
Ritor1
parents:
diff changeset
218 {
Ritor1
parents:
diff changeset
219 ItemsTable *v1; // edi@1
Ritor1
parents:
diff changeset
220 char *result; // eax@23
Ritor1
parents:
diff changeset
221
Ritor1
parents:
diff changeset
222 v1 = this;
Ritor1
parents:
diff changeset
223 if ( pMonstersTXT_Raw )
Ritor1
parents:
diff changeset
224 pAllocator->FreeChunk(pMonstersTXT_Raw);
Ritor1
parents:
diff changeset
225 if ( pMonsterPlacementTXT_Raw )
Ritor1
parents:
diff changeset
226 pAllocator->FreeChunk(pMonsterPlacementTXT_Raw);
Ritor1
parents:
diff changeset
227 if ( pSkillDescTXT_Raw )
Ritor1
parents:
diff changeset
228 pAllocator->FreeChunk(pSkillDescTXT_Raw);
Ritor1
parents:
diff changeset
229 if ( v1->pSpcItemsTXT_Raw )
Ritor1
parents:
diff changeset
230 pAllocator->FreeChunk(v1->pSpcItemsTXT_Raw);
Ritor1
parents:
diff changeset
231 if ( v1->pStdItemsTXT_Raw )
Ritor1
parents:
diff changeset
232 pAllocator->FreeChunk(v1->pStdItemsTXT_Raw);
Ritor1
parents:
diff changeset
233 if ( v1->pRndItemsTXT_Raw )
Ritor1
parents:
diff changeset
234 pAllocator->FreeChunk(v1->pRndItemsTXT_Raw);
Ritor1
parents:
diff changeset
235 if ( v1->pItemsTXT_Raw )
Ritor1
parents:
diff changeset
236 pAllocator->FreeChunk(v1->pItemsTXT_Raw);
Ritor1
parents:
diff changeset
237 if ( pHostileTXT_Raw )
Ritor1
parents:
diff changeset
238 pAllocator->FreeChunk(pHostileTXT_Raw);
Ritor1
parents:
diff changeset
239 if ( pHistoryTXT_Raw )
Ritor1
parents:
diff changeset
240 pAllocator->FreeChunk(pHistoryTXT_Raw);
Ritor1
parents:
diff changeset
241 if ( pPotionsTXT_Raw )
Ritor1
parents:
diff changeset
242 pAllocator->FreeChunk(pPotionsTXT_Raw);
Ritor1
parents:
diff changeset
243 if ( pPotionNotesTXT_Raw )
Ritor1
parents:
diff changeset
244 pAllocator->FreeChunk(pPotionNotesTXT_Raw);
Ritor1
parents:
diff changeset
245 v1->pSpcItemsTXT_Raw = 0;
Ritor1
parents:
diff changeset
246 pSkillDescTXT_Raw = 0;
Ritor1
parents:
diff changeset
247 v1->pStdItemsTXT_Raw = 0;
Ritor1
parents:
diff changeset
248 v1->pRndItemsTXT_Raw = pSkillDescTXT_Raw;
Ritor1
parents:
diff changeset
249 result = pSkillDescTXT_Raw;
Ritor1
parents:
diff changeset
250 v1->pItemsTXT_Raw = pSkillDescTXT_Raw;
Ritor1
parents:
diff changeset
251 return result;
Ritor1
parents:
diff changeset
252 }
Ritor1
parents:
diff changeset
253
Ritor1
parents:
diff changeset
254
Ritor1
parents:
diff changeset
255 //----- (00456D84) --------------------------------------------------------
Ritor1
parents:
diff changeset
256 void ItemsTable::Initialize()
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
257 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
258 int i,j;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
259 char* test_string;
229
Gloval
parents: 224
diff changeset
260 unsigned char c;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
261 bool break_loop;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
262 unsigned int temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
263 char* tmp_pos;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
264 int decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
265 int item_counter;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
266
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
267 pMapStats = new MapStats;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
268 pMapStats->Initialize();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
269
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
270 pMonsterStats = new MonsterStats;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
271 pMonsterStats->Initialize();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
272 pMonsterStats->InitializePlacements();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
273
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
274 pSpellStats = new SpellStats;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
275 pSpellStats->Initialize();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
276
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
277 LoadPotions();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
278 LoadPotionNotes();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
279
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
280 pFactionTable = new FactionTable;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
281 pFactionTable->Initialize();
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
282
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
283 pStorylineText = new StorylineText;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
284 pStorylineText->Initialize();
0
Ritor1
parents:
diff changeset
285
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
286 pStdItemsTXT_Raw = NULL;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
287 pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
288 strtok(pStdItemsTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
289 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
290 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
291 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
292 //Standard Bonuses by Group
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
293 for (i=0;i<24;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
294 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
295 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
296 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
297 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
298 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
299 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
300 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
301 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
302 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
303 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
304 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
305 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
306 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
307 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
308 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
309 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
310 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
311 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
312 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
313 switch (decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
314 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
315 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
316 pEnchantments[i].pBonusStat=RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
317 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
318 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
319 pEnchantments[i].pOfName= RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
320 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
321 default:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
322 pEnchantments[i].to_item[decode_step-2]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
323 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
324 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
325 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
326 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
327 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
328 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
329 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
330 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
331 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
332 } while ((decode_step<11)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
333 }
0
Ritor1
parents:
diff changeset
334
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
335 memset(&pEnchantmentsSumm, 0, 36);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
336 for(i=0;i<9;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
337 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
338 for (j=0;j<24;++j)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
339 pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
340 }
0
Ritor1
parents:
diff changeset
341
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
342 //Bonus range for Standard by Level
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
343 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
344 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
345 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
346 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
347 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
348 for(i=0;i<6;++i) //counted from 1
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
349 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
350 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
351 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
352 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
353 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
354 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
355 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
356 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
357 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
358 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
359 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
360 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
361 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
362 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
363 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
364 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
365 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
366 if (decode_step==2)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
367 bonus_ranges[i].minR = atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
368 else if (decode_step==3)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
369 bonus_ranges[i].maxR =atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
370 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
371 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
372 } while ((decode_step<4)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
373 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
374
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
375
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
376 pSpcItemsTXT_Raw = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
377 pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
378 strtok(pSpcItemsTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
379 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
380 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
381 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
382 for (i=0;i<72;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
383 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
384 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
385 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
386 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
387 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
388 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
389 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
390 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
391 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
392 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
393 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
394 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
395 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
396 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
397 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
398 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
399 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
400 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
401 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
402 switch (decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
403 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
404 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
405 pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
406 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
407 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
408 pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
409 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
410 case 14:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
411 int res;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
412 res=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
413 if(!res)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
414 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
415 ++test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
416 while (*test_string==' ')//fix X 2 case
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
417 ++test_string;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
418 res=atoi(test_string);
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
419 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
420 pSpecialEnchantments[i].iValue=res;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
421 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
422 case 15:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
423 pSpecialEnchantments[i].iTreasureLevel= tolower(*test_string) - 97;;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
424 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
425 default:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
426 pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
427 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
428 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
429 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
430 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
431 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
432 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
433 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
434 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
435 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
436 } while ((decode_step<16)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
437 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
438
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
439 pSpecialEnchantments_count = 71;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
440 memset(&pSpecialEnchantmentsSumm, 0, 96);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
441 for(i=0;i<12;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
442 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
443 for (j=0;j<pSpecialEnchantments_count;++j)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
444 pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
445 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
446
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
447
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
448
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
449 Initialize2DA();
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
450
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
451 pItemsTXT_Raw = NULL;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
452 pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
453 strtok(pItemsTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
454 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
455 uAllItemsCount = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
456 item_counter = 0;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
457 while (true)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
458 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
459 test_string = strtok(NULL, "\r") + 1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
460 break_loop = false;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
461 decode_step=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
462 do
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
463 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
464 c = *(unsigned char*)test_string;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
465 temp_str_len = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
466 while((c!='\t')&&(c>0))
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
467 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
468 ++temp_str_len;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
469 c=test_string[temp_str_len];
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
470 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
471 tmp_pos=test_string+temp_str_len;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
472 if (*tmp_pos == 0)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
473 break_loop = true;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
474 *tmp_pos = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
475 if (temp_str_len)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
476 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
477 switch (decode_step)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
478 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
479 case 0: //Item #
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
480 item_counter=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
481 uAllItemsCount=item_counter;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
482 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
483 case 1: //Pic File
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
484 pItems[item_counter].pIconName = RemoveQuotes(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
485 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
486 case 2: //Name
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
487 pItems[item_counter].pName = RemoveQuotes(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
488 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
489 case 3: //Value
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
490 pItems[item_counter].uValue=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
491 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
492 case 4: //Equip Stat
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
493 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
494 if ( !_strcmpi(test_string, "weapon") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
495 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
496 pItems[item_counter].uEquipType = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
497 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
498 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
499 if ( !_strcmpi(test_string, "weapon2") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
500 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
501 pItems[item_counter].uEquipType = 1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
502 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
503 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
504 if ( !_strcmpi(test_string, "weapon1or2") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
505 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
506 pItems[item_counter].uEquipType = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
507 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
508 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
509 if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow")))
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
510 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
511 pItems[item_counter].uEquipType = 2;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
512 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
513 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
514 if ( !_strcmpi(test_string, "armor") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
515 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
516 pItems[item_counter].uEquipType = 3;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
517 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
518 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
519 if ( !_strcmpi(test_string, "shield") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
520 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
521 pItems[item_counter].uEquipType = 4;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
522 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
523 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
524 if ( !_strcmpi(test_string, "helm") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
525 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
526 pItems[item_counter].uEquipType = 5;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
527 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
528 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
529 if ( !_strcmpi(test_string, "belt") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
530 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
531 pItems[item_counter].uEquipType = 6;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
532 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
533 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
534 if ( !_strcmpi(test_string, "cloak") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
535 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
536 pItems[item_counter].uEquipType = 7;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
537 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
538 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
539 if ( !_strcmpi(test_string, "gauntlets") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
540 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
541 pItems[item_counter].uEquipType = 8;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
542 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
543 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
544 if ( !_strcmpi(test_string, "boots") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
545 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
546 pItems[item_counter].uEquipType = 9;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
547 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
548 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
549 if ( !_strcmpi(test_string, "ring") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
550 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
551 pItems[item_counter].uEquipType = 10;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
552 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
553 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
554 if ( !_strcmpi(test_string, "amulet") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
555 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
556 pItems[item_counter].uEquipType = 11;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
557 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
558 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
559 if ( !_strcmpi(test_string, "weaponw") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
560 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
561 pItems[item_counter].uEquipType = 12;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
562 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
563 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
564 if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent")))
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
565 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
566 pItems[item_counter].uEquipType = 13;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
567 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
568 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
569 if ( !_strcmpi(test_string, "bottle") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
570 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
571 pItems[item_counter].uEquipType = 14;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
572 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
573 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
574 if ( !_strcmpi(test_string, "sscroll") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
575 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
576 pItems[item_counter].uEquipType = 15;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
577 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
578 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
579 if ( !_strcmpi(test_string, "book") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
580 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
581 pItems[item_counter].uEquipType = 16;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
582 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
583 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
584 if ( !_strcmpi(test_string, "mscroll") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
585 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
586 pItems[item_counter].uEquipType = 17;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
587 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
588 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
589 if ( !_strcmpi(test_string, "gold") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
590 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
591 pItems[item_counter].uEquipType = 18;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
592 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
593 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
594 if ( !_strcmpi(test_string, "gem") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
595 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
596 pItems[item_counter].uEquipType = 19;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
597 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
598 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
599 pItems[item_counter].uEquipType = 20;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
600 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
601 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
602 case 5: //Skill Group
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
603 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
604 if ( !_strcmpi(test_string, "staff") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
605 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
606 pItems[item_counter].uSkillType = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
607 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
608 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
609 if ( !_strcmpi(test_string, "sword") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
610 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
611 pItems[item_counter].uSkillType = 1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
612 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
613 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
614 if ( !_strcmpi(test_string, "dagger") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
615 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
616 pItems[item_counter].uSkillType = 2;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
617 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
618 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
619 if ( !_strcmpi(test_string, "axe") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
620 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
621 pItems[item_counter].uSkillType = 3;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
622 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
623 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
624 if ( !_strcmpi(test_string, "spear") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
625 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
626 pItems[item_counter].uSkillType = 4;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
627 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
628 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
629 if ( !_strcmpi(test_string, "bow") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
630 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
631 pItems[item_counter].uSkillType = 5;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
632 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
633 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
634 if ( !_strcmpi(test_string, "mace") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
635 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
636 pItems[item_counter].uSkillType = 6;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
637 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
638 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
639 if ( !_strcmpi(test_string, "blaster") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
640 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
641 pItems[item_counter].uSkillType = 7;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
642 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
643 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
644 if ( !_strcmpi(test_string, "shield") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
645 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
646 pItems[item_counter].uSkillType = 8;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
647 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
648 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
649 if ( !_strcmpi(test_string, "leather") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
650 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
651 pItems[item_counter].uSkillType = 9;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
652 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
653 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
654 if ( !_strcmpi(test_string, "chain") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
655 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
656 pItems[item_counter].uSkillType = 10;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
657 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
658 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
659 if ( !_strcmpi(test_string, "plate") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
660 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
661 pItems[item_counter].uSkillType = 11;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
662 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
663 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
664 if ( !_strcmpi(test_string, "club") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
665 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
666 pItems[item_counter].uSkillType = 37;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
667 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
668 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
669 pItems[item_counter].uSkillType = 38;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
670 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
671 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
672 case 6: //Mod1
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
673 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
674 int ii;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
675 char* test_char;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
676 int tst_len;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
677 tst_len=strlen(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
678 pItems[item_counter].uDamageDice=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
679 pItems[item_counter].uDamageRoll=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
680 test_char=test_string;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
681 for (ii=0; ii<tst_len; ++ii)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
682 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
683 if (tolower(*test_char)=='d')
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
684 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
685 *test_char=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
686 pItems[item_counter].uDamageDice=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
687 pItems[item_counter].uDamageRoll=atoi(test_char+1);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
688 *test_char='d';
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
689 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
690 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
691 ++test_char;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
692 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
693 test_char=test_string;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
694 if ((ii==tst_len)&&(tolower(*test_char)=='s'))
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
695 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
696 pItems[item_counter].uDamageDice=atoi(test_char+1);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
697 pItems[item_counter].uDamageRoll=1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
698 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
699 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
700 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
701 case 7: //Mod2
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
702 pItems[item_counter].uDamageMod=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
703 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
704 case 8: //material
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
705 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
706 if ( !_strcmpi(test_string, "artifact") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
707 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
708 pItems[item_counter].uMaterial = 1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
709 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
710 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
711 if ( !_strcmpi(test_string, "relic") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
712 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
713 pItems[item_counter].uMaterial = 2;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
714 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
715 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
716 if ( !_strcmpi(test_string, "special") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
717 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
718 pItems[item_counter].uMaterial = 3;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
719 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
720 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
721 pItems[item_counter].uMaterial = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
722 break;}
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
723 case 9: //ID/Rep/St
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
724 pItems[item_counter].uItemID_Rep_St=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
725 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
726 case 10: //Not identified name
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
727 pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
728 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
729 case 11: //Sprite Index
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
730 pItems[item_counter].uSpriteID=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
731 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
732 case 12: //VarA
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
733 {
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
734 pItems[item_counter]._additional_value=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
735 pItems[item_counter]._bonus_type=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
736 if (pItems[item_counter].uMaterial==3)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
737 {
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
738 for(int ii=0; ii<24; ++ii)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
739 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
740 if (stricmp(test_string,pEnchantments[ii].pBonusStat))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
741 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
742 pItems[item_counter]._bonus_type=ii+1;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
743 break;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
744 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
745 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
746 if (!pItems[item_counter]._bonus_type)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
747 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
748 for(int ii=0; ii<72; ++ii)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
749 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
750 if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement))
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
751 {
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
752 pItems[item_counter]._additional_value=ii+1;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
753 }
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
754 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
755 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
756 }
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
757
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
758 break;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
759 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
760 case 13: //VarB
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
761 if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type))
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
762 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
763 char b_s=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
764 if (b_s)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
765 pItems[item_counter]._bonus_strength=b_s;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
766 else
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
767 pItems[item_counter]._bonus_strength=1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
768 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
769 else
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
770 pItems[item_counter]._bonus_strength=0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
771 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
772 case 14: //Equip X
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
773 pItems[item_counter].uEquipX=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
774 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
775 case 15: //Equip Y
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
776 pItems[item_counter].uEquipY=atoi(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
777 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
778 case 16: //Notes
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
779 pItems[item_counter].pDescription = RemoveQuotes(test_string);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
780 break;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
781
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
782 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
783 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
784 else
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
785 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
786 if (!decode_step)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
787 break_loop = true;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
788 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
789 ++decode_step;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
790 test_string=tmp_pos+1;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
791 } while ((decode_step<17)&&!break_loop);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
792 ++item_counter;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
793 if (item_counter>799)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
794 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
795 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
796
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
797
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
798 pRndItemsTXT_Raw = NULL;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
799 uAllItemsCount = item_counter;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
800 pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
801 strtok(pRndItemsTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
802 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
803 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
804 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
805 item_counter = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
806 while (true)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
807 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
808 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
809 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
810 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
811 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
812 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
813 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
814 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
815 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
816 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
817 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
818 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
819 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
820 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
821 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
822 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
823 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
824 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
825 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
826 switch (decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
827 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
828 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
829 item_counter=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
830 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
831 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
832 pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
833 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
834 case 3:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
835 pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
836 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
837 case 4:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
838 pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
839 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
840 case 5:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
841 pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
842 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
843 case 6:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
844 pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
845 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
846 case 7:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
847 pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
848 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
849 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
850 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
851 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
852 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
853 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
854 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
855 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
856 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
857 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
858 } while ((decode_step<8)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
859 ++item_counter;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
860 if (item_counter>618)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
861 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
862 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
863
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
864 if ( pRndItemsTXT_Raw )
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
865 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
866 pAllocator->FreeChunk(pRndItemsTXT_Raw);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
867 pRndItemsTXT_Raw = NULL;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
868 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
869 //ChanceByTreasureLvl Summ - anti cheating?
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
870 memset(&uChanceByTreasureLvlSumm, 0, 24);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
871 for(i=0;i<6;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
872 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
873 for (j=0;j<800;++j)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
874 uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
875 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
876
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
877 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
878 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
879 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
880 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
881 strtok(NULL, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
882 for (i=0;i<3;++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
883 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
884 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
885 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
886 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
887 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
888 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
889 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
890 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
891 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
892 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
893 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
894 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
895 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
896 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
897 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
898 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
899 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
900 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
901 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
902 switch (decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
903 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
904 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
905 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
906 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
907 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
908 uBonusChanceStandart[0]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
909 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
910 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
911 uBonusChanceSpecial[0]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
912 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
913 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
914 uBonusChanceWpSpecial[0]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
915 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
916 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
917 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
918 case 3:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
919 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
920 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
921 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
922 uBonusChanceStandart[1]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
923 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
924 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
925 uBonusChanceSpecial[1]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
926 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
927 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
928 uBonusChanceWpSpecial[1]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
929 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
930 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
931 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
932 case 4:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
933 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
934 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
935 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
936 uBonusChanceStandart[2]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
937 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
938 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
939 uBonusChanceSpecial[2]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
940 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
941 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
942 uBonusChanceWpSpecial[2]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
943 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
944 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
945 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
946 case 5:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
947 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
948 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
949 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
950 uBonusChanceStandart[3]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
951 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
952 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
953 uBonusChanceSpecial[3]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
954 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
955 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
956 uBonusChanceWpSpecial[3]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
957 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
958 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
959 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
960 case 6:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
961 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
962 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
963 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
964 uBonusChanceStandart[4]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
965 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
966 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
967 uBonusChanceSpecial[4]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
968 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
969 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
970 uBonusChanceWpSpecial[4]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
971 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
972 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
973 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
974 case 7:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
975 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
976 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
977 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
978 uBonusChanceStandart[5]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
979 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
980 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
981 uBonusChanceSpecial[5]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
982 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
983 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
984 uBonusChanceWpSpecial[5]=atoi(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
985 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
986 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
987 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
988 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
989 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
990 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
991 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
992 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
993 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
994 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
995 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
996 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
997 } while ((decode_step<8)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
998 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
999
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1000 pSkillDescTXT_Raw = NULL;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1001 pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1002 strtok(pSkillDescTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1003 for (i=0; i<37; ++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1004 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1005 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1006 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1007 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1008 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1009 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1010 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1011 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1012 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1013 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1014 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1015 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1016 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1017 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1018 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1019 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1020 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1021 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1022 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1023 switch (decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1024 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1025 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1026 pSkillDesc[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1027 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1028 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1029 pNormalSkillDesc[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1030 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1031 case 3:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1032 pExpertSkillDesc[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1033 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1034 case 4:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1035 pMasterSkillDesc[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1036 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1037 case 5:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1038 pGrandSkillDesc[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1039 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1040 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1041 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1042 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1043 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1044 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1045 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1046 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1047 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1048 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1049 } while ((decode_step<6)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1050 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1051
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1052 pStatsTXT_Raw = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1053 pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1054 strtok(pStatsTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1055 for (i=0; i<26; ++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1056 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1057 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1058 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1059 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1060 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1061 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1062 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1063 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1064 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1065 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1066 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1067 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1068 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1069 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1070 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1071 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1072 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1073 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1074 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1075 switch (i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1076 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1077 case 0:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1078 case 1:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1079 case 2:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1080 case 3:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1081 case 4:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1082 case 5:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1083 case 6:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1084 pAttributeDescriptions[i] = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1085 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1086 case 7:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1087 pHealthPointsAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1088 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1089 case 8:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1090 pArmourClassAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1091 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1092 case 9:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1093 pSpellPointsAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1094 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1095 case 10:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1096 pPlayerConditionAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1097 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1098 case 11:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1099 pFastSpellAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1100 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1101 case 12:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1102 pPlayerAgeAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1103 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1104 case 13:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1105 pPlayerLevelAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1106 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1107 case 14:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1108 pPlayerExperienceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1109 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1110 case 15:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1111 pAttackBonusAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1112 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1113 case 16:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1114 pAttackDamageAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1115 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1116 case 17:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1117 pMissleBonusAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1118 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1119 case 18:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1120 pMissleDamageAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1121 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1122 case 19:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1123 pFireResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1124 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1125 case 20:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1126 pAirResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1127 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1128 case 21:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1129 pWaterResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1130 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1131 case 22:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1132 pEarthResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1133 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1134 case 23:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1135 pMindResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1136 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1137 case 24:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1138 pBodyResistanceAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1139 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1140 case 25:
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1141 pSkillPointsAttributeDescription = RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1142 break;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1143 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1144 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1145 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1146 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1147 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1148 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1149 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1150 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1151 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1152 } while ((decode_step<2)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1153 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1154
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1155
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1156 pClassTXT_Raw = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1157 pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1158 strtok(pClassTXT_Raw, "\r");
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1159 for (i=0; i<36; ++i)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1160 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1161 test_string = strtok(NULL, "\r") + 1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1162 break_loop = false;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1163 decode_step=0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1164 do
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1165 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1166 c = *(unsigned char*)test_string;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1167 temp_str_len = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1168 while((c!='\t')&&(c>0))
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1169 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1170 ++temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1171 c=test_string[temp_str_len];
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1172 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1173 tmp_pos=test_string+temp_str_len;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1174 if (*tmp_pos == 0)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1175 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1176 *tmp_pos = 0;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1177 if (temp_str_len)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1178 {
229
Gloval
parents: 224
diff changeset
1179 //if(i)
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1180 pClassDescriptions[i]=RemoveQuotes(test_string);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1181 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1182 else
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1183 {
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1184 if (!decode_step)
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1185 break_loop = true;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1186 }
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1187 ++decode_step;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1188 test_string=tmp_pos+1;
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1189 } while ((decode_step<2)&&!break_loop);
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1190 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1191
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1192 }
0
Ritor1
parents:
diff changeset
1193
Ritor1
parents:
diff changeset
1194 //----- (00456D17) --------------------------------------------------------
Ritor1
parents:
diff changeset
1195 void ItemsTable::SetSpecialBonus(ItemGen *pItem)
Ritor1
parents:
diff changeset
1196 {
Ritor1
parents:
diff changeset
1197 ItemDesc *v2; // eax@1
Ritor1
parents:
diff changeset
1198
Ritor1
parents:
diff changeset
1199 v2 = &this->pItems[pItem->uItemID];
Ritor1
parents:
diff changeset
1200 if ( v2->uMaterial == 3 )
Ritor1
parents:
diff changeset
1201 {
Ritor1
parents:
diff changeset
1202 pItem->_bonus_type = v2->_bonus_type;
Ritor1
parents:
diff changeset
1203 pItem->uAdditionalValue = v2->_additional_value;
Ritor1
parents:
diff changeset
1204 pItem->_bonus_strength = v2->_bonus_strength;
Ritor1
parents:
diff changeset
1205 }
Ritor1
parents:
diff changeset
1206 }
Ritor1
parents:
diff changeset
1207
Ritor1
parents:
diff changeset
1208 //----- (00456D43) --------------------------------------------------------
Ritor1
parents:
diff changeset
1209 bool ItemsTable::_456D43_is_material_equals_3(ItemGen *pItem)
Ritor1
parents:
diff changeset
1210 {
Ritor1
parents:
diff changeset
1211 return this->pItems[pItem->uItemID].uMaterial == 3;
Ritor1
parents:
diff changeset
1212 }
Ritor1
parents:
diff changeset
1213
Ritor1
parents:
diff changeset
1214 //----- (00456D5E) --------------------------------------------------------
Ritor1
parents:
diff changeset
1215 bool ItemsTable::_456D5E_is_some_material(ItemGen *pItem)
Ritor1
parents:
diff changeset
1216 {
Ritor1
parents:
diff changeset
1217 unsigned __int8 v2; // al@1
Ritor1
parents:
diff changeset
1218
Ritor1
parents:
diff changeset
1219 v2 = this->pItems[pItem->uItemID].uMaterial;
Ritor1
parents:
diff changeset
1220 return v2 == 3 || v2 == 1 || v2 == 2;
Ritor1
parents:
diff changeset
1221 }
Ritor1
parents:
diff changeset
1222
Ritor1
parents:
diff changeset
1223
Ritor1
parents:
diff changeset
1224 //----- (00453B3C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1225 void ItemsTable::LoadPotions()
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1226 {
0
Ritor1
parents:
diff changeset
1227
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1228 CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1229 char* test_string;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1230 unsigned int uRow;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1231 unsigned int uColumn;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1232 unsigned __int8 potion_value;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1233
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1234 if ( pPotionsTXT_Raw )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1235 pAllocator->FreeChunk(pPotionsTXT_Raw);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1236 pPotionsTXT_Raw = NULL;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1237 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
1238 test_string = strtok(pPotionsTXT_Raw,"\t\r\n");
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1239 while ( 1 )
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1240 {
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1241 if ( !test_string )
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1242 {
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1243 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
1244 return;
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1245 }
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1246 if ( !strcmp(test_string, "222") )
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1247 break;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1248
193
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1249 test_string = strtok(NULL, "\t\r\n");
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1250 }
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1251 while ( 1 )
193
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1252 {
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1253 test_string = strtok(NULL, "\t\r\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1254
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1255 if ( !test_string )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1256 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1257 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1258 return;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1259 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1260 if ( !strcmp(test_string, "222") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1261 break;
193
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1262 }
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1263
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1264 for (uRow = 0;uRow < 50; ++uRow)
193
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1265 {
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1266 int skip_count;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1267 for (skip_count = 0;skip_count < 6; ++skip_count)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1268 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1269 if ( !strtok(NULL, "\r\t\n") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1270 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1271 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1272 if ( skip_count != 6 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1273 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1274 for (uColumn = 0; uColumn < 50; ++uColumn)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1275 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1276 test_string = strtok(NULL, "\r\t\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1277 if ( !test_string )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1278 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1279 potion_value = atoi(test_string);
233
0df4136b6aac store_line
Gloval
parents: 230
diff changeset
1280 unsigned char c=*test_string;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1281 if ( !potion_value )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1282 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1283 if ( tolower(c) == 'e' )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1284 potion_value = atoi(test_string + 1);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1285 else
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1286 potion_value = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1287 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1288 this->potion_data[uRow][uColumn]=potion_value;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1289 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1290 if ( uColumn != 50 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1291 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1292 strtok(NULL, "\r\t\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1293 }
193
821fd955c379 fixed potion data parsing. Somehow 3d render was affected
Gloval
parents: 189
diff changeset
1294
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1295 if ( uRow != 50 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1296 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1297 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1298 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1299 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1300 if ( pPotionsTXT_Raw )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1301 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1302 pAllocator->FreeChunk(pPotionsTXT_Raw);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1303 pPotionsTXT_Raw = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1304 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1305 }
0
Ritor1
parents:
diff changeset
1306
Ritor1
parents:
diff changeset
1307 //----- (00453CE5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1308 void ItemsTable::LoadPotionNotes()
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1309 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1310
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1311 CHAR Text[90];
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1312 char* test_string;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1313 unsigned int uRow;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1314 unsigned int uColumn;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1315 unsigned __int8 potion_note;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1316
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1317 if ( pPotionNotesTXT_Raw )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1318 pAllocator->FreeChunk(pPotionNotesTXT_Raw);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1319 pPotionNotesTXT_Raw = NULL;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1320 pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1321 test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1322 while ( 1 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1323 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1324 if ( !test_string )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1325 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1326 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1327 return;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1328 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1329 if ( !strcmp(test_string, "222") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1330 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1331 test_string = strtok(NULL, "\t\r\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1332 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1333 while ( 1 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1334 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1335 test_string = strtok(NULL, "\t\r\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1336
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1337 if ( !test_string )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1338 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1339 MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1340 return;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1341 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1342 if ( !strcmp(test_string, "222") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1343 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1344 }
0
Ritor1
parents:
diff changeset
1345
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1346 for (uRow = 0;uRow < 50; ++uRow)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1347 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1348 int skip_count;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1349 for (skip_count = 0;skip_count < 6; ++skip_count)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1350 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1351 if ( !strtok(NULL, "\r\t\n") )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1352 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1353 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1354 if ( skip_count != 6 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1355 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1356 for (uColumn = 0; uColumn < 50; ++uColumn)
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1357 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1358 test_string = strtok(NULL, "\r\t\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1359 if ( !test_string )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1360 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1361 potion_note = atoi(test_string);
233
0df4136b6aac store_line
Gloval
parents: 230
diff changeset
1362 unsigned char c=*test_string;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1363 if ( !potion_note )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1364 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1365 if ( tolower(c) == 'e' )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1366 potion_note = atoi(test_string + 1);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1367 else
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1368 potion_note = 0;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1369 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1370 this->potion_note[uRow][uColumn]=potion_note;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1371 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1372 if ( uColumn != 50 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1373 break;
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1374 strtok(NULL, "\r\t\n");
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1375 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1376 if ( uRow != 50 )
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1377 {
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1378 wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1379 MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1380 }
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1381 }
0
Ritor1
parents:
diff changeset
1382
Ritor1
parents:
diff changeset
1383
Ritor1
parents:
diff changeset
1384 //----- (00456442) --------------------------------------------------------
Ritor1
parents:
diff changeset
1385 unsigned int ItemGen::GetValue()
Ritor1
parents:
diff changeset
1386 {
Ritor1
parents:
diff changeset
1387 ItemGen *v1; // esi@1
Ritor1
parents:
diff changeset
1388 unsigned int uBaseValue; // edi@1
Ritor1
parents:
diff changeset
1389 int v3; // eax@4
Ritor1
parents:
diff changeset
1390 int v4; // esi@5
Ritor1
parents:
diff changeset
1391 unsigned int result; // eax@7
Ritor1
parents:
diff changeset
1392
Ritor1
parents:
diff changeset
1393 v1 = this;
Ritor1
parents:
diff changeset
1394 uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
Ritor1
parents:
diff changeset
1395 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->_456D5E_is_some_material(this) )
243
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1396 return uBaseValue;
0
Ritor1
parents:
diff changeset
1397 if ( v1->_bonus_type )
Ritor1
parents:
diff changeset
1398 {
Ritor1
parents:
diff changeset
1399 v3 = 100 * v1->_bonus_strength;
Ritor1
parents:
diff changeset
1400 return uBaseValue + v3;
Ritor1
parents:
diff changeset
1401 }
Ritor1
parents:
diff changeset
1402 v4 = v1->uAdditionalValue;
Ritor1
parents:
diff changeset
1403 if ( !v4 )
Ritor1
parents:
diff changeset
1404 {
Ritor1
parents:
diff changeset
1405 result = uBaseValue;
Ritor1
parents:
diff changeset
1406 }
Ritor1
parents:
diff changeset
1407 else
Ritor1
parents:
diff changeset
1408 {
243
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1409 v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel;
0
Ritor1
parents:
diff changeset
1410 if ( (unsigned int)v3 > 0xA )
Ritor1
parents:
diff changeset
1411 return uBaseValue + v3;
Ritor1
parents:
diff changeset
1412 result = uBaseValue * v3;
Ritor1
parents:
diff changeset
1413 }
Ritor1
parents:
diff changeset
1414 return result;
Ritor1
parents:
diff changeset
1415 }
Ritor1
parents:
diff changeset
1416
Ritor1
parents:
diff changeset
1417 //----- (00456499) --------------------------------------------------------
Ritor1
parents:
diff changeset
1418 const char *ItemGen::GetDisplayName()
Ritor1
parents:
diff changeset
1419 {
Ritor1
parents:
diff changeset
1420 const char *result; // eax@2
Ritor1
parents:
diff changeset
1421
Ritor1
parents:
diff changeset
1422 if ( this->uAttributes & ITEM_IDENTIFIED )
Ritor1
parents:
diff changeset
1423 result = GetIdentifiedName();
Ritor1
parents:
diff changeset
1424 else
Ritor1
parents:
diff changeset
1425 result = pItemsTable->pItems[uItemID].pUnidentifiedName;
Ritor1
parents:
diff changeset
1426 return result;
Ritor1
parents:
diff changeset
1427 }
Ritor1
parents:
diff changeset
1428
Ritor1
parents:
diff changeset
1429 //----- (004564B3) --------------------------------------------------------
Ritor1
parents:
diff changeset
1430 const char *ItemGen::GetIdentifiedName()
Ritor1
parents:
diff changeset
1431 {
Ritor1
parents:
diff changeset
1432 ItemGen *v1; // esi@1
Ritor1
parents:
diff changeset
1433 unsigned int v2; // eax@1
Ritor1
parents:
diff changeset
1434 unsigned __int8 v3; // cl@1
Ritor1
parents:
diff changeset
1435 char *v4; // edi@4
Ritor1
parents:
diff changeset
1436 char v5; // al@6
Ritor1
parents:
diff changeset
1437 const char *v6; // esi@8
Ritor1
parents:
diff changeset
1438 int v7; // eax@15
Ritor1
parents:
diff changeset
1439 const char *v9; // [sp-Ch] [bp-14h]@14
Ritor1
parents:
diff changeset
1440 const char *v10; // [sp-8h] [bp-10h]@4
Ritor1
parents:
diff changeset
1441 char *v11; // [sp-4h] [bp-Ch]@4
Ritor1
parents:
diff changeset
1442
Ritor1
parents:
diff changeset
1443 v1 = this;
Ritor1
parents:
diff changeset
1444 v2 = this->uItemID;
Ritor1
parents:
diff changeset
1445 v3 = pItemsTable->pItems[v2].uEquipType;
Ritor1
parents:
diff changeset
1446 if ( v3 >= EQUIP_REAGENT && (v3 <= EQUIP_POTION || v3 == EQUIP_GOLD) )
Ritor1
parents:
diff changeset
1447 {
Ritor1
parents:
diff changeset
1448 v11 = pItemsTable->pItems[v2].pName;
Ritor1
parents:
diff changeset
1449 v4 = item__getname_buffer;
Ritor1
parents:
diff changeset
1450 v10 = "%s";
Ritor1
parents:
diff changeset
1451 sprintf(v4, v10, v11);
Ritor1
parents:
diff changeset
1452 return v4;
Ritor1
parents:
diff changeset
1453 }
Ritor1
parents:
diff changeset
1454 v4 = item__getname_buffer;
Ritor1
parents:
diff changeset
1455 sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName);
Ritor1
parents:
diff changeset
1456 if ( v1->uItemID == 601 )
Ritor1
parents:
diff changeset
1457 {
Ritor1
parents:
diff changeset
1458 v5 = v1->field_1A;
Ritor1
parents:
diff changeset
1459 if ( (unsigned __int8)v5 >= 1u )
Ritor1
parents:
diff changeset
1460 {
Ritor1
parents:
diff changeset
1461 if ( (unsigned __int8)v5 <= 4u )
Ritor1
parents:
diff changeset
1462 {
Ritor1
parents:
diff changeset
1463 v6 = pPlayers[(unsigned __int8)v5]->pName;
Ritor1
parents:
diff changeset
1464 strlen(pPlayers[(unsigned __int8)v5]->pName);
Ritor1
parents:
diff changeset
1465 v11 = (char *)v6;
Ritor1
parents:
diff changeset
1466 if ( v6[strlen(v6) - 1] == 115 )
Ritor1
parents:
diff changeset
1467 v10 = pGlobalTXT_LocalizationStrings[655];
Ritor1
parents:
diff changeset
1468 else
Ritor1
parents:
diff changeset
1469 v10 = pGlobalTXT_LocalizationStrings[654];
243
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1470 sprintf(v4, v10, v11);
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1471 return v4;
0
Ritor1
parents:
diff changeset
1472 }
Ritor1
parents:
diff changeset
1473 }
Ritor1
parents:
diff changeset
1474 }
Ritor1
parents:
diff changeset
1475 if ( !pItemsTable->_456D5E_is_some_material(v1) )
Ritor1
parents:
diff changeset
1476 {
Ritor1
parents:
diff changeset
1477 if ( v1->_bonus_type )
Ritor1
parents:
diff changeset
1478 {
Ritor1
parents:
diff changeset
1479 strcat(item__getname_buffer, " ");
Ritor1
parents:
diff changeset
1480 v9 = (const char *)*((unsigned int *)&pItemsTable->pItems[799].uEquipType + 5 * v1->_bonus_type);
Ritor1
parents:
diff changeset
1481 }
Ritor1
parents:
diff changeset
1482 else
Ritor1
parents:
diff changeset
1483 {
Ritor1
parents:
diff changeset
1484 v7 = v1->uAdditionalValue;
Ritor1
parents:
diff changeset
1485 if ( !v7 )
Ritor1
parents:
diff changeset
1486 return v4;
Ritor1
parents:
diff changeset
1487 if ( v7 == 16
Ritor1
parents:
diff changeset
1488 || v7 == 39
Ritor1
parents:
diff changeset
1489 || v7 == 40
Ritor1
parents:
diff changeset
1490 || v7 == 45
Ritor1
parents:
diff changeset
1491 || v7 == 56
Ritor1
parents:
diff changeset
1492 || v7 == 57
Ritor1
parents:
diff changeset
1493 || v7 == 58
Ritor1
parents:
diff changeset
1494 || v7 == 60
Ritor1
parents:
diff changeset
1495 || v7 == 61
Ritor1
parents:
diff changeset
1496 || v7 == 59
Ritor1
parents:
diff changeset
1497 || v7 == 63
Ritor1
parents:
diff changeset
1498 || v7 == 64
Ritor1
parents:
diff changeset
1499 || v7 == 67
Ritor1
parents:
diff changeset
1500 || v7 == 68 )
Ritor1
parents:
diff changeset
1501 {
Ritor1
parents:
diff changeset
1502 sprintf(
Ritor1
parents:
diff changeset
1503 item__getname_buffer,
Ritor1
parents:
diff changeset
1504 "%s %s",
243
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1505 pItemsTable->pSpecialEnchantments[v7].pBonusStatement,
0
Ritor1
parents:
diff changeset
1506 pItemsTable->pItems[v1->uItemID].pName);
Ritor1
parents:
diff changeset
1507 return v4;
Ritor1
parents:
diff changeset
1508 }
Ritor1
parents:
diff changeset
1509 strcat(item__getname_buffer, " ");
243
a6a8fa73b4ec cleaning
zipi
parents: 233
diff changeset
1510 v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement;
0
Ritor1
parents:
diff changeset
1511 }
Ritor1
parents:
diff changeset
1512 strcat(item__getname_buffer, v9);
Ritor1
parents:
diff changeset
1513 }
Ritor1
parents:
diff changeset
1514 return v4;
Ritor1
parents:
diff changeset
1515 }
Ritor1
parents:
diff changeset
1516
Ritor1
parents:
diff changeset
1517
Ritor1
parents:
diff changeset
1518 //----- (00456620) --------------------------------------------------------
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1519 void ItemsTable::GenerateItem(int treasure_level, int a3, ItemGen *out_item)
0
Ritor1
parents:
diff changeset
1520 {
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1521
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1522 ItemGen *v4; // esi@1
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1523 ItemsTable *v5; // edi@1
0
Ritor1
parents:
diff changeset
1524 int v6; // ebx@3
Ritor1
parents:
diff changeset
1525 int *v7; // ecx@33
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1526 //int v8; // eax@34
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1527 //int v9; // eax@39
0
Ritor1
parents:
diff changeset
1528 int v10; // ebx@43
Ritor1
parents:
diff changeset
1529 int v11; // ecx@47
Ritor1
parents:
diff changeset
1530 unsigned int *v12; // edx@48
Ritor1
parents:
diff changeset
1531 unsigned int v13; // eax@49
Ritor1
parents:
diff changeset
1532 signed int v14; // ebx@52
Ritor1
parents:
diff changeset
1533 int v15; // eax@53
Ritor1
parents:
diff changeset
1534 signed int v16; // eax@55
Ritor1
parents:
diff changeset
1535 int v17; // ebx@57
Ritor1
parents:
diff changeset
1536 int v18; // edx@62
Ritor1
parents:
diff changeset
1537 signed int v19; // ebx@70
Ritor1
parents:
diff changeset
1538 unsigned __int8 v20; // al@81
Ritor1
parents:
diff changeset
1539 int v21; // eax@84
Ritor1
parents:
diff changeset
1540 int v22; // ebx@85
Ritor1
parents:
diff changeset
1541 int v23; // eax@86
Ritor1
parents:
diff changeset
1542 int v24; // ebx@86
Ritor1
parents:
diff changeset
1543 int v25; // edx@86
Ritor1
parents:
diff changeset
1544 int v26; // edx@89
Ritor1
parents:
diff changeset
1545 unsigned int v27; // eax@89
Ritor1
parents:
diff changeset
1546 int i; // ebx@89
Ritor1
parents:
diff changeset
1547 unsigned int v29; // ecx@90
Ritor1
parents:
diff changeset
1548 int v30; // ebx@91
Ritor1
parents:
diff changeset
1549 int v31; // eax@91
Ritor1
parents:
diff changeset
1550 int v32; // ecx@91
Ritor1
parents:
diff changeset
1551 int v33; // eax@91
Ritor1
parents:
diff changeset
1552 int v34; // eax@97
Ritor1
parents:
diff changeset
1553 unsigned __int8 v35; // sf@97
Ritor1
parents:
diff changeset
1554 unsigned __int8 v36; // of@97
Ritor1
parents:
diff changeset
1555 int v37; // ebx@98
Ritor1
parents:
diff changeset
1556 int v38; // edx@99
Ritor1
parents:
diff changeset
1557 signed int v39; // ebx@101
Ritor1
parents:
diff changeset
1558 int v40; // ecx@102
Ritor1
parents:
diff changeset
1559 char v41; // zf@107
Ritor1
parents:
diff changeset
1560 char v42; // al@108
Ritor1
parents:
diff changeset
1561 char v43; // al@111
Ritor1
parents:
diff changeset
1562 int *v44; // edx@118
Ritor1
parents:
diff changeset
1563 int v45; // eax@120
Ritor1
parents:
diff changeset
1564 int v46; // edx@120
Ritor1
parents:
diff changeset
1565 int *j; // eax@121
Ritor1
parents:
diff changeset
1566 unsigned int v48; // ecx@123
Ritor1
parents:
diff changeset
1567 int v49; // eax@123
Ritor1
parents:
diff changeset
1568 int v50; // eax@123
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1569 int Dst[800]; // [sp+Ch] [bp-C88h]@33
0
Ritor1
parents:
diff changeset
1570 int v52; // [sp+C8Ch] [bp-8h]@33
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1571 int v53; // [sp+C90h] [bp-4h]@1
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1572 int v54; // [sp+C9Ch] [bp+8h]@3
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1573 //int v55; // [sp+CA0h] [bp+Ch]@34
0
Ritor1
parents:
diff changeset
1574 signed int v56; // [sp+CA0h] [bp+Ch]@55
Ritor1
parents:
diff changeset
1575 int v57; // [sp+CA0h] [bp+Ch]@62
Ritor1
parents:
diff changeset
1576 int *v58; // [sp+CA0h] [bp+Ch]@102
Ritor1
parents:
diff changeset
1577 int v59; // [sp+CA0h] [bp+Ch]@123
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1578 //signed int a2a; // [sp+CA4h] [bp+10h]@33
0
Ritor1
parents:
diff changeset
1579 int a2b; // [sp+CA4h] [bp+10h]@101
Ritor1
parents:
diff changeset
1580 int a2c; // [sp+CA4h] [bp+10h]@120
Ritor1
parents:
diff changeset
1581
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1582 v53 = -1;
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1583 v5 = this;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1584 if (!out_item)
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1585 out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen");
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1586 memset(out_item, 0, sizeof(*out_item));
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1587
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1588 v4 = out_item;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1589 v6 = treasure_level - 1;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1590 //v54 = treasure_level - 1;
0
Ritor1
parents:
diff changeset
1591 if ( a3 )
Ritor1
parents:
diff changeset
1592 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1593 ITEM_EQUIP_TYPE requested_equip;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1594 PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1595 switch (a3)
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1596 {
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1597 case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1598 case 21: requested_equip = EQUIP_ARMOUR; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1599 case 22: requested_skill = (PLAYER_SKILL_TYPE)38; __debugbreak();/*check this skill*/ break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1600 case 23: requested_skill = PLAYER_SKILL_SWORD; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1601 case 24: requested_skill = PLAYER_SKILL_DAGGER; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1602 case 25: requested_skill = PLAYER_SKILL_AXE; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1603 case 26: requested_skill = PLAYER_SKILL_SPEAR; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1604 case 27: requested_skill = PLAYER_SKILL_BOW; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1605 case 28: requested_skill = PLAYER_SKILL_MACE; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1606 case 29: requested_skill = (PLAYER_SKILL_TYPE)37; __debugbreak();/*check this skill*/break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1607 case 30: requested_skill = PLAYER_SKILL_STAFF; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1608 case 31: requested_skill = PLAYER_SKILL_LEATHER; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1609 case 32: requested_skill = PLAYER_SKILL_CHAIN; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1610 case 33: requested_skill = PLAYER_SKILL_PLATE; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1611 case 34: requested_equip = EQUIP_SHIELD; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1612 case 35: requested_equip = EQUIP_HELMET; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1613 case 36: requested_equip = EQUIP_BELT; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1614 case 37: requested_equip = EQUIP_CLOAK; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1615 case 38: requested_equip = EQUIP_GAUNTLETS; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1616 case 39: requested_equip = EQUIP_BOOTS; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1617 case 40: requested_equip = EQUIP_RING; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1618 case 41: requested_equip = EQUIP_AMULET; break;
295
640a176c030f sub_42ECB5
Nomad
parents: 245
diff changeset
1619 case 42: requested_equip = EQUIP_WAND; break;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1620 case 43: requested_equip = EQUIP_F; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1621 case 44: requested_equip = EQUIP_POTION; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1622 case 45: requested_equip = EQUIP_REAGENT; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1623 case 46: requested_equip = EQUIP_GEM; break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1624 default:
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1625 __debugbreak(); // check this condition
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1626 requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1);
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1627 break;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1628 }
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1629 memset(Dst, 0, sizeof(Dst));
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1630 v52 = 0;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1631 v7 = Dst;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1632 //a2a = 1;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1633 if (requested_skill == PLAYER_SKILL_INVALID)
0
Ritor1
parents:
diff changeset
1634 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1635 for (uint i = 1; i < 500; ++i)
0
Ritor1
parents:
diff changeset
1636 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1637 if (pItems[i].uEquipType == requested_equip)
0
Ritor1
parents:
diff changeset
1638 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1639 *v7++ = i;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1640 v52 += pItems[i].uChanceByTreasureLvl[v6];
0
Ritor1
parents:
diff changeset
1641 }
Ritor1
parents:
diff changeset
1642 }
Ritor1
parents:
diff changeset
1643 }
Ritor1
parents:
diff changeset
1644 else
Ritor1
parents:
diff changeset
1645 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1646 for (uint i = 1; i < 500; ++i)
0
Ritor1
parents:
diff changeset
1647 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1648 if (pItems[i].uSkillType == requested_skill)
0
Ritor1
parents:
diff changeset
1649 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1650 *v7++ = i;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1651 v52 += pItems[i].uChanceByTreasureLvl[v6];
0
Ritor1
parents:
diff changeset
1652 }
Ritor1
parents:
diff changeset
1653 }
Ritor1
parents:
diff changeset
1654 }
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1655
0
Ritor1
parents:
diff changeset
1656 v10 = 0;
Ritor1
parents:
diff changeset
1657 if ( v52 )
Ritor1
parents:
diff changeset
1658 v10 = rand() % v52;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1659
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1660 v4->uItemID = *Dst;
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1661 if (!v4->uItemID)
0
Ritor1
parents:
diff changeset
1662 v4->uItemID = 1;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1663
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1664 v11 = pItems[v4->uItemID].uChanceByTreasureLvl[v6];
0
Ritor1
parents:
diff changeset
1665 if ( v11 < v10 )
Ritor1
parents:
diff changeset
1666 {
Ritor1
parents:
diff changeset
1667 v12 = (uint *)Dst;
Ritor1
parents:
diff changeset
1668 do
Ritor1
parents:
diff changeset
1669 {
Ritor1
parents:
diff changeset
1670 ++v12;
Ritor1
parents:
diff changeset
1671 v13 = *v12;
Ritor1
parents:
diff changeset
1672 v4->uItemID = *v12;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1673 v11 += pItems[v13].uChanceByTreasureLvl[v6];
0
Ritor1
parents:
diff changeset
1674 }
Ritor1
parents:
diff changeset
1675 while ( v11 < v10 );
Ritor1
parents:
diff changeset
1676 }
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1677 if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE )
0
Ritor1
parents:
diff changeset
1678 {
Ritor1
parents:
diff changeset
1679 v4->_bonus_type = 0;
Ritor1
parents:
diff changeset
1680 v14 = 2;
Ritor1
parents:
diff changeset
1681 do
Ritor1
parents:
diff changeset
1682 {
Ritor1
parents:
diff changeset
1683 v4->_bonus_type += rand() % 4 + 1;
Ritor1
parents:
diff changeset
1684 v15 = v4->_bonus_type;
Ritor1
parents:
diff changeset
1685 --v14;
Ritor1
parents:
diff changeset
1686 }
Ritor1
parents:
diff changeset
1687 while ( v14 );
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1688 v4->_bonus_type = v15 * treasure_level;
0
Ritor1
parents:
diff changeset
1689 }
Ritor1
parents:
diff changeset
1690 }
Ritor1
parents:
diff changeset
1691 else
Ritor1
parents:
diff changeset
1692 {
Ritor1
parents:
diff changeset
1693 v16 = 0;
Ritor1
parents:
diff changeset
1694 v56 = 0;
Ritor1
parents:
diff changeset
1695 do
Ritor1
parents:
diff changeset
1696 v56 += pParty->field_7BA[v16++];
Ritor1
parents:
diff changeset
1697 while ( v16 < 29 );
Ritor1
parents:
diff changeset
1698 v17 = rand() % 29;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1699 if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 )
0
Ritor1
parents:
diff changeset
1700 {
Ritor1
parents:
diff changeset
1701 pParty->field_7BA[v17] = 1;
Ritor1
parents:
diff changeset
1702 v4->uAttributes = 0;
Ritor1
parents:
diff changeset
1703 v4->uItemID = v17 + 500;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1704 SetSpecialBonus(v4);
0
Ritor1
parents:
diff changeset
1705 return;
Ritor1
parents:
diff changeset
1706 }
Ritor1
parents:
diff changeset
1707 v57 = 0;
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1708 v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54];
0
Ritor1
parents:
diff changeset
1709 v4->uItemID = 0;
Ritor1
parents:
diff changeset
1710 if ( v18 > 0 )
Ritor1
parents:
diff changeset
1711 {
Ritor1
parents:
diff changeset
1712 do
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1713 v57 += pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[v6];
0
Ritor1
parents:
diff changeset
1714 while ( v57 < v18 );
Ritor1
parents:
diff changeset
1715 }
Ritor1
parents:
diff changeset
1716 if ( !v18 )
Ritor1
parents:
diff changeset
1717 v4->uItemID = 1;
Ritor1
parents:
diff changeset
1718 if ( !v4->uItemID )
Ritor1
parents:
diff changeset
1719 v4->uItemID = 1;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1720 if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE)
0
Ritor1
parents:
diff changeset
1721 {
Ritor1
parents:
diff changeset
1722 v4->_bonus_type = 0;
Ritor1
parents:
diff changeset
1723 v19 = 2;
Ritor1
parents:
diff changeset
1724 do
Ritor1
parents:
diff changeset
1725 {
Ritor1
parents:
diff changeset
1726 v4->_bonus_type += rand() % 4 + 1;
Ritor1
parents:
diff changeset
1727 v15 = v4->_bonus_type;
Ritor1
parents:
diff changeset
1728 --v19;
Ritor1
parents:
diff changeset
1729 }
Ritor1
parents:
diff changeset
1730 while ( v19 );
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1731 v4->_bonus_type = v15 * treasure_level;
0
Ritor1
parents:
diff changeset
1732 }
Ritor1
parents:
diff changeset
1733 }
Ritor1
parents:
diff changeset
1734 if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
Ritor1
parents:
diff changeset
1735 && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) )
Ritor1
parents:
diff changeset
1736 v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
222
8113753ed2ae more item init fixing
Gloval
parents: 193
diff changeset
1737 if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St )
0
Ritor1
parents:
diff changeset
1738 v4->uAttributes = 0;
Ritor1
parents:
diff changeset
1739 else
Ritor1
parents:
diff changeset
1740 v4->uAttributes = 1;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1741 if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION )
0
Ritor1
parents:
diff changeset
1742 {
Ritor1
parents:
diff changeset
1743 v4->uAdditionalValue = 0;
Ritor1
parents:
diff changeset
1744 v4->_bonus_type = 0;
Ritor1
parents:
diff changeset
1745 }
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1746 v20 = pItems[v4->uItemID].uEquipType;
0
Ritor1
parents:
diff changeset
1747 if ( v20 <= EQUIP_BOW )
Ritor1
parents:
diff changeset
1748 {
294
a672f297c163 item gen restore
Gloval
parents: 245
diff changeset
1749 v37 = v5->uBonusChanceWpSpecial[v54];
0
Ritor1
parents:
diff changeset
1750 if ( !*(unsigned int *)v37 )
Ritor1
parents:
diff changeset
1751 return;
Ritor1
parents:
diff changeset
1752 v38 = rand() % 100;
Ritor1
parents:
diff changeset
1753 v36 = __OFSUB__(v38, *(unsigned int *)v37);
Ritor1
parents:
diff changeset
1754 v35 = v38 - *(unsigned int *)v37 < 0;
Ritor1
parents:
diff changeset
1755 }
Ritor1
parents:
diff changeset
1756 else
Ritor1
parents:
diff changeset
1757 {
Ritor1
parents:
diff changeset
1758 if ( v20 > EQUIP_AMULET )
Ritor1
parents:
diff changeset
1759 {
295
640a176c030f sub_42ECB5
Nomad
parents: 245
diff changeset
1760 if ( v20 == EQUIP_WAND )
0
Ritor1
parents:
diff changeset
1761 {
Ritor1
parents:
diff changeset
1762 v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1;
Ritor1
parents:
diff changeset
1763 v4->uNumCharges = v21;
Ritor1
parents:
diff changeset
1764 v4->uMaxCharges = v21;
Ritor1
parents:
diff changeset
1765 }
Ritor1
parents:
diff changeset
1766 return;
Ritor1
parents:
diff changeset
1767 }
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1768 v22 = (int)&uBonusChanceStandart[v6];
0
Ritor1
parents:
diff changeset
1769 if ( !*(unsigned int *)v22 )
Ritor1
parents:
diff changeset
1770 return;
Ritor1
parents:
diff changeset
1771 v23 = rand();
Ritor1
parents:
diff changeset
1772 v24 = *(unsigned int *)v22;
Ritor1
parents:
diff changeset
1773 v25 = v23 % 100;
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1774 if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24))
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1775 return;
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1776 if ( v25 < v24 || v23 % 100 < v24)
0
Ritor1
parents:
diff changeset
1777 {
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1778 v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
0
Ritor1
parents:
diff changeset
1779 v27 = v4->uItemID;
Ritor1
parents:
diff changeset
1780 v4->_bonus_type = 0;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1781 for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
0
Ritor1
parents:
diff changeset
1782 i < v26;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1783 i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] )
0
Ritor1
parents:
diff changeset
1784 {
Ritor1
parents:
diff changeset
1785 v29 = v4->uItemID;
Ritor1
parents:
diff changeset
1786 ++v4->_bonus_type;
Ritor1
parents:
diff changeset
1787 }
Ritor1
parents:
diff changeset
1788 ++v4->_bonus_type;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1789 v30 = 10;// v5->field_116D8[2 * v54 + 12];
0
Ritor1
parents:
diff changeset
1790 v31 = rand();
Ritor1
parents:
diff changeset
1791 v32 = v4->_bonus_type - 1;
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1792 v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
0
Ritor1
parents:
diff changeset
1793 v4->_bonus_strength = v33;
Ritor1
parents:
diff changeset
1794 if ( v32 == 21 || v32 == 22 || v32 == 23 )
Ritor1
parents:
diff changeset
1795 v4->_bonus_strength = v33 >> 1;
Ritor1
parents:
diff changeset
1796 if ( v4->_bonus_strength <= 0 )
Ritor1
parents:
diff changeset
1797 v4->_bonus_strength = 1;
Ritor1
parents:
diff changeset
1798 return;
Ritor1
parents:
diff changeset
1799 }
224
9917d3b4925e items init refactored
Gloval
parents: 223
diff changeset
1800 v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24];
0
Ritor1
parents:
diff changeset
1801 v36 = __OFSUB__(v25, v34);
Ritor1
parents:
diff changeset
1802 v35 = v25 - v34 < 0;
Ritor1
parents:
diff changeset
1803 }
Ritor1
parents:
diff changeset
1804 if ( !(v35 ^ v36) )
Ritor1
parents:
diff changeset
1805 return;
Ritor1
parents:
diff changeset
1806 memset(&Dst, 0, 0xC80u);
Ritor1
parents:
diff changeset
1807 v39 = 0;
Ritor1
parents:
diff changeset
1808 a2b = 0;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1809 if ( pSpecialEnchantments_count > 0 )
0
Ritor1
parents:
diff changeset
1810 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1811 v52 = -16 - (uint)this;
0
Ritor1
parents:
diff changeset
1812 v58 = (int *)&Dst;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1813 v40 = (int)&pSpecialEnchantments[1];
0
Ritor1
parents:
diff changeset
1814 do
Ritor1
parents:
diff changeset
1815 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1816 switch ( v6 )
0
Ritor1
parents:
diff changeset
1817 {
Ritor1
parents:
diff changeset
1818 case 2:
Ritor1
parents:
diff changeset
1819 if ( !*(unsigned char *)v40 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1820 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1821 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1822 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1823 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1824 v44 = v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1825 ++v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1826 *v44 = a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1827 }
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1828 ++a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1829 v40 += 28;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1830 continue;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1831 }
0
Ritor1
parents:
diff changeset
1832 v41 = *(unsigned char *)v40 == 1;
Ritor1
parents:
diff changeset
1833 break;
Ritor1
parents:
diff changeset
1834 case 3:
Ritor1
parents:
diff changeset
1835 v43 = *(unsigned char *)v40;
Ritor1
parents:
diff changeset
1836 if ( !*(unsigned char *)v40 || v43 == 1 )
Ritor1
parents:
diff changeset
1837 {
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1838 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1839 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
0
Ritor1
parents:
diff changeset
1840 {
Ritor1
parents:
diff changeset
1841 v44 = v58;
Ritor1
parents:
diff changeset
1842 ++v58;
Ritor1
parents:
diff changeset
1843 *v44 = a2b;
Ritor1
parents:
diff changeset
1844 }
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1845 ++a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1846 v40 += 28;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1847 continue;
0
Ritor1
parents:
diff changeset
1848 }
Ritor1
parents:
diff changeset
1849 v41 = v43 == 2;
Ritor1
parents:
diff changeset
1850 break;
Ritor1
parents:
diff changeset
1851 case 4:
Ritor1
parents:
diff changeset
1852 v42 = *(unsigned char *)v40;
Ritor1
parents:
diff changeset
1853 if ( *(unsigned char *)v40 == 1 || v42 == 2 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1854 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1855 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1856 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1857 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1858 v44 = v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1859 ++v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1860 *v44 = a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1861 }
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1862 ++a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1863 v40 += 28;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1864 continue;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1865 }
0
Ritor1
parents:
diff changeset
1866 v41 = v42 == 3;
Ritor1
parents:
diff changeset
1867 break;
Ritor1
parents:
diff changeset
1868 default:
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1869 if ( v6 != 5 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1870 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1871 ++a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1872 v40 += 28;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1873 continue;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1874 }
0
Ritor1
parents:
diff changeset
1875 v41 = *(unsigned char *)v40 == 3;
Ritor1
parents:
diff changeset
1876 break;
Ritor1
parents:
diff changeset
1877 }
Ritor1
parents:
diff changeset
1878 if ( v41 )
245
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1879 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1880 v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1881 if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1882 {
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1883 v44 = v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1884 ++v58;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1885 *v44 = a2b;
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1886 }
f070b49d40dd goto cleaning
zipi
parents: 243
diff changeset
1887 }
0
Ritor1
parents:
diff changeset
1888 LABEL_119:
Ritor1
parents:
diff changeset
1889 ++a2b;
Ritor1
parents:
diff changeset
1890 v40 += 28;
Ritor1
parents:
diff changeset
1891 }
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1892 while ( a2b < pSpecialEnchantments_count );
0
Ritor1
parents:
diff changeset
1893 }
Ritor1
parents:
diff changeset
1894 v45 = rand();
Ritor1
parents:
diff changeset
1895 v4->uAdditionalValue = *(uint *)Dst;
Ritor1
parents:
diff changeset
1896 v46 = v45 % v39 + 1;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1897 a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType);
0
Ritor1
parents:
diff changeset
1898 if ( a2c < v46 )
Ritor1
parents:
diff changeset
1899 {
Ritor1
parents:
diff changeset
1900 for ( j = (int *)&Dst; ; j = (int *)v59 )
Ritor1
parents:
diff changeset
1901 {
Ritor1
parents:
diff changeset
1902 v48 = v4->uItemID;
Ritor1
parents:
diff changeset
1903 v49 = (int)(j + 1);
Ritor1
parents:
diff changeset
1904 v59 = v49;
Ritor1
parents:
diff changeset
1905 v50 = *(unsigned int *)v49;
Ritor1
parents:
diff changeset
1906 v4->uAdditionalValue = v50;
228
46ae2602aceb Item generation doesn't crash (thou still generates weird stuff)
Nomad
parents: 224
diff changeset
1907 a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType);
0
Ritor1
parents:
diff changeset
1908 if ( a2c >= v46 )
Ritor1
parents:
diff changeset
1909 break;
Ritor1
parents:
diff changeset
1910 }
Ritor1
parents:
diff changeset
1911 }
Ritor1
parents:
diff changeset
1912 ++v4->uAdditionalValue;
Ritor1
parents:
diff changeset
1913 }
Ritor1
parents:
diff changeset
1914
Ritor1
parents:
diff changeset
1915 //----- (004505CC) --------------------------------------------------------
Ritor1
parents:
diff changeset
1916 bool ItemGen::GenerateArtifact()
Ritor1
parents:
diff changeset
1917 {
Ritor1
parents:
diff changeset
1918 ItemGen *v1; // edi@1
Ritor1
parents:
diff changeset
1919 signed int uNumArtifactsNotFound; // esi@1
Ritor1
parents:
diff changeset
1920 int v3; // eax@1
Ritor1
parents:
diff changeset
1921 bool result; // eax@6
Ritor1
parents:
diff changeset
1922 int v5[32]; // [sp+8h] [bp-A0h]@3
Ritor1
parents:
diff changeset
1923 char Dst[32]; // [sp+88h] [bp-20h]@1
Ritor1
parents:
diff changeset
1924
Ritor1
parents:
diff changeset
1925 auto a2 = this;
Ritor1
parents:
diff changeset
1926 v1 = a2;
Ritor1
parents:
diff changeset
1927 memset(Dst, 0, 0x20u);
Ritor1
parents:
diff changeset
1928 uNumArtifactsNotFound = 0;
Ritor1
parents:
diff changeset
1929 v3 = 500;
Ritor1
parents:
diff changeset
1930 do
Ritor1
parents:
diff changeset
1931 {
Ritor1
parents:
diff changeset
1932 if ( !pParty->field_3C.pIsArtifactFound[v3] )
Ritor1
parents:
diff changeset
1933 v5[uNumArtifactsNotFound++] = v3;
Ritor1
parents:
diff changeset
1934 ++v3;
Ritor1
parents:
diff changeset
1935 }
Ritor1
parents:
diff changeset
1936 while ( v3 < 529 );
Ritor1
parents:
diff changeset
1937 v1->Reset();
Ritor1
parents:
diff changeset
1938 if ( uNumArtifactsNotFound )
Ritor1
parents:
diff changeset
1939 {
Ritor1
parents:
diff changeset
1940 v1->uItemID = v5[rand() % uNumArtifactsNotFound];
Ritor1
parents:
diff changeset
1941 pItemsTable->SetSpecialBonus(v1);
Ritor1
parents:
diff changeset
1942 result = 1;
Ritor1
parents:
diff changeset
1943 }
Ritor1
parents:
diff changeset
1944 else
Ritor1
parents:
diff changeset
1945 {
Ritor1
parents:
diff changeset
1946 result = 0;
Ritor1
parents:
diff changeset
1947 }
Ritor1
parents:
diff changeset
1948 return result;
Ritor1
parents:
diff changeset
1949 }
Ritor1
parents:
diff changeset
1950 // 4505CC: using guessed type int var_A0[32];