0
|
1 #include <stdlib.h>
|
|
2
|
|
3 #include "Spells.h"
|
|
4 #include "Overlays.h"
|
|
5 #include "Allocator.h"
|
|
6 #include "LOD.h"
|
|
7 #include "stru123.h"
|
189
|
8 #include "texts.h"
|
0
|
9
|
|
10 #include "mm7_data.h"
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16 struct SpellStats *pSpellStats;
|
|
17
|
|
18
|
|
19 stru324_spell stru_4E3ACC[102];
|
|
20
|
192
|
21 SpellData pSpellDatas[100]={
|
|
22 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
23 {1, 1, 1, 1, 60, 60, 60, 40, 0, 0},
|
|
24 {2, 2, 2, 2, 110, 110, 100, 90, 768, 0},
|
|
25 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
26 {4, 4, 4, 4, 120, 120, 120, 120, 0, 0},
|
|
27 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
|
|
28 {8, 8, 8, 8, 100, 100, 90, 80, 1536, 0},
|
|
29 {10, 10, 10, 10, 150, 150, 150, 150, 1536, 0},
|
|
30 {15, 15, 15, 15, 120, 120, 120, 120, 1536, 0},
|
|
31 {20, 20, 20, 20, 100, 100, 100, 90, 264, 0},
|
|
32 {25, 25, 25, 25, 100, 100, 100, 90, 268, 0},
|
|
33 {30, 30, 30, 30, 90, 90, 90, 90, 3855, 0},
|
|
34 {1, 1, 1, 0, 60, 60, 60, 60, 0, 0},
|
|
35 {2, 2, 2, 2, 120, 120, 120, 100, 0, 0},
|
|
36 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
37 {4, 4, 4, 4, 110, 100, 90, 80, 258, 0},
|
|
38 {5, 5, 5, 5, 90, 90, 70, 50, 0, 0},
|
|
39 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
|
|
40 {10, 10, 10, 10, 100, 100, 90, 70, 2048, 0},
|
|
41 {15, 15, 15, 15, 200, 200, 200, 200, 0, 0},
|
|
42 {20, 20, 20, 20, 100, 100, 100, 90, 2570, 0},
|
|
43 {25, 25, 25, 25, 250, 250, 250, 250, 0, 0},
|
|
44 {30, 30, 30, 30, 90, 90, 90, 90, 276, 0},
|
|
45 {1, 1, 1, 1, 60, 60, 60, 20, 0, 0},
|
|
46 {2, 2, 2, 2, 110, 100, 90, 70, 514, 0},
|
|
47 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
48 {4, 4, 4, 4, 110, 100, 90, 80, 1024, 0},
|
|
49 {5, 5, 5, 5, 150, 150, 150, 150, 0, 0},
|
|
50 {8, 8, 8, 8, 200, 200, 200, 200, 0, 0},
|
|
51 {10, 10, 10, 10, 100, 100, 90, 80, 2313, 0},
|
|
52 {15, 15, 15, 15, 140, 140, 140, 140, 0, 0},
|
|
53 {20, 20, 20, 20, 200, 200, 200, 200, 0, 0},
|
|
54 {25, 25, 25, 25, 80, 80, 80, 80, 780, 0},
|
|
55 {30, 30, 30, 30, 250, 250, 250, 250, 0, 0},
|
|
56 {1, 1, 1, 1, 80, 80, 80, 80, 0, 0},
|
|
57 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
|
|
58 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
59 {4, 4, 4, 4, 110, 100, 90, 80, 773, 0},
|
|
60 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
|
|
61 {8, 8, 8, 8, 100, 100, 90, 80, 2304, 0},
|
|
62 {10, 10, 10, 10, 140, 140, 140, 140, 0, 0},
|
|
63 {15, 15, 15, 15, 90, 90, 90, 80, 2048, 0},
|
|
64 {20, 20, 20, 20, 150, 150, 150, 150, 0, 0},
|
|
65 {25, 25, 25, 25, 100, 100, 100, 90, 276, 0},
|
|
66 {30, 30, 30, 30, 90, 90, 90, 90, 25, 0},
|
|
67 {1, 1, 1, 1, 100, 100, 100, 100, 0, 0},
|
|
68 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
|
|
69 {3, 3, 3, 3, 90, 90, 90, 90, 0, 0},
|
|
70 {4, 4, 4, 4, 120, 120, 120, 120, 0, 0},
|
|
71 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
|
|
72 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
|
|
73 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
|
|
74 {15, 15, 15, 15, 100, 100, 100, 100, 2058, 0},
|
|
75 {20, 20, 20, 20, 240, 240, 240, 240, 0, 0},
|
|
76 {25, 25, 25, 25, 150, 150, 150, 150, 0, 0},
|
|
77 {30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0},
|
|
78 {1, 1, 1, 1, 120, 120, 120, 120, 0, 0},
|
|
79 {2, 2, 2, 2, 110, 110, 110, 110, 771, 0},
|
|
80 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
81 {4, 4, 4, 4, 110, 100, 90, 80, 0, 0},
|
|
82 {5, 5, 5, 5, 100, 100, 100, 100, 0, 0},
|
|
83 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
|
|
84 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
|
|
85 {15, 15, 15, 15, 80, 80, 80, 80, 0, 0},
|
|
86 {20, 20, 20, 20, 120, 120, 120, 120, 0, 0},
|
|
87 {25, 25, 25, 25, 110, 110, 110, 100, 268, 0},
|
|
88 {30, 30, 30, 30, 120, 120, 120, 120, 0, 0},
|
|
89 {1, 1, 1, 1, 120, 120, 120, 120, 0, 0},
|
|
90 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
|
|
91 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
|
|
92 {4, 4, 4, 4, 110, 100, 90, 80, 520, 0},
|
|
93 {5, 5, 5, 5, 110, 110, 110, 110, 0, 0},
|
|
94 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
|
|
95 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
|
|
96 {15, 15, 15, 15, 120, 120, 120, 120, 0, 0},
|
|
97 {20, 20, 20, 20, 120, 120, 120, 120, 0, 0},
|
|
98 {25, 25, 25, 25, 110, 110, 110, 100, 1310, 0},
|
|
99 {30, 30, 30, 30, 100, 100, 100, 100, 0, 0},
|
|
100 {5, 5, 5, 5, 110, 100, 90, 80, 1024, 0},
|
|
101 {10, 10, 10, 10, 120, 110, 100, 90, 4112, 0},
|
|
102 {15, 15, 15, 15, 120, 110, 100, 90, 0, 0},
|
|
103 {20, 20, 20, 20, 160, 140, 120, 100, 0, 0},
|
|
104 {25, 25, 25, 25, 140, 140, 140, 140, 0, 0},
|
|
105 {30, 30, 30, 30, 500, 500, 500, 500, 0, 0},
|
|
106 {35, 35, 35, 35, 135, 135, 120, 100, 281, 0},
|
|
107 {40, 40, 40, 40, 500, 500, 500, 500, 0, 0},
|
|
108 {45, 45, 45, 45, 250, 250, 250, 250, 0, 0},
|
|
109 {50, 50, 50, 50, 150, 150, 150, 135, 5140, 0},
|
|
110 {55, 55, 55, 55, 300, 300, 300, 300, 0, 0},
|
|
111 {10, 10, 10, 10, 140, 140, 140, 140, 0, 0},
|
|
112 {15, 15, 15, 15, 120, 110, 100, 90, 2585, 0},
|
|
113 {20, 20, 20, 20, 120, 100, 90, 120, 0, 0},
|
|
114 {25, 25, 25, 25, 120, 120, 120, 120, 0, 0},
|
|
115 {30, 30, 30, 30, 90, 90, 80, 70, 1542, 0},
|
|
116 {35, 35, 35, 35, 120, 120, 100, 80, 0, 0},
|
|
117 {40, 40, 40, 40, 110, 110, 110, 110, 0, 0},
|
|
118 {45, 45, 45, 45, 200, 200, 200, 150, 0, 0},
|
|
119 {50, 50, 50, 50, 120, 120, 120, 100, 6400, 0},
|
|
120 {55, 55, 55, 55, 250, 250, 250, 250, 306, 0},
|
|
121 {60, 60, 60, 60, 300, 300, 300, 300, 2073, 0}
|
|
122 };
|
0
|
123
|
357
|
124 unsigned char pSpellbookSpellIndices[9][12] = // 4E2430
|
|
125 {
|
|
126 {0, 3, 1, 8, 11, 7, 4, 10, 6, 2, 5, 9},
|
|
127 {0, 11, 2, 9, 6, 8, 5, 10, 3, 7, 1, 4},
|
|
128 {0, 4, 8, 9, 1, 10, 3, 11, 7, 6, 2, 5},
|
|
129 {0, 7, 10, 8, 2, 11, 1, 5, 3, 6, 4, 9},
|
|
130 {0, 5, 10, 11, 7, 2, 8, 1, 4, 9, 3, 6},
|
|
131 {0, 5, 9, 8, 3, 7, 6, 4, 1, 11, 2, 10},
|
|
132 {0, 1, 6, 9, 3, 5, 8, 11, 7, 10, 4, 2},
|
|
133 {0, 1, 10, 11, 9, 4, 3, 6, 5, 7, 8, 2},
|
|
134 {0, 9, 3, 7, 1, 5, 2, 10, 11, 8, 6, 4}
|
|
135 };
|
0
|
136
|
357
|
137 struct SpellBookIconPos pIconPos[108]={
|
|
138 {0, 0},
|
|
139 {17, 13},
|
|
140 {115, 2},
|
|
141 {217, 15},
|
|
142 {299, 6},
|
|
143 {28, 125},
|
|
144 {130, 133},
|
|
145 {294, 114},
|
|
146 {11, 232},
|
|
147 {134, 233},
|
|
148 {237, 171},
|
|
149 {296, 231},
|
0
|
150
|
357
|
151 {0, 0},
|
|
152 {19, 9},
|
|
153 {117, 3},
|
|
154 {206, 13},
|
|
155 {285, 7},
|
|
156 {16, 123},
|
|
157 {113, 101},
|
|
158 {201, 118},
|
|
159 {317, 110},
|
|
160 {11, 230},
|
|
161 {149, 236},
|
|
162 {296, 234},
|
|
163
|
|
164 {0, 0},
|
|
165 {17, 9},
|
|
166 {140, 0},
|
|
167 {210, 34},
|
|
168 {293, 5},
|
|
169 {15, 98},
|
|
170 {78, 121},
|
|
171 {175, 136},
|
|
172 {301, 115},
|
|
173 {15, 226},
|
|
174 {154, 225},
|
|
175 {272, 220},
|
|
176
|
|
177 {0, 0},
|
|
178 {7, 9},
|
|
179 {156, 2},
|
|
180 {277, 9},
|
|
181 {11, 117},
|
|
182 {111, 82},
|
|
183 {180, 102},
|
|
184 {303, 108},
|
|
185 {10, 229},
|
|
186 {120, 221},
|
|
187 {201, 217},
|
|
188 {296, 225},
|
|
189
|
|
190 {0, 0},
|
|
191 {18, 8},
|
|
192 {89, 15},
|
|
193 {192, 14},
|
|
194 {292, 7},
|
|
195 {22, 129},
|
|
196 {125, 146},
|
|
197 {217, 136},
|
|
198 {305, 115},
|
|
199 {22, 226},
|
|
200 {174, 237},
|
|
201 {290, 231},
|
|
202
|
|
203 {0, 0},
|
|
204 {18, 12},
|
|
205 {148, 9},
|
|
206 {292, 7},
|
|
207 {17, 122},
|
|
208 {121, 99},
|
|
209 {220, 87},
|
|
210 {293, 112},
|
|
211 {13, 236},
|
|
212 {128, 213},
|
|
213 {220, 223},
|
|
214 {315, 223},
|
|
215
|
|
216 {0, 0},
|
|
217 {23, 14},
|
|
218 {127, 8},
|
|
219 {204, 0},
|
|
220 {306, 8},
|
|
221 {14, 115},
|
|
222 {122, 132},
|
|
223 {200, 116},
|
|
224 {293, 122},
|
|
225 {20, 228},
|
|
226 {154, 228},
|
|
227 {294, 239},
|
|
228
|
|
229 {0, 0},
|
|
230 {19, 14},
|
|
231 {124, 10},
|
|
232 {283, 12},
|
|
233 {8, 105},
|
|
234 {113, 89},
|
|
235 {190, 82},
|
|
236 {298, 108},
|
|
237 {18, 181},
|
|
238 {101, 204},
|
|
239 {204, 203},
|
|
240 {285, 218},
|
|
241
|
|
242 {0, 0},
|
|
243 {18, 17},
|
|
244 {110, 16},
|
|
245 {201, 15},
|
|
246 {307, 15},
|
|
247 {18, 148},
|
|
248 {125, 166},
|
|
249 {201, 123},
|
|
250 {275, 120},
|
|
251 {28, 235},
|
|
252 {217, 222},
|
|
253 {324, 216} };
|
0
|
254
|
|
255
|
|
256 //----- (0042EB31) --------------------------------------------------------
|
|
257 bool SpellBuff::NotExpired()
|
|
258 {
|
189
|
259 return (signed __int64)this->uExpireTime > 0 ? true:false;
|
0
|
260 }
|
|
261
|
|
262
|
|
263 //----- (00458585) --------------------------------------------------------
|
|
264 void SpellBuff::Reset()
|
|
265 {
|
|
266 SpellBuff *v1; // esi@1
|
|
267 unsigned __int16 v2; // ax@1
|
|
268
|
|
269 this->uSkill = 0;
|
|
270 this->uPower = 0;
|
|
271 this->uExpireTime = 0i64;
|
|
272 this->uCaster = 0;
|
|
273 this->uFlags = 0;
|
189
|
274 if ( this->uOverlayID )
|
0
|
275 {
|
189
|
276 ((OtherOverlay *)&stru_5E4C90._decor_events[20 * this->uOverlayID + 105])->Reset();
|
142
|
277 pOtherOverlayList->bRedraw = true;
|
189
|
278 this->uOverlayID = 0;
|
0
|
279 }
|
|
280 }
|
|
281
|
|
282 //----- (004585CA) --------------------------------------------------------
|
|
283 signed int SpellBuff::_4585CA(__int64 a2)
|
|
284 {
|
|
285 signed int result; // eax@3
|
|
286
|
|
287 if ( this->uExpireTime && (signed __int64)this->uExpireTime < a2 )
|
|
288 {
|
|
289 this->uExpireTime = 0i64;
|
|
290 this->uPower = 0;
|
|
291 this->uSkill = 0;
|
|
292 this->uOverlayID = 0;
|
|
293 result = 1;
|
|
294 }
|
|
295 else
|
|
296 {
|
|
297 result = 0;
|
|
298 }
|
|
299 return result;
|
|
300 }
|
|
301
|
|
302 //----- (004584E0) --------------------------------------------------------
|
|
303 signed int SpellBuff::Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int a5, unsigned __int8 a6)
|
|
304 {
|
|
305 SpellBuff *v6; // esi@1
|
|
306 signed int result; // eax@3
|
|
307 int v8; // eax@4
|
|
308
|
|
309 v6 = this;
|
|
310 if ( this->uExpireTime && (signed __int64)uExpireTime < (signed __int64)this->uExpireTime )
|
|
311 {
|
|
312 result = 0;
|
|
313 }
|
|
314 else
|
|
315 {
|
|
316 this->uSkill = uSkillLevel;
|
|
317 this->uPower = uPower;
|
|
318 LOWORD(v8) = this->uOverlayID;
|
|
319 this->uExpireTime = uExpireTime;
|
|
320 if ( (short)v8 )
|
|
321 {
|
|
322 v8 = (unsigned __int16)v8;
|
|
323 if ( (unsigned __int16)v8 != a5 )
|
|
324 {
|
|
325 ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset();
|
142
|
326 pOtherOverlayList->bRedraw = true;
|
0
|
327 v6->uOverlayID = 0;
|
|
328 }
|
|
329 }
|
|
330 v6->uOverlayID = a5;
|
|
331 v6->uCaster = a6;
|
|
332 result = 1;
|
|
333 }
|
|
334 return result;
|
|
335 }
|
|
336
|
|
337 //----- (0045384A) --------------------------------------------------------
|
|
338 void SpellStats::Initialize()
|
191
|
339 {
|
0
|
340
|
191
|
341 int decode_step;
|
|
342 char* test_string;
|
|
343 bool break_loop;
|
|
344 unsigned char c;
|
|
345 unsigned int temp_str_len;
|
|
346 char* tmp_pos;
|
189
|
347
|
191
|
348 if ( pSpellsTXT_Raw )
|
|
349 pAllocator->FreeChunk(pSpellsTXT_Raw);
|
|
350 pSpellsTXT_Raw = NULL;
|
189
|
351
|
191
|
352 pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
|
|
353 strtok(pSpellsTXT_Raw, "\r");
|
|
354 strtok(NULL, "\r");
|
|
355 for(int i=1; i<100; ++i)
|
|
356 {
|
|
357 test_string=strtok(NULL, "\r")+1;
|
|
358 decode_step =0;
|
|
359 break_loop=false;
|
|
360 do
|
|
361 {
|
|
362 c = *(unsigned char*)test_string;
|
|
363 temp_str_len = 0;
|
|
364 while((c!='\t')&&(c>0))
|
|
365 {
|
|
366 ++temp_str_len;
|
|
367 c=test_string[temp_str_len];
|
|
368 }
|
|
369 tmp_pos=test_string+temp_str_len;
|
|
370 if (*tmp_pos == 0)
|
|
371 break_loop = true;
|
|
372 *tmp_pos = 0;
|
|
373 if (temp_str_len)
|
|
374 {
|
|
375 switch (decode_step)
|
|
376 {
|
|
377 case 2:
|
|
378 pInfos[i].pName=RemoveQuotes(test_string);
|
|
379 break;
|
|
380 case 3:
|
192
|
381 pInfos[i].uSchool = SPELL_SCHOOL_NONE;
|
191
|
382 if (!_strcmpi("fire", test_string) )
|
|
383 {
|
192
|
384 pInfos[i].uSchool =SPELL_SCHOOL_FIRE;
|
191
|
385 break;
|
|
386 }
|
|
387 if ( !_strcmpi("air", test_string) )
|
|
388 {
|
192
|
389 pInfos[i].uSchool = SPELL_SCHOOL_AIR;
|
191
|
390 break;
|
|
391 }
|
|
392 if ( !_strcmpi("water", test_string))
|
|
393 {
|
192
|
394 pInfos[i].uSchool = SPELL_SCHOOL_WATER;
|
191
|
395 break;
|
|
396 }
|
|
397 if ( !_strcmpi("earth", test_string))
|
|
398 {
|
192
|
399 pInfos[i].uSchool = SPELL_SCHOOL_EARTH;
|
191
|
400 break;
|
|
401 }
|
|
402 if ( !_strcmpi("spirit", test_string))
|
|
403 {
|
192
|
404 pInfos[i].uSchool = SPELL_SCHOOL_SPIRIT;
|
191
|
405 break;
|
|
406 }
|
|
407 if ( !_strcmpi("mind", test_string))
|
|
408 {
|
192
|
409 pInfos[i].uSchool = SPELL_SCHOOL_MIND;
|
191
|
410 break;
|
|
411 }
|
|
412 if ( !_strcmpi("body", test_string) )
|
|
413 {
|
192
|
414 pInfos[i].uSchool = SPELL_SCHOOL_BODY;
|
191
|
415 break;
|
|
416 }
|
|
417 if ( !_strcmpi("light", test_string) )
|
|
418 {
|
192
|
419 pInfos[i].uSchool = SPELL_SCHOOL_LIGHT;
|
191
|
420 break;
|
|
421 }
|
|
422 if ( !_strcmpi("dark", test_string))
|
|
423 {
|
192
|
424 pInfos[i].uSchool = SPELL_SCHOOL_DARK;
|
191
|
425 break;
|
|
426 }
|
|
427
|
|
428 if ( !_strcmpi("magic", test_string))
|
|
429 {
|
192
|
430 pInfos[i].uSchool = SPELL_SCHOOL_MAGIC;
|
191
|
431 break;
|
|
432 }
|
|
433 break;
|
|
434 case 4:
|
|
435 pInfos[i].pShortName=RemoveQuotes(test_string);
|
|
436 break;
|
|
437 case 5:
|
|
438 pInfos[i].pDescription=RemoveQuotes(test_string);
|
|
439 break;
|
|
440 case 6:
|
|
441 pInfos[i].pBasicSkillDesc=RemoveQuotes(test_string);
|
|
442 break;
|
|
443 case 7:
|
|
444 pInfos[i].pExpertSkillDesc=RemoveQuotes(test_string);
|
|
445 break;
|
|
446 case 8:
|
|
447 pInfos[i].pMasterSkillDesc=RemoveQuotes(test_string);
|
|
448 break;
|
|
449 case 9:
|
|
450 pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(test_string);
|
|
451 break;
|
|
452 case 10:
|
|
453 int in_string_pos=0;
|
192
|
454 unsigned char test;
|
191
|
455 int in_str_len=strlen(test_string);
|
192
|
456 for (int j=0; j<in_str_len; ++j)
|
|
457 {
|
|
458 test= tolower(test_string[j]);
|
|
459 switch (test)
|
|
460 {
|
|
461 case 109:
|
|
462 pSpellDatas[i].field_12|=1;
|
|
463 break;
|
|
464 case 101:
|
|
465 pSpellDatas[i].field_12|=2;
|
|
466 break;
|
|
467 case 99:
|
|
468 pSpellDatas[i].field_12|=4;
|
|
469 break;
|
|
470 case 120:
|
|
471 pSpellDatas[i].field_12|=8;
|
|
472 break;
|
|
473 }
|
|
474 }
|
191
|
475 break;
|
|
476 }
|
|
477 }
|
|
478 else
|
|
479 break_loop=true;
|
|
480 ++decode_step;
|
|
481 test_string=tmp_pos+1;
|
|
482 } while ((decode_step<11)&&!break_loop);
|
|
483 if ((i%11)==0)
|
|
484 strtok(NULL, "\r");
|
|
485 }
|
|
486
|
|
487 } |