1296
|
1 #include "CastSpellInfo.h"
|
|
2 #include "Actor.h"
|
|
3 #include "Party.h"
|
|
4 #include "mm7_data.h"
|
|
5 #include "MM7.h"
|
|
6 #include "BSPModel.h"
|
|
7 #include "Mouse.h"
|
|
8 #include "stru6.h"
|
|
9 #include "Game.h"
|
|
10 #include "GUIWindow.h"
|
|
11 #include "GUIFont.h"
|
|
12 #include "AudioPlayer.h"
|
|
13 #include "Outdoor.h"
|
|
14 #include "Overlays.h"
|
|
15 #include "Events.h"
|
|
16 #include "Viewport.h"
|
|
17 #include "Math.h"
|
|
18 #include "SpriteObject.h"
|
|
19 #include "ObjectList.h"
|
|
20 #include "stru123.h"
|
|
21 #include "Time.h"
|
|
22 #include "IconFrameTable.h"
|
|
23 #include "Awards.h"
|
|
24 #include "TurnEngine.h"
|
|
25 #include "texts.h"
|
|
26 #include "LOD.h"
|
|
27
|
|
28 //----- (00427E01) --------------------------------------------------------
|
|
29 void CastSpellInfo::_427E01_cast_spell()
|
|
30 {
|
|
31 int v2; // edi@1
|
|
32 CastSpellInfo *pCastSpell; // ebx@2
|
|
33 signed int v6; // eax@14
|
|
34 unsigned __int16 v11; // cx@45
|
|
35 unsigned __int8 v14; // zf@53
|
|
36 signed int i; // esi@76
|
|
37 __int16 v23; // ax@88
|
|
38 int v51; // eax@146
|
|
39 __int16 v52; // ax@153
|
|
40 signed __int64 v54; // qax@164
|
|
41 Actor *v55; // edi@164
|
|
42 signed __int64 v58; // qax@177
|
|
43 Actor *pActor; // edi@177
|
|
44 unsigned __int16 v60; // ax@184
|
|
45 int v61; // ecx@184
|
|
46 ItemGen *v69; // esi@211
|
|
47 double v90; // st7@245
|
|
48 Player *v92; // eax@255
|
|
49 int v105; // edi@271
|
|
50 __int16 v108; // ST1C_2@274
|
|
51 __int16 v109; // ST18_2@274
|
|
52 stru6 *v110; // eax@274
|
|
53 int v111; // eax@274
|
|
54 Actor *v112; // esi@278
|
|
55 int v113; // eax@278
|
|
56 int v114; // ebx@278
|
|
57 unsigned int v115; // ecx@278
|
|
58 int v116; // edx@279
|
|
59 int v117; // edx@281
|
|
60 int v118; // edx@283
|
|
61 signed int v122; // eax@286
|
|
62 int v127; // eax@296
|
|
63 int v153; // ecx@322
|
|
64 int v154; // eax@322
|
|
65 int v155; // eax@323
|
|
66 int v156; // eax@323
|
|
67 int v162; // edi@340
|
|
68 signed int v164; // eax@340
|
|
69 signed int v165; // edi@340
|
|
70 signed int v168; // edi@343
|
|
71 int v169; // eax@344
|
|
72 signed int v174; // edi@355
|
|
73 int v188; // esi@369
|
|
74 int v189; // edi@369
|
|
75 signed int v191; // edi@379
|
|
76 signed int v205; // edi@405
|
|
77 int v206; // eax@407
|
|
78 __int16 v207; // cx@407
|
|
79 int v208; // eax@411
|
|
80 signed int v209; // ecx@412
|
|
81 int v210; // edx@412
|
|
82 signed int v211; // ecx@412
|
|
83 int v212; // eax@413
|
|
84 int v213; // eax@413
|
|
85 int v214; // eax@413
|
|
86 int v215; // eax@415
|
|
87 double v216; // st7@415
|
|
88 double v217; // st6@415
|
|
89 signed __int64 v218; // qtt@423
|
|
90 char v223; // al@438
|
|
91
|
|
92 int v227; // esi@453
|
|
93 unsigned int v228; // edi@454
|
|
94 int v229; // edi@466
|
|
95
|
|
96 ItemGen *v240; // ecx@472
|
|
97 double v241; // st7@478
|
|
98 ItemGen *v245; // edi@492
|
|
99 int v254; // eax@513
|
|
100 int v255; // esi@513
|
|
101 int v256; // ecx@513
|
|
102 int v257; // edx@514
|
|
103 int v258; // ecx@514
|
|
104 char v259; // al@516
|
|
105 int v260; // eax@518
|
|
106 int v261; // esi@519
|
|
107 int v262; // edx@521
|
|
108 int *v263; // ecx@521
|
|
109 int v264; // esi@521
|
|
110 int v265; // edx@521
|
|
111 int *ii; // eax@522
|
|
112 int v267; // eax@524
|
|
113 int v268; // eax@524
|
|
114 char v271; // al@531
|
|
115 int v277; // edx@548
|
|
116 int v278; // ecx@548
|
|
117 char v279; // al@550
|
|
118 int v280; // eax@552
|
|
119 int *v281; // esi@553
|
|
120 int v282; // edx@555
|
|
121 int *v283; // ecx@555
|
|
122 int v284; // esi@555
|
|
123 int v285; // edx@555
|
|
124 int *l; // eax@556
|
|
125 ItemGen *v294; // esi@575
|
|
126 int v295; // edx@575
|
|
127 int kk; // edi@575
|
|
128 char v313; // al@606pGame->GetStru6()
|
|
129 const char *v317; // ecx@617
|
|
130 Player *v318; // ecx@619
|
|
131 unsigned int v319; // edi@627
|
|
132 int v323; // edi@635
|
|
133 char *v324; // eax@635
|
|
134 Player *v325; // ecx@640
|
|
135 int v328; // ecx@651
|
|
136 int v329; // ecx@652
|
|
137 int v330; // edi@654
|
|
138 signed int v342; // edi@668
|
|
139 signed int v343; // edi@670
|
|
140 unsigned __int64 v344; // ST08_8@670
|
|
141 Player *v351; // edi@680
|
|
142 Player *v357; // edi@694
|
|
143 Actor *v369; // edi@705
|
|
144 int v373; // eax@715
|
|
145 int v374; // eax@717
|
|
146 int v376; // eax@717
|
|
147 Player *v377; // ecx@719
|
|
148 int v381; // edi@727
|
|
149 int v382; // ecx@727
|
|
150 Player *v383; // eax@728
|
|
151 int v384; // eax@733
|
|
152 int v388; // edi@740
|
|
153 int v396; // eax@752
|
|
154 int v397; // eax@757
|
|
155 int v398; // eax@757
|
|
156 int v399; // eax@757
|
|
157 Actor *v417; // eax@787
|
|
158 int v418; // ecx@789
|
|
159 __int16 v419; // ax@791
|
|
160 signed int v420; // eax@793
|
|
161 ItemGen *v421; // edx@793
|
|
162 const char *v422; // eax@801
|
|
163 signed int v426; // eax@815
|
|
164 Actor *v433; // edi@832
|
|
165 int v435; // ecx@837
|
|
166 int v440; // eax@843
|
|
167 int v441; // eax@847
|
|
168 signed int v445; // edi@857
|
|
169 int v446; // ecx@862
|
|
170 LevelDecoration *v447; // edi@864
|
|
171 __int16 v448; // ax@864
|
|
172 char *v449; // esi@870
|
|
173 int v450; // eax@870
|
|
174 signed int v460; // eax@895
|
|
175 Actor *v461; // eax@897
|
|
176 unsigned __int16 v462; // cx@897
|
|
177 signed int v463; // edx@897
|
|
178 int v470; // edi@913
|
|
179 int v471; // eax@917
|
|
180 int v472; // eax@917
|
|
181 int v498; // edi@931
|
|
182 int v499; // eax@935
|
|
183 int v500; // eax@935
|
|
184 Player *v501; // edi@939
|
|
185 int v505; // eax@943
|
|
186 int v507; // edi@944
|
|
187 signed int v509; // eax@944
|
|
188 //signed int v510; // edi@944
|
|
189 Actor *v518; // edx@957
|
|
190 __int16 v519; // cx@958
|
|
191 int v531; // eax@982
|
|
192 int v533; // edi@983
|
|
193 signed int v535; // eax@983
|
|
194 signed int v536; // edi@983
|
|
195 stru6 *v537; // eax@984
|
|
196 double v549; // st7@991
|
|
197 unsigned __int16 v550; // di@991
|
|
198 Player *v553; // edi@1001
|
|
199 unsigned __int16 v562; // di@1005
|
|
200 signed int v563; // eax@1010
|
|
201 unsigned int v564; // ecx@1011
|
|
202 signed int v565; // eax@1012
|
|
203 Player **v566; // ecx@1012
|
|
204 int v567; // eax@1012
|
|
205 Player *v571; // eax@1013
|
|
206 char *v572; // ecx@1013
|
|
207 signed int v576; // eax@1025
|
|
208 Player *v577; // eax@1026
|
|
209 int v578; // eax@1028
|
|
210 __int16 v579; // ax@1029
|
|
211 int v581; // edi@1031
|
|
212 char *v585; // esi@1034
|
|
213 signed int v587; // eax@1035
|
|
214 char v591; // al@1048
|
|
215 ItemGen *v592; // esi@1052
|
|
216 int v596; // esi@1066
|
|
217 unsigned int v597; // edi@1067
|
|
218 int v600; // edi@1086
|
|
219 int v601; // edx@1086
|
|
220 int v602; // eax@1086
|
|
221 int v603; // ecx@1086
|
|
222 NPCData *pNPCData; // eax@1089
|
|
223 int v606; // edx@1091
|
|
224 AwardType *v607; // ecx@1100
|
|
225 __int16 v608; // ax@1102
|
|
226 signed int v609; // eax@1104
|
|
227 int v610; // edi@1106
|
|
228 unsigned int v611; // eax@1106
|
|
229 Player *v612; // edi@1106
|
|
230 DDM_DLV_Header *v613; // eax@1108
|
|
231 int v615; // edi@1119
|
|
232 Player *v619; // edi@1123
|
|
233 signed __int64 v623; // qax@1127
|
|
234 int v625; // edi@1129
|
|
235 signed int v627; // eax@1129
|
|
236 signed int v628; // edi@1129
|
|
237 int v629; // ecx@1130
|
|
238 Player *v630; // eax@1131
|
|
239 int v631; // eax@1137
|
|
240 int v635; // edi@1142
|
|
241 int v642; // edi@1156
|
|
242 int v643; // eax@1156
|
|
243 int v644; // eax@1156
|
|
244 signed int v645; // eax@1158
|
|
245 unsigned int v656; // [sp-4h] [bp-E88h]@639
|
|
246 int v657; // [sp-4h] [bp-E88h]@807
|
|
247 int v659; // [sp+0h] [bp-E84h]@123
|
|
248 int v660; // [sp+0h] [bp-E84h]@146
|
|
249 Actor *v661; // [sp+0h] [bp-E84h]@164
|
|
250 unsigned __int64 v663; // [sp+0h] [bp-E84h]@639
|
|
251 const char *v664; // [sp+0h] [bp-E84h]@802
|
|
252 int v665; // [sp+0h] [bp-E84h]@807
|
|
253 int v666; // [sp+4h] [bp-E80h]@12
|
|
254 PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25
|
|
255 int v671; // [sp+4h] [bp-E80h]@146
|
|
256 int v675; // [sp+4h] [bp-E80h]@800
|
|
257 int v676; // [sp+4h] [bp-E80h]@807
|
|
258 int v677; // [sp+4h] [bp-E80h]@861
|
|
259 int v679[800]; // [sp+14h] [bp-E70h]@515
|
|
260 AIDirection a3; // [sp+C94h] [bp-1F0h]@21
|
|
261 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137
|
|
262 int v682[4]; // [sp+CC0h] [bp-1C4h]@731
|
|
263 ItemGen v683; // [sp+CD0h] [bp-1B4h]@791
|
|
264 int v684; // [sp+D04h] [bp-180h]@416
|
|
265 unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416
|
|
266 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327
|
|
267 Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943
|
|
268 Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137
|
|
269 Vec3_int_ v694; // [sp+D44h] [bp-140h]@982
|
|
270 Vec3_int_ v697; // [sp+D50h] [bp-134h]@129
|
|
271 Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339
|
|
272 Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286
|
|
273 Vec3_int_ v704; // [sp+D74h] [bp-110h]@132
|
|
274 Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127
|
|
275 int v710; // [sp+D8Ch] [bp-F8h]@1156
|
|
276 __int64 v712; // [sp+D94h] [bp-F0h]@991
|
|
277 int v713; // [sp+D9Ch] [bp-E8h]@324
|
|
278 int n; // [sp+DA0h] [bp-E4h]@1
|
|
279 AIDirection v715; // [sp+DA4h] [bp-E0h]@21
|
|
280 int v716; // [sp+DC0h] [bp-C4h]@272
|
|
281 __int64 v717; // [sp+DC4h] [bp-C0h]@271
|
|
282 float v718; // [sp+DCCh] [bp-B8h]@176
|
|
283 signed int sRecoveryTime; // [sp+DD0h] [bp-B4h]@53
|
|
284 char *y; // [sp+DD4h] [bp-B0h]@325
|
|
285 int v721; // [sp+DD8h] [bp-ACh]@163
|
|
286 int v723; // [sp+E4Ch] [bp-38h]@1
|
|
287 ItemGen *_this; // [sp+E50h] [bp-34h]@23
|
|
288 float v725; // [sp+E54h] [bp-30h]@23
|
|
289 Player *v726; // [sp+E58h] [bp-2Ch]@131
|
|
290 float v727; // [sp+E5Ch] [bp-28h]@1
|
|
291 unsigned int uRequiredMana; // [sp+E60h] [bp-24h]@53
|
|
292 Player *pPlayer; // [sp+E64h] [bp-20h]@8
|
|
293 int v730; // [sp+E68h] [bp-1Ch]@53
|
|
294 Player *v730b;
|
|
295 ItemGen *v730c;
|
|
296 int v731; // [sp+E6Ch] [bp-18h]@48
|
|
297 signed int v732; // [sp+E70h] [bp-14h]@325
|
|
298 unsigned __int64 v733; // [sp+E74h] [bp-10h]@1
|
|
299 signed int a2; // [sp+E7Ch] [bp-8h]@14
|
|
300 int amount; // [sp+E80h] [bp-4h]@1
|
|
301
|
|
302 SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1
|
|
303
|
|
304 v2 = 0;
|
|
305 amount = 0;
|
|
306 LODWORD(v733) = 0;
|
|
307 v723 = 0;
|
|
308 v727 = 0.0;
|
|
309 for(n = 0; n < 10; ++n)
|
|
310 {
|
|
311 pCastSpell = &this[n];
|
|
312 HIDWORD(v733) = (int)pCastSpell;
|
|
313 if ( pCastSpell->spellnum == 0 )
|
|
314 continue;
|
|
315
|
|
316 if (pParty->Invisible())
|
|
317 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
|
|
318
|
|
319 if ( pCastSpell->field_8 & 0x3CA )
|
|
320 {
|
|
321 if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() )
|
|
322 this->_427D48(1);
|
|
323 continue;
|
|
324 }
|
|
325 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
|
|
326
|
|
327 a2 = pCastSpell->spell_target_pid;
|
|
328 if (!pCastSpell->spell_target_pid)
|
|
329 {
|
|
330 if (pCastSpell->spellnum == SPELL_LIGHT_DESTROY_UNDEAD ||
|
|
331 pCastSpell->spellnum == SPELL_SPIRIT_TURN_UNDEAD ||
|
|
332 pCastSpell->spellnum == SPELL_DARK_CONTROL_UNDEAD )
|
|
333 v666 = 1;
|
|
334 else
|
|
335 v666 = 0;
|
|
336
|
|
337 a2 = stru_50C198.FindClosestActor(5120, 1, v666);
|
|
338 v6 = pMouse->uPointingObjectID;
|
|
339 if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() )
|
|
340 a2 = pMouse->uPointingObjectID;
|
|
341 }
|
|
342
|
|
343
|
|
344 pSpellSprite.uType = stru_4E3ACC[pCastSpell->spellnum].uType;
|
|
345 if (pSpellSprite.uType)
|
|
346 {
|
|
347 if (PID_TYPE(a2) == OBJECT_Actor)
|
|
348 {
|
|
349 memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, pCastSpell->uPlayerID + 1), a2, &a3, 0), sizeof(v715));
|
|
350 v2 = v723;
|
|
351 }
|
|
352 else
|
|
353 {
|
|
354 v715.uYawAngle = pParty->sRotationY;
|
|
355 v715.uPitchAngle = pParty->sRotationX;
|
|
356 }
|
|
357 }
|
|
358
|
|
359 LODWORD(v725) = 0;
|
|
360 _this = 0;
|
|
361 if (pCastSpell->forced_spell_skill_level)
|
|
362 {
|
|
363 v11 = pCastSpell->forced_spell_skill_level;
|
|
364 v723 = v11 & 0x3F; // 6 bytes
|
|
365 v2 = v723;
|
|
366 }
|
|
367 else
|
|
368 {
|
|
369 //v667 = PLAYER_SKILL_STAFF;
|
|
370 if (pCastSpell->spellnum < SPELL_AIR_WIZARD_EYE)
|
|
371 v667 = PLAYER_SKILL_FIRE;
|
|
372 else if (pCastSpell->spellnum < SPELL_WATER_AWAKEN)
|
|
373 v667 = PLAYER_SKILL_AIR;
|
|
374 else if (pCastSpell->spellnum < SPELL_EARTH_STUN)
|
|
375 v667 = PLAYER_SKILL_WATER;
|
|
376 else if (pCastSpell->spellnum < SPELL_SPIRIT_DETECT_LIFE)
|
|
377 v667 = PLAYER_SKILL_EARTH;
|
|
378 else if (pCastSpell->spellnum < SPELL_MIND_REMOVE_FEAR)
|
|
379 v667 = PLAYER_SKILL_SPIRIT;
|
|
380 else if (pCastSpell->spellnum < SPELL_BODY_CURE_WEAKNESS)
|
|
381 v667 = PLAYER_SKILL_MIND;
|
|
382 else if (pCastSpell->spellnum < SPELL_LIGHT_LIGHT_BOLT)
|
|
383 v667 = PLAYER_SKILL_BODY;
|
|
384 else if (pCastSpell->spellnum < SPELL_DARK_REANIMATE)
|
|
385 v667 = PLAYER_SKILL_LIGHT;
|
|
386 else if (pCastSpell->spellnum < SPELL_BOW_ARROW)
|
|
387 v667 = PLAYER_SKILL_DARK;
|
|
388 else if (pCastSpell->spellnum == SPELL_BOW_ARROW)
|
|
389 v667 = PLAYER_SKILL_BOW;
|
|
390 else assert(false && "Unknown spell");
|
|
391
|
|
392 LODWORD(v725) = v667;
|
|
393 v723 = pPlayer->GetActualSkillLevel(v667) & 0x3F;
|
|
394 v2 = v723;
|
|
395 v11 = pPlayer->pActiveSkills[LODWORD(v725)];
|
|
396 }
|
|
397
|
|
398 v731 = SkillToMastery(v11);
|
|
399
|
|
400 if (pCastSpell->forced_spell_skill_level)
|
|
401 uRequiredMana = 0;
|
|
402 else
|
|
403 uRequiredMana = pSpellDatas[pCastSpell->spellnum - 1].mana_per_skill[v731 - 1];
|
|
404 sRecoveryTime = pSpellDatas[pCastSpell->spellnum - 1].recovery_per_skill[v731 - 1];
|
|
405
|
|
406 if (LODWORD(v725) == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 ||
|
|
407 LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0)
|
|
408 uRequiredMana = 0;
|
|
409
|
|
410 if (pCastSpell->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana)
|
|
411 {
|
|
412 ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points"
|
|
413 pCastSpell->spellnum = 0;
|
|
414 continue;
|
|
415 }
|
|
416 v730 = pCastSpell->spellnum;
|
|
417 if (pPlayer->Cursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
|
|
418 {
|
|
419 if (!pParty->bTurnBasedModeOn)
|
|
420 {
|
|
421 //v646 = pPlayer;
|
|
422 pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
|
|
423 //v647 = n;
|
|
424 }
|
|
425 else
|
|
426 {
|
|
427 //v647 = n;
|
|
428 //v646 = pPlayer;
|
|
429 //v648 = sRecoveryTime;
|
|
430 //v649 = pPlayer;
|
|
431 pParty->pTurnBasedPlayerRecoveryTimes[this[n].uPlayerID] = 100;
|
|
432 pPlayer->SetRecoveryTime(sRecoveryTime);
|
|
433 pTurnEngine->_40471C();
|
|
434 }
|
|
435 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed"
|
|
436 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
437 this[n].spellnum = 0;
|
|
438 pPlayer->sMana -= uRequiredMana;
|
|
439 return;
|
|
440 }
|
|
441
|
|
442 switch ( pCastSpell->spellnum )
|
|
443 {
|
|
444 case SPELL_101:
|
|
445 assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
|
|
446 case SPELL_BOW_ARROW:
|
|
447 {
|
|
448 amount = 1;
|
|
449 if ( SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
|
|
450 amount = 2;
|
|
451 sRecoveryTime = pPlayer->GetAttackRecoveryTime(true);
|
|
452 pSpellSprite.stru_24.Reset();
|
|
453 pSpellSprite.spell_level = v2;
|
|
454 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
455 pSpellSprite.spell_skill = v731;
|
|
456 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
457 if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) )
|
|
458 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
|
|
459 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
460 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
461 pSpellSprite.uAttributes = 0;
|
|
462 pSpellSprite.uSpriteFrameID = 0;
|
|
463 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
464 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
465 pSpellSprite.spell_target_pid = a2;
|
|
466 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
467 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
468 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
469 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
|
|
470 memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24));
|
|
471 pSpellSprite.uAttributes = 256;
|
|
472 if ( pParty->bTurnBasedModeOn == 1 )
|
|
473 pSpellSprite.uAttributes = 260;
|
|
474 for ( i = 0; i < amount; ++i )
|
|
475 {
|
|
476 if ( i )
|
|
477 pSpellSprite.vPosition.z += 32;
|
|
478 pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
|
|
479 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
|
|
480 pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
481 ++pTurnEngine->field_1C;
|
|
482 }
|
|
483 break;
|
|
484 }
|
|
485 case SPELL_LASER_PROJECTILE:
|
|
486 {
|
|
487 sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
|
|
488 pSpellSprite.stru_24.Reset();
|
|
489 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
490 pSpellSprite.spell_level = v723;
|
|
491 pSpellSprite.spell_skill = v731;
|
|
492 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
493 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
494 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
495 pSpellSprite.uAttributes = 0;
|
|
496 pSpellSprite.uSpriteFrameID = 0;
|
|
497 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
|
|
498 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
499 pSpellSprite.spell_target_pid = a2;
|
|
500 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
501 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
502 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
503 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
|
|
504 memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uMainHand-1],sizeof(pSpellSprite.stru_24));
|
|
505 // &pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
|
|
506 // * pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], );
|
|
507 v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
|
|
508 HIBYTE(pSpellSprite.uAttributes) |= 1u;
|
|
509 pSpellSprite.uSectorID = v23;
|
|
510 if ( pParty->bTurnBasedModeOn == 1 )
|
|
511 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
512 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
|
|
513 pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
514 ++pTurnEngine->field_1C;
|
|
515 break;
|
|
516 }
|
|
517 case SPELL_FIRE_TORCH_LIGHT:
|
|
518 {
|
|
519 switch (v731)
|
|
520 {
|
|
521 case 1: amount = 2; break;
|
|
522 case 2: amount = 3; break;
|
|
523 case 3:
|
|
524 case 4: amount = 4; break;
|
|
525 default:
|
|
526 assert(false);
|
|
527 }
|
|
528 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
529 break;
|
|
530 pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0);
|
|
531 LODWORD(v727) = 1;
|
|
532 break;
|
|
533 }
|
|
534 case SPELL_FIRE_FIRE_SPIKE:
|
|
535 {
|
|
536 switch (v731)
|
|
537 {
|
|
538 case 1: amount = 3; break;
|
|
539 case 2: amount = 5; break;
|
|
540 case 3: amount = 7; break;
|
|
541 case 4: amount = 9; break;
|
|
542 default:
|
|
543 assert(false);
|
|
544 }
|
|
545
|
|
546 //v31 = v3->uPlayerID;
|
|
547 //v32 = 8 * v31;
|
|
548 //LOBYTE(v32) = v32 | OBJECT_Player;
|
|
549
|
|
550 //if ( (signed int)uNumSpriteObjects > 0 )
|
|
551 int _v733 = 0;
|
|
552 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
553 {
|
|
554 auto object = &pSpriteObjects[i];
|
|
555 if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID))
|
|
556 ++_v733;
|
|
557 /*v33 = (char *)&pSpriteObjects[0].field_48;
|
|
558 v730 = uNumSpriteObjects;
|
|
559 do
|
|
560 {
|
|
561 if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 )
|
|
562 ++HIDWORD(v733);
|
|
563 v33 += 112;
|
|
564 --v730;
|
|
565 }
|
|
566 while ( v730 );*/
|
|
567 }
|
|
568 if (_v733 > amount)
|
|
569 {
|
|
570 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
571 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
572 pCastSpell->spellnum = 0;
|
|
573 continue;
|
|
574 }
|
|
575 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
576 break;
|
|
577 pSpellSprite.stru_24.Reset();
|
|
578 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
579 pSpellSprite.spell_level = v2;
|
|
580 pSpellSprite.spell_skill = v731;
|
|
581 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
582 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
583 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
584 pSpellSprite.uAttributes = 0;
|
|
585 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
586 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
587 pSpellSprite.uSpriteFrameID = 0;
|
|
588 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
589 pSpellSprite.spell_target_pid = a2;
|
|
590 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
591 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
592 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
593 if ( pParty->bTurnBasedModeOn == 1 )
|
|
594 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
595 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
596 if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
597 ++pTurnEngine->field_1C;
|
|
598 LODWORD(v727) = 1;
|
|
599 break;
|
|
600 }
|
|
601 case SPELL_AIR_IMPLOSION:
|
|
602 {
|
|
603 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
604 break;
|
|
605 if (!a2)
|
|
606 {
|
|
607 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
608 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
609 pCastSpell->spellnum = 0;
|
|
610 continue;
|
|
611 }
|
|
612 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
613 {
|
|
614 LODWORD(v727) = 1;
|
|
615 break;
|
|
616 }
|
|
617 v697.x = 0;
|
|
618 v697.y = 0;
|
|
619 v697.z = 0;
|
|
620 pSpellSprite.stru_24.Reset();
|
|
621 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
622 pSpellSprite.spell_level = v2;
|
|
623 pSpellSprite.spell_skill = v731;
|
|
624 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
625 pSpellSprite.uAttributes = 0;
|
|
626 pSpellSprite.uSectorID = 0;
|
|
627 pSpellSprite.uSpriteFrameID = 0;
|
|
628 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
629 pSpellSprite.uFacing = 0;
|
|
630 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
631 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
632 pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
|
|
633 pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
|
|
634 pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
|
|
635 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
|
|
636 auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
|
|
637 DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
|
|
638 LODWORD(v727) = 1;
|
|
639 break;
|
|
640 }
|
|
641 case SPELL_EARTH_MASS_DISTORTION:
|
|
642 {
|
|
643 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
644 break;
|
|
645 if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) )
|
|
646 {
|
|
647 LODWORD(v727) = 1;
|
|
648 break;
|
|
649 }
|
|
650 pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
|
|
651 v704.x = 0;
|
|
652 v704.y = 0;
|
|
653 v704.z = 0;
|
|
654 pSpellSprite.stru_24.Reset();
|
|
655 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
656 pSpellSprite.spell_level = v2;
|
|
657 pSpellSprite.spell_skill = v731;
|
|
658 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
659 pSpellSprite.uAttributes = 0;
|
|
660 pSpellSprite.uSectorID = 0;
|
|
661 pSpellSprite.uSpriteFrameID = 0;
|
|
662 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
663 pSpellSprite.uFacing = 0;
|
|
664 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
665 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
666 pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
|
|
667 pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
|
|
668 pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
|
|
669 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
|
|
670 auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
|
|
671 DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704);
|
|
672 LODWORD(v727) = 1;
|
|
673 break;
|
|
674 }
|
|
675 case SPELL_LIGHT_DESTROY_UNDEAD:
|
|
676 {
|
|
677 if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor)
|
|
678 break;
|
|
679 //v730 = a2 >> 3;
|
|
680 //HIDWORD(v733) = (int)&pActors[PID_ID(a2)];
|
|
681 v691.x = 0;
|
|
682 v691.y = 0;
|
|
683 v691.z = 0;
|
|
684 pSpellSprite.stru_24.Reset();
|
|
685 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
686 pSpellSprite.spell_level = v2;
|
|
687 pSpellSprite.spell_skill = v731;
|
|
688 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
689 pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
|
|
690 pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
|
|
691 pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
|
|
692 pSpellSprite.uAttributes = 0;
|
|
693 pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
|
|
694 pSpellSprite.uSpriteFrameID = 0;
|
|
695 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
696 pSpellSprite.spell_target_pid = a2;
|
|
697 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
698 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
699 pSpellSprite.uAttributes |= 0x80u;
|
|
700 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
701 auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
|
|
702 if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
|
|
703 {
|
|
704 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
705 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
706 pCastSpell->spellnum = 0;
|
|
707 continue;
|
|
708 }
|
|
709 DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691);
|
|
710 LODWORD(v727) = 1;
|
|
711 break;
|
|
712 }
|
|
713 case SPELL_FIRE_FIRE_BOLT:
|
|
714 case SPELL_FIRE_FIREBALL:
|
|
715 case SPELL_FIRE_INCINERATE:
|
|
716 case SPELL_AIR_LIGHNING_BOLT:
|
|
717 case SPELL_WATER_ICE_BOLT:
|
|
718 case SPELL_WATER_ICE_BLAST:
|
|
719 case SPELL_EARTH_STUN:
|
|
720 case SPELL_EARTH_DEADLY_SWARM:
|
|
721 case SPELL_MIND_MIND_BLAST:
|
|
722 case SPELL_MIND_PSYCHIC_SHOCK:
|
|
723 case SPELL_BODY_HARM:
|
|
724 case SPELL_LIGHT_LIGHT_BOLT:
|
|
725 case SPELL_DARK_DRAGON_BREATH:
|
|
726 {
|
|
727 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
728 break;
|
|
729 pSpellSprite.stru_24.Reset();
|
|
730 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
731 pSpellSprite.spell_level = v2;
|
|
732 pSpellSprite.spell_skill = v731;
|
|
733 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
734 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
735 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
736 pSpellSprite.uAttributes = 0;
|
|
737 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
738 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
739 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
740 else
|
|
741 pSpellSprite.uSectorID = 0;
|
|
742 pSpellSprite.uSpriteFrameID = 0;
|
|
743 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
744 pSpellSprite.spell_target_pid = a2;
|
|
745 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
746 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
747 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
748 if ( pParty->bTurnBasedModeOn == 1 )
|
|
749 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
750 if ( pCastSpell->spellnum == SPELL_AIR_LIGHNING_BOLT )
|
|
751 LOBYTE(pSpellSprite.uAttributes) |= 0x40u;
|
|
752 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
753 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
754 ++pTurnEngine->field_1C;
|
|
755 LODWORD(v727) = 1;
|
|
756 break;
|
|
757 }
|
|
758 case SPELL_WATER_ACID_BURST:
|
|
759 case SPELL_EARTH_BLADES:
|
|
760 case SPELL_BODY_FLYING_FIST:
|
|
761 case SPELL_DARK_TOXIC_CLOUD:
|
|
762 {
|
|
763 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
764 break;
|
|
765 pSpellSprite.stru_24.Reset();
|
|
766 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
767 pSpellSprite.spell_level = v2;
|
|
768 pSpellSprite.spell_skill = v731;
|
|
769 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
770 v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
|
|
771 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
772 v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
|
|
773 v660 = pParty->vPosition.y;
|
|
774 pSpellSprite.uAttributes = 0;
|
|
775 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
776 pSpellSprite.vPosition.z = v51;
|
|
777 v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671);
|
|
778 pSpellSprite.uSpriteFrameID = 0;
|
|
779 pSpellSprite.uSectorID = v52;
|
|
780 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
781 pSpellSprite.spell_target_pid = a2;
|
|
782 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
783 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
784 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
785 if ( pParty->bTurnBasedModeOn == 1 )
|
|
786 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
787 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
788 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
789 ++pTurnEngine->field_1C;
|
|
790 LODWORD(v727) = 1;
|
|
791 break;
|
|
792 }
|
|
793 case SPELL_LIGHT_SUNRAY:
|
|
794 {
|
|
795 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
|
|
796 || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 21) )
|
|
797 {
|
|
798 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
799 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
800 pCastSpell->spellnum = 0;
|
|
801 continue;
|
|
802 }
|
|
803 if ( pPlayer->CanCastSpell(uRequiredMana) )
|
|
804 {
|
|
805 pSpellSprite.stru_24.Reset();
|
|
806 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
807 pSpellSprite.spell_skill = v731;
|
|
808 pSpellSprite.spell_level = v2;
|
|
809 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
810 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
811 v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
812 v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
813 v660 = pParty->vPosition.y;
|
|
814 pSpellSprite.uAttributes = 0;
|
|
815 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
816 pSpellSprite.vPosition.z = v51;
|
|
817 v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671);
|
|
818 pSpellSprite.uSpriteFrameID = 0;
|
|
819 pSpellSprite.uSectorID = v52;
|
|
820 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
821 pSpellSprite.spell_target_pid = a2;
|
|
822 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
823 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
824 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
825 if ( pParty->bTurnBasedModeOn == 1 )
|
|
826 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
827 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
828 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
829 ++pTurnEngine->field_1C;
|
|
830 LODWORD(v727) = 1;
|
|
831 }
|
|
832 break;
|
|
833 }
|
|
834 case SPELL_LIGHT_PARALYZE:
|
|
835 {
|
|
836 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
837 break;
|
|
838 if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)],
|
|
839 !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9)) )
|
|
840 {
|
|
841 LODWORD(v727) = 1;
|
|
842 break;
|
|
843 }
|
|
844 Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0);
|
|
845 v54 = (signed __int64)((double)(23040 * v2) * 0.033333335);
|
|
846 v55 = &pActors[PID_ID(a2)];
|
|
847 v55->pActorBuffs[6].Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0);
|
|
848 BYTE2(v55->uAttributes) |= 8u;
|
|
849 v55->vVelocity.x = 0;
|
|
850 //v672 = 0;
|
|
851 v55->vVelocity.y = 0;
|
|
852 v661 = v55;
|
|
853 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
|
|
854 LODWORD(v727) = 1;
|
|
855 break;
|
|
856 }
|
|
857 case SPELL_EARTH_SLOW:
|
|
858 {
|
|
859 switch (v731)
|
|
860 {
|
|
861 case 1: LODWORD(v733) = 180 * v2; amount = 2; break;
|
|
862 case 2: LODWORD(v733) = 300 * v2; amount = 2; break;
|
|
863 case 3: LODWORD(v733) = 300 * v2; amount = 4; break;
|
|
864 case 4: LODWORD(v733) = 300 * v2; amount = 8; break;
|
|
865 default:
|
|
866 assert(false);
|
|
867 }
|
|
868 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
869 break;
|
|
870 if (PID_TYPE(a2) != OBJECT_Actor
|
|
871 || (v721 = 836 * PID_ID(a2),
|
|
872 LODWORD(v718) = (int)&pActors[PID_ID(a2)],
|
|
873 !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u)) )
|
|
874 {
|
|
875 LODWORD(v727) = 1;
|
|
876 break;
|
|
877 }
|
|
878 v58 = (signed __int64)((double)(23040 * v2) * 0.033333335);
|
|
879 //v59 = v721;
|
|
880 pActor = &pActors[PID_ID(a2)];
|
|
881 //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
|
|
882 pActor->pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, v731, amount, 0, 0);
|
|
883 //*((char *)&pActors[0].uAttributes + v59 + 2) |= 8u;
|
|
884 BYTE2(pActor->uAttributes) |= 8u;
|
|
885 //v672 = 0;
|
|
886 v661 = (Actor *)LODWORD(v718);
|
|
887 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
|
|
888 LODWORD(v727) = 1;
|
|
889 break;
|
|
890 }
|
|
891 case SPELL_MIND_CHARM:
|
|
892 {
|
|
893 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
894 break;
|
|
895
|
|
896 if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) )
|
|
897 {
|
|
898 LODWORD(v727) = 1;
|
|
899 break;
|
|
900 }
|
|
901
|
|
902 uint power = 300 * v2;
|
|
903 if ( v731 == 2 )
|
|
904 {
|
|
905 power = 600 * v2;
|
|
906 }
|
|
907 else if ( v731 == 3 )
|
|
908 power = 29030400;
|
|
909
|
|
910 //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
|
|
911 pActors[PID_ID(a2)].pActorBuffs[9].Reset();
|
|
912 //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset();
|
|
913 pActors[PID_ID(a2)].pActorBuffs[12].Reset();
|
|
914 //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply(
|
|
915 pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335),
|
|
916 v731, 0, 0, 0);
|
|
917 pSpellSprite.stru_24.Reset();
|
|
918 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
919 pSpellSprite.spell_level = v2;
|
|
920 pSpellSprite.spell_skill = v731;
|
|
921 v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
922 v61 = PID_ID(a2);
|
|
923 v600 = pActors[v61].vPosition.y;
|
|
924 v601 = pActors[v61].vPosition.x;
|
|
925 pSpellSprite.uObjectDescID = v60;
|
|
926 pSpellSprite.vPosition.x = v601;
|
|
927 v602 = pActors[v61].uActorHeight;
|
|
928 v603 = pActors[v61].vPosition.z;
|
|
929 pSpellSprite.vPosition.y = v600;
|
|
930 v676 = v603 + v602;
|
|
931 v665 = v600;
|
|
932 pSpellSprite.vPosition.z = v603 + v602;
|
|
933 v657 = v601;
|
|
934 pSpellSprite.uAttributes = 0;
|
|
935 pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
|
|
936 pSpellSprite.uSpriteFrameID = 0;
|
|
937 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
938 pSpellSprite.spell_target_pid = a2;
|
|
939 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
940 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
941 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
|
|
942 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
943 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
|
|
944 LODWORD(v727) = 1;
|
|
945 break;
|
|
946 }
|
|
947 case SPELL_DARK_SHRINKING_RAY:
|
|
948 {
|
|
949 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
950 break;
|
|
951 pSpellSprite.stru_24.Reset();
|
|
952 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
953 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
954 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
955 pSpellSprite.uAttributes = 0;
|
|
956 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
957 pSpellSprite.uSectorID = pIndoor->GetSector(
|
|
958 pParty->vPosition.x,
|
|
959 pParty->vPosition.y,
|
|
960 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
961 pSpellSprite.uSpriteFrameID = 0;
|
|
962 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
963 pSpellSprite.spell_target_pid = a2;
|
|
964 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
965 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
966 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
967 pSpellSprite.spell_skill = v731;
|
|
968 pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
|
|
969 pSpellSprite.spell_level = 300 * v2;
|
|
970 if ( pParty->bTurnBasedModeOn == 1 )
|
|
971 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
972
|
|
973 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
974
|
|
975 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
976 ++pTurnEngine->field_1C;
|
|
977 LODWORD(v727) = 1;
|
|
978 break;
|
|
979 }
|
|
980 case SPELL_FIRE_FIRE_AURA:
|
|
981 {
|
|
982 switch (v731)
|
|
983 {
|
|
984 case 1: LODWORD(v733) = 3600 * v2; amount = 10; break;
|
|
985 case 2: LODWORD(v733) = 3600 * v2; amount = 11; break;
|
|
986 case 3: LODWORD(v733) = 3600 * v2; amount = 12; break;
|
|
987 case 4: LODWORD(v733) = 0; amount = 12; break;
|
|
988 default:
|
|
989 assert(false);
|
|
990 }
|
|
991
|
|
992 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
993 break;
|
|
994 v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2];
|
|
995 auto _itm = &pItemsTable->pItems[v730c->uItemID];
|
|
996 v730c->UpdateTempBonus(pParty->uTimePlayed);
|
|
997 if ( v730c->uItemID < 64 || v730c->uItemID > 65
|
|
998 && !v730c->Broken()
|
|
999 && !v730c->uSpecEnchantmentType
|
|
1000 && !v730c->uEnchantmentType
|
|
1001 && ( _itm->uEquipType == 0 || _itm->uEquipType == 1 || _itm->uEquipType == 2)
|
|
1002 && !pItemsTable->IsMaterialNonCommon(v730c) )
|
|
1003 {
|
|
1004 v69 = v730c;
|
|
1005 v14 = v731 == 4;
|
|
1006 v730c->uSpecEnchantmentType = amount;
|
|
1007 if ( !v14 )
|
|
1008 {
|
|
1009 v69->uExpireTime = pParty->uTimePlayed
|
|
1010 + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7)
|
|
1011 * 0.033333335);
|
|
1012 v69->uAttributes |= 8u;
|
|
1013 }
|
|
1014 v69->uAttributes |= 0x10u;
|
|
1015 _50C9A8_item_enchantment_timer = 256;
|
|
1016 LODWORD(v727) = 1;
|
|
1017 break;
|
|
1018 }
|
|
1019
|
|
1020 dword_50C9D0 = 113;
|
|
1021 dword_50C9D4 = 0;
|
|
1022 dword_50C9D8 = 1;
|
|
1023
|
|
1024 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
1025 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1026 pCastSpell->spellnum = 0;
|
|
1027 continue;
|
|
1028 }
|
|
1029 case SPELL_BODY_REGENERATION:
|
|
1030 {
|
|
1031 switch (v731)
|
|
1032 {
|
|
1033 case 1: LODWORD(v733) = 3600 * v2; amount = 1; break;
|
|
1034 case 2: LODWORD(v733) = 3600 * v2; amount = 1; break;
|
|
1035 case 3: LODWORD(v733) = 3600 * v2; amount = 3; break;
|
|
1036 case 4: LODWORD(v733) = 3600 * v2; amount = 10; break;
|
|
1037 default:
|
|
1038 assert(false);
|
|
1039 }
|
|
1040 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1041 break;
|
|
1042
|
|
1043 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
1044
|
|
1045 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0);
|
|
1046 LODWORD(v727) = 1;
|
|
1047 break;
|
|
1048 }
|
|
1049 case SPELL_FIRE_PROTECTION_FROM_FIRE:
|
|
1050 case SPELL_AIR_PROTECTION_FROM_AIR:
|
|
1051 case SPELL_WATER_PROTECTION_FROM_WATER:
|
|
1052 case SPELL_EARTH_PROTECTION_FROM_EARTH:
|
|
1053 case SPELL_MIND_PROTECTION_FROM_MIND:
|
|
1054 case SPELL_BODY_PROTECTION_FROM_BODY:
|
|
1055 {
|
|
1056 switch (v731)
|
|
1057 {
|
|
1058 case 1:
|
|
1059 case 2:
|
|
1060 case 3:
|
|
1061 case 4: LODWORD(v733) = 3600 * v2; amount = v731 * v2; break;
|
|
1062 default:
|
|
1063 assert(false);
|
|
1064 }
|
|
1065
|
|
1066 switch (pCastSpell->spellnum)
|
|
1067 {
|
|
1068 case SPELL_FIRE_PROTECTION_FROM_FIRE:
|
|
1069 LODWORD(v725) = PARTY_BUFF_RESIST_FIRE;
|
|
1070 break;
|
|
1071 case SPELL_AIR_PROTECTION_FROM_AIR:
|
|
1072 LODWORD(v725) = PARTY_BUFF_RESIST_AIR;
|
|
1073 break;
|
|
1074 case SPELL_WATER_PROTECTION_FROM_WATER:
|
|
1075 LODWORD(v725) = PARTY_BUFF_RESIST_WATER;
|
|
1076 break;
|
|
1077 case SPELL_EARTH_PROTECTION_FROM_EARTH:
|
|
1078 LODWORD(v725) = PARTY_BUFF_RESIST_EARTH;
|
|
1079 break;
|
|
1080 case SPELL_MIND_PROTECTION_FROM_MIND:
|
|
1081 LODWORD(v725) = PARTY_BUFF_RESIST_MIND;
|
|
1082 break;
|
|
1083 case SPELL_BODY_PROTECTION_FROM_BODY:
|
|
1084 LODWORD(v725) = PARTY_BUFF_RESIST_BODY;
|
|
1085 break;
|
|
1086 default:
|
|
1087 assert(false);
|
|
1088 continue;
|
|
1089 }
|
|
1090 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1091 break;
|
|
1092 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1093 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1094 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1095 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1096 v90 = (double)(signed int)v733 * 4.2666669;
|
|
1097 pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
|
|
1098 LODWORD(v727) = 1;
|
|
1099 break;
|
|
1100 }
|
|
1101 case SPELL_FIRE_HASTE:
|
|
1102 {
|
|
1103 switch (v731)
|
|
1104 {
|
|
1105 case 1: LODWORD(v733) = 60 * (v2 + 60); break;
|
|
1106 case 2: LODWORD(v733) = 60 * (v2 + 60); break;
|
|
1107 case 3: LODWORD(v733) = 180 * (v2 + 20); break;
|
|
1108 case 4: LODWORD(v733) = 240 * (v2 + 15); break;
|
|
1109 default:
|
|
1110 assert(false);
|
|
1111 }
|
|
1112 if ( pPlayer->CanCastSpell(uRequiredMana) )
|
|
1113 {
|
|
1114 v92 = pParty->pPlayers;//[0].pConditions[1];
|
|
1115 LODWORD(v727) = 1;
|
|
1116 do
|
|
1117 {
|
|
1118 if ( v92->pConditions[1] )
|
|
1119 LODWORD(v727) = 0;
|
|
1120 ++v92;
|
|
1121 }
|
|
1122 while ( v92 <= &pParty->pPlayers[3] );
|
|
1123 if (LODWORD(v727))
|
|
1124 {
|
|
1125 pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
|
|
1126
|
|
1127 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1128 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1129 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1130 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1131 }
|
|
1132 }
|
|
1133 break;
|
|
1134 }
|
|
1135 case SPELL_SPIRIT_BLESS:
|
|
1136 {
|
|
1137 switch (v731)
|
|
1138 {
|
|
1139 case 1: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
1140 case 2: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
1141 case 3: LODWORD(v733) = 900 * (v2 + 4); break;
|
|
1142 case 4: LODWORD(v733) = 3600 * (v2 + 1); break;
|
|
1143 default:
|
|
1144 assert(false);
|
|
1145 }
|
|
1146 amount = v2 + 5;
|
|
1147 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1148 break;
|
|
1149 if ( v731 == 1 )
|
|
1150 {
|
|
1151 v108 = pCastSpell->uPlayerID_2;
|
|
1152 v109 = pCastSpell->spellnum;
|
|
1153 v110 = pGame->GetStru6();
|
|
1154 pGame->GetStru6()->SetPlayerBuffAnim(v109, v108);
|
|
1155 v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536);
|
|
1156 //v668 = 0;
|
|
1157 v716 = v111;
|
|
1158 //v658 = v111;
|
|
1159 //v653 = amount;
|
|
1160 //v651 = 1;
|
|
1161 //v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
1162 //v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS];
|
|
1163 //LABEL_103:
|
|
1164 //HIDWORD(v650) = HIDWORD(v28);
|
|
1165 //LABEL_104:
|
|
1166 //LODWORD(v650) = v28;
|
|
1167 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0);
|
|
1168 LODWORD(v727) = 1;
|
|
1169 break;
|
|
1170 }
|
|
1171 v105 = 0;
|
|
1172 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
1173 v730b = pParty->pPlayers;//[0].pPlayerBuffs[1];
|
|
1174 do
|
|
1175 {
|
|
1176 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v105);
|
|
1177 v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536);
|
|
1178 v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0);
|
|
1179 ++v730b;
|
|
1180 ++v105;
|
|
1181 }
|
|
1182 while ( v730b <= &pParty->pPlayers[3] );
|
|
1183 LODWORD(v727) = 1;
|
|
1184 break;
|
|
1185 }
|
|
1186 case SPELL_SPIRIT_SPIRIT_LASH:
|
|
1187 {
|
|
1188 if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor)
|
|
1189 {
|
|
1190 //v730 = a2 >> 3;
|
|
1191 v112 = &pActors[PID_ID(a2)];
|
|
1192 //v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z);
|
|
1193 v721 = abs(v112->vPosition.y - pParty->vPosition.y);
|
|
1194 v113 = abs(v112->vPosition.x - pParty->vPosition.x);
|
|
1195 _this = (ItemGen *)v113;
|
|
1196 v114 = v721;
|
|
1197 v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z);
|
|
1198 if ( v113 < v721 )
|
|
1199 {
|
|
1200 v116 = v113;
|
|
1201 v113 = v721;
|
|
1202 v114 = v116;
|
|
1203 }
|
|
1204 if ( v113 < (signed int)v115 )
|
|
1205 {
|
|
1206 v117 = v113;
|
|
1207 v113 = (int)v115;
|
|
1208 v115 = v117;
|
|
1209 }
|
|
1210 if ( v114 < (signed int)v115 )
|
|
1211 {
|
|
1212 v118 = v115;
|
|
1213 v115 = v114;
|
|
1214 v114 = v118;
|
|
1215 }
|
|
1216 _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113);
|
|
1217 if ( (double)(signed int)this <= 307.2 )
|
|
1218 {
|
|
1219 v701.x = 0;
|
|
1220 v701.y = 0;
|
|
1221 v701.z = 0;
|
|
1222 pSpellSprite.stru_24.Reset();
|
|
1223 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1224 pSpellSprite.spell_level = v723;
|
|
1225 pSpellSprite.spell_skill = v731;
|
|
1226 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1227 pSpellSprite.uAttributes = 0;
|
|
1228 pSpellSprite.uSectorID = 0;
|
|
1229 pSpellSprite.uSpriteFrameID = 0;
|
|
1230 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
1231 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1232 pSpellSprite.uFacing = 0;
|
|
1233 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1234 pSpellSprite.vPosition.x = v112->vPosition.x;
|
|
1235 pSpellSprite.vPosition.y = v112->vPosition.y;
|
|
1236 pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548);
|
|
1237 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
|
|
1238 v122 = pSpellSprite.Create(0, 0, 0, 0);
|
|
1239 DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701);
|
|
1240 LODWORD(v727) = 1;
|
|
1241 }
|
|
1242 else
|
|
1243 {
|
|
1244 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
|
|
1245 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1246 pCastSpell->spellnum = 0;
|
|
1247 }
|
|
1248 //pCastSpell = (CastSpellInfo *)HIDWORD(v733);
|
|
1249 }
|
|
1250 break;
|
|
1251 }
|
|
1252 case SPELL_AIR_SHIELD:
|
|
1253 case SPELL_EARTH_STONESKIN:
|
|
1254 case SPELL_SPIRIT_HEROISM:
|
|
1255 {
|
|
1256 switch (v731)
|
|
1257 {
|
|
1258 case 1: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
1259 case 2: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
1260 case 3: LODWORD(v733) = 900 * (v2 + 4); break;
|
|
1261 case 4: LODWORD(v733) = 3600 * (v2 + 1); break;
|
|
1262 default:
|
|
1263 assert(false);
|
|
1264 }
|
|
1265 v127 = pCastSpell->spellnum;
|
|
1266 if ( v127 == 17 )
|
|
1267 {
|
|
1268 amount = 0;
|
|
1269 LODWORD(v725) = 14;
|
|
1270 }
|
|
1271 else
|
|
1272 {
|
|
1273 if ( v127 == 38 )
|
|
1274 {
|
|
1275 LODWORD(v725) = 15;
|
|
1276 amount = v2 + 5;
|
|
1277 }
|
|
1278 else
|
|
1279 {
|
|
1280 if ( v127 != 51 )
|
|
1281 continue;
|
|
1282 LODWORD(v725) = 9;
|
|
1283 amount = v2 + 5;
|
|
1284 }
|
|
1285 }
|
|
1286 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1287 break;
|
|
1288 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1289 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1290 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1291 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1292 v90 = (double)(signed int)((int)v733 << 7) * 0.033333335;
|
|
1293 //LABEL_304:
|
|
1294 pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
|
|
1295 LODWORD(v727) = 1;
|
|
1296 break;
|
|
1297 }
|
|
1298 case SPELL_FIRE_IMMOLATION:
|
|
1299 {
|
|
1300 if ( v731 == 4 )
|
|
1301 LODWORD(v733) = 600 * v2;
|
|
1302 else
|
|
1303 LODWORD(v733) = 60 * v2;
|
|
1304 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1305 break;
|
|
1306
|
|
1307 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1308 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1309 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1310 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1311
|
|
1312 pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0);
|
|
1313 LODWORD(v727) = 1;
|
|
1314 break;
|
|
1315 }
|
|
1316 case SPELL_FIRE_METEOR_SHOWER:
|
|
1317 {
|
|
1318 //v149 = v731 - 1;
|
|
1319 //if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 )
|
|
1320 int i;
|
|
1321 if ( v731 == 4 )
|
|
1322 {
|
|
1323 i = 20;
|
|
1324 }
|
|
1325 else
|
|
1326 {
|
|
1327 i = 16;
|
|
1328 }
|
|
1329 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
1330 {
|
|
1331 ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors!
|
|
1332 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1333 pCastSpell->spellnum = 0;
|
|
1334 continue;
|
|
1335 }
|
|
1336 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1337 break;
|
|
1338 LODWORD(v725) = PID_TYPE(a2);
|
|
1339 if (PID_TYPE(a2) == OBJECT_Actor)
|
|
1340 {
|
|
1341 uRequiredMana = pActors[PID_ID(a2)].vPosition.x;
|
|
1342 v153 = pActors[PID_ID(a2)].vPosition.y;
|
|
1343 v154 = pActors[PID_ID(a2)].vPosition.z;
|
|
1344 LODWORD(v727) = v153;
|
|
1345 }
|
|
1346 else
|
|
1347 {
|
|
1348 v155 = stru_5C6E00->Cos(pParty->sRotationY);
|
|
1349 uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155);
|
|
1350 v156 = stru_5C6E00->Sin(pParty->sRotationY);
|
|
1351 LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156);
|
|
1352 v154 = pParty->vPosition.z;
|
|
1353 }
|
|
1354 unsigned __int64 k = 0;
|
|
1355 int j = 0;
|
|
1356 if ( (signed int)i > 0 )
|
|
1357 {
|
|
1358 v730 = LODWORD(v725) == 3 ? a2 : 0;
|
|
1359 do
|
|
1360 {
|
|
1361 a2 = rand() % 1000;
|
|
1362 if ( sqrt((double)(rand() % 1000) - 2500 *
|
|
1363 (double)(rand() % 1000) - 2500 +
|
|
1364 j * j + k * k) <= 1.0 )
|
|
1365 {
|
|
1366 LODWORD(v687) = 0;
|
|
1367 HIDWORD(v687) = 0;
|
|
1368 }
|
|
1369 else
|
|
1370 {
|
|
1371 v687 = __PAIR__(
|
|
1372 stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)),
|
|
1373 (double)(rand() % 1000) - 2500),
|
|
1374 stru_5C6E00->Atan2(j, k));
|
|
1375 }
|
|
1376 pSpellSprite.stru_24.Reset();
|
|
1377 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1378 pSpellSprite.spell_level = v2;
|
|
1379 pSpellSprite.spell_skill = v731;
|
|
1380 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1381 pSpellSprite.uAttributes = 0;
|
|
1382 pSpellSprite.vPosition.x = uRequiredMana;
|
|
1383 pSpellSprite.vPosition.y = LODWORD(v727);
|
|
1384 pSpellSprite.uSectorID = 0;
|
|
1385 pSpellSprite.vPosition.z = a2 + v154;
|
|
1386 pSpellSprite.uSpriteFrameID = 0;
|
|
1387 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1388 pSpellSprite.spell_target_pid = v730;
|
|
1389 pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
|
|
1390 pSpellSprite.uFacing = v687;
|
|
1391 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1392 if ( pParty->bTurnBasedModeOn == 1 )
|
|
1393 pSpellSprite.uAttributes = 4;
|
|
1394 if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
|
|
1395 && pParty->bTurnBasedModeOn == 1 )
|
|
1396 ++pTurnEngine->field_1C;
|
|
1397 j = rand() % 1024 - 512;
|
|
1398 k = rand() % 1024 - 512;
|
|
1399 }
|
|
1400 while ( i-- != 1 );
|
|
1401 }
|
|
1402 LODWORD(v727) = 1;
|
|
1403 break;
|
|
1404 }
|
|
1405 case SPELL_FIRE_INFERNO:
|
|
1406 {
|
|
1407 //v67 = 2;
|
|
1408 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
1409 {
|
|
1410 ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
|
|
1411 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1412 pCastSpell->spellnum = 0;
|
|
1413 continue;
|
|
1414 }
|
|
1415 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1416 break;
|
|
1417 auto _v726 = sub_46A6AC((int)dword_50BF30.data(), 100, 4096);
|
|
1418 v700.z = 0;
|
|
1419 v700.y = 0;
|
|
1420 v700.x = 0;
|
|
1421 pSpellSprite.stru_24.Reset();
|
|
1422 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1423 pSpellSprite.spell_level = v2;
|
|
1424 pSpellSprite.spell_skill = v731;
|
|
1425 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1426 pSpellSprite.uAttributes = 0;
|
|
1427 pSpellSprite.uSectorID = 0;
|
|
1428 pSpellSprite.uSpriteFrameID = 0;
|
|
1429 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
1430 pSpellSprite.uFacing = 0;
|
|
1431 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1432 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1433 a2 = 0;
|
|
1434 if ( (signed int)_v726 > 0 )
|
|
1435 {
|
|
1436 do
|
|
1437 {
|
|
1438 v162 = dword_50BF30[a2];
|
|
1439 pSpellSprite.vPosition.x = pActors[v162].vPosition.x;
|
|
1440 pSpellSprite.vPosition.y = pActors[v162].vPosition.y;
|
|
1441 pSpellSprite.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548);
|
|
1442 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
1443 v164 = pSpellSprite.Create(0, 0, 0, 0);
|
|
1444 v165 = a2;
|
|
1445 DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700);
|
|
1446 pGame->GetStru6()->_4A81CA(&pSpellSprite);
|
|
1447 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u);
|
|
1448 a2 = v165 + 1;
|
|
1449 }
|
|
1450 while ( v165 + 1 < (signed int)_v726 );
|
|
1451 }
|
|
1452 LODWORD(v727) = 1;
|
|
1453 break;
|
|
1454 }
|
|
1455 case SPELL_AIR_WIZARD_EYE:
|
|
1456 {
|
|
1457 LODWORD(v733) = 3600 * v2;
|
|
1458 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1459 break;
|
|
1460 v168 = 0;
|
|
1461 do
|
|
1462 {
|
|
1463 v169 = pOtherOverlayList->_4418B1(2000, v168++ + 100, 0, 65536);
|
|
1464 v716 = v169;
|
|
1465 }
|
|
1466 while ( v168 < 4 );
|
|
1467
|
|
1468 pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
|
|
1469 LODWORD(v727) = 1;
|
|
1470 break;
|
|
1471 }
|
|
1472 case SPELL_AIR_FEATHER_FALL:
|
|
1473 {
|
|
1474 switch (v731)
|
|
1475 {
|
|
1476 case 1: LODWORD(v733) = 300 * v2; break;
|
|
1477 case 2: LODWORD(v733) = 600 * v2; break;
|
|
1478 case 3: LODWORD(v733) = 3600 * v2; break;
|
|
1479 case 4: LODWORD(v733) = 3600 * v2; break;
|
|
1480 default:
|
|
1481 assert(false);
|
|
1482 }
|
|
1483 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1484 break;
|
|
1485 v174 = 0;
|
|
1486 do
|
|
1487 pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536);
|
|
1488 while ( v174 < 4 );
|
|
1489 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1490 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1491 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1492 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1493
|
|
1494 pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
|
|
1495 LODWORD(v727) = 1;
|
|
1496 break;
|
|
1497 }
|
|
1498 case SPELL_AIR_SPARKS:
|
|
1499 {
|
|
1500 switch (v731)
|
|
1501 {
|
|
1502 case 1: amount = 3; break;
|
|
1503 case 2: amount = 5; break;
|
|
1504 case 3: amount = 7; break;
|
|
1505 case 4: amount = 9; break;
|
|
1506 default:
|
|
1507 assert(false);
|
|
1508 }
|
|
1509 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1510 break;
|
|
1511 auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
|
|
1512 pSpellSprite.stru_24.Reset();
|
|
1513 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1514 pSpellSprite.spell_level = v2;
|
|
1515 pSpellSprite.spell_skill = v731;
|
|
1516 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1517 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
1518 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
1519 pSpellSprite.uAttributes = 0;
|
|
1520 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
1521 pSpellSprite.uSectorID = pIndoor->GetSector(
|
|
1522 pParty->vPosition.x,
|
|
1523 pParty->vPosition.y,
|
|
1524 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
1525 pSpellSprite.uSpriteFrameID = 0;
|
|
1526 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1527 pSpellSprite.spell_target_pid = a2;
|
|
1528 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
1529 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1530 if ( pParty->bTurnBasedModeOn == 1 )
|
|
1531 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
1532 v188 = (signed int)_v726 / -2;
|
|
1533 v189 = (signed int)_v726 / 2;
|
|
1534 while ( v188 <= v189 )
|
|
1535 {
|
|
1536 pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle);
|
|
1537 if ( pSpellSprite.Create(
|
|
1538 (signed __int16)(v188 + LOWORD(v715.uYawAngle)),
|
|
1539 v715.uPitchAngle,
|
|
1540 pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
|
|
1541 pCastSpell->uPlayerID + 1) != -1
|
|
1542 && pParty->bTurnBasedModeOn == 1 )
|
|
1543 ++pTurnEngine->field_1C;
|
|
1544 v188 += _v726 / (amount - 1);
|
|
1545 }
|
|
1546 LODWORD(v727) = 1;
|
|
1547 break;
|
|
1548 }
|
|
1549 case SPELL_AIR_JUMP:
|
|
1550 {
|
|
1551 if ( pParty->uFlags & PARTY_FLAGS_1_FALLING)
|
|
1552 {
|
|
1553 ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne!
|
|
1554 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1555 break;
|
|
1556 }
|
|
1557 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1558 break;
|
|
1559 v191 = 0;
|
|
1560 do
|
|
1561 pOtherOverlayList->_4418B1(2040, v191++ + 100, 0, 65536);
|
|
1562 while ( v191 < 4 );
|
|
1563 BYTE1(pParty->uFlags) |= 1u;
|
|
1564 pParty->uFallSpeed = 1000;
|
|
1565 LODWORD(v727) = 1;
|
|
1566 break;
|
|
1567 }
|
|
1568 case SPELL_AIR_INVISIBILITY:
|
|
1569 {
|
|
1570 switch (v731)
|
|
1571 {
|
|
1572 case 1: LODWORD(v733) = 600 * v2; amount = v2; break;
|
|
1573 case 2: LODWORD(v733) = 600 * v2; amount = 2 * v2; break;
|
|
1574 case 3: LODWORD(v733) = 600 * v2; amount = 3 * v2; break;
|
|
1575 case 4: LODWORD(v733) = 3600 * v2; amount = 4 * v2; break;
|
|
1576 default:
|
|
1577 assert(false);
|
|
1578 }
|
|
1579 if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW))
|
|
1580 {
|
|
1581 ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby!
|
|
1582 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1583 pCastSpell->spellnum = 0;
|
|
1584 continue;
|
|
1585 }
|
|
1586 if ( pPlayer->CanCastSpell(uRequiredMana) )
|
|
1587 {
|
|
1588 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1589 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1590 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1591 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1592
|
|
1593 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0);
|
|
1594 LODWORD(v727) = 1;
|
|
1595 }
|
|
1596 break;
|
|
1597 }
|
|
1598 case SPELL_AIR_FLY:
|
|
1599 {
|
|
1600 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
1601 {
|
|
1602 ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors!
|
|
1603 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1604 break;
|
|
1605 }
|
|
1606 if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
|
|
1607 {
|
|
1608 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
1609 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1610 break;
|
|
1611 }
|
|
1612 LODWORD(v733) = 3600 * v2;
|
|
1613 if ( v731 == 1 || v731 == 2 || v731 == 3 )
|
|
1614 amount = 1;
|
|
1615 else
|
|
1616 amount = 0;
|
|
1617 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1618 break;
|
|
1619 v205 = 0;
|
|
1620 do
|
|
1621 pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536);
|
|
1622 while ( v205 < 4 );
|
|
1623 v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
|
|
1624 v207 = pCastSpell->uPlayerID + 1;
|
|
1625 v716 = v206;
|
|
1626
|
|
1627 pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207);
|
|
1628 LODWORD(v727) = 1;
|
|
1629 break;
|
|
1630 }
|
|
1631 case SPELL_AIR_STARBURST:
|
|
1632 {
|
|
1633 //v67 = 2;
|
|
1634 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
1635 {
|
|
1636 ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors!
|
|
1637 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1638 pCastSpell->spellnum = 0;
|
|
1639 continue;
|
|
1640 }
|
|
1641 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1642 break;
|
|
1643 v208 = PID_TYPE(a2);
|
|
1644 LODWORD(v725) = PID_TYPE(a2);
|
|
1645 if ( v208 == 3 )
|
|
1646 {
|
|
1647 v209 = PID_ID(a2);
|
|
1648 LODWORD(v718) = pActors[v209].vPosition.x;
|
|
1649 v210 = pActors[v209].vPosition.y;
|
|
1650 v211 = pActors[v209].vPosition.z;
|
|
1651 v713 = v210;
|
|
1652 }
|
|
1653 else
|
|
1654 {
|
|
1655 v212 = stru_5C6E00->Cos(pParty->sRotationY);
|
|
1656 LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
|
|
1657 v213 = stru_5C6E00->Sin(pParty->sRotationY);
|
|
1658 v214 = sub_42EBBE(2048, v213);
|
|
1659 v211 = pParty->vPosition.z;
|
|
1660 v713 = pParty->vPosition.y + v214;
|
|
1661 v208 = LODWORD(v725);
|
|
1662 }
|
|
1663 signed int _v733 = 0;
|
|
1664 *(float *)&v732 = (double)v211;
|
|
1665 LODWORD(v725) = v211 + 2500;
|
|
1666 v721 = 0;
|
|
1667 *(float *)&y = (double)(v211 + 2500);
|
|
1668 v730 = v208 == 3 ? a2 : 0;
|
|
1669 a2 = 20;
|
|
1670 do
|
|
1671 {
|
|
1672 v215 = rand();
|
|
1673 v216 = (double)v721;
|
|
1674 v217 = (double)_v733;
|
|
1675 *(float *)&uRequiredMana = v217;
|
|
1676 _this = (ItemGen *)(v215 % 1000);
|
|
1677 *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y;
|
|
1678 *(float *)&v721 = v217 * v217;
|
|
1679 //*(float *)&v726 = v216 * v216;
|
|
1680 if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 )
|
|
1681 {
|
|
1682 LODWORD(v685) = 0;
|
|
1683 HIDWORD(v685) = 0;
|
|
1684 }
|
|
1685 else
|
|
1686 {
|
|
1687 v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721);
|
|
1688 v685 = __PAIR__(
|
|
1689 stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)),
|
|
1690 stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana));
|
|
1691 }
|
|
1692 pSpellSprite.stru_24.Reset();
|
|
1693 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1694 pSpellSprite.spell_level = v2;
|
|
1695 pSpellSprite.spell_skill = v731;
|
|
1696 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1697 pSpellSprite.uAttributes = 0;
|
|
1698 pSpellSprite.vPosition.x = LODWORD(v718);
|
|
1699 pSpellSprite.vPosition.y = v713;
|
|
1700 pSpellSprite.uSectorID = 0;
|
|
1701 pSpellSprite.vPosition.z = (int)((char *)_this + LODWORD(v725));
|
|
1702 pSpellSprite.uSpriteFrameID = 0;
|
|
1703 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1704 pSpellSprite.spell_target_pid = v730;
|
|
1705 //__debugbreak();//
|
|
1706 pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
|
|
1707 pSpellSprite.uFacing = v685;
|
|
1708 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1709 if ( pParty->bTurnBasedModeOn == 1 )
|
|
1710 pSpellSprite.uAttributes = 4;
|
|
1711 if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
|
|
1712 && pParty->bTurnBasedModeOn == 1 )
|
|
1713 ++pTurnEngine->field_1C;
|
|
1714 v721 = rand() % 1024 - 512;
|
|
1715 v218 = rand();
|
|
1716 v14 = a2-- == 1;
|
|
1717 _v733 = (unsigned __int64)(v218 % 1024) - 512;
|
|
1718 }
|
|
1719 while ( !v14 );
|
|
1720 LODWORD(v727) = 1;
|
|
1721 break;
|
|
1722 }
|
|
1723 case SPELL_WATER_AWAKEN:
|
|
1724 {
|
|
1725 switch (v731)
|
|
1726 {
|
|
1727 case 1: amount = 180 * v2; break;
|
|
1728 case 2: amount = 3600 * v2; break;
|
|
1729 case 3: amount = 86400 * v2; break;
|
|
1730 case 4: amount = 0; break;
|
|
1731 default:
|
|
1732 assert(false);
|
|
1733 }
|
|
1734 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1735 break;
|
|
1736 for( int i=0; i < 4; i++ )
|
|
1737 {
|
|
1738 pPlayer = &pParty->pPlayers[i];
|
|
1739 if ( v731 == 4 )
|
|
1740 {
|
|
1741 if ( pPlayer->pConditions[2] )
|
|
1742 {
|
|
1743 //*((int *)v222 + 4) = 0;
|
|
1744 //*((int *)v222 + 5) = 0;
|
|
1745 pPlayer->pConditions[2] = 0;
|
|
1746 pPlayer->PlaySound(SPEECH_103, 0);
|
|
1747 }
|
|
1748 }
|
|
1749 else
|
|
1750 {
|
|
1751 v223 = pPlayer->DiscardConditionIfLastsLongerThan(
|
|
1752 2u,
|
|
1753 pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335));
|
|
1754 if ( v223 )
|
|
1755 pPlayer->PlaySound(SPEECH_103, 0);
|
|
1756 }
|
|
1757 }
|
|
1758 LODWORD(v727) = 1;
|
|
1759 break;
|
|
1760 }
|
|
1761 case SPELL_WATER_POISON_SPRAY:
|
|
1762 {
|
|
1763 switch (v731)
|
|
1764 {
|
|
1765 case 1: amount = 1; break;
|
|
1766 case 2: amount = 3; break;
|
|
1767 case 3: amount = 5; break;
|
|
1768 case 4: amount = 7; break;
|
|
1769 default:
|
|
1770 assert(false);
|
|
1771 }
|
|
1772 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1773 break;
|
|
1774 signed int _v733 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
|
|
1775 if ( amount == 1 )
|
|
1776 {
|
|
1777 pSpellSprite.stru_24.Reset();
|
|
1778 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1779 pSpellSprite.spell_skill = v731;
|
|
1780 pSpellSprite.spell_level = v2;
|
|
1781 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1782 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
1783 v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
1784 v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
1785 v660 = pParty->vPosition.y;
|
|
1786 // LABEL_153:
|
|
1787 pSpellSprite.uAttributes = 0;
|
|
1788 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
1789 pSpellSprite.vPosition.z = v51;
|
|
1790 v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671);
|
|
1791 pSpellSprite.uSpriteFrameID = 0;
|
|
1792 pSpellSprite.uSectorID = v52;
|
|
1793 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1794 pSpellSprite.spell_target_pid = a2;
|
|
1795 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
1796 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
1797 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1798 if ( pParty->bTurnBasedModeOn == 1 )
|
|
1799 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
1800 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
1801 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
1802 ++pTurnEngine->field_1C;
|
|
1803 }
|
|
1804 else
|
|
1805 {
|
|
1806 pSpellSprite.stru_24.Reset();
|
|
1807 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
1808 pSpellSprite.spell_level = v2;
|
|
1809 pSpellSprite.spell_skill = v731;
|
|
1810 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
1811 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
1812 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
1813 pSpellSprite.uAttributes = 0;
|
|
1814 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
1815 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
1816 pSpellSprite.uSpriteFrameID = 0;
|
|
1817 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
1818 pSpellSprite.spell_target_pid = a2;
|
|
1819 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
1820 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
1821 if ( pParty->bTurnBasedModeOn == 1 )
|
|
1822 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
1823 v227 = _v733 / -2;
|
|
1824 signed int _y = _v733 / 2;
|
|
1825 if ( _v733 / -2 <= _v733 / 2 )
|
|
1826 {
|
|
1827 v228 = v715.uYawAngle;
|
|
1828 do
|
|
1829 {
|
|
1830 pSpellSprite.uFacing = v227 + v228;
|
|
1831 if ( pSpellSprite.Create(
|
|
1832 v227 + v228,
|
|
1833 v715.uPitchAngle,
|
|
1834 pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
|
|
1835 pCastSpell->uPlayerID + 1) != -1
|
|
1836 && pParty->bTurnBasedModeOn == 1 )
|
|
1837 ++pTurnEngine->field_1C;
|
|
1838 v227 += _v733 / (amount - 1);
|
|
1839 }
|
|
1840 while ( v227 <= _y );
|
|
1841 }
|
|
1842 }
|
|
1843 LODWORD(v727) = 1;
|
|
1844 break;
|
|
1845 }
|
|
1846 case SPELL_WATER_WATER_WALK:
|
|
1847 {
|
|
1848 if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
|
|
1849 {
|
|
1850 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
1851 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1852 break;
|
|
1853 }
|
|
1854 if ( v731 == 2 || v731 != 3 && v731 != 4 )
|
|
1855 v229 = 600 * v2;
|
|
1856 else
|
|
1857 v229 = 3600 * v2;
|
|
1858 LODWORD(v733) = v229;
|
|
1859 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1860 break;
|
|
1861 v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
|
|
1862 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
1863 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
1864 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
1865 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
1866
|
|
1867 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(
|
|
1868 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335),
|
|
1869 v731,
|
|
1870 amount,
|
|
1871 v716,
|
|
1872 pCastSpell->uPlayerID + 1);
|
|
1873 if ( v731 == 4 )
|
|
1874 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
|
|
1875 LODWORD(v727) = 1;
|
|
1876 break;
|
|
1877 }
|
|
1878 case SPELL_WATER_RECHARGE_ITEM:
|
|
1879 {
|
|
1880 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1881 break;
|
|
1882 v240 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2];
|
|
1883
|
|
1884 if ( pItemsTable->pItems[v240->uItemID].uEquipType != 12 || v240->uAttributes & 2 )
|
|
1885 {
|
|
1886 dword_50C9D0 = 113;
|
|
1887 dword_50C9D4 = 0;
|
|
1888 dword_50C9D8 = 1;
|
|
1889
|
|
1890 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
1891 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1892 pCastSpell->spellnum = 0;
|
|
1893 continue;
|
|
1894 }
|
|
1895 if ( v731 == 1 || v731 == 2 )
|
|
1896 {
|
|
1897 v241 = (double)v723 * 0.0099999998 + 0.5;
|
|
1898 }
|
|
1899 else if ( v731 == 3 )
|
|
1900 {
|
|
1901 v241 = (double)v723 * 0.0099999998 + 0.69999999;
|
|
1902 }
|
|
1903 else if ( v731 == 4 )
|
|
1904 {
|
|
1905 v241 = (double)v723 * 0.0099999998 + 0.80000001;
|
|
1906 }
|
|
1907 else
|
|
1908 {
|
|
1909 v241 = 0.0;
|
|
1910 }
|
|
1911 if ( v241 > 1.0 )
|
|
1912 v241 = 1.0;
|
|
1913 int uNewCharges = v240->uMaxCharges * v241;
|
|
1914 v240->uMaxCharges = uNewCharges;
|
|
1915 v240->uNumCharges = uNewCharges;
|
|
1916 if ( uNewCharges <= 0 )
|
|
1917 {
|
|
1918 v240 = 0;
|
|
1919 dword_50C9D0 = 113;
|
|
1920 dword_50C9D4 = 0;
|
|
1921 dword_50C9D8 = 1;
|
|
1922 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
|
|
1923 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
1924 pCastSpell->spellnum = 0;
|
|
1925 v2 = v723;
|
|
1926 continue;
|
|
1927 }
|
|
1928 v240->uAttributes |= 0x40u;
|
|
1929 _50C9A8_item_enchantment_timer = 256;
|
|
1930 LODWORD(v727) = 1;
|
|
1931 break;
|
|
1932 }
|
|
1933 case SPELL_WATER_ENCHANT_ITEM:
|
|
1934 {
|
|
1935 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
1936 break;
|
|
1937 uRequiredMana = 0;
|
|
1938 amount = 10 * v2;
|
|
1939 v730 = 1;
|
|
1940 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
1941 v245 = &pPlayer->pInventoryItems[a2];
|
|
1942 ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID];
|
|
1943 if (
|
|
1944 v731 == 1 || v731 == 2 && _v725->uEquipType > 2 ||
|
|
1945 v731 == 3 || v731 == 4 &&
|
|
1946 v245->uItemID <= 134 &&
|
|
1947 v245->uSpecEnchantmentType == 0 &&
|
|
1948 v245->uEnchantmentType == 0 &&
|
|
1949 v245->_bonus_strength== 0 &&
|
|
1950 !v245->Broken() )
|
|
1951 {
|
|
1952 if ( v245->GetValue() < 450 ||
|
|
1953 (v245->GetValue() < 250 && (v731 == 3 || v731 == 4) && _v725->uEquipType >= 0 && _v725->uEquipType <= 2)
|
|
1954 )
|
|
1955 {
|
|
1956 v730 = 0;
|
|
1957 }
|
|
1958 if ( rand() % 100 < 10 * v2 ||
|
|
1959 (rand() % 100 < 80 && (v731 == 3 || v731 == 4 )) ||
|
|
1960 v245->GetValue() < 450 ||
|
|
1961 (v245->GetValue() < 250 && (v731 == 3 || v731 == 4) && v271 >= 0 && v271 <= 2)
|
|
1962 )
|
|
1963 {
|
|
1964 v313 = _v725->uEquipType;
|
|
1965 if ( _v725->uEquipType >= 3 && _v725->uEquipType <= 11 )
|
|
1966 {
|
|
1967 v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
|
|
1968 v245->uEnchantmentType = 0;
|
|
1969 for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1];
|
|
1970 ;
|
|
1971 kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1] )
|
|
1972 {
|
|
1973 ++v245->uEnchantmentType;
|
|
1974 if ( kk >= v295 )
|
|
1975 break;
|
|
1976 }
|
|
1977 v255 = 10;//pItemsTable->field_116D8[17];
|
|
1978 v256 = 10;//pItemsTable->field_116D8[16];
|
|
1979 v245->_bonus_strength = v256 + rand() % (v255 - v256 + 1);
|
|
1980 v245->uAttributes |= 0x20u;
|
|
1981 _50C9A8_item_enchantment_timer = 256;
|
|
1982 LODWORD(v727) = 1;
|
|
1983 break;
|
|
1984 }
|
|
1985 else if ( v731 == 3 || v731 == 4)
|
|
1986 {
|
|
1987 v257 = pItemsTable->pSpecialEnchantments_count;
|
|
1988 v258 = 0;
|
|
1989 v725 = 0.0;
|
|
1990 int _v733 = 0;
|
|
1991 if ( pItemsTable->pSpecialEnchantments_count > 0 )
|
|
1992 {
|
|
1993 v730 = (int)&v679;
|
|
1994 do
|
|
1995 {
|
|
1996 v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement);
|
|
1997 if ( !v259 || v259 == 1 )
|
|
1998 {
|
|
1999 v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
|
|
2000 + 4]
|
|
2001 + v258 * 28);
|
|
2002 LODWORD(v725) += v260;
|
|
2003 if ( v260 )
|
|
2004 {
|
|
2005 v261 = v730;
|
|
2006 v730 += 4;
|
|
2007 *(int *)v261 = _v733;
|
|
2008 }
|
|
2009 }
|
|
2010 ++_v733;
|
|
2011 ++v258;
|
|
2012 }
|
|
2013 while ( _v733 < v257 );
|
|
2014 }
|
|
2015 v262 = rand() % SLODWORD(v725);
|
|
2016 v263 = v679;
|
|
2017 v245->uSpecEnchantmentType = v679[0];
|
|
2018 v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
|
|
2019 v265 = v262 + 1;
|
|
2020 if ( v264 < v265 )
|
|
2021 {
|
|
2022 for ( ii = v679; ; ii = (int *)v732 )
|
|
2023 {
|
|
2024 v267 = (int)(ii + 1);
|
|
2025 v732 = v267;
|
|
2026 v268 = *(int *)v267;
|
|
2027 *(int *)(v245 + 12) = v268;
|
|
2028 v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
|
|
2029 + 4];
|
|
2030 if ( v264 >= v265 )
|
|
2031 break;
|
|
2032 }
|
|
2033 }
|
|
2034
|
|
2035 v277 = pItemsTable->pSpecialEnchantments_count;
|
|
2036 v278 = 0;
|
|
2037 v725 = 0.0;
|
|
2038 _v733 = 0;
|
|
2039 if ( pItemsTable->pSpecialEnchantments_count > 0 )
|
|
2040 {
|
|
2041 int *_v730 = v679;
|
|
2042 do
|
|
2043 {
|
|
2044 v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement);
|
|
2045 if ( !v279 || v279 == 1 )
|
|
2046 {
|
|
2047 v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType]);
|
|
2048 _v733 += v280;
|
|
2049 if ( v280 )
|
|
2050 {
|
|
2051 v281 = _v730;
|
|
2052 ++_v730;
|
|
2053 *v281 = _v733;
|
|
2054 }
|
|
2055 }
|
|
2056 ++_v733;
|
|
2057 ++v278;
|
|
2058 }
|
|
2059 while ( _v733 < v277 );
|
|
2060 }
|
|
2061 v282 = rand() % _v733;
|
|
2062 v283 = v679;
|
|
2063 v245->uSpecEnchantmentType = v679[0];
|
|
2064 v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType ];
|
|
2065 v285 = v282 + 1;
|
|
2066 for ( l = v679; v284 < v285; ++l )
|
|
2067 {
|
|
2068 v245->uSpecEnchantmentType = *(l+1);
|
|
2069 v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[pItemsTable->pItems[v245->uItemID].uEquipType];
|
|
2070 }
|
|
2071 ++v245->uSpecEnchantmentType;
|
|
2072 v245->uAttributes |= 0x20u;
|
|
2073 _50C9A8_item_enchantment_timer = 256;
|
|
2074 LODWORD(v727) = 1;
|
|
2075 break;
|
|
2076 }
|
|
2077 }
|
|
2078 else
|
|
2079 {
|
|
2080 if ( !(BYTE1(v245->uAttributes) & 2) )
|
|
2081 {
|
|
2082 v245->uAttributes |= 2;
|
|
2083 }
|
|
2084 }
|
|
2085
|
|
2086 }
|
|
2087
|
|
2088 if ( LODWORD(v727) == 0 )
|
|
2089 {
|
|
2090 v317 = pGlobalTXT_LocalizationStrings[428];
|
|
2091 if ( v730 == 0 )
|
|
2092 v317 = pGlobalTXT_LocalizationStrings[585];
|
|
2093 ShowStatusBarString(v317, 2u);
|
|
2094 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
2095 v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
2096 pCastSpell->spellnum = 0;
|
|
2097 v318->PlaySound(SPEECH_43, 0);
|
|
2098 }
|
|
2099
|
|
2100 break;
|
|
2101 }
|
|
2102 case SPELL_WATER_TOWN_PORTAL:
|
|
2103 {
|
|
2104 amount = 10 * v2;
|
|
2105 if ( pPlayer->sMana < (signed int)uRequiredMana )
|
|
2106 break;
|
|
2107 if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v731 != 4 || rand() % 100 >= amount && v731 != 4 )
|
|
2108 {
|
|
2109 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
2110 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
2111 pCastSpell->spellnum = 0;
|
|
2112 continue;
|
|
2113 }
|
|
2114 town_portal_caster_id = LOBYTE(pCastSpell->uPlayerID);
|
|
2115 pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
|
|
2116 LODWORD(v727) = 1;
|
|
2117 break;
|
|
2118 }
|
|
2119 case SPELL_WATER_LLOYDS_BEACON:
|
|
2120 {
|
|
2121 LODWORD(v733) = 604800 * v2;
|
|
2122 if ( !_stricmp(pCurrentMapName.data(), "d05.blv") )
|
|
2123 {
|
|
2124 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
2125 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
2126 pCastSpell->spellnum = 0;
|
|
2127 continue;
|
|
2128 }
|
|
2129 v319 = uRequiredMana;
|
|
2130 if ( pPlayer->sMana >= (signed int)uRequiredMana )
|
|
2131 {
|
|
2132 pEventTimer->Pause();
|
|
2133 pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastLloydsBeacon, 0, 0);
|
|
2134 qword_506350 = (signed int)v733;
|
|
2135 _506348_current_lloyd_playerid = pCastSpell->uPlayerID;
|
|
2136 ::uRequiredMana = v319;
|
|
2137 ::sRecoveryTime = sRecoveryTime;
|
|
2138 dword_50633C = pCastSpell->sound_id;
|
|
2139 dword_506338 = pCastSpell->spellnum;
|
|
2140 LOBYTE(pCastSpell->field_8) |= 0x20u;
|
|
2141 }
|
|
2142 break;
|
|
2143 }
|
|
2144 case SPELL_EARTH_STONE_TO_FLESH:
|
|
2145 {
|
|
2146 __debugbreak(); // missing GM ?
|
|
2147 switch (v731)
|
|
2148 {
|
|
2149 case 1: amount = 3600 * v2; break;
|
|
2150 case 2: amount = 3600 * v2; break;
|
|
2151 case 3: amount = 86400 * v2; break;
|
|
2152 case 4: break;
|
|
2153 default:
|
|
2154 assert(false);
|
|
2155 }
|
|
2156 //LABEL_634:
|
|
2157 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2158 break;
|
|
2159 v323 = pCastSpell->uPlayerID_2;
|
|
2160 v324 = (char *)&pParty->pPlayers[v323].pConditions[15];
|
|
2161 if ( !pParty->pPlayers[v323].pConditions[15] )
|
|
2162 {
|
|
2163 LODWORD(v727) = 1;
|
|
2164 break;
|
|
2165 }
|
|
2166 if ( v731 == 4 )
|
|
2167 {
|
|
2168 *(int *)v324 = 0;
|
|
2169 *((int *)v324 + 1) = 0;
|
|
2170 LODWORD(v727) = 1;
|
|
2171 break;
|
|
2172 }
|
|
2173 v732 = amount << 7;
|
|
2174 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
|
|
2175 v656 = 15;
|
|
2176 v325 = &pParty->pPlayers[v323];
|
|
2177 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
2178 LODWORD(v727) = 1;
|
|
2179 break;
|
|
2180 }
|
|
2181 case SPELL_EARTH_ROCK_BLAST:
|
|
2182 {
|
|
2183 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2184 break;
|
|
2185 pSpellSprite.stru_24.Reset();
|
|
2186 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2187 pSpellSprite.spell_level = v2;
|
|
2188 pSpellSprite.spell_skill = v731;
|
|
2189 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2190 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
2191 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
2192 pSpellSprite.uAttributes = 0;
|
|
2193 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
2194 pSpellSprite.uSectorID = pIndoor->GetSector(
|
|
2195 pParty->vPosition.x,
|
|
2196 pParty->vPosition.y,
|
|
2197 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
|
|
2198 pSpellSprite.uSpriteFrameID = 0;
|
|
2199 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2200 pSpellSprite.spell_target_pid = a2;
|
|
2201 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
2202 pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
|
|
2203 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2204 if ( pParty->bTurnBasedModeOn == 1 )
|
|
2205 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
2206
|
|
2207 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
2208 if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
2209 ++pTurnEngine->field_1C;
|
|
2210 LODWORD(v727) = 1;
|
|
2211 break;
|
|
2212 }
|
|
2213 case SPELL_EARTH_DEATH_BLOSSOM:
|
|
2214 {
|
|
2215 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
2216 {
|
|
2217 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
2218 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
2219 pCastSpell->spellnum = 0;
|
|
2220 continue;
|
|
2221 }
|
|
2222 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2223 break;
|
|
2224 pSpellSprite.uType = 4090;
|
|
2225 pSpellSprite.stru_24.Reset();
|
|
2226 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2227 pSpellSprite.spell_level = v2;
|
|
2228 pSpellSprite.spell_skill = v731;
|
|
2229 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2230 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
2231 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
2232 pSpellSprite.uAttributes = 0;
|
|
2233 pSpellSprite.uSectorID = 0;
|
|
2234 pSpellSprite.uSpriteFrameID = 0;
|
|
2235 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
|
|
2236 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
2237 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2238 pSpellSprite.spell_target_pid = a2;
|
|
2239 pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
|
|
2240 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2241 if ( pParty->bTurnBasedModeOn == 1 )
|
|
2242 pSpellSprite.uAttributes = 4;
|
|
2243
|
|
2244 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
|
|
2245 if ( pSpellSprite.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 )
|
|
2246 ++pTurnEngine->field_1C;
|
|
2247 LODWORD(v727) = 1;
|
|
2248 break;
|
|
2249 }
|
|
2250 case SPELL_SPIRIT_DETECT_LIFE:
|
|
2251 {
|
|
2252 v328 = v731 - 2;
|
|
2253 if ( v328 )
|
|
2254 {
|
|
2255 v329 = v328 - 1;
|
|
2256 if ( v329 && v329 != 1 )
|
|
2257 v330 = 600 * v2;
|
|
2258 else
|
|
2259 v330 = 3600 * v2;
|
|
2260 }
|
|
2261 else
|
|
2262 {
|
|
2263 v330 = 1800 * v2;
|
|
2264 }
|
|
2265 LODWORD(v733) = v330;
|
|
2266 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2267 break;
|
|
2268 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
2269 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
2270 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
2271 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
2272
|
|
2273 pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
|
|
2274 LODWORD(v727) = 1;
|
|
2275 break;
|
|
2276 }
|
|
2277 case SPELL_SPIRIT_FATE:
|
|
2278 {
|
|
2279 switch (v731)
|
|
2280 {
|
|
2281 case 1: amount = 1 * v2; break;
|
|
2282 case 2: amount = 2 * v2; break;
|
|
2283 case 3: amount = 4 * v2; break;
|
|
2284 case 4: amount = 6 * v2; break;
|
|
2285 default:
|
|
2286 assert(false);
|
|
2287 }
|
|
2288 LODWORD(v733) = 300;
|
|
2289 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2290 break;
|
|
2291 v342 = pCastSpell->spell_target_pid;
|
|
2292 if ( v342 == 0 )
|
|
2293 {
|
|
2294 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2295
|
|
2296 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0);
|
|
2297 LODWORD(v727) = 1;
|
|
2298 break;
|
|
2299 }
|
|
2300 if (PID_TYPE(v342) == OBJECT_Actor)
|
|
2301 {
|
|
2302 v343 = PID_ID(v342);
|
|
2303 HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32);
|
|
2304 LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280;
|
|
2305 pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0);
|
|
2306 BYTE2(pActors[v343].uAttributes) |= 8u;
|
|
2307 //v672 = 0;
|
|
2308 v661 = &pActors[v343];
|
|
2309 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
|
|
2310 }
|
|
2311 LODWORD(v727) = 1;
|
|
2312 break;
|
|
2313 }
|
|
2314 case SPELL_SPIRIT_REMOVE_CURSE:
|
|
2315 {
|
|
2316 switch (v731)
|
|
2317 {
|
|
2318 case 1: amount = 3600 * v2; break;
|
|
2319 case 2: amount = 3600 * v2; break;
|
|
2320 case 3: amount = 86400 * v2; break;
|
|
2321 case 4: amount = 0; break;
|
|
2322 default:
|
|
2323 assert(false);
|
|
2324 }
|
|
2325 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2326 break;
|
|
2327 v351 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
2328 if ( !v351->pConditions[0] )
|
|
2329 {
|
|
2330 LODWORD(v727) = 1;
|
|
2331 break;
|
|
2332 }
|
|
2333 if ( v731 == 4 )
|
|
2334 {
|
|
2335 LODWORD(v351->pConditions[0]) = 0;
|
|
2336 HIDWORD(v351->pConditions[0]) = 0;
|
|
2337 }
|
|
2338 else
|
|
2339 {
|
|
2340 v732 = amount << 7;
|
|
2341 v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
|
|
2342 if ( HIDWORD(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[0]) )
|
|
2343 {
|
|
2344 LODWORD(v727) = 1;
|
|
2345 break;
|
|
2346 }
|
|
2347 }
|
|
2348 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2349 LODWORD(v727) = 1;
|
|
2350 break;
|
|
2351 }
|
|
2352 case SPELL_SPIRIT_PRESERVATION:
|
|
2353 {
|
|
2354 if ( v731 == 4 )
|
|
2355 LODWORD(v733) = 900 * (v2 + 4);
|
|
2356 else
|
|
2357 LODWORD(v733) = 300 * (v2 + 12);
|
|
2358 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2359 break;
|
|
2360 if ( v731 == 1 || v731 == 2 )
|
|
2361 {
|
|
2362 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2363 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
|
|
2364 LODWORD(v727) = 1;
|
|
2365 break;
|
|
2366 }
|
|
2367 a2 = 0;
|
|
2368 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
2369 v357 = pParty->pPlayers;//[0].pPlayerBuffs[11];
|
|
2370 do
|
|
2371 {
|
|
2372 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
|
|
2373 v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0);
|
|
2374 ++a2;
|
|
2375 ++v357;// = (SpellBuff *)((char *)v357 + 6972);
|
|
2376 }
|
|
2377 while ( v357 <= &pParty->pPlayers[3] );
|
|
2378 LODWORD(v727) = 1;
|
|
2379 break;
|
|
2380 }
|
|
2381 case SPELL_SPIRIT_TURN_UNDEAD:
|
|
2382 {
|
|
2383 if ( v731 == 1 || v731 == 2)
|
|
2384 LODWORD(v733) = 60 * (v2 + 3);
|
|
2385 else
|
|
2386 LODWORD(v733) = 300 * v2 + 180;
|
|
2387 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2388 break;
|
|
2389 auto _v726 = sub_46A6AC((int)dword_50BF30.data(), 100, 4096);
|
|
2390 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u);
|
|
2391 ++pSpellSprite.uType;
|
|
2392 pSpellSprite.stru_24.Reset();
|
|
2393 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2394 pSpellSprite.spell_level = v2;
|
|
2395 pSpellSprite.spell_skill = v731;
|
|
2396 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2397 pSpellSprite.uAttributes = 0;
|
|
2398 pSpellSprite.uSectorID = 0;
|
|
2399 pSpellSprite.uSpriteFrameID = 0;
|
|
2400 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
2401 pSpellSprite.uFacing = 0;
|
|
2402 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2403 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2404 for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
|
|
2405 {
|
|
2406 v369 = &pActors[dword_50BF30[a2]];
|
|
2407 if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
|
|
2408 {
|
|
2409 pSpellSprite.vPosition.x = v369->vPosition.x;
|
|
2410 pSpellSprite.vPosition.y = v369->vPosition.y;
|
|
2411 pSpellSprite.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548);
|
|
2412
|
|
2413 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
2414 pSpellSprite.Create(0, 0, 0, 0);
|
|
2415 v369->pActorBuffs[4].Apply(
|
|
2416 pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
|
|
2417 v731, 0, 0, 0);
|
|
2418 }
|
|
2419 }
|
|
2420 LODWORD(v727) = 1;
|
|
2421 break;
|
|
2422 }
|
|
2423 case SPELL_SPIRIT_RAISE_DEAD:
|
|
2424 {
|
|
2425 if ( v731 == 4 )
|
|
2426 amount = 0;
|
|
2427 else
|
|
2428 amount = 86400 * v2;
|
|
2429 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2430 break;
|
|
2431 pOtherOverlayList->_4418B1(5080, pCastSpell->uPlayerID_2 + 100, 0, 65536);
|
|
2432 v373 = pCastSpell->uPlayerID_2;
|
|
2433 if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) )
|
|
2434 {
|
|
2435 LODWORD(v727) = 1;
|
|
2436 break;
|
|
2437 }
|
|
2438 v14 = v731 == 4;
|
|
2439 pParty->pPlayers[v373].sHealth = 1;
|
|
2440 if ( v14 )
|
|
2441 {
|
|
2442 v374 = pCastSpell->uPlayerID_2;
|
|
2443 LODWORD(pParty->pPlayers[v374].pConditions[14]) = 0;
|
|
2444 HIDWORD(pParty->pPlayers[v374].pConditions[14]) = 0;
|
|
2445 v376 = pCastSpell->uPlayerID_2;
|
|
2446 LODWORD(pParty->pPlayers[v376].pConditions[13]) = 0;
|
|
2447 HIDWORD(pParty->pPlayers[v376].pConditions[13]) = 0;
|
|
2448 }
|
|
2449 else
|
|
2450 {
|
|
2451 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
|
|
2452 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
|
|
2453 0xEu,
|
|
2454 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
2455 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
|
|
2456 0xDu,
|
|
2457 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
2458 }
|
|
2459 v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
2460 v377->SetCondition(1, 0);
|
|
2461 LODWORD(v727) = 1;
|
|
2462 break;
|
|
2463 }
|
|
2464 case SPELL_SPIRIT_SHARED_LIFE:
|
|
2465 {
|
|
2466 if ( v731 == 4 )
|
|
2467 amount = 4 * v2;
|
|
2468 else
|
|
2469 amount = 3 * v2;
|
|
2470 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2471 break;
|
|
2472 v381 = 0;
|
|
2473 signed int _v733 = amount;
|
|
2474 v730 = 0;
|
|
2475 v382 = 1;
|
|
2476 do
|
|
2477 {
|
|
2478 v383 = pPlayers[v382];
|
|
2479 if ( !v383->pConditions[14] && !v383->pConditions[15] && !v383->pConditions[16] )
|
|
2480 v682[v381++] = v382;
|
|
2481 ++v382;
|
|
2482 }
|
|
2483 while ( v382 <= 4 );
|
|
2484 v384 = 0;
|
|
2485 v730 = v381;
|
|
2486 if ( v381 > 0 )
|
|
2487 {
|
|
2488 do
|
|
2489 _v733 += pPlayers[v682[v384++]]->sHealth;
|
|
2490 while ( v384 < v381 );
|
|
2491 }
|
|
2492 v732 = (signed __int64)((double)_v733 / (double)v730);
|
|
2493 _v733 = 0;
|
|
2494 if ( v381 > 0 )
|
|
2495 {
|
|
2496 do
|
|
2497 {
|
|
2498 //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]];
|
|
2499 v726 = pPlayers[v682[_v733]];
|
|
2500 v726->sHealth = v732;
|
|
2501 //v386 = v726->GetMaxHealth();
|
|
2502 if ( v726->sHealth > v726->GetMaxHealth())
|
|
2503 v726->sHealth = v726->GetMaxHealth();
|
|
2504 if ( v726->sHealth > 0 )
|
|
2505 {
|
|
2506 v726->pConditions[Player::Condition_Unconcious] = 0;
|
|
2507 }
|
|
2508 v388 = _v733;
|
|
2509
|
|
2510 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[_v733]) - 1);
|
|
2511 _v733 = v388 + 1;
|
|
2512 }
|
|
2513 while ( v388 + 1 < v730 );
|
|
2514 }
|
|
2515 LODWORD(v727) = 1;
|
|
2516 break;
|
|
2517 }
|
|
2518 case SPELL_SPIRIT_RESSURECTION:
|
|
2519 {
|
|
2520 switch (v731)
|
|
2521 {
|
|
2522 case 1: amount = 180 * v2; break;
|
|
2523 case 2: amount = 10800 * v2; break;
|
|
2524 case 3: amount = 259200 * v2; break;
|
|
2525 case 4: amount = 0; break;
|
|
2526 default:
|
|
2527 assert(false);
|
|
2528 }
|
|
2529 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2530 break;
|
|
2531 v396 = pCastSpell->uPlayerID_2;
|
|
2532 if ( HIDWORD(pParty->pPlayers[v396].pConditions[16]) | LODWORD(pParty->pPlayers[v396].pConditions[16])
|
|
2533 || HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) )
|
|
2534 {
|
|
2535 if ( !(HIDWORD(pParty->pPlayers[v396].pConditions[1]) | LODWORD(pParty->pPlayers[v396].pConditions[1])) )
|
|
2536 pParty->pPlayers[v396].PlaySound(SPEECH_25, 0);
|
|
2537 if ( v731 == 4 )
|
|
2538 {
|
|
2539 v397 = pCastSpell->uPlayerID_2;
|
|
2540 LODWORD(pParty->pPlayers[v397].pConditions[16]) = 0;
|
|
2541 HIDWORD(pParty->pPlayers[v397].pConditions[16]) = 0;
|
|
2542 v398 = pCastSpell->uPlayerID_2;
|
|
2543 LODWORD(pParty->pPlayers[v398].pConditions[14]) = 0;
|
|
2544 HIDWORD(pParty->pPlayers[v398].pConditions[14]) = 0;
|
|
2545 v399 = pCastSpell->uPlayerID_2;
|
|
2546 LODWORD(pParty->pPlayers[v399].pConditions[13]) = 0;
|
|
2547 HIDWORD(pParty->pPlayers[v399].pConditions[13]) = 0;
|
|
2548 }
|
|
2549 else
|
|
2550 {
|
|
2551 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
|
|
2552 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u,
|
|
2553 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
2554 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu,
|
|
2555 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
2556 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu,
|
|
2557 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
2558 }
|
|
2559 pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(1u, 1);
|
|
2560 pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1;
|
|
2561 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2562 }
|
|
2563 LODWORD(v727) = 1;
|
|
2564 break;
|
|
2565 }
|
|
2566 case SPELL_MIND_CURE_PARALYSIS:
|
|
2567 {
|
|
2568 switch (v731)
|
|
2569 {
|
|
2570 case 1: amount = 3600 * v2; break;
|
|
2571 case 2: amount = 3600 * v2; break;
|
|
2572 case 3: amount = 86400 * v2; break;
|
|
2573 case 4: amount = 0; break;
|
|
2574 default:
|
|
2575 assert(false);
|
|
2576 }
|
|
2577 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2578 break;
|
|
2579
|
|
2580 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2581 v323 = pCastSpell->uPlayerID_2;
|
|
2582 v324 = (char *)&pParty->pPlayers[v323].pConditions[12];
|
|
2583 if ( !pParty->pPlayers[v323].pConditions[12] )
|
|
2584 {
|
|
2585 LODWORD(v727) = 1;
|
|
2586 break;
|
|
2587 }
|
|
2588 if ( v731 == 4 )
|
|
2589 {
|
|
2590 *(int *)v324 = 0;
|
|
2591 *((int *)v324 + 1) = 0;
|
|
2592 LODWORD(v727) = 1;
|
|
2593 break;
|
|
2594 }
|
|
2595 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
|
|
2596 v656 = 12;
|
|
2597 v325 = &pParty->pPlayers[v323];
|
|
2598 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
2599 LODWORD(v727) = 1;
|
|
2600 break;
|
|
2601 }
|
|
2602 case SPELL_MIND_REMOVE_FEAR:
|
|
2603 {
|
|
2604 switch (v731)
|
|
2605 {
|
|
2606 case 1: amount = 180 * v2; break;
|
|
2607 case 2: amount = 3600 * v2; break;
|
|
2608 case 3: amount = 86400 * v2; break;
|
|
2609 case 4: amount = 0; break;
|
|
2610 default:
|
|
2611 assert(false);
|
|
2612 }
|
|
2613
|
|
2614 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2615 break;
|
|
2616
|
|
2617 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2618 v323 = pCastSpell->uPlayerID_2;
|
|
2619 v324 = (char *)&pParty->pPlayers[v323].pConditions[3];
|
|
2620 if ( !pParty->pPlayers[v323].pConditions[3] )
|
|
2621 {
|
|
2622 LODWORD(v727) = 1;
|
|
2623 break;
|
|
2624 }
|
|
2625 if ( v731 == 4 )
|
|
2626 {
|
|
2627 *(int *)v324 = 0;
|
|
2628 *((int *)v324 + 1) = 0;
|
|
2629 LODWORD(v727) = 1;
|
|
2630 break;
|
|
2631 }
|
|
2632 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
|
|
2633 v656 = 3;
|
|
2634 v325 = &pParty->pPlayers[v323];
|
|
2635 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
2636 LODWORD(v727) = 1;
|
|
2637 break;
|
|
2638 }
|
|
2639 case SPELL_MIND_TELEPATHY:
|
|
2640 {
|
|
2641 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2642 break;
|
|
2643 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
2644 {
|
|
2645 LODWORD(v727) = 1;
|
|
2646 break;
|
|
2647 }
|
|
2648 v417 = &pActors[PID_ID(a2)];
|
|
2649 Actor * _v730 = v417;
|
|
2650 if ( !(BYTE2(v417->uAttributes) & 0x80) )
|
|
2651 {
|
|
2652 v417->SetRandomGoldIfTheresNoItem();
|
|
2653 v417 = _v730;
|
|
2654 }
|
|
2655 v418 = v417->array_000234[3].uItemID;
|
|
2656 signed int _v733 = 0;
|
|
2657 if ( pItemsTable->pItems[v418].uEquipType == 18 )
|
|
2658 _v733 = v417->array_000234[3].uSpecEnchantmentType;
|
|
2659
|
|
2660 //ItemGen::ItemGen(&v683);
|
|
2661 v683.Reset();
|
|
2662
|
|
2663 v419 = _v730->uCarriedItemID;
|
|
2664 if (v419)
|
|
2665 {
|
|
2666 v683.uItemID = v419;
|
|
2667 //goto LABEL_799;
|
|
2668 }
|
|
2669 else
|
|
2670 {
|
|
2671 v420 = 0;
|
|
2672 v421 = _v730->array_000234;
|
|
2673 while ( !v421->uItemID || pItemsTable->pItems[v421->uItemID].uEquipType == 18 )
|
|
2674 {
|
|
2675 ++v420;
|
|
2676 ++v421;
|
|
2677 if ( v420 >= 4 )
|
|
2678 break;
|
|
2679 }
|
|
2680 if ( v420 < 4 )
|
|
2681 {
|
|
2682 memcpy(&v683, &_v730->array_000234[v420], sizeof(v683));
|
|
2683 v2 = v723;
|
|
2684 //v1 = 0;
|
|
2685 }
|
|
2686 }
|
|
2687 // LABEL_799:
|
|
2688 if ( _v733 != 0 )
|
|
2689 {
|
|
2690 v675 = _v733;
|
|
2691 if (v683.uItemID)
|
|
2692 {
|
|
2693 v422 = v683.GetDisplayName();
|
|
2694 sprintf(pTmpBuf2.data(), "(%s), and %d gold", v422, v675);
|
|
2695
|
|
2696 }
|
|
2697 else
|
|
2698 {
|
|
2699 v664 = "%d gold";
|
|
2700 sprintf(pTmpBuf2.data(), v664, v675);
|
|
2701 }
|
|
2702 }
|
|
2703 else
|
|
2704 {
|
|
2705 if (v683.uItemID)
|
|
2706 {
|
|
2707 const char *_v675 = v683.GetDisplayName();
|
|
2708 v664 = "(%s)";
|
|
2709 sprintf(pTmpBuf2.data(), v664, _v675);
|
|
2710 }
|
|
2711 else
|
|
2712 {
|
|
2713 strcpy(pTmpBuf2.data(), "nothing");
|
|
2714 ShowStatusBarString(pTmpBuf2.data(), 2u);
|
|
2715 }
|
|
2716 }
|
|
2717 ShowStatusBarString(pTmpBuf2.data(), 2u);
|
|
2718 pSpellSprite.stru_24.Reset();
|
|
2719 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2720 pSpellSprite.spell_level = v2;
|
|
2721 pSpellSprite.spell_skill = v731;
|
|
2722 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2723 pSpellSprite.vPosition.x = _v730->vPosition.x;
|
|
2724 pSpellSprite.vPosition.y = _v730->vPosition.y;
|
|
2725 v676 = _v730->uActorHeight;
|
|
2726 v665 = pSpellSprite.vPosition.y;
|
|
2727 pSpellSprite.vPosition.z = _v730->uActorHeight;
|
|
2728 v657 = pSpellSprite.vPosition.x;
|
|
2729 pSpellSprite.uAttributes = 0;
|
|
2730 pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
|
|
2731 pSpellSprite.uSpriteFrameID = 0;
|
|
2732 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2733 pSpellSprite.spell_target_pid = a2;
|
|
2734 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
2735 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
2736 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
|
|
2737 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2738 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
|
|
2739 LODWORD(v727) = 1;
|
|
2740 break;
|
|
2741 }
|
|
2742 case SPELL_MIND_BERSERK:
|
|
2743 {
|
|
2744 switch (v731)
|
|
2745 {
|
|
2746 case 1: amount = 300 * v2; break;
|
|
2747 case 2: amount = 300 * v2; break;
|
|
2748 case 3: amount = 600 * v2; break;
|
|
2749 case 4: amount = 3600; break;
|
|
2750 default:
|
|
2751 assert(false);
|
|
2752 }
|
|
2753 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2754 break;
|
|
2755 v426 = PID_ID(a2);
|
|
2756 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
2757 {
|
|
2758 LODWORD(v727) = 1;
|
|
2759 break;
|
|
2760 }
|
|
2761 v730 = 836 * v426;
|
|
2762 if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) )
|
|
2763 {
|
|
2764 pActors[v426].pActorBuffs[1].Reset();
|
|
2765 pActors[v426].pActorBuffs[12].Reset();
|
|
2766 pActors[v426].pActorBuffs[9].Apply(
|
|
2767 pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
|
|
2768 v731, 0, 0, 0);
|
|
2769 pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
|
|
2770 }
|
|
2771 pSpellSprite.stru_24.Reset();
|
|
2772 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2773 pSpellSprite.spell_level = v2;
|
|
2774 pSpellSprite.spell_skill = v731;
|
|
2775 v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2776 v61 = v426;
|
|
2777 v600 = pActors[v61].vPosition.y;
|
|
2778 v601 = pActors[v61].vPosition.x;
|
|
2779 pSpellSprite.uObjectDescID = v60;
|
|
2780 pSpellSprite.vPosition.x = v601;
|
|
2781 v602 = pActors[v61].uActorHeight;
|
|
2782 v603 = pActors[v61].vPosition.z;
|
|
2783 pSpellSprite.vPosition.y = v600;
|
|
2784 v676 = v603 + v602;
|
|
2785 v665 = v600;
|
|
2786 pSpellSprite.vPosition.z = v603 + v602;
|
|
2787 v657 = v601;
|
|
2788 pSpellSprite.uAttributes = 0;
|
|
2789 pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
|
|
2790 pSpellSprite.uSpriteFrameID = 0;
|
|
2791 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2792 pSpellSprite.spell_target_pid = a2;
|
|
2793 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
2794 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
2795 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
|
|
2796 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2797 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
|
|
2798 LODWORD(v727) = 1;
|
|
2799 break;
|
|
2800 }
|
|
2801 case SPELL_MIND_ENSLAVE:
|
|
2802 {
|
|
2803 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2804 break;
|
|
2805 amount = 600 * v2;
|
|
2806 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
2807 {
|
|
2808 LODWORD(v727) = 1;
|
|
2809 break;
|
|
2810 }
|
|
2811 v730 = 836 * PID_ID(a2);
|
|
2812 if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
|
|
2813 break;
|
|
2814 if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) )
|
|
2815 {
|
|
2816 pActors[PID_ID(a2)].pActorBuffs[9].Reset();
|
|
2817 pActors[PID_ID(a2)].pActorBuffs[1].Reset();
|
|
2818 pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
|
|
2819 v731, 0, 0, 0);
|
|
2820 }
|
|
2821 pSpellSprite.stru_24.Reset();
|
|
2822 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2823 pSpellSprite.spell_level = v2;
|
|
2824 pSpellSprite.spell_skill = v731;
|
|
2825 v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2826 v61 = PID_ID(a2);
|
|
2827 v600 = pActors[v61].vPosition.y;
|
|
2828 v601 = pActors[v61].vPosition.x;
|
|
2829 pSpellSprite.uObjectDescID = v60;
|
|
2830 pSpellSprite.vPosition.x = v601;
|
|
2831 v602 = pActors[v61].uActorHeight;
|
|
2832 v603 = pActors[v61].vPosition.z;
|
|
2833 pSpellSprite.vPosition.y = v600;
|
|
2834 v676 = v603 + v602;
|
|
2835 v665 = v600;
|
|
2836 pSpellSprite.vPosition.z = v603 + v602;
|
|
2837 v657 = v601;
|
|
2838 pSpellSprite.uAttributes = 0;
|
|
2839 pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
|
|
2840 pSpellSprite.uSpriteFrameID = 0;
|
|
2841 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2842 pSpellSprite.spell_target_pid = a2;
|
|
2843 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
2844 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
2845 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
|
|
2846 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2847 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
|
|
2848 LODWORD(v727) = 1;
|
|
2849 break;
|
|
2850 }
|
|
2851 case SPELL_MIND_MASS_FEAR:
|
|
2852 {
|
|
2853 if ( v731 == 4 )
|
|
2854 amount = 300 * v2;
|
|
2855 else
|
|
2856 amount = 180 * v2;
|
|
2857 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2858 break;
|
|
2859 auto _v726 = sub_46A6AC((int)dword_50BF30.data(), 100, 4096);
|
|
2860 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u);
|
|
2861 ++pSpellSprite.uType;
|
|
2862 pSpellSprite.stru_24.Reset();
|
|
2863 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
2864 pSpellSprite.spell_level = v2;
|
|
2865 pSpellSprite.spell_skill = v731;
|
|
2866 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
2867 pSpellSprite.uAttributes = 0;
|
|
2868 pSpellSprite.uSectorID = 0;
|
|
2869 pSpellSprite.uSpriteFrameID = 0;
|
|
2870 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
2871 pSpellSprite.uFacing = 0;
|
|
2872 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
2873 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
2874 for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
|
|
2875 {
|
|
2876 v433 = &pActors[dword_50BF30[a2]];
|
|
2877 if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
|
|
2878 break;
|
|
2879 pSpellSprite.vPosition.x = v433->vPosition.x;
|
|
2880 pSpellSprite.vPosition.y = v433->vPosition.y;
|
|
2881 pSpellSprite.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548);
|
|
2882
|
|
2883 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
2884 pSpellSprite.Create(0, 0, 0, 0);
|
|
2885 if ( stru_50C198.GetMagicalResistance(v433, 7u) )
|
|
2886 {
|
|
2887 v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
|
|
2888 v731, 0, 0, 0);
|
|
2889 }
|
|
2890 }
|
|
2891 LODWORD(v727) = 1;
|
|
2892 break;
|
|
2893 }
|
|
2894 case SPELL_MIND_CURE_INSANITY:
|
|
2895 {
|
|
2896 v435 = v731 - 2;
|
|
2897 if ( v731 == 4 )
|
|
2898 amount = 0;
|
|
2899 else
|
|
2900 amount = 86400 * v2;
|
|
2901 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2902 break;
|
|
2903
|
|
2904 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
2905 v440 = pCastSpell->uPlayerID_2;
|
|
2906 if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) )
|
|
2907 {
|
|
2908 if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) )
|
|
2909 pParty->pPlayers[v440].PlaySound(SPEECH_25, 0);
|
|
2910 if ( v731 == 4 )
|
|
2911 {
|
|
2912 v441 = pCastSpell->uPlayerID_2;
|
|
2913 LODWORD(pParty->pPlayers[v441].pConditions[5]) = 0;
|
|
2914 HIDWORD(pParty->pPlayers[v441].pConditions[5]) = 0;
|
|
2915 }
|
|
2916 else
|
|
2917 {
|
|
2918 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u,
|
|
2919 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
|
|
2920 }
|
|
2921 v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
2922 v377->SetCondition(1, 0);
|
|
2923 }
|
|
2924 LODWORD(v727) = 1;
|
|
2925 break;
|
|
2926 }
|
|
2927 case SPELL_EARTH_TELEKINESIS:
|
|
2928 {
|
|
2929 switch (v731)
|
|
2930 {
|
|
2931 case 1: amount = 2 * v2; break;
|
|
2932 case 2: amount = 2 * v2; break;
|
|
2933 case 3: amount = 3 * v2; break;
|
|
2934 case 4: amount = 4 * v2; break;
|
|
2935 default:
|
|
2936 assert(false);
|
|
2937 }
|
|
2938 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
2939 break;
|
|
2940 v445 = PID_ID(a2);
|
|
2941 if (PID_TYPE(a2) == OBJECT_Item)
|
|
2942 {
|
|
2943 v449 = (char *)&pSpriteObjects[v445].stru_24;
|
|
2944 v450 = *(int *)v449;
|
|
2945 if ( pItemsTable->pItems[v450].uEquipType == 18 )
|
|
2946 {
|
|
2947 party_finds_gold(*((int *)v449 + 3), 0);
|
|
2948 viewparams->bRedrawGameUI = 1;
|
|
2949 }
|
|
2950 else
|
|
2951 {
|
|
2952 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName);
|
|
2953 ShowStatusBarString(pTmpBuf2.data(), 2u);
|
|
2954 if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) )
|
|
2955 pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24);
|
|
2956 }
|
|
2957 SpriteObject::OnInteraction(v445);
|
|
2958 }
|
|
2959 else
|
|
2960 {
|
|
2961 if (PID_TYPE(a2) == OBJECT_Actor)
|
|
2962 {
|
|
2963 stru_50C198.LootActor(&pActors[v445]);
|
|
2964 }
|
|
2965 else
|
|
2966 {
|
|
2967 if (PID_TYPE(a2) != OBJECT_Decoration)
|
|
2968 {
|
|
2969 if (PID_TYPE(a2) != OBJECT_BModel)
|
|
2970 {
|
|
2971 LODWORD(v727) = 1;
|
|
2972 break;
|
|
2973 }
|
|
2974 dword_507CD8 = 1;
|
|
2975 v677 = 1;
|
|
2976 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
2977 v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID;
|
|
2978 else
|
|
2979 v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID;
|
|
2980 EventProcessor(v446, a2, v677);
|
|
2981 LODWORD(v727) = 1;
|
|
2982 break;
|
|
2983 }
|
|
2984 v447 = &pLevelDecorations[v445];
|
|
2985 dword_507CD8 = 1;
|
|
2986 v448 = v447->field_16_event_id;
|
|
2987 if (v448)
|
|
2988 {
|
|
2989 v677 = 1;
|
|
2990 v446 = v448;
|
|
2991 EventProcessor(v446, a2, v677);
|
|
2992 LODWORD(v727) = 1;
|
|
2993 break;
|
|
2994 }
|
|
2995 if ( v447->IsInteractive() )
|
|
2996 {
|
|
2997 activeLevelDecoration = v447;
|
|
2998 EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1);
|
|
2999 activeLevelDecoration = NULL;
|
|
3000 }
|
|
3001 }
|
|
3002 }
|
|
3003 LODWORD(v727) = 1;
|
|
3004 break;
|
|
3005 }
|
|
3006 case SPELL_BODY_CURE_WEAKNESS:
|
|
3007 {
|
|
3008 switch (v731)
|
|
3009 {
|
|
3010 case 1: amount = 180 * v2; break;
|
|
3011 case 2: amount = 3600 * v2; break;
|
|
3012 case 3: amount = 86400 * v2; break;
|
|
3013 case 4: amount = 0; break;
|
|
3014 default:
|
|
3015 assert(false);
|
|
3016 }
|
|
3017 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3018 break;
|
|
3019
|
|
3020 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3021 v323 = pCastSpell->uPlayerID_2;
|
|
3022 v324 = (char *)&pParty->pPlayers[v323].pConditions[1];
|
|
3023 if ( !pParty->pPlayers[v323].pConditions[1] )
|
|
3024 {
|
|
3025 LODWORD(v727) = 1;
|
|
3026 break;
|
|
3027 }
|
|
3028 if ( v731 == 4 )
|
|
3029 {
|
|
3030 *(int *)v324 = 0;
|
|
3031 *((int *)v324 + 1) = 0;
|
|
3032 LODWORD(v727) = 1;
|
|
3033 break;
|
|
3034 }
|
|
3035 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
|
|
3036 v656 = 1;
|
|
3037 v325 = &pParty->pPlayers[v323];
|
|
3038 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
3039 LODWORD(v727) = 1;
|
|
3040 break;
|
|
3041 }
|
|
3042 case SPELL_BODY_FIRST_AID:
|
|
3043 {
|
|
3044 switch (v731)
|
|
3045 {
|
|
3046 case 1: amount = 2 * v2 + 5; break;
|
|
3047 case 2: amount = 3 * v2 + 5; break;
|
|
3048 case 3: amount = 4 * v2 + 5; break;
|
|
3049 case 4: amount = 5 * v2 + 5; break;
|
|
3050 default:
|
|
3051 assert(false);
|
|
3052 }
|
|
3053 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3054 break;
|
|
3055 v460 = pCastSpell->spell_target_pid;
|
|
3056 if (!v460)
|
|
3057 {
|
|
3058 pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount);
|
|
3059 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3060 }
|
|
3061 else
|
|
3062 {
|
|
3063 if (PID_TYPE(v460) == OBJECT_Actor)
|
|
3064 {
|
|
3065 v461 = &pActors[PID_ID(v460)];
|
|
3066 v462 = v461->uAIState;
|
|
3067 v463 = v461->pMonsterInfo.uHP;
|
|
3068 if ( v462 != 5 )
|
|
3069 {
|
|
3070 if ( v462 != 4 )
|
|
3071 {
|
|
3072 if ( v462 != 19 )
|
|
3073 {
|
|
3074 if ( v462 != 11 )
|
|
3075 {
|
|
3076 v461->sCurrentHP += amount;
|
|
3077 if ( v461->sCurrentHP > v463 )
|
|
3078 v461->sCurrentHP = v463;
|
|
3079 }
|
|
3080 }
|
|
3081 }
|
|
3082 }
|
|
3083 }
|
|
3084 }
|
|
3085 LODWORD(v727) = 1;
|
|
3086 break;
|
|
3087 }
|
|
3088 case SPELL_BODY_CURE_POISON:
|
|
3089 {
|
|
3090 switch (v731)
|
|
3091 {
|
|
3092 case 1: amount = 3600 * v2; break;
|
|
3093 case 2: amount = 3600 * v2; break;
|
|
3094 case 3: amount = 86400 * v2; break;
|
|
3095 case 4: amount = 0; break;
|
|
3096 default:
|
|
3097 assert(false);
|
|
3098 }
|
|
3099 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3100 break;
|
|
3101
|
|
3102 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3103 v470 = pCastSpell->uPlayerID_2;
|
|
3104 if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6]))
|
|
3105 && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8]))
|
|
3106 && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) )
|
|
3107 {
|
|
3108 LODWORD(v727) = 1;
|
|
3109 break;
|
|
3110 }
|
|
3111 if ( v731 == 4 )
|
|
3112 {
|
|
3113 LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0;
|
|
3114 HIDWORD(pParty->pPlayers[v470].pConditions[6]) = 0;
|
|
3115 v471 = pCastSpell->uPlayerID_2;
|
|
3116 LODWORD(pParty->pPlayers[v471].pConditions[8]) = 0;
|
|
3117 HIDWORD(pParty->pPlayers[v471].pConditions[8]) = 0;
|
|
3118 v472 = pCastSpell->uPlayerID_2;
|
|
3119 LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0;
|
|
3120 HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0;
|
|
3121 LODWORD(v727) = 1;
|
|
3122 break;
|
|
3123 }
|
|
3124 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
|
|
3125 pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan(
|
|
3126 6u,
|
|
3127 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
3128 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
|
|
3129 8u,
|
|
3130 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
3131 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
|
|
3132 v656 = 10;
|
|
3133 v325 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
3134 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
3135 LODWORD(v727) = 1;
|
|
3136 break;
|
|
3137 }
|
|
3138 case SPELL_BODY_PROTECTION_FROM_MAGIC:
|
|
3139 {
|
|
3140 amount = v2;
|
|
3141 LODWORD(v733) = 3600 * v2;
|
|
3142 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3143 break;
|
|
3144
|
|
3145 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
3146 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
3147 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
3148 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
3149
|
|
3150 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0);
|
|
3151 LODWORD(v727) = 1;
|
|
3152 break;
|
|
3153 }
|
|
3154 case SPELL_BODY_HAMMERHANDS:
|
|
3155 {
|
|
3156 LODWORD(v733) = 3600 * v2;
|
|
3157 amount = v2;
|
|
3158 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3159 break;
|
|
3160 if ( v731 == 4 )
|
|
3161 {
|
|
3162 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
3163 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
3164 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
3165 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
3166 v732 = (int)v733 << 7;
|
|
3167 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
3168 pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0);
|
|
3169 pParty->pPlayers[1].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0);
|
|
3170 pParty->pPlayers[2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0);
|
|
3171
|
|
3172 pParty->pPlayers[3].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4, v2, v2, 0);
|
|
3173 LODWORD(v727) = 1;
|
|
3174 break;
|
|
3175 }
|
|
3176 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3177
|
|
3178 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0);
|
|
3179 LODWORD(v727) = 1;
|
|
3180 break;
|
|
3181 }
|
|
3182 case SPELL_BODY_CURE_DISEASE:
|
|
3183 {
|
|
3184 if ( v731 == 4 )
|
|
3185 amount = 0;
|
|
3186 else
|
|
3187 amount = 86400 * v2;
|
|
3188 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3189 break;
|
|
3190
|
|
3191 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3192 v498 = pCastSpell->uPlayerID_2;
|
|
3193 if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7]))
|
|
3194 && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9]))
|
|
3195 && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) )
|
|
3196 {
|
|
3197 LODWORD(v727) = 1;
|
|
3198 break;
|
|
3199 }
|
|
3200 if ( v731 == 4 )
|
|
3201 {
|
|
3202 LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0;
|
|
3203 HIDWORD(pParty->pPlayers[v498].pConditions[7]) = 0;
|
|
3204 v499 = pCastSpell->uPlayerID_2;
|
|
3205 LODWORD(pParty->pPlayers[v499].pConditions[9]) = 0;
|
|
3206 HIDWORD(pParty->pPlayers[v499].pConditions[9]) = 0;
|
|
3207 v500 = pCastSpell->uPlayerID_2;
|
|
3208 LODWORD(pParty->pPlayers[v500].pConditions[11]) = 0;
|
|
3209 HIDWORD(pParty->pPlayers[v500].pConditions[11]) = 0;
|
|
3210 }
|
|
3211 else
|
|
3212 {
|
|
3213 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
|
|
3214 pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan(
|
|
3215 7u,
|
|
3216 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
3217 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
|
|
3218 9u,
|
|
3219 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
|
|
3220 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
|
|
3221 v656 = 11;
|
|
3222 v325 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
3223 v325->DiscardConditionIfLastsLongerThan(v656, v663);
|
|
3224 }
|
|
3225 LODWORD(v727) = 1;
|
|
3226 break;
|
|
3227 }
|
|
3228 case SPELL_BODY_POWER_CURE:
|
|
3229 {
|
|
3230 amount = 5 * v2 + 10;
|
|
3231 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3232 break;
|
|
3233 v501 = pParty->pPlayers;
|
|
3234 int v1 = 0;
|
|
3235 do
|
|
3236 {
|
|
3237 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v1);
|
|
3238 v501->Heal(amount);
|
|
3239 ++v501;
|
|
3240 ++v1;
|
|
3241 }
|
|
3242 while ( (signed int)v501 < (signed int)pParty->pHirelings );
|
|
3243 LODWORD(v727) = 1;
|
|
3244 break;
|
|
3245 }
|
|
3246 case SPELL_LIGHT_DISPEL_MAGIC:
|
|
3247 {
|
|
3248 sRecoveryTime -= v2;
|
|
3249 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3250 break;
|
|
3251
|
|
3252 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u);
|
|
3253 v505 = sub_46A6AC((int)dword_50BF30.data(), 100, 4096);
|
|
3254 ++pSpellSprite.uType;
|
|
3255 //signed int _v733 = v505;
|
|
3256 v688.x = 0;
|
|
3257 v688.y = 0;
|
|
3258 v688.z = 0;
|
|
3259 pSpellSprite.stru_24.Reset();
|
|
3260 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3261 pSpellSprite.spell_level = v2;
|
|
3262 pSpellSprite.spell_skill = v731;
|
|
3263 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3264 pSpellSprite.uAttributes = 0;
|
|
3265 pSpellSprite.uSectorID = 0;
|
|
3266 pSpellSprite.uSpriteFrameID = 0;
|
|
3267 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
3268 pSpellSprite.uFacing = 0;
|
|
3269 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3270 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3271 a2 = 0;
|
|
3272 for ( a2 = 0; a2 < v505; ++a2 )
|
|
3273 {
|
|
3274 v507 = dword_50BF30[a2];
|
|
3275 pSpellSprite.vPosition.x = pActors[v507].vPosition.x;
|
|
3276 pSpellSprite.vPosition.y = pActors[v507].vPosition.y;
|
|
3277 pSpellSprite.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548);
|
|
3278 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
3279 v509 = pSpellSprite.Create(0, 0, 0, 0);
|
|
3280 DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], &v688);
|
|
3281 }
|
|
3282 for ( a2 = 0; a2 < v505; ++a2 )
|
|
3283 {
|
|
3284 pActor = &pActors[dword_50BF30[a2]];
|
|
3285 pSpellSprite.vPosition.x = pActor->vPosition.x;
|
|
3286 pSpellSprite.vPosition.y = pActor->vPosition.y;
|
|
3287 pSpellSprite.vPosition.z = pActor->vPosition.z - (unsigned int)(signed __int64)((double)pActor->uActorHeight * unk_4D8548);
|
|
3288 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
3289 pSpellSprite.Create(0, 0, 0, 0);
|
|
3290 for (int i = 0; i < 22; ++i)
|
|
3291 {
|
|
3292 pActor->pActorBuffs[i].Reset();
|
|
3293 }
|
|
3294 }
|
|
3295 LODWORD(v727) = 1;
|
|
3296 break;
|
|
3297 }
|
|
3298 case SPELL_LIGHT_SUMMON_ELEMENTAL:
|
|
3299 {
|
|
3300 switch (v731)
|
|
3301 {
|
|
3302 case 1: v733 = 300 * v2; amount = 1; break;
|
|
3303 case 2: v733 = 300 * v2; amount = 1; break;
|
|
3304 case 3: v733 = 900 * v2; amount = 3; break;
|
|
3305 case 4: v733 = 900 * v2; amount = 5; break;
|
|
3306 default:
|
|
3307 assert(false);
|
|
3308 }
|
|
3309 //v733 = __PAIR__(0, v516);
|
|
3310 signed int _v733 = 0;
|
|
3311 if ( (signed int)uNumActors > 0 )
|
|
3312 {
|
|
3313 v518 = pActors.data();//[0].uAIState;
|
|
3314 auto _v726 = uNumActors;
|
|
3315 do
|
|
3316 {
|
|
3317 v519 = v518->uAIState;
|
|
3318 if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, pCastSpell->uPlayerID) == v518->uSummonerID )
|
|
3319 ++_v733;
|
|
3320 ++v518;
|
|
3321 --_v726;
|
|
3322 }
|
|
3323 while ( _v726 != 0 );
|
|
3324 }
|
|
3325 if ( _v733 >= amount )
|
|
3326 {
|
|
3327 ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters!
|
|
3328 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3329 pCastSpell->spellnum = 0;
|
|
3330 continue;
|
|
3331 }
|
|
3332 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3333 break;
|
|
3334 sub_44FA4C_spawn_light_elemental(pCastSpell->uPlayerID, v731, v733);
|
|
3335 LODWORD(v727) = 1;
|
|
3336 break;
|
|
3337 }
|
|
3338 case SPELL_LIGHT_DAY_OF_THE_GODS:
|
|
3339 {
|
|
3340 switch (v731)
|
|
3341 {
|
|
3342 case 1: LODWORD(v733) = 10800 * v2; amount = 3 * v2 + 10; break;
|
|
3343 case 2: LODWORD(v733) = 10800 * v2; amount = 3 * v2 + 10; break;
|
|
3344 case 3: LODWORD(v733) = 14400 * v2; amount = 4 * v2 + 10; break;
|
|
3345 case 4: LODWORD(v733) = 18000 * v2; amount = 5 * v2 + 10; break;
|
|
3346 default:
|
|
3347 assert(false);
|
|
3348 }
|
|
3349 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3350 break;
|
|
3351
|
|
3352 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
3353 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
3354 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
3355 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
3356
|
|
3357 pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0);
|
|
3358 LODWORD(v727) = 1;
|
|
3359 break;
|
|
3360 }
|
|
3361 case SPELL_LIGHT_PRISMATIC_LIGHT:
|
|
3362 {
|
|
3363 //v67 = 2;
|
|
3364 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
3365 {
|
|
3366 ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors!
|
|
3367 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3368 pCastSpell->spellnum = 0;
|
|
3369 continue;
|
|
3370 }
|
|
3371 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3372 break;
|
|
3373 v531 = sub_46A6AC((int)dword_50BF30.data(), 100, 4096);
|
|
3374 ++pSpellSprite.uType;
|
|
3375 v694.x = 0;
|
|
3376 v694.y = 0;
|
|
3377 v694.z = 0;
|
|
3378 pSpellSprite.stru_24.Reset();
|
|
3379 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3380 pSpellSprite.spell_level = v2;
|
|
3381 pSpellSprite.spell_skill = v731;
|
|
3382 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3383 pSpellSprite.uAttributes = 0;
|
|
3384 pSpellSprite.uSectorID = 0;
|
|
3385 pSpellSprite.uSpriteFrameID = 0;
|
|
3386 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
3387 pSpellSprite.uFacing = 0;
|
|
3388 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3389 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3390 a2 = 0;
|
|
3391 if ( (signed int)v531 > 0 )
|
|
3392 {
|
|
3393 do
|
|
3394 {
|
|
3395 v533 = dword_50BF30[a2];
|
|
3396 pSpellSprite.vPosition.x = pActors[v533].vPosition.x;
|
|
3397 pSpellSprite.vPosition.y = pActors[v533].vPosition.y;
|
|
3398 pSpellSprite.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548);
|
|
3399 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
3400 v535 = pSpellSprite.Create(0, 0, 0, 0);
|
|
3401 v536 = a2;
|
|
3402 DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694);
|
|
3403 a2 = v536 + 1;
|
|
3404 }
|
|
3405 while ( v536 + 1 < (signed int)v531 );
|
|
3406 }
|
|
3407 v537 = pGame->GetStru6();
|
|
3408 pGame->GetStru6()->_4A8BFC();
|
|
3409 LODWORD(v727) = 1;
|
|
3410 break;
|
|
3411 }
|
|
3412 case SPELL_LIGHT_DAY_OF_PROTECTION:
|
|
3413 {
|
|
3414 switch (v731)
|
|
3415 {
|
|
3416 case 1: LODWORD(v733) = 14400 * v2; amount = 4 * v2; break;
|
|
3417 case 2: LODWORD(v733) = 14400 * v2; amount = 4 * v2; break;
|
|
3418 case 3: LODWORD(v733) = 14400 * v2; amount = 4 * v2; break;
|
|
3419 case 4: LODWORD(v733) = 18000 * v2; amount = 5 * v2; break;
|
|
3420 default:
|
|
3421 assert(false);
|
|
3422 }
|
|
3423 v730 = LODWORD(v733);
|
|
3424 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3425 break;
|
|
3426
|
|
3427 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
3428 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
3429 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
3430 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
3431
|
|
3432 v732 = v730 << 7;
|
|
3433 v549 = (double)(v730 << 7) * 0.033333335;
|
|
3434 *((float *)&v733 + 1) = v549;
|
|
3435 v712 = (signed __int64)v549;
|
|
3436 pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + (signed __int64)v549, v731, amount, 0, 0);
|
|
3437 pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0);
|
|
3438 pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0);
|
|
3439 pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0);
|
|
3440 pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0);
|
|
3441 pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v712, v731, amount, 0, 0);
|
|
3442 v550 = v2 + 5;
|
|
3443 pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(
|
|
3444 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
|
|
3445 v731,
|
|
3446 v550, 0, 0);
|
|
3447
|
|
3448 pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v550, 0, 0);
|
|
3449 LODWORD(v727) = 1;
|
|
3450 break;
|
|
3451 }
|
|
3452 case SPELL_LIGHT_HOUR_OF_POWER:
|
|
3453 {
|
|
3454 switch (v731)
|
|
3455 {
|
|
3456 case 1: LODWORD(v733) = 4; amount = 4; break;
|
|
3457 case 2: LODWORD(v733) = 4; amount = 4; break;
|
|
3458 case 3: LODWORD(v733) = 12; amount = 12; break;
|
|
3459 case 4: LODWORD(v733) = 20; amount = 15; break;
|
|
3460 default:
|
|
3461 assert(false);
|
|
3462 }
|
|
3463 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3464 break;
|
|
3465 y = (char *)(60 * (v2 * LODWORD(v733) + 60));
|
|
3466 v732 = (300 * amount * v2 + 60) << 7;
|
|
3467 v730 = v2 + 5;
|
|
3468 int _v726 = 0;
|
|
3469 v553 = pParty->pPlayers;//[0].pConditions[1];
|
|
3470 *((float *)&v733) = (double)v732 * 0.033333335;
|
|
3471 do
|
|
3472 {
|
|
3473 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
|
|
3474 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
|
|
3475 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
|
|
3476 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
|
|
3477
|
|
3478 //((SpellBuff *)(v553 + 6056))->Apply(
|
|
3479 v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0);
|
|
3480 if ( *(_QWORD *)v553 )
|
|
3481 _v726 = 1;
|
|
3482 ++v553;
|
|
3483 }
|
|
3484 while ( v553 <= &pParty->pPlayers[3] );
|
|
3485 v562 = v731;
|
|
3486 pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0);
|
|
3487 pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v562, 0, 0, 0);
|
|
3488 pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v562, v730, 0, 0);
|
|
3489 if (!_v726)
|
|
3490 {
|
|
3491 pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0);
|
|
3492 }
|
|
3493 LODWORD(v727) = 1;
|
|
3494 break;
|
|
3495 }
|
|
3496 case SPELL_LIGHT_DIVINE_INTERVENTION:
|
|
3497 {
|
|
3498 amount = 3;
|
|
3499 if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u )
|
|
3500 {
|
|
3501 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
3502 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3503 pCastSpell->spellnum = 0;
|
|
3504 continue;
|
|
3505 }
|
|
3506 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3507 break;
|
|
3508 a2 = 0;
|
|
3509 _this = (ItemGen *)&pPlayers[1];
|
|
3510 do
|
|
3511 {
|
|
3512 v563 = 0;
|
|
3513 do
|
|
3514 {
|
|
3515 v564 = _this->uItemID;
|
|
3516 *(int *)(v563 + _this->uItemID) = 0;
|
|
3517 v563 += 8;
|
|
3518 *(int *)(v563 + v564 - 4) = 0;
|
|
3519 }
|
|
3520 while ( v563 <= 128 );
|
|
3521 v565 = ((Player *)_this->uItemID)->GetMaxHealth();
|
|
3522 v566 = (Player **)_this;
|
|
3523 *(int *)(_this->uItemID + 6460) = v565;
|
|
3524 v567 = (*v566)->GetMaxMana();
|
|
3525 *(int *)(_this->uItemID + 6464) = v567;
|
|
3526 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
|
|
3527 ++a2;
|
|
3528 _this = (ItemGen *)((char *)_this + 4);
|
|
3529 }
|
|
3530 while ( (signed int)this < (signed int)&qword_A750D8 );
|
|
3531 v571 = pPlayer;
|
|
3532 v572 = (char *)&pPlayer->sAgeModifier;
|
|
3533 if ( pPlayer->sAgeModifier + 10 >= 120 )
|
|
3534 *(short *)v572 = 120;
|
|
3535 else
|
|
3536 *(short *)v572 = pPlayer->sAgeModifier + 10;
|
|
3537 sRecoveryTime += -5 * v2;
|
|
3538 ++v571->uNumDivineInterventionCastsThisDay;
|
|
3539 LODWORD(v727) = 1;
|
|
3540 break;
|
|
3541 }
|
|
3542 case SPELL_DARK_REANIMATE:
|
|
3543 {
|
|
3544 switch (v731)
|
|
3545 {
|
|
3546 case 1: amount = 2 * v2; break;
|
|
3547 case 2: amount = 3 * v2; break;
|
|
3548 case 3: amount = 4 * v2; break;
|
|
3549 case 4: amount = 5 * v2; break;
|
|
3550 default:
|
|
3551 assert(false);
|
|
3552 }
|
|
3553 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3554 break;
|
|
3555 v576 = pCastSpell->spell_target_pid;
|
|
3556 if (!v576)
|
|
3557 {
|
|
3558 v585 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2];
|
|
3559 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3560 if ( *((_QWORD *)v585 + 14) )
|
|
3561 {
|
|
3562 ((Player *)v585)->SetCondition(0x11u, 1);
|
|
3563 v587 = ((Player *)v585)->GetSexByVoice();
|
|
3564 ReloadPlayerPortraits(pCastSpell->uPlayerID_2, (v587 != 0) + 23);
|
|
3565 *((_QWORD *)v585 + 17) = pParty->uTimePlayed;
|
|
3566 }
|
|
3567 break;
|
|
3568 }
|
|
3569 v577 = (Player *)(PID_ID(v576));
|
|
3570 //v726 = v577;
|
|
3571 if ( v577 == (Player *)-1 )
|
|
3572 {
|
|
3573 ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists!
|
|
3574 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3575 pCastSpell->spellnum = 0;
|
|
3576 continue;
|
|
3577 }
|
|
3578 v578 = (int)&pActors[(int)v577];
|
|
3579 v721 = v578;
|
|
3580 if ( *(short *)(v578 + 40) > 0 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 )
|
|
3581 {
|
|
3582 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
3583 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3584 pCastSpell->spellnum = 0;
|
|
3585 continue;
|
|
3586 }
|
|
3587 ++pSpellSprite.uType;
|
|
3588 pSpellSprite.stru_24.Reset();
|
|
3589 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3590 pSpellSprite.spell_level = v2;
|
|
3591 pSpellSprite.spell_skill = v731;
|
|
3592 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3593 pSpellSprite.uAttributes = 0;
|
|
3594 pSpellSprite.uSectorID = 0;
|
|
3595 pSpellSprite.uSpriteFrameID = 0;
|
|
3596 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
3597 v581 = v721;
|
|
3598 pSpellSprite.uFacing = 0;
|
|
3599 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3600 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3601 pSpellSprite.vPosition.x = *(short *)(v721 + 142);
|
|
3602 pSpellSprite.vPosition.y = *(short *)(v721 + 144);
|
|
3603 v732 = *(short *)(v721 + 138);
|
|
3604 pSpellSprite.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
|
|
3605 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v577);
|
|
3606 pSpellSprite.Create(0, 0, 0, 0);
|
|
3607 if ( *(char *)(v581 + 52) > amount )
|
|
3608 break;
|
|
3609 Actor::Resurrect((unsigned int)v577);
|
|
3610 *(char *)(v581 + 61) = 0;
|
|
3611 *(char *)(v581 + 53) = 0;
|
|
3612 *(char *)(v581 + 54) = 0;
|
|
3613 *(char *)(v581 + 55) = 0;
|
|
3614 *(char *)(v581 + 56) = 0;
|
|
3615 *(char *)(v581 + 57) = 0;
|
|
3616 *(int *)(v581 + 712) = 9999;
|
|
3617 *(char *)(v581 + 38) &= 0xF7u;
|
|
3618 *(int *)(v581 + 708) = 0;
|
|
3619 ((SpellBuff *)(v581 + 356))->Reset();
|
|
3620 ((SpellBuff *)(v581 + 228))->Reset();
|
|
3621 ((SpellBuff *)(v581 + 404))->Reset();
|
|
3622 if ( *(short *)(v581 + 40) > 10 * amount )
|
|
3623 *(short *)(v581 + 40) = 10 * amount;
|
|
3624 LODWORD(v727) = 1;
|
|
3625 break;
|
|
3626 }
|
|
3627 case SPELL_DARK_VAMPIRIC_WEAPON:
|
|
3628 {
|
|
3629 amount = 16;
|
|
3630 if ( v731 == 4 )
|
|
3631 {
|
|
3632 LODWORD(v733) = 0;
|
|
3633 }
|
|
3634 else
|
|
3635 {
|
|
3636 LODWORD(v733) = 3600 * v2;
|
|
3637 }
|
|
3638 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3639 break;
|
|
3640 __debugbreak();
|
|
3641 //HIDWORD(v733) = (int)(char *)&pParty + 6972 * pCastSpell->uPlayerID_2 + 36 * a2 + 3040;
|
|
3642 ItemGen *_v733 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2];
|
|
3643 ItemDesc *_v732 = &pItemsTable->pItems[_v733->uItemID];
|
|
3644 _v733->UpdateTempBonus(pParty->uTimePlayed);
|
|
3645 if ( _v733->uItemID >= 64 && _v733->uItemID <= 65
|
|
3646 || LOBYTE(_v733->uAttributes) & 2
|
|
3647 || _v733->uSpecEnchantmentType != 0
|
|
3648 || _v733->uEnchantmentType != 0
|
|
3649 || (v591 = _v732->uEquipType) != 0 && v591 != 1 && v591 != 2
|
|
3650 || pItemsTable->IsMaterialNonCommon(_v733) )
|
|
3651 {
|
|
3652 dword_50C9D0 = 113;
|
|
3653 dword_50C9D4 = 0;
|
|
3654 dword_50C9D8 = 1;
|
|
3655
|
|
3656 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
3657 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3658 pCastSpell->spellnum = 0;
|
|
3659 continue;
|
|
3660 }
|
|
3661 v592 = _v733;
|
|
3662 v14 = v731 == 4;
|
|
3663 _v733->uSpecEnchantmentType = 16;
|
|
3664 if ( !v14 )
|
|
3665 {
|
|
3666 v732 = (int)v733 << 7;
|
|
3667 v592->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
3668 v592->uAttributes |= 8u;
|
|
3669 }
|
|
3670 LOBYTE(v592->uAttributes) |= 0x80u;
|
|
3671 _50C9A8_item_enchantment_timer = 256;
|
|
3672 LODWORD(v727) = 1;
|
|
3673 break;
|
|
3674 }
|
|
3675 case SPELL_DARK_SHARPMETAL:
|
|
3676 {
|
|
3677 switch (v731)
|
|
3678 {
|
|
3679 case 1: amount = 5; break;
|
|
3680 case 2: amount = 5; break;
|
|
3681 case 3: amount = 7; break;
|
|
3682 case 4: amount = 9; break;
|
|
3683 default:
|
|
3684 assert(false);
|
|
3685 }
|
|
3686 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3687 break;
|
|
3688 auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360);
|
|
3689 pSpellSprite.stru_24.Reset();
|
|
3690 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3691 pSpellSprite.spell_level = v2;
|
|
3692 pSpellSprite.spell_skill = v731;
|
|
3693 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3694 pSpellSprite.vPosition.x = pParty->vPosition.x;
|
|
3695 pSpellSprite.vPosition.y = pParty->vPosition.y;
|
|
3696 pSpellSprite.uAttributes = 0;
|
|
3697 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
|
|
3698 pSpellSprite.uSectorID = pIndoor->GetSector(
|
|
3699 pParty->vPosition.x,
|
|
3700 pParty->vPosition.y,
|
|
3701 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
|
|
3702 pSpellSprite.uSpriteFrameID = 0;
|
|
3703 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3704 pSpellSprite.spell_target_pid = a2;
|
|
3705 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
3706 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3707 if ( pParty->bTurnBasedModeOn == 1 )
|
|
3708 LOBYTE(pSpellSprite.uAttributes) |= 4u;
|
|
3709 v596 = (signed int)_v726 / -2;
|
|
3710 y = (char *)((signed int)_v726 / 2);
|
|
3711 if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 )
|
|
3712 {
|
|
3713 v597 = v715.uYawAngle;
|
|
3714 do
|
|
3715 {
|
|
3716 pSpellSprite.uFacing = v596 + v597;
|
|
3717 if ( pSpellSprite.Create(
|
|
3718 v596 + v597,
|
|
3719 v715.uPitchAngle,
|
|
3720 pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
|
|
3721 pCastSpell->uPlayerID + 1) != -1
|
|
3722 && pParty->bTurnBasedModeOn == 1 )
|
|
3723 ++pTurnEngine->field_1C;
|
|
3724 v596 += _v726 / (amount - 1);
|
|
3725 }
|
|
3726 while ( v596 <= (signed int)y );
|
|
3727 }
|
|
3728 LODWORD(v727) = 1;
|
|
3729 break;
|
|
3730 }
|
|
3731 case SPELL_DARK_CONTROL_UNDEAD:
|
|
3732 {
|
|
3733 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3734 break;
|
|
3735 switch (v731)
|
|
3736 {
|
|
3737 case 1: LODWORD(v733) = 180 * v2; break;
|
|
3738 case 2: LODWORD(v733) = 180 * v2; break;
|
|
3739 case 3: LODWORD(v733) = 300 * v2; break;
|
|
3740 case 4: LODWORD(v733) = 29030400; break;
|
|
3741 default:
|
|
3742 assert(false);
|
|
3743 }
|
|
3744 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
3745 {
|
|
3746 LODWORD(v727) = 1;
|
|
3747 break;
|
|
3748 }
|
|
3749 pActor = &pActors[PID_ID(a2)];
|
|
3750 if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
|
|
3751 break;
|
|
3752 if ( !stru_50C198.GetMagicalResistance(pActor, 0xAu) )
|
|
3753 {
|
|
3754 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
3755 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3756 pCastSpell->spellnum = 0;
|
|
3757 continue;
|
|
3758 }
|
|
3759 pActor->pActorBuffs[9].Reset();
|
|
3760 pActor->pActorBuffs[1].Reset();
|
|
3761 pActor->pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
|
|
3762 v731, 0, 0, 0);
|
|
3763 pSpellSprite.stru_24.Reset();
|
|
3764 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3765 pSpellSprite.spell_level = v2;
|
|
3766 pSpellSprite.spell_skill = v731;
|
|
3767 v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3768
|
|
3769 v600 = pActor->vPosition.y;
|
|
3770 v601 = pActor->vPosition.x;
|
|
3771 pSpellSprite.uObjectDescID = v60;
|
|
3772 pSpellSprite.vPosition.x = v601;
|
|
3773 v602 = pActor->uActorHeight;
|
|
3774 v603 = pActor->vPosition.z;
|
|
3775 pSpellSprite.vPosition.y = v600;
|
|
3776 v676 = v603 + v602;
|
|
3777 v665 = v600;
|
|
3778 pSpellSprite.vPosition.z = v603 + v602;
|
|
3779 v657 = v601;
|
|
3780 pSpellSprite.uAttributes = 0;
|
|
3781 pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
|
|
3782 pSpellSprite.uSpriteFrameID = 0;
|
|
3783 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3784 pSpellSprite.spell_target_pid = a2;
|
|
3785 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
|
|
3786 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
|
|
3787 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
|
|
3788 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3789 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
|
|
3790 LODWORD(v727) = 1;
|
|
3791 break;
|
|
3792 }
|
|
3793 case SPELL_DARK_SACRIFICE:
|
|
3794 {
|
|
3795 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3796 break;
|
|
3797 int _v733 = 0;
|
|
3798 memset(&achieved_awards, 0, 4000);
|
|
3799 int i = 0;
|
|
3800 pNPCData = pParty->pHirelings;
|
|
3801 do
|
|
3802 {
|
|
3803 if ( pNPCData->pName != 0)
|
|
3804 {
|
|
3805 v606 = _v733++;
|
|
3806 achieved_awards[v606] = (AwardType)(i + 1);
|
|
3807 }
|
|
3808 ++i;
|
|
3809 ++pNPCData;
|
|
3810 }
|
|
3811 while ( pNPCData <= &pParty->pHirelings[1] );
|
|
3812 i = 0;
|
|
3813 if ( (signed int)pNPCStats->uNumNewNPCs > 0)
|
|
3814 {
|
|
3815 pNPCData = pNPCStats->pNewNPCData;
|
|
3816 //__debugbreak(); // data offset
|
|
3817 AwardType *_v734 = &achieved_awards[_v733];
|
|
3818 do
|
|
3819 {
|
|
3820 if ( pNPCData->uFlags & 0x80
|
|
3821 && (!pParty->pHirelings[0].pName || strcmp(pNPCData->pName, pParty->pHirelings[0].pName))
|
|
3822 && (!pParty->pHirelings[1].pName || strcmp(pNPCData->pName, pParty->pHirelings[1].pName)) )
|
|
3823 {
|
|
3824 v607 = _v734;
|
|
3825 ++_v734;
|
|
3826 *v607 = (AwardType)(i + 3);
|
|
3827 }
|
|
3828 ++i;
|
|
3829 ++pNPCData;
|
|
3830 }
|
|
3831 while ( (signed int)i < (signed int)pNPCStats->uNumNewNPCs );
|
|
3832 }
|
|
3833 v608 = pCastSpell->uPlayerID_2;
|
|
3834 if ( v608 != 4 && v608 != 5
|
|
3835 || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0)
|
|
3836 || v609 >= 3 )
|
|
3837 {
|
|
3838 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
3839 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3840 pCastSpell->spellnum = 0;
|
|
3841 continue;
|
|
3842 }
|
|
3843 v610 = 76 * v609;
|
|
3844 //*((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0;
|
|
3845 pParty->pHirelings[v609-1].evt_B = 0;
|
|
3846 v611 = pIconsFrameTable->FindIcon("spell96");
|
|
3847 //*(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + v610 + 4) = pIconsFrameTable->GetIconAnimLength(v611);
|
|
3848 pParty->pHirelings[v609-1].evt_C = pIconsFrameTable->GetIconAnimLength(v611);
|
|
3849 //*(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[3].field_18 + v610) = 1;
|
|
3850 pParty->pHirelings[v609-1].evt_A = 1;
|
|
3851
|
|
3852 v612 = pParty->pPlayers;
|
|
3853 do
|
|
3854 {
|
|
3855 v612->sHealth = v612->GetMaxHealth();
|
|
3856 v612->sMana = v612->GetMaxMana();
|
|
3857 ++v612;
|
|
3858 }
|
|
3859 while ( v612 <= &pParty->pPlayers[3] );
|
|
3860 v613 = &pOutdoor->ddm;
|
|
3861 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
|
|
3862 v613 = &pIndoor->dlv;
|
|
3863 v613->uReputation += 15;
|
|
3864 if ( v613->uReputation > 10000 )
|
|
3865 v613->uReputation = 10000;
|
|
3866 LODWORD(v727) = 1;
|
|
3867 break;
|
|
3868 }
|
|
3869 case SPELL_DARK_PAIN_REFLECTION:
|
|
3870 {
|
|
3871 switch (v731)
|
|
3872 {
|
|
3873 case 1: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
3874 case 2: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
3875 case 3: LODWORD(v733) = 300 * (v2 + 12); break;
|
|
3876 case 4: LODWORD(v733) = 900 * (v2 + 4); break;
|
|
3877 default:
|
|
3878 assert(false);
|
|
3879 }
|
|
3880 amount = v2 + 5;
|
|
3881 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3882 break;
|
|
3883 if ( v731 != 3 && v731 != 4 )
|
|
3884 {
|
|
3885 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
|
|
3886 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v716, 0);
|
|
3887 LODWORD(v727) = 1;
|
|
3888 break;
|
|
3889 }
|
|
3890 a2 = 0;
|
|
3891 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
|
|
3892 v619 = pParty->pPlayers;//[0].pPlayerBuffs[10];
|
|
3893 do
|
|
3894 {
|
|
3895 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
|
|
3896 v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0);
|
|
3897 ++a2;
|
|
3898 ++v619;
|
|
3899 }
|
|
3900 while ( v619 <= &pParty->pPlayers[3] );
|
|
3901 LODWORD(v727) = 1;
|
|
3902 break;
|
|
3903 }
|
|
3904 case SPELL_DARK_SOULDRINKER:
|
|
3905 {
|
|
3906 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
3907 break;
|
|
3908 pGame->GetIndoorCamera();
|
|
3909 v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth();
|
|
3910 signed int _v733 = sub_46A6AC((int)dword_50BF30.data(), 100, v623);
|
|
3911 v707.x = 0;
|
|
3912 v707.y = 0;
|
|
3913 v707.z = 0;
|
|
3914 pSpellSprite.stru_24.Reset();
|
|
3915 pSpellSprite.spell_id = pCastSpell->spellnum;
|
|
3916 pSpellSprite.spell_level = v2;
|
|
3917 pSpellSprite.spell_skill = v731;
|
|
3918 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
|
|
3919 pSpellSprite.uAttributes = 0;
|
|
3920 pSpellSprite.uSectorID = 0;
|
|
3921 pSpellSprite.uSpriteFrameID = 0;
|
|
3922 pSpellSprite.field_60_distance_related_prolly_lod = 0;
|
|
3923 pSpellSprite.uFacing = 0;
|
|
3924 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
|
|
3925 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
|
|
3926 a2 = 0;
|
|
3927 int _v726 = 0;
|
|
3928 if ( _v733 > 0 )
|
|
3929 {
|
|
3930 _v726 = (_v733 * (7 * v2 + 25));
|
|
3931 do
|
|
3932 {
|
|
3933 v625 = dword_50BF30[a2];
|
|
3934 pSpellSprite.vPosition.x = pActors[v625].vPosition.x;
|
|
3935 pSpellSprite.vPosition.y = pActors[v625].vPosition.y;
|
|
3936 //v732 = pActors[v625].uActorHeight;
|
|
3937 pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548);
|
|
3938 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
|
|
3939 v627 = pSpellSprite.Create(0, 0, 0, 0);
|
|
3940 v628 = a2;
|
|
3941 DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707);
|
|
3942 a2 = v628 + 1;
|
|
3943 }
|
|
3944 while ( v628 + 1 < _v733 );
|
|
3945 }
|
|
3946 v730 = 0;
|
|
3947 v629 = 1;
|
|
3948 do
|
|
3949 {
|
|
3950 v630 = pPlayers[v629];
|
|
3951 if ( !v630->pConditions[2]
|
|
3952 && !v630->pConditions[12]
|
|
3953 && !v630->pConditions[13]
|
|
3954 && !v630->pConditions[14]
|
|
3955 && !v630->pConditions[15]
|
|
3956 && !v630->pConditions[16] )
|
|
3957 {
|
|
3958 v631 = v730++;
|
|
3959 v681[v631] = v629;
|
|
3960 }
|
|
3961 ++v629;
|
|
3962 }
|
|
3963 while ( v629 <= 4 );
|
|
3964 v732 = (signed __int64)((double)(signed int)_v726 / (double)v730);
|
|
3965 _v733 = 0;
|
|
3966 if ( v730 > 0 )
|
|
3967 {
|
|
3968 do
|
|
3969 {
|
|
3970 //v632 = 4 * v681[HIDWORD(v733)] + 10965188;
|
|
3971 v726 = pPlayers[v681[_v733]];
|
|
3972 //v633 = pPlayers[v681[HIDWORD(v733)]];
|
|
3973 v726->sHealth += v732;
|
|
3974 //v726 = *(Player **)v632;
|
|
3975 //v634 = v726->GetMaxHealth();
|
|
3976 if ( v726->sHealth > v726->GetMaxHealth())
|
|
3977 v726->sHealth = v726->GetMaxHealth();
|
|
3978 v635 = _v733;
|
|
3979
|
|
3980 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733));
|
|
3981 _v733 = v635 + 1;
|
|
3982 }
|
|
3983 while ( v635 + 1 < v730 );
|
|
3984 }
|
|
3985 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 0x40u);
|
|
3986 LODWORD(v727) = 1;
|
|
3987 break;
|
|
3988 }
|
|
3989 case SPELL_DARK_ARMAGEDDON:
|
|
3990 {
|
|
3991 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
3992 {
|
|
3993 ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors!
|
|
3994 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
3995 pCastSpell->spellnum = 0;
|
|
3996 continue;
|
|
3997 }
|
|
3998 if ( v731 == 4)
|
|
3999 amount = 4;
|
|
4000 else
|
|
4001 amount = 3;
|
|
4002 if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 )
|
|
4003 {
|
|
4004 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
|
|
4005 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
|
|
4006 pCastSpell->spellnum = 0;
|
|
4007 continue;
|
|
4008 }
|
|
4009 if ( !pPlayer->CanCastSpell(uRequiredMana) )
|
|
4010 break;
|
|
4011 pParty->armageddon_timer = 256;
|
|
4012 pParty->field_16140 = v2;
|
|
4013 ++pPlayer->uNumArmageddonCasts;
|
|
4014 if ( pParty->bTurnBasedModeOn == 1 )
|
|
4015 ++pTurnEngine->field_1C;
|
|
4016 auto _v726 = 50;
|
|
4017 do
|
|
4018 {
|
|
4019 v642 = rand() % 4096 - 2048;
|
|
4020 v643 = rand();
|
|
4021 v721 = v642 + pParty->vPosition.x;
|
|
4022 y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048);
|
|
4023 v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, &v710, 0);
|
|
4024 v644 = rand();
|
|
4025 sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0);
|
|
4026 --_v726;
|
|
4027 }
|
|
4028 while ( _v726 != 0 );
|
|
4029 LODWORD(v727) = 1;
|
|
4030 break;
|
|
4031 }
|
|
4032
|
|
4033 default:
|
|
4034 break;
|
|
4035 }
|
|
4036 if ( pCastSpell->field_8 & 0x20 )
|
|
4037 {
|
|
4038 if ( v727 != 0.0 )
|
|
4039 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0);
|
|
4040 }
|
|
4041 else
|
|
4042 {
|
|
4043 if ( sRecoveryTime < 0 )
|
|
4044 sRecoveryTime = 0;
|
|
4045 if ( pParty->bTurnBasedModeOn )
|
|
4046 {
|
|
4047 v645 = sRecoveryTime;
|
|
4048 pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime;
|
|
4049 pPlayer->SetRecoveryTime(v645);
|
|
4050 if ( !some_active_character )
|
|
4051 pTurnEngine->_40471C();
|
|
4052 }
|
|
4053 else
|
|
4054 {
|
|
4055 pPlayer->SetRecoveryTime(
|
|
4056 (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
|
|
4057 }
|
|
4058 if ( v727 != 0.0 )
|
|
4059 {
|
|
4060 pPlayer->PlaySound(SPEECH_49, 0);
|
|
4061 if ( v727 != 0.0 )
|
|
4062 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0);
|
|
4063 }
|
|
4064 }
|
|
4065 pCastSpell->spellnum = 0;
|
|
4066 v2 = v723;
|
|
4067 continue;
|
|
4068 }
|
|
4069
|
|
4070 }
|
|
4071 //----- (00427DA0) --------------------------------------------------------
|
|
4072 unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id)
|
|
4073 {
|
|
4074 unsigned int result; // eax@1
|
|
4075 CastSpellInfo *v7; // edx@1
|
|
4076 CastSpellInfo *v8; // ecx@5
|
|
4077
|
|
4078 result = 0;
|
|
4079 v7 = this;
|
|
4080 while ( v7->spellnum )
|
|
4081 {
|
|
4082 ++result;
|
|
4083 ++v7;
|
|
4084 if ( (signed int)result >= 10 )
|
|
4085 goto LABEL_8;
|
|
4086 }
|
|
4087 v8 = &this[result];
|
|
4088 v8->spellnum = a2;
|
|
4089 v8->uPlayerID = uPlayerID;
|
|
4090 if ( a5 & 0x10 )
|
|
4091 v8->uPlayerID_2 = uPlayerID;
|
|
4092 v8->field_6 = 0;
|
|
4093 v8->spell_target_pid = 0;
|
|
4094 v8->field_8 = a5;
|
|
4095 v8->forced_spell_skill_level = skill_level;
|
|
4096 v8->sound_id = spell_sound_id;
|
|
4097 LABEL_8:
|
|
4098 if ( result == 10 )
|
|
4099 result = -1;
|
|
4100 return result;
|
|
4101 }
|
|
4102 //----- (00427D48) --------------------------------------------------------
|
|
4103 void CastSpellInfo::_427D48(unsigned int uPlayerID)
|
|
4104 {
|
|
4105 CastSpellInfo *v2; // esi@1
|
|
4106 signed int v3; // ebx@1
|
|
4107
|
|
4108 v2 = this;
|
|
4109 v3 = 10;
|
|
4110 do
|
|
4111 {
|
|
4112 if ( v2->spellnum )
|
|
4113 {
|
|
4114 if ( v2->field_8 & 0x3CA )
|
|
4115 {
|
|
4116 v2->spellnum = 0;
|
|
4117 pGUIWindow_Settings->Release();
|
|
4118 pGUIWindow_Settings = 0;
|
|
4119 pMouse->SetCursorBitmap("MICON1");
|
|
4120 GameUI_Footer_TimeLeft = 0;
|
|
4121 unk_50C9A0 = 0;
|
|
4122 back_to_game();
|
|
4123 }
|
|
4124 }
|
|
4125 ++v2;
|
|
4126 --v3;
|
|
4127 }
|
|
4128 while ( v3 );
|
|
4129 }
|
|
4130 //----- (0042777D) --------------------------------------------------------
|
|
4131 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6)
|
|
4132 {
|
|
4133 //bool result; // eax@2
|
|
4134 //__int16 v6; // bx@4
|
|
4135 //Player *v7; // eax@4
|
|
4136 //char v8; // zf@12
|
|
4137 unsigned __int16 v9; // cx@16
|
|
4138 unsigned int v10; // eax@18
|
|
4139 unsigned __int8 v11; // sf@18
|
|
4140 unsigned __int8 v12; // of@18
|
|
4141 unsigned __int16 v13; // cx@21
|
|
4142 unsigned int v14; // eax@23
|
|
4143 //stru277 *v15; // esi@27
|
|
4144 //stru277 *v16; // eax@28
|
|
4145 //GUIWindow *v17; // eax@43
|
|
4146 //GUIWindow *v18; // [sp-30h] [bp-48h]@44
|
|
4147 //unsigned int v19; // [sp-2Ch] [bp-44h]@44
|
|
4148 //unsigned int v20; // [sp-28h] [bp-40h]@44
|
|
4149 //unsigned int v21; // [sp-24h] [bp-3Ch]@44
|
|
4150 //unsigned int v22; // [sp-20h] [bp-38h]@44
|
|
4151 //int v23; // [sp-1Ch] [bp-34h]@44
|
|
4152 //int v24; // [sp-18h] [bp-30h]@44
|
|
4153 //unsigned int v25; // [sp-14h] [bp-2Ch]@43
|
|
4154 //unsigned int v26; // [sp-10h] [bp-28h]@43
|
|
4155 //unsigned __int8 v27; // [sp-Ch] [bp-24h]@43
|
|
4156 //char *v28; // [sp-8h] [bp-20h]@43
|
|
4157 //Texture *v29; // [sp-4h] [bp-1Ch]@43
|
|
4158 //__int16 a3a; // [sp+10h] [bp-8h]@1
|
|
4159 //__int16 a2a; // [sp+14h] [bp-4h]@1
|
|
4160
|
|
4161 //a3a = uPlayerID;
|
|
4162 //a2a = a1;
|
|
4163
|
|
4164 //if ( pParty->bTurnBasedModeOn != 1
|
|
4165 // || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 )
|
|
4166 if (pParty->bTurnBasedModeOn)
|
|
4167 {
|
|
4168 if (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3)
|
|
4169 return;
|
|
4170 }
|
|
4171
|
|
4172
|
|
4173 //v6 = a5;
|
|
4174 //v7 = &pParty->pPlayers[uPlayerID];
|
|
4175 assert(uPlayerID < 4);
|
|
4176 auto player = &pParty->pPlayers[uPlayerID];
|
|
4177 if ( !(a5 & 0x10) )
|
|
4178 {
|
|
4179 switch ( a1 )
|
|
4180 {
|
|
4181 case SPELL_SPIRIT_FATE:
|
|
4182 case SPELL_BODY_FIRST_AID:
|
|
4183 case SPELL_DARK_REANIMATE:
|
|
4184 //HIBYTE(v6) = HIBYTE(a5) | 1;
|
|
4185 a5 |= 0x0100;
|
|
4186 break;
|
|
4187
|
|
4188 case SPELL_FIRE_FIRE_AURA:
|
|
4189 case SPELL_WATER_RECHARGE_ITEM:
|
|
4190 case SPELL_WATER_ENCHANT_ITEM:
|
|
4191 case SPELL_DARK_VAMPIRIC_WEAPON:
|
|
4192 //LOBYTE(v6) = a5 | 0x80;
|
|
4193 a5 |= 0x0080;
|
|
4194 break;
|
|
4195
|
|
4196 case SPELL_FIRE_FIRE_BOLT:
|
|
4197 case SPELL_FIRE_FIREBALL:
|
|
4198 case SPELL_FIRE_INCINERATE:
|
|
4199 case SPELL_AIR_LIGHNING_BOLT:
|
|
4200 case SPELL_AIR_IMPLOSION:
|
|
4201 case SPELL_WATER_POISON_SPRAY:
|
|
4202 case SPELL_WATER_ICE_BOLT:
|
|
4203 case SPELL_WATER_ACID_BURST:
|
|
4204 case SPELL_WATER_ICE_BLAST:
|
|
4205 case SPELL_EARTH_STUN:
|
|
4206 case SPELL_EARTH_SLOW:
|
|
4207 case SPELL_EARTH_DEADLY_SWARM:
|
|
4208 case SPELL_EARTH_BLADES:
|
|
4209 case SPELL_EARTH_MASS_DISTORTION:
|
|
4210 case SPELL_SPIRIT_SPIRIT_LASH:
|
|
4211 case SPELL_MIND_MIND_BLAST:
|
|
4212 case SPELL_MIND_CHARM:
|
|
4213 case SPELL_MIND_PSYCHIC_SHOCK:
|
|
4214 case SPELL_BODY_HARM:
|
|
4215 case SPELL_BODY_FLYING_FIST:
|
|
4216 case SPELL_LIGHT_LIGHT_BOLT:
|
|
4217 case SPELL_LIGHT_DESTROY_UNDEAD:
|
|
4218 case SPELL_LIGHT_SUNRAY:
|
|
4219 case SPELL_DARK_TOXIC_CLOUD:
|
|
4220 case SPELL_DARK_SHRINKING_RAY:
|
|
4221 case SPELL_DARK_SHARPMETAL:
|
|
4222 case SPELL_DARK_DRAGON_BREATH:
|
|
4223 if ( !a6 )
|
|
4224 a5 |= 0x0008;
|
|
4225 break;
|
|
4226 case SPELL_MIND_TELEPATHY:
|
|
4227 case SPELL_MIND_BERSERK:
|
|
4228 case SPELL_MIND_ENSLAVE:
|
|
4229 case SPELL_LIGHT_PARALYZE:
|
|
4230 case SPELL_DARK_CONTROL_UNDEAD:
|
|
4231 //LABEL_9:
|
|
4232 //v6 = a5 | 8;
|
|
4233 a5 |= 0x0008;
|
|
4234 break;
|
|
4235
|
|
4236 case SPELL_EARTH_TELEKINESIS:
|
|
4237 a5 |= 0x0040;
|
|
4238 break;
|
|
4239
|
|
4240 case SPELL_SPIRIT_BLESS:
|
|
4241 if (a4 && ~a4 & 0x01C0)
|
|
4242 //goto LABEL_25;
|
|
4243 {
|
|
4244 a5 |= 0x0002;
|
|
4245 break;
|
|
4246 }
|
|
4247 else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0)
|
|
4248 //goto LABEL_25;
|
|
4249 {
|
|
4250 a5 |= 0x0002;
|
|
4251 break;
|
|
4252 }
|
|
4253 break;
|
|
4254
|
|
4255 case SPELL_SPIRIT_PRESERVATION:
|
|
4256 v9 = a4;
|
|
4257 if ( !a4 )
|
|
4258 v9 = player->pActiveSkills[PLAYER_SKILL_SPIRIT];
|
|
4259 //goto LABEL_18;
|
|
4260 v10 = SkillToMastery(v9);
|
|
4261 v12 = __OFSUB__(v10, 3);
|
|
4262 v11 = ((v10 - 3) & 0x80000000u) != 0;
|
|
4263 //goto LABEL_24;
|
|
4264 if ( v11 ^ v12 )
|
|
4265 {
|
|
4266 a5 |= 0x0002;
|
|
4267 break;
|
|
4268 }
|
|
4269 break;
|
|
4270
|
|
4271 case SPELL_DARK_PAIN_REFLECTION:
|
|
4272 v9 = a4;
|
|
4273 if ( !a4 )
|
|
4274 v9 = player->pActiveSkills[PLAYER_SKILL_DARK];
|
|
4275 //LABEL_18:
|
|
4276 v10 = SkillToMastery(v9);
|
|
4277 v12 = __OFSUB__(v10, 3);
|
|
4278 v11 = ((v10 - 3) & 0x80000000u) != 0;
|
|
4279 //goto LABEL_24;
|
|
4280 if ( v11 ^ v12 )
|
|
4281 {
|
|
4282 a5 |= 0x0002;
|
|
4283 break;
|
|
4284 }
|
|
4285 break;
|
|
4286
|
|
4287 case SPELL_BODY_HAMMERHANDS:
|
|
4288 v13 = a4;
|
|
4289 if ( !a4 )
|
|
4290 v13 = player->pActiveSkills[PLAYER_SKILL_BODY];
|
|
4291 v14 = SkillToMastery(v13);
|
|
4292 v12 = __OFSUB__(v14, 4);
|
|
4293 v11 = ((v14 - 4) & 0x80000000u) != 0;
|
|
4294 //LABEL_24:
|
|
4295 if ( v11 ^ v12 )
|
|
4296 //goto LABEL_25;
|
|
4297 {
|
|
4298 a5 |= 0x0002;
|
|
4299 break;
|
|
4300 }
|
|
4301 break;
|
|
4302
|
|
4303 case SPELL_EARTH_STONE_TO_FLESH:
|
|
4304 case SPELL_SPIRIT_REMOVE_CURSE:
|
|
4305 case SPELL_SPIRIT_RAISE_DEAD:
|
|
4306 case SPELL_SPIRIT_RESSURECTION:
|
|
4307 case SPELL_MIND_REMOVE_FEAR:
|
|
4308 case SPELL_MIND_CURE_PARALYSIS:
|
|
4309 case SPELL_MIND_CURE_INSANITY:
|
|
4310 case SPELL_BODY_CURE_WEAKNESS:
|
|
4311 case SPELL_BODY_REGENERATION:
|
|
4312 case SPELL_BODY_CURE_POISON:
|
|
4313 case SPELL_BODY_CURE_DISEASE:
|
|
4314 //LABEL_25:
|
|
4315 //v6 = a5 | 2;
|
|
4316 a5 |= 0x0002;
|
|
4317 break;
|
|
4318
|
|
4319 case SPELL_DARK_SACRIFICE:
|
|
4320 //HIBYTE(v6) = HIBYTE(a5) | 2;
|
|
4321 a5 |= 0x0200;
|
|
4322 break;
|
|
4323 default:
|
|
4324 break;
|
|
4325 }
|
|
4326 }
|
|
4327
|
|
4328
|
|
4329 if (a5 & 0x3CA)
|
|
4330 {
|
|
4331 assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10);
|
|
4332 for (uint i = 0; i < 10; ++i)
|
|
4333 if (pCastSpellInfo[i].field_8 & 0x3CA)
|
|
4334 {
|
|
4335 pCastSpellInfo[i].spellnum = 0;
|
|
4336 break;
|
|
4337 }
|
|
4338 }
|
|
4339
|
|
4340 assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10);
|
|
4341 for (uint i = 0; i < 10; ++i)
|
|
4342 {
|
|
4343 auto spell = &pCastSpellInfo[i];
|
|
4344 if (!spell->spellnum)
|
|
4345 continue;
|
|
4346
|
|
4347 spell->spellnum = 0;
|
|
4348 if (spell->field_8 & 0x3CA)
|
|
4349 {
|
|
4350 pGUIWindow_Settings->Release();
|
|
4351 pGUIWindow_Settings = nullptr;
|
|
4352 pMouse->SetCursorBitmap("MICON1");
|
|
4353 GameUI_Footer_TimeLeft = 0;
|
|
4354 unk_50C9A0 = 0;
|
|
4355 back_to_game();
|
|
4356 }
|
|
4357 }
|
|
4358
|
|
4359 int result = pCastSpellInfo.data()->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6);
|
|
4360 if ( result != -1 )
|
|
4361 {
|
|
4362 if ( a5 & 2 )
|
|
4363 {
|
|
4364 if ( pGUIWindow_Settings )
|
|
4365 return;
|
|
4366 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
|
|
4367 pGUIWindow_Settings->CreateButton(52, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 0, 49, "", 0);
|
|
4368 pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0);
|
|
4369 pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0);
|
|
4370 pGUIWindow_Settings->CreateButton(390, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 3, 52, "", 0);
|
|
4371 sub_421B2C_PlaceInInventory_or_DropPickedItem();
|
|
4372 return;
|
|
4373 }
|
|
4374 if ( a5 & 8 )
|
|
4375 {
|
|
4376 if ( pGUIWindow_Settings )
|
|
4377 return;
|
|
4378
|
|
4379 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
|
|
4380 pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0);
|
|
4381 sub_421B2C_PlaceInInventory_or_DropPickedItem();
|
|
4382 return;
|
|
4383 }
|
|
4384 if ( a5 & 0x40 )
|
|
4385 {
|
|
4386 if ( pGUIWindow_Settings )
|
|
4387 return;
|
|
4388
|
|
4389 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
|
1326
|
4390 pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0);
|
1296
|
4391 sub_421B2C_PlaceInInventory_or_DropPickedItem();
|
|
4392 return;
|
|
4393 }
|
|
4394 if ( (char)a5 < 0 )
|
|
4395 {
|
|
4396 if ( pGUIWindow_Settings )
|
|
4397 return;
|
|
4398 ++pIcons_LOD->uTexturePacksCount;
|
|
4399 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
4400 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
4401 pGUIWindow_Settings = pCastSpellInfo[result].sub_4219BE();
|
|
4402 unk_50C9A0 = 1;
|
|
4403 some_active_character = uActiveCharacter;
|
|
4404 sub_421B2C_PlaceInInventory_or_DropPickedItem();
|
|
4405 return;
|
|
4406 }
|
|
4407 if ( HIBYTE(a5) & 1 )
|
|
4408 {
|
|
4409 if ( pGUIWindow_Settings )
|
|
4410 return;
|
|
4411 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
|
|
4412 pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 0, 0x31u, "", 0);
|
|
4413 pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 1, 0x32u, "", 0);
|
|
4414 pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0);
|
|
4415 pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 3, 0x34u, "", 0);
|
|
4416 pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Monster_Improvement, 0, 0, "", NULL);
|
|
4417 sub_421B2C_PlaceInInventory_or_DropPickedItem();
|
|
4418 }
|
|
4419 if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings )
|
|
4420 {
|
|
4421 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
|
|
4422 pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178,
|
|
4423 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
|
|
4424 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
|
|
4425 1, 0, UIMSG_ScrollNPCPanel, 0, 0, "",
|
|
4426 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
|
|
4427 pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178,
|
|
4428 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth,
|
|
4429 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight,
|
|
4430 1, 0, UIMSG_ScrollNPCPanel, 1, 0, "",
|
|
4431 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
|
|
4432 pGUIWindow_Settings->CreateButton(491, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 4, 0x35u, "", 0);
|
|
4433 pGUIWindow_Settings->CreateButton(561, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 5, 0x36u, "", 0);
|
|
4434 }
|
|
4435 }
|
|
4436 }
|
|
4437
|
|
4438 const wchar_t *UIMessage2String(UIMessageType msg)
|
|
4439 {
|
|
4440 #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b;
|
|
4441 static wchar_t b[256]; // bad for threads
|
|
4442 switch (msg)
|
|
4443 {
|
|
4444 CASE(UIMSG_SelectSpell)
|
|
4445 CASE(UIMSG_ChangeGameState)
|
|
4446 CASE(UIMSG_Attack)
|
|
4447 CASE(UIMSG_PlayArcomage)
|
|
4448 CASE(UIMSG_MainMenu_ShowPartyCreationWnd)
|
|
4449 CASE(UIMSG_MainMenu_ShowLoadWindow)
|
|
4450 CASE(UIMSG_ShowCredits)
|
|
4451 CASE(UIMSG_ExitToWindows)
|
|
4452 CASE(UIMSG_PlayerCreationChangeName)
|
|
4453 CASE(UIMSG_PlayerCreationClickPlus)
|
|
4454 CASE(UIMSG_PlayerCreationClickMinus)
|
|
4455 CASE(UIMSG_PlayerCreationSelectActiveSkill)
|
|
4456 CASE(UIMSG_PlayerCreationSelectClass)
|
|
4457 CASE(UIMSG_PlayerCreationClickOK)
|
|
4458 CASE(UIMSG_PlayerCreationClickReset)
|
|
4459 CASE(UIMSG_ClickBooksBtn)
|
|
4460 CASE(UIMSG_PlayerCreationRemoveUpSkill)
|
|
4461 CASE(UIMSG_PlayerCreationRemoveDownSkill)
|
|
4462 CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo)
|
|
4463 CASE(UIMSG_LoadGame)
|
|
4464 CASE(UIMSG_SaveGame)
|
|
4465 CASE(UIMSG_ShowStatus_DateTime)
|
|
4466 CASE(UIMSG_ShowStatus_ManaHP)
|
|
4467 CASE(UIMSG_ShowStatus_Player)
|
|
4468 CASE(UIMSG_Wait5Minutes)
|
|
4469 CASE(UIMSG_Wait1Hour)
|
|
4470 CASE(UIMSG_ShowStatus_Food)
|
|
4471 CASE(UIMSG_ShowStatus_Funds)
|
|
4472 CASE(UIMSG_QuickReference)
|
|
4473 CASE(UIMSG_GameMenuButton)
|
|
4474 CASE(UIMSG_AlreadyResting)
|
|
4475 CASE(UIMSG_SelectCharacter)
|
|
4476 CASE(UIMSG_ChangeSoundVolume)
|
|
4477 CASE(UIMSG_ChangeMusicVolume)
|
|
4478 CASE(UIMSG_Escape)
|
|
4479 CASE(UIMSG_PlayerCreation_SelectAttribute)
|
|
4480 CASE(UIMSG_InventoryLeftClick)
|
|
4481 CASE(UIMSG_SkillUp)
|
|
4482 CASE(UIMSG_GameMenu_ReturnToGame)
|
|
4483 CASE(UIMSG_StartNewGame)
|
|
4484 CASE(UIMSG_Game_OpenLoadGameDialog)
|
|
4485 CASE(UIMSG_Game_OpenSaveGameDialog)
|
|
4486 CASE(UIMSG_Game_OpenOptionsDialog)
|
|
4487 CASE(UIMSG_SetGraphicsMode)
|
|
4488 CASE(UIMSG_Quit)
|
|
4489 CASE(UIMSG_StartHireling1Dialogue)
|
|
4490 CASE(UIMSG_StartHireling2Dialogue)
|
|
4491 CASE(UIMSG_SelectNPCDialogueOption)
|
|
4492 CASE(UIMSG_CastSpellFromBook)
|
|
4493 CASE(UIMSG_PlayerCreation_VoicePrev)
|
|
4494 CASE(UIMSG_PlayerCreation_VoiceNext)
|
|
4495 CASE(UIMSG_StartNPCDialogue)
|
|
4496 CASE(UIMSG_ArrowUp)
|
|
4497 CASE(UIMSG_DownArrow)
|
|
4498 CASE(UIMSG_SaveLoadBtn)
|
|
4499 CASE(UIMSG_SelectLoadSlot)
|
|
4500 CASE(UIMSG_Cancel)
|
|
4501 CASE(UIMSG_ExitRest)
|
|
4502 CASE(UIMSG_PlayerCreation_FacePrev)
|
|
4503 CASE(UIMSG_PlayerCreation_FaceNext)
|
|
4504 CASE(UIMSG_CycleCharacters)
|
|
4505 CASE(UIMSG_SetTurnSpeed)
|
|
4506 CASE(UIMSG_ToggleWalkSound)
|
|
4507 CASE(UIMSG_ChangeVoiceVolume)
|
|
4508 CASE(UIMSG_ToggleShowDamage)
|
|
4509 CASE(UIMSG_ScrollNPCPanel)
|
|
4510 CASE(UIMSG_ShowFinalWindow)
|
|
4511 CASE(UIMSG_OpenQuestBook)
|
|
4512 CASE(UIMSG_OpenAutonotes)
|
|
4513 CASE(UIMSG_OpenMapBook)
|
|
4514 CASE(UIMSG_OpenCalendar)
|
|
4515 CASE(UIMSG_OpenHistoryBook)
|
|
4516 CASE(UIMSG_ToggleAlwaysRun)
|
|
4517 CASE(UIMSG_ToggleFlipOnExit)
|
|
4518 CASE(UIMSG_Game_Action)
|
|
4519 CASE(UIMSG_RentRoom)
|
|
4520 CASE(UIMSG_TransitionUI_Confirm)
|
|
4521 CASE(UIMSG_OpenKeyMappingOptions)
|
|
4522 CASE(UIMSG_SelectKeyPage1)
|
|
4523 CASE(UIMSG_SelectKeyPage2)
|
|
4524 CASE(UIMSG_ResetKeyMapping)
|
|
4525 CASE(UIMSG_ChangeKeyButton)
|
|
4526 CASE(UIMSG_OpenVideoOptions)
|
|
4527 CASE(UIMSG_ToggleBloodsplats)
|
|
4528 CASE(UIMSG_ToggleColoredLights)
|
|
4529 CASE(UIMSG_ToggleTint)
|
|
4530 default:
|
|
4531 swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b;
|
|
4532 };
|
|
4533 #undef CASE
|
|
4534 } |