annotate Spells.cpp @ 209:29545d87e11d

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