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 SpellData pSpellDatas[95];
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27 //----- (0042EB31) --------------------------------------------------------
|
|
28 bool SpellBuff::NotExpired()
|
|
29 {
|
189
|
30 return (signed __int64)this->uExpireTime > 0 ? true:false;
|
0
|
31 }
|
|
32
|
|
33
|
|
34 //----- (00458585) --------------------------------------------------------
|
|
35 void SpellBuff::Reset()
|
|
36 {
|
|
37 SpellBuff *v1; // esi@1
|
|
38 unsigned __int16 v2; // ax@1
|
|
39
|
|
40 this->uSkill = 0;
|
|
41 this->uPower = 0;
|
|
42 this->uExpireTime = 0i64;
|
|
43 this->uCaster = 0;
|
|
44 this->uFlags = 0;
|
189
|
45 if ( this->uOverlayID )
|
0
|
46 {
|
189
|
47 ((OtherOverlay *)&stru_5E4C90._decor_events[20 * this->uOverlayID + 105])->Reset();
|
142
|
48 pOtherOverlayList->bRedraw = true;
|
189
|
49 this->uOverlayID = 0;
|
0
|
50 }
|
|
51 }
|
|
52
|
|
53 //----- (004585CA) --------------------------------------------------------
|
|
54 signed int SpellBuff::_4585CA(__int64 a2)
|
|
55 {
|
|
56 signed int result; // eax@3
|
|
57
|
|
58 if ( this->uExpireTime && (signed __int64)this->uExpireTime < a2 )
|
|
59 {
|
|
60 this->uExpireTime = 0i64;
|
|
61 this->uPower = 0;
|
|
62 this->uSkill = 0;
|
|
63 this->uOverlayID = 0;
|
|
64 result = 1;
|
|
65 }
|
|
66 else
|
|
67 {
|
|
68 result = 0;
|
|
69 }
|
|
70 return result;
|
|
71 }
|
|
72
|
|
73 //----- (004584E0) --------------------------------------------------------
|
|
74 signed int SpellBuff::Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int a5, unsigned __int8 a6)
|
|
75 {
|
|
76 SpellBuff *v6; // esi@1
|
|
77 signed int result; // eax@3
|
|
78 int v8; // eax@4
|
|
79
|
|
80 v6 = this;
|
|
81 if ( this->uExpireTime && (signed __int64)uExpireTime < (signed __int64)this->uExpireTime )
|
|
82 {
|
|
83 result = 0;
|
|
84 }
|
|
85 else
|
|
86 {
|
|
87 this->uSkill = uSkillLevel;
|
|
88 this->uPower = uPower;
|
|
89 LOWORD(v8) = this->uOverlayID;
|
|
90 this->uExpireTime = uExpireTime;
|
|
91 if ( (short)v8 )
|
|
92 {
|
|
93 v8 = (unsigned __int16)v8;
|
|
94 if ( (unsigned __int16)v8 != a5 )
|
|
95 {
|
|
96 ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset();
|
142
|
97 pOtherOverlayList->bRedraw = true;
|
0
|
98 v6->uOverlayID = 0;
|
|
99 }
|
|
100 }
|
|
101 v6->uOverlayID = a5;
|
|
102 v6->uCaster = a6;
|
|
103 result = 1;
|
|
104 }
|
|
105 return result;
|
|
106 }
|
|
107
|
|
108 //----- (0045384A) --------------------------------------------------------
|
|
109 void SpellStats::Initialize()
|
191
|
110 {
|
0
|
111
|
191
|
112 int decode_step;
|
|
113 char* test_string;
|
|
114 bool break_loop;
|
|
115 unsigned char c;
|
|
116 unsigned int temp_str_len;
|
|
117 char* tmp_pos;
|
189
|
118
|
191
|
119 if ( pSpellsTXT_Raw )
|
|
120 pAllocator->FreeChunk(pSpellsTXT_Raw);
|
|
121 pSpellsTXT_Raw = NULL;
|
189
|
122
|
191
|
123 pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
|
|
124 strtok(pSpellsTXT_Raw, "\r");
|
|
125 strtok(NULL, "\r");
|
|
126 v14 = 1;
|
|
127 for(int i=1; i<100; ++i)
|
|
128 {
|
|
129 test_string=strtok(NULL, "\r")+1;
|
|
130 decode_step =0;
|
|
131 break_loop=false;
|
|
132 do
|
|
133 {
|
|
134 c = *(unsigned char*)test_string;
|
|
135 temp_str_len = 0;
|
|
136 while((c!='\t')&&(c>0))
|
|
137 {
|
|
138 ++temp_str_len;
|
|
139 c=test_string[temp_str_len];
|
|
140 }
|
|
141 tmp_pos=test_string+temp_str_len;
|
|
142 if (*tmp_pos == 0)
|
|
143 break_loop = true;
|
|
144 *tmp_pos = 0;
|
|
145 if (temp_str_len)
|
|
146 {
|
|
147 switch (decode_step)
|
|
148 {
|
|
149 case 2:
|
|
150 pInfos[i].pName=RemoveQuotes(test_string);
|
|
151 break;
|
|
152 case 3:
|
|
153 pInfos[i].uSchool = 4;
|
|
154 if (!_strcmpi("fire", test_string) )
|
|
155 {
|
|
156 pInfos[i].uSchool =0;
|
|
157 break;
|
|
158 }
|
|
159 if ( !_strcmpi("air", test_string) )
|
|
160 {
|
|
161 pInfos[i].uSchool = 1;
|
|
162 break;
|
|
163 }
|
|
164 if ( !_strcmpi("water", test_string))
|
|
165 {
|
|
166 pInfos[i].uSchool = 2;
|
|
167 break;
|
|
168 }
|
|
169 if ( !_strcmpi("earth", test_string))
|
|
170 {
|
|
171 pInfos[i].uSchool = 3;
|
|
172 break;
|
|
173 }
|
|
174 if ( !_strcmpi("spirit", test_string))
|
|
175 {
|
|
176 pInfos[i].uSchool = 6;
|
|
177 break;
|
|
178 }
|
|
179 if ( !_strcmpi("mind", test_string))
|
|
180 {
|
|
181 pInfos[i].uSchool = 7;
|
|
182 break;
|
|
183 }
|
|
184 if ( !_strcmpi("body", test_string) )
|
|
185 {
|
|
186 pInfos[i].uSchool = 8;
|
|
187 break;
|
|
188 }
|
|
189 if ( !_strcmpi("light", test_string) )
|
|
190 {
|
|
191 pInfos[i].uSchool = 9;
|
|
192 break;
|
|
193 }
|
|
194 if ( !_strcmpi("dark", test_string))
|
|
195 {
|
|
196 pInfos[i].uSchool = 10;
|
|
197 break;
|
|
198 }
|
|
199
|
|
200 if ( !_strcmpi("magic", test_string))
|
|
201 {
|
|
202 pInfos[i].uSchool = 5;
|
|
203 break;
|
|
204 }
|
|
205
|
|
206 break;
|
|
207 case 4:
|
|
208 pInfos[i].pShortName=RemoveQuotes(test_string);
|
|
209 break;
|
|
210 case 5:
|
|
211 pInfos[i].pDescription=RemoveQuotes(test_string);
|
|
212 break;
|
|
213 case 6:
|
|
214 pInfos[i].pBasicSkillDesc=RemoveQuotes(test_string);
|
|
215 break;
|
|
216 case 7:
|
|
217 pInfos[i].pExpertSkillDesc=RemoveQuotes(test_string);
|
|
218 break;
|
|
219 case 8:
|
|
220 pInfos[i].pMasterSkillDesc=RemoveQuotes(test_string);
|
|
221 break;
|
|
222 case 9:
|
|
223 pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(test_string);
|
|
224 break;
|
|
225 case 10:
|
|
226 int in_string_pos=0;
|
|
227 int in_str_len=strlen(test_string);
|
|
228 /*v4 = 0; fix_me
|
|
229 v8 = strlen(v5);
|
|
230 if ( (signed int)v8 > 0 )
|
|
231 {
|
|
232 do
|
|
233 {
|
|
234 v9 = tolower((unsigned __int8)v5[v4]) - 99;
|
|
235 if ( v9 )
|
|
236 {
|
|
237 v10 = v9 - 2;
|
|
238 if ( v10 )
|
|
239 {
|
|
240 v11 = v10 - 8;
|
|
241 if ( v11 )
|
|
242 {
|
|
243 if ( v11 == 11 )
|
|
244 *v12 |= 8u;
|
|
245 }
|
|
246 else
|
|
247 {
|
|
248 *v12 |= 1u;
|
|
249 }
|
|
250 }
|
|
251 else
|
|
252 {
|
|
253 *v12 |= 2u;
|
|
254 }
|
|
255 }
|
|
256 else
|
|
257 {
|
|
258 *v12 |= 4u;
|
|
259 }
|
|
260 ++v4;
|
|
261 }
|
|
262 while ( v4 < (signed int)v8 );*/
|
|
263 break;
|
|
264 }
|
|
265 }
|
|
266 else
|
|
267 break_loop=true;
|
|
268 ++decode_step;
|
|
269 test_string=tmp_pos+1;
|
|
270 } while ((decode_step<11)&&!break_loop);
|
|
271 if ((i%11)==0)
|
|
272 strtok(NULL, "\r");
|
|
273 }
|
|
274
|
|
275 } |