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