comparison Engine/Spells/CastSpellInfo.cpp @ 2499:68cdef6879a0

engine folder
author Ritor1
date Fri, 19 Sep 2014 02:57:42 +0600
parents
children 0ff6a9e9bf7f
comparison
equal deleted inserted replaced
2498:92eeeb5200f2 2499:68cdef6879a0
1 #define _CRTDBG_MAP_ALLOC
2 #include <stdlib.h>
3 #include <crtdbg.h>
4
5 #define _CRT_SECURE_NO_WARNINGS
6 #include "CastSpellInfo.h"
7 #include "../Objects/Actor.h"
8 #include "../Party.h"
9 #include "../MM7.h"
10 #include "Mouse.h"
11 #include "../../stru6.h"
12 #include "../Game.h"
13 #include "GUIWindow.h"
14 #include "AudioPlayer.h"
15 #include "../Graphics/Outdoor.h"
16 #include "../Graphics/Overlays.h"
17 #include "../Events.h"
18 #include "../Graphics/Viewport.h"
19 #include "../OurMath.h"
20 #include "../Objects/SpriteObject.h"
21 #include "../Objects/ObjectList.h"
22 #include "../stru123.h"
23 #include "../Timer.h"
24 #include "../Tables/IconFrameTable.h"
25 #include "../Awards.h"
26 #include "../TurnEngine/TurnEngine.h"
27 #include "../texts.h"
28 #include "../LOD.h"
29 #include "../Graphics/Level/Decoration.h"
30
31 #include "UI\UIPartyCreation.h"
32
33 const size_t CastSpellInfoCount = 10;
34 std::array<CastSpellInfo, CastSpellInfoCount> pCastSpellInfo;
35
36 //----- (00427E01) --------------------------------------------------------
37 void CastSpellInfoHelpers::_427E01_cast_spell()
38 {
39 int spell_level; // edi@1
40 CastSpellInfo *pCastSpell; // ebx@2
41 signed int v6; // eax@14
42 unsigned __int16 v11; // cx@45
43 signed int i; // esi@76
44 // Actor *pActor; // edi@177
45 int v61; // ecx@184
46 int v111; // eax@274
47 int dist_X; // eax@278
48 // int new_dist_Y;
49 int dist_Z;
50 // int v116; // edx@279
51 // int v117; // edx@281
52 // int v118; // edx@283
53 int v169; // eax@344
54 int v188; // esi@369
55 int v189; // edi@369
56 int v206; // eax@407
57 double v241; // st7@478
58 ItemGen *v245; // edi@492
59 int v258; // ecx@514
60 char v259; // al@516
61 int v260; // eax@518
62 int v261; // esi@519
63 int v262; // edx@521
64 int *v263; // ecx@521
65 int v264; // esi@521
66 int v265; // edx@521
67 int *ii; // eax@522
68 int v267; // eax@524
69 int v268; // eax@524
70 int v278; // ecx@548
71 char v279; // al@550
72 int v280; // eax@552
73 int *v281; // esi@553
74 int v282; // edx@555
75 int *v283; // ecx@555
76 int v284; // esi@555
77 int v285; // edx@555
78 int *l; // eax@556
79 int v295; // edx@575
80 char v313; // al@606pGame->GetStru6()
81 const char *v317; // ecx@617
82 // int v396; // eax@752
83 __int16 v448; // ax@864
84 DDM_DLV_Header *v613; // eax@1108
85 int v642; // edi@1156
86 int v643; // eax@1156
87 int v659; // [sp+0h] [bp-E84h]@123
88 unsigned __int64 v663; // [sp+0h] [bp-E84h]@639
89 int v666; // [sp+4h] [bp-E80h]@12
90 PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25
91 int v679[800]; // [sp+14h] [bp-E70h]@515
92 unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416
93 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327
94 Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943
95 Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137
96 Vec3_int_ v694; // [sp+D44h] [bp-140h]@982
97 Vec3_int_ v697; // [sp+D50h] [bp-134h]@129
98 Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339
99 Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286
100 Vec3_int_ v704; // [sp+D74h] [bp-110h]@132
101 Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127
102 int v710; // [sp+D8Ch] [bp-F8h]@1156
103 int n; // [sp+DA0h] [bp-E4h]@1
104 AIDirection v715; // [sp+DA4h] [bp-E0h]@21
105 int mon_id;
106 int dist_Y; // [sp+DD8h] [bp-ACh]@163
107 int v723; // [sp+E4Ch] [bp-38h]@1
108 ItemGen *_this; // [sp+E50h] [bp-34h]@23
109 int v725; // [sp+E54h] [bp-30h]@23
110 int buff_resist;
111 bool spell_sound_flag; // [sp+E5Ch] [bp-28h]@1
112 Player *pPlayer; // [sp+E64h] [bp-20h]@8
113 int v730; // [sp+E68h] [bp-1Ch]@53
114 ItemGen *v730c;
115 int skill_level; // [sp+E6Ch] [bp-18h]@48
116 signed int v732; // [sp+E70h] [bp-14h]@325
117 unsigned __int64 v733; // [sp+E74h] [bp-10h]@1
118 int duration;
119 signed int a2; // [sp+E7Ch] [bp-8h]@14
120 int amount; // [sp+E80h] [bp-4h]@1
121 int obj_type;
122 ItemDesc* _item;
123
124 SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1
125
126 spell_level = 0;
127 amount = 0;
128 LODWORD(v733) = 0;
129 v723 = 0;
130 spell_sound_flag = false;
131 for(n = 0; n < CastSpellInfoCount; ++n)
132 {
133 pCastSpell = &pCastSpellInfo[n];
134 HIDWORD(v733) = (int)pCastSpell;
135 if ( pCastSpell->uSpellID == 0 )
136 continue;
137
138 if (pParty->Invisible())
139 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
140
141 if ( pCastSpell->uFlags & 0x3CA )
142 {
143 if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() )
144 _427D48();
145 continue;
146 }
147 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
148
149 a2 = pCastSpell->spell_target_pid;
150 if (!pCastSpell->spell_target_pid)
151 {
152 if (pCastSpell->uSpellID == SPELL_LIGHT_DESTROY_UNDEAD ||
153 pCastSpell->uSpellID == SPELL_SPIRIT_TURN_UNDEAD ||
154 pCastSpell->uSpellID == SPELL_DARK_CONTROL_UNDEAD )
155 v666 = 1;
156 else
157 v666 = 0;
158
159 a2 = stru_50C198.FindClosestActor(5120, 1, v666);
160 v6 = pMouse->uPointingObjectID;
161 if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() )
162 a2 = pMouse->uPointingObjectID;
163 }
164
165
166 pSpellSprite.uType = stru_4E3ACC[pCastSpell->uSpellID].uType;
167 if (pSpellSprite.uType)
168 {
169 if (PID_TYPE(a2) == OBJECT_Actor)
170 {
171 Actor::GetDirectionInfo(PID(OBJECT_Player, pCastSpell->uPlayerID + 1), a2, &v715, 0);
172 spell_level = v723;
173 }
174 else
175 {
176 v715.uYawAngle = pParty->sRotationY;
177 v715.uPitchAngle = pParty->sRotationX;
178 }
179 }
180
181 v725 = 0;
182 _this = 0;
183 if (pCastSpell->forced_spell_skill_level)
184 {
185 v11 = pCastSpell->forced_spell_skill_level;
186 v723 = v11 & 0x3F; // 6 bytes
187 spell_level = v723;
188 }
189 else
190 {
191 //v667 = PLAYER_SKILL_STAFF;
192 if (pCastSpell->uSpellID < SPELL_AIR_WIZARD_EYE)
193 v667 = PLAYER_SKILL_FIRE;
194 else if (pCastSpell->uSpellID < SPELL_WATER_AWAKEN)
195 v667 = PLAYER_SKILL_AIR;
196 else if (pCastSpell->uSpellID < SPELL_EARTH_STUN)
197 v667 = PLAYER_SKILL_WATER;
198 else if (pCastSpell->uSpellID < SPELL_SPIRIT_DETECT_LIFE)
199 v667 = PLAYER_SKILL_EARTH;
200 else if (pCastSpell->uSpellID < SPELL_MIND_REMOVE_FEAR)
201 v667 = PLAYER_SKILL_SPIRIT;
202 else if (pCastSpell->uSpellID < SPELL_BODY_CURE_WEAKNESS)
203 v667 = PLAYER_SKILL_MIND;
204 else if (pCastSpell->uSpellID < SPELL_LIGHT_LIGHT_BOLT)
205 v667 = PLAYER_SKILL_BODY;
206 else if (pCastSpell->uSpellID < SPELL_DARK_REANIMATE)
207 v667 = PLAYER_SKILL_LIGHT;
208 else if (pCastSpell->uSpellID < SPELL_BOW_ARROW)
209 v667 = PLAYER_SKILL_DARK;
210 else if (pCastSpell->uSpellID == SPELL_BOW_ARROW)
211 v667 = PLAYER_SKILL_BOW;
212 else if (pCastSpell->uSpellID == SPELL_101 || pCastSpell->uSpellID == SPELL_LASER_PROJECTILE )
213 v667 = PLAYER_SKILL_BLASTER;
214 else assert(false && "Unknown spell");
215
216 v725 = v667;
217 v723 = pPlayer->GetActualSkillLevel(v667) & 0x3F;
218 spell_level = v723;
219 v11 = pPlayer->pActiveSkills[v725];
220 }
221
222 skill_level = SkillToMastery(v11);
223 if (pCastSpell->uSpellID < SPELL_BOW_ARROW )
224 {
225 if (pCastSpell->forced_spell_skill_level)
226 uRequiredMana = 0;
227 else
228 uRequiredMana = pSpellDatas[pCastSpell->uSpellID].mana_per_skill[skill_level - 1];
229 sRecoveryTime = pSpellDatas[pCastSpell->uSpellID].recovery_per_skill[skill_level - 1];
230 }
231
232 if (v725 == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 ||
233 v725 == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0)
234 uRequiredMana = 0;
235
236 if (pCastSpell->uSpellID < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana)
237 {
238 ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2); // "Not enough spell points"
239 pCastSpell->uSpellID = 0;
240 continue;
241 }
242 v730 = pCastSpell->uSpellID;
243 if (pPlayer->IsCursed() && pCastSpell->uSpellID < SPELL_BOW_ARROW && rand() % 100 < 50)//неудачное кастование
244 {
245 if (!pParty->bTurnBasedModeOn)
246 pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
247 else
248 {
249 pParty->pTurnBasedPlayerRecoveryTimes[pCastSpellInfo[n].uPlayerID] = 100;
250 pPlayer->SetRecoveryTime(sRecoveryTime);
251 pTurnEngine->ApplyPlayerAction();
252 }
253 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // "Spell failed"
254 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
255 pCastSpellInfo[n].uSpellID = 0;
256 pPlayer->sMana -= uRequiredMana;
257 return;
258 }
259
260 switch ( pCastSpell->uSpellID )
261 {
262 case SPELL_101:
263 assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
264 case SPELL_BOW_ARROW://стрельба из лука
265 {
266 amount = 1;
267 if ( SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
268 amount = 2;
269 sRecoveryTime = pPlayer->GetAttackRecoveryTime(true);
270 pSpellSprite.stru_24.Reset();
271 pSpellSprite.spell_level = spell_level;
272 pSpellSprite.spell_id = pCastSpell->uSpellID;
273 pSpellSprite.spell_skill = skill_level;
274 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
275 if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) )
276 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
277 pSpellSprite.vPosition.x = pParty->vPosition.x;
278 pSpellSprite.vPosition.y = pParty->vPosition.y;
279 pSpellSprite.uAttributes = 0;
280 pSpellSprite.uSpriteFrameID = 0;
281 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
282 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
283 pSpellSprite.spell_target_pid = a2;
284 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
285 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
286 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
287 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
288 memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24));
289 pSpellSprite.uAttributes = 256;
290 if ( pParty->bTurnBasedModeOn == 1 )
291 pSpellSprite.uAttributes = 260;
292 for ( i = 0; i < amount; ++i )
293 {
294 if ( i )
295 pSpellSprite.vPosition.z += 32;
296 pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
297 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
298 pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
299 ++pTurnEngine->pending_actions;
300 }
301 break;
302 }
303 case SPELL_LASER_PROJECTILE://стрельба из бластера
304 {
305 sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
306 pSpellSprite.stru_24.Reset();
307 pSpellSprite.spell_id = pCastSpell->uSpellID;
308 pSpellSprite.spell_level = v723;
309 pSpellSprite.spell_skill = skill_level;
310 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
311 pSpellSprite.vPosition.x = pParty->vPosition.x;
312 pSpellSprite.vPosition.y = pParty->vPosition.y;
313 pSpellSprite.uAttributes = 0;
314 pSpellSprite.uSpriteFrameID = 0;
315 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
316 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
317 pSpellSprite.spell_target_pid = a2;
318 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
319 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
320 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
321 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
322 memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uMainHand - 1],sizeof(pSpellSprite.stru_24));
323 // &pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
324 // * pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], );
325 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
326 HIBYTE(pSpellSprite.uAttributes) |= 1;
327 if ( pParty->bTurnBasedModeOn == 1 )
328 LOBYTE(pSpellSprite.uAttributes) |= 4;
329 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
330 pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
331 ++pTurnEngine->pending_actions;
332 break;
333 }
334 case SPELL_FIRE_TORCH_LIGHT://свет факела
335 {
336 switch (skill_level)
337 {
338 case 1: amount = 2; break;
339 case 2: amount = 3; break;
340 case 3:
341 case 4: amount = 4; break;
342 default:
343 assert(false);
344 }
345 if ( !pPlayer->CanCastSpell(uRequiredMana) )
346 break;
347 pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * spell_level * 4.2666669), skill_level, amount, 0, 0);
348 spell_sound_flag = true;
349 break;
350 }
351 case SPELL_FIRE_FIRE_SPIKE://огненный шип
352 {
353 switch (skill_level)
354 {
355 case 1: amount = 3; break;
356 case 2: amount = 5; break;
357 case 3: amount = 7; break;
358 case 4: amount = 9; break;
359 default:
360 assert(false);
361 }
362 int _v733 = 0;
363 for (uint i = 0; i < uNumSpriteObjects; ++i)
364 {
365 SpriteObject* object = &pSpriteObjects[i];
366 if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID))
367 ++_v733;
368 }
369 if ( _v733 > amount )
370 {
371 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
372 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
373 pCastSpell->uSpellID = 0;
374 continue;
375 }
376 if ( !pPlayer->CanCastSpell(uRequiredMana) )
377 break;
378 pSpellSprite.stru_24.Reset();
379 pSpellSprite.spell_id = pCastSpell->uSpellID;
380 pSpellSprite.spell_level = spell_level;
381 pSpellSprite.spell_skill = skill_level;
382 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
383 pSpellSprite.vPosition.y = pParty->vPosition.y;
384 pSpellSprite.vPosition.x = pParty->vPosition.x;
385 pSpellSprite.uAttributes = 0;
386 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
387 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
388 pSpellSprite.uSpriteFrameID = 0;
389 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
390 pSpellSprite.spell_target_pid = a2;
391 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
392 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
393 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
394 if ( pParty->bTurnBasedModeOn == 1 )
395 LOBYTE(pSpellSprite.uAttributes) |= 4;
396 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
397 if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
398 ++pTurnEngine->pending_actions;
399 spell_sound_flag = true;
400 break;
401 }
402 case SPELL_AIR_IMPLOSION://Точный взрыв
403 {
404 mon_id = PID_ID(a2);
405 if ( !pPlayer->CanCastSpell(uRequiredMana) )
406 break;
407 if (!a2)
408 {
409 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
410 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
411 pCastSpell->uSpellID = 0;
412 continue;
413 }
414 if (PID_TYPE(a2) == OBJECT_Actor)
415 {
416 v697.x = 0;
417 v697.y = 0;
418 v697.z = 0;
419 pSpellSprite.stru_24.Reset();
420 pSpellSprite.spell_id = pCastSpell->uSpellID;
421 pSpellSprite.spell_level = spell_level;
422 pSpellSprite.spell_skill = skill_level;
423 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
424 pSpellSprite.uAttributes = 0;
425 pSpellSprite.uSectorID = 0;
426 pSpellSprite.uSpriteFrameID = 0;
427 pSpellSprite.field_60_distance_related_prolly_lod = 0;
428 pSpellSprite.uFacing = 0;
429 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
430 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
431 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
432 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z;
433 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
434 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id);
435 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v697);
436 }
437 spell_sound_flag = true;
438 break;
439 }
440 case SPELL_EARTH_MASS_DISTORTION://Изменение веса
441 {
442 mon_id = PID_ID(a2);
443 if ( !pPlayer->CanCastSpell(uRequiredMana) )
444 break;
445 if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) )
446 {
447 pActors[mon_id].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
448 v704.x = 0;
449 v704.y = 0;
450 v704.z = 0;
451 pSpellSprite.stru_24.Reset();
452 pSpellSprite.spell_id = pCastSpell->uSpellID;
453 pSpellSprite.spell_level = spell_level;
454 pSpellSprite.spell_skill = skill_level;
455 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
456 pSpellSprite.uAttributes = 0;
457 pSpellSprite.uSectorID = 0;
458 pSpellSprite.uSpriteFrameID = 0;
459 pSpellSprite.field_60_distance_related_prolly_lod = 0;
460 pSpellSprite.uFacing = 0;
461 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
462 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
463 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
464 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
465 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z;
466 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id);
467 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v704);
468 }
469 spell_sound_flag = true;
470 break;
471 }
472 case SPELL_LIGHT_DESTROY_UNDEAD://Уничтожение нежити
473 {
474 if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor)
475 break;
476 //v730 = a2 >> 3;
477 //HIDWORD(v733) = (int)&pActors[PID_ID(a2)];
478 v691.x = 0;
479 v691.y = 0;
480 v691.z = 0;
481 pSpellSprite.stru_24.Reset();
482 pSpellSprite.spell_id = pCastSpell->uSpellID;
483 pSpellSprite.spell_level = spell_level;
484 pSpellSprite.spell_skill = skill_level;
485 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
486 pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
487 pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
488 pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
489 pSpellSprite.uAttributes = 0;
490 pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
491 pSpellSprite.uSpriteFrameID = 0;
492 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
493 pSpellSprite.spell_target_pid = a2;
494 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
495 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
496 pSpellSprite.uAttributes |= 0x80u;
497 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
498 int obj_id = pSpellSprite.Create(0, 0, 0, 0);
499 if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
500 {
501 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
502 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
503 pCastSpell->uSpellID = 0;
504 continue;
505 }
506 Actor::DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691);
507 spell_sound_flag = true;
508 break;
509 }
510 case SPELL_FIRE_FIRE_BOLT://Удар огня
511 case SPELL_FIRE_FIREBALL://Огненный шар
512 case SPELL_FIRE_INCINERATE://Испепеление
513 case SPELL_AIR_LIGHNING_BOLT://Удар молнии
514 case SPELL_WATER_ICE_BOLT://Льдяная молния
515 case SPELL_WATER_ICE_BLAST://Льдяной взрыв
516 case SPELL_EARTH_STUN://Оглушить
517 case SPELL_EARTH_DEADLY_SWARM://Рой смерти
518 case SPELL_MIND_MIND_BLAST://Удар мысли
519 case SPELL_MIND_PSYCHIC_SHOCK://Психический шок
520 case SPELL_BODY_HARM://Вред
521 case SPELL_LIGHT_LIGHT_BOLT://Луч света
522 case SPELL_DARK_DRAGON_BREATH://Дыхание дракона
523 {
524 if ( !pPlayer->CanCastSpell(uRequiredMana) )
525 break;
526 pSpellSprite.stru_24.Reset();
527 pSpellSprite.spell_id = pCastSpell->uSpellID;
528 pSpellSprite.spell_level = spell_level;
529 pSpellSprite.spell_skill = skill_level;
530 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
531 pSpellSprite.vPosition.y = pParty->vPosition.y;
532 pSpellSprite.vPosition.x = pParty->vPosition.x;
533 pSpellSprite.uAttributes = 0;
534 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
535 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
536 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
537 else
538 pSpellSprite.uSectorID = 0;
539 pSpellSprite.uSpriteFrameID = 0;
540 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
541 pSpellSprite.spell_target_pid = a2;
542 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
543 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
544 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
545 if ( pParty->bTurnBasedModeOn == 1 )
546 LOBYTE(pSpellSprite.uAttributes) |= 4;
547 if ( pCastSpell->uSpellID == SPELL_AIR_LIGHNING_BOLT )
548 LOBYTE(pSpellSprite.uAttributes) |= 0x40;
549 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
550 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
551 ++pTurnEngine->pending_actions;
552 spell_sound_flag = true;
553 break;
554 }
555 case SPELL_WATER_ACID_BURST://Всплеск кислоты
556 case SPELL_EARTH_BLADES://Лезвия
557 case SPELL_BODY_FLYING_FIST://Летающий кулак
558 case SPELL_DARK_TOXIC_CLOUD://Облако-токсин
559 {
560 if ( !pPlayer->CanCastSpell(uRequiredMana) )
561 break;
562 pSpellSprite.stru_24.Reset();
563 pSpellSprite.spell_id = pCastSpell->uSpellID;
564 pSpellSprite.spell_level = spell_level;
565 pSpellSprite.spell_skill = skill_level;
566 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
567 pSpellSprite.uAttributes = 0;
568 pSpellSprite.vPosition.x = pParty->vPosition.x;
569 pSpellSprite.vPosition.y = pParty->vPosition.y;
570 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
571 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
572 pSpellSprite.uSpriteFrameID = 0;
573 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
574 pSpellSprite.spell_target_pid = a2;
575 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
576 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
577 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
578 if ( pParty->bTurnBasedModeOn == 1 )
579 LOBYTE(pSpellSprite.uAttributes) |= 4;
580 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
581 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
582 ++pTurnEngine->pending_actions;
583 spell_sound_flag = true;
584 break;
585 }
586 case SPELL_LIGHT_SUNRAY://Луч Солнца
587 {
588 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
589 || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 21) )//только в дневное время
590 {
591 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
592 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
593 pCastSpell->uSpellID = 0;
594 continue;
595 }
596 if ( pPlayer->CanCastSpell(uRequiredMana) )
597 {
598 pSpellSprite.stru_24.Reset();
599 pSpellSprite.spell_id = pCastSpell->uSpellID;
600 pSpellSprite.spell_skill = skill_level;
601 pSpellSprite.spell_level = spell_level;
602 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
603 pSpellSprite.uAttributes = 0;
604 pSpellSprite.vPosition.x = pParty->vPosition.x;
605 pSpellSprite.vPosition.y = pParty->vPosition.y;
606 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
607 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
608 pSpellSprite.uSpriteFrameID = 0;
609 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
610 pSpellSprite.spell_target_pid = a2;
611 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
612 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
613 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
614 if ( pParty->bTurnBasedModeOn == 1 )
615 LOBYTE(pSpellSprite.uAttributes) |= 4;
616 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
617 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
618 ++pTurnEngine->pending_actions;
619 spell_sound_flag = true;
620 }
621 break;
622 }
623 case SPELL_LIGHT_PARALYZE://Паралич
624 {
625 if ( !pPlayer->CanCastSpell(uRequiredMana) )
626 break;
627 mon_id = PID_ID(a2);
628 if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)9) )
629 {
630 Actor::AI_Stand(PID_ID(a2), 4, 0x80, 0);
631 pActors[mon_id].pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, 0, 0, 0);
632 pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR;
633 pActors[mon_id].vVelocity.x = 0;
634 pActors[mon_id].vVelocity.y = 0;
635 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0);
636 }
637 spell_sound_flag = true;
638 break;
639 }
640 case SPELL_EARTH_SLOW://Замедление
641 {
642 switch (skill_level)
643 {
644 case 1: LODWORD(v733) = 180 * spell_level; amount = 2; break;//LODWORD(v733)???не применяется далее
645 case 2: LODWORD(v733) = 300 * spell_level; amount = 2; break;
646 case 3: LODWORD(v733) = 300 * spell_level; amount = 4; break;
647 case 4: LODWORD(v733) = 300 * spell_level; amount = 8; break;
648 default:
649 assert(false);
650 }
651 if ( !pPlayer->CanCastSpell(uRequiredMana) )
652 break;
653 //v721 = 836 * PID_ID(a2);
654 mon_id = PID_ID(a2);
655 if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) )
656 {
657 pActors[mon_id].pActorBuffs[ACTOR_BUFF_SLOWED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, amount, 0, 0);
658 pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR;
659 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0);
660 }
661 spell_sound_flag = true;
662 break;
663 }
664 case SPELL_MIND_CHARM:// Очарование
665 {
666 v61 = PID_ID(a2);
667 if ( !pPlayer->CanCastSpell(uRequiredMana) )
668 break;
669 if ( pActors[v61].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) )
670 {
671 uint power = 300 * spell_level;
672 if ( skill_level == 2 )
673 power = 600 * spell_level;
674 else if ( skill_level == 3 )
675 power = 29030400;
676
677 pActors[v61].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
678 pActors[v61].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset();
679 pActors[v61].pActorBuffs[ACTOR_BUFF_CHARM].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), skill_level, 0, 0, 0);
680 pSpellSprite.stru_24.Reset();
681 pSpellSprite.spell_id = pCastSpell->uSpellID;
682 pSpellSprite.spell_level = spell_level;
683 pSpellSprite.spell_skill = skill_level;
684 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
685 pSpellSprite.vPosition.x = pActors[v61].vPosition.x;
686 pSpellSprite.vPosition.y = pActors[v61].vPosition.y;
687 pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight;
688 pSpellSprite.uAttributes = 0;
689 pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].vPosition.y, pSpellSprite.vPosition.z);
690 pSpellSprite.uSpriteFrameID = 0;
691 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
692 pSpellSprite.spell_target_pid = a2;
693 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
694 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
695 LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
696 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
697 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
698 }
699 spell_sound_flag = true;
700 break;
701 }
702 case SPELL_DARK_SHRINKING_RAY://Сжимающий луч
703 {
704 if ( !pPlayer->CanCastSpell(uRequiredMana) )
705 break;
706 pSpellSprite.stru_24.Reset();
707 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
708 pSpellSprite.vPosition.x = pParty->vPosition.x;
709 pSpellSprite.vPosition.y = pParty->vPosition.y;
710 pSpellSprite.uAttributes = 0;
711 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
712 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
713 pSpellSprite.uSpriteFrameID = 0;
714 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
715 pSpellSprite.spell_target_pid = a2;
716 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
717 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
718 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
719 pSpellSprite.spell_skill = skill_level;
720 pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
721 pSpellSprite.spell_level = 300 * spell_level;
722 if ( pParty->bTurnBasedModeOn == 1 )
723 LOBYTE(pSpellSprite.uAttributes) |= 4;
724 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
725 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
726 ++pTurnEngine->pending_actions;
727 spell_sound_flag = true;
728 break;
729 }
730 case SPELL_FIRE_FIRE_AURA: //Аура огня
731 {
732 switch (skill_level)
733 {
734 case 1: duration = 3600 * spell_level; amount = 10; break; //Огня
735 case 2: duration = 3600 * spell_level; amount = 11; break; //Огненного жара
736 case 3: duration = 3600 * spell_level; amount = 12; break;
737 case 4: duration = 0; amount = 12; break;
738 default:
739 assert(false);
740 }
741 if ( !pPlayer->CanCastSpell(uRequiredMana) )
742 break;
743 v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
744 _item = &pItemsTable->pItems[v730c->uItemID];
745 v730c->UpdateTempBonus(pParty->uTimePlayed);
746 if ( v730c->uItemID < 64 || v730c->uItemID > 65
747 && !v730c->IsBroken()
748 && !v730c->uSpecEnchantmentType
749 && !v730c->uEnchantmentType
750 && ( _item->uEquipType == EQUIP_SINGLE_HANDED || _item->uEquipType == EQUIP_TWO_HANDED || _item->uEquipType == EQUIP_BOW)
751 && !pItemsTable->IsMaterialNonCommon(v730c) )
752 {
753 v730c->uSpecEnchantmentType = amount;
754 if ( skill_level != 4 )
755 {
756 v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335);
757 v730c->uAttributes |= ITEM_TEMP_BONUS;
758 }
759 v730c->uAttributes |= ITEM_AURA_EFFECT_RED;
760 _50C9A8_item_enchantment_timer = 256;
761 spell_sound_flag = true;
762 break;
763 }
764 _50C9D0_AfterEnchClickEventId = 113;
765 _50C9D4_AfterEnchClickEventSecondParam = 0;
766 _50C9D8_AfterEnchClickEventTimeout = 1;
767 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
768 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
769 pCastSpell->uSpellID = 0;
770 continue;
771 }
772 case SPELL_BODY_REGENERATION://Регенерация
773 {
774 switch (skill_level)
775 {
776 case 1: amount = 1; break;
777 case 2: amount = 1; break;
778 case 3: amount = 3; break;
779 case 4: amount = 10; break;
780 default:
781 assert(false);
782 }
783 if ( !pPlayer->CanCastSpell(uRequiredMana) )
784 break;
785 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
786 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0);
787 spell_sound_flag = true;
788 break;
789 }
790 case SPELL_FIRE_PROTECTION_FROM_FIRE://Защита от Огня
791 case SPELL_AIR_PROTECTION_FROM_AIR://Звщита от Воздуха
792 case SPELL_WATER_PROTECTION_FROM_WATER://Защита от Воды
793 case SPELL_EARTH_PROTECTION_FROM_EARTH://Защита от Земли
794 case SPELL_MIND_PROTECTION_FROM_MIND://Защита от Мысли
795 case SPELL_BODY_PROTECTION_FROM_BODY://Защита от Тела
796 {
797 switch (skill_level)
798 {
799 case 1:
800 case 2:
801 case 3:
802 case 4: amount = skill_level * spell_level; break;
803 default:
804 assert(false);
805 }
806 switch (pCastSpell->uSpellID)
807 {
808 case SPELL_FIRE_PROTECTION_FROM_FIRE:
809 buff_resist = PARTY_BUFF_RESIST_FIRE;
810 break;
811 case SPELL_AIR_PROTECTION_FROM_AIR:
812 buff_resist = PARTY_BUFF_RESIST_AIR;
813 break;
814 case SPELL_WATER_PROTECTION_FROM_WATER:
815 buff_resist = PARTY_BUFF_RESIST_WATER;
816 break;
817 case SPELL_EARTH_PROTECTION_FROM_EARTH:
818 buff_resist = PARTY_BUFF_RESIST_EARTH;
819 break;
820 case SPELL_MIND_PROTECTION_FROM_MIND:
821 buff_resist = PARTY_BUFF_RESIST_MIND;
822 break;
823 case SPELL_BODY_PROTECTION_FROM_BODY:
824 buff_resist = PARTY_BUFF_RESIST_BODY;
825 break;
826 default:
827 assert(false);
828 continue;
829 }
830 if ( !pPlayer->CanCastSpell(uRequiredMana) )
831 break;
832 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
833 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
834 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
835 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
836 //v90 = (double)(signed int)(3600 * spell_level) * 4.2666669;
837 pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0);
838 spell_sound_flag = true;
839 break;
840 }
841 case SPELL_FIRE_HASTE://Спешка
842 {
843 switch (skill_level)
844 {
845 case 1: duration = 60 * (spell_level + 60); break;
846 case 2: duration = 60 * (spell_level + 60); break;
847 case 3: duration = 180 * (spell_level + 20); break;
848 case 4: duration = 240 * (spell_level + 15); break;
849 default:
850 assert(false);
851 }
852 if ( pPlayer->CanCastSpell(uRequiredMana) )
853 {
854 spell_sound_flag = true;
855 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
856 {
857 if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] )
858 spell_sound_flag = false;
859 }
860 if ( spell_sound_flag )
861 {
862 pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
863 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
864 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
865 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
866 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
867 }
868 }
869 break;
870 }
871 case SPELL_SPIRIT_BLESS://Благословение
872 {
873 switch (skill_level)
874 {
875 case 1: duration = 300 * (spell_level + 12); break;
876 case 2: duration = 300 * (spell_level + 12); break;
877 case 3: duration = 900 * (spell_level + 4); break;
878 case 4: duration = 3600 * (spell_level + 1); break;
879 default:
880 assert(false);
881 }
882 amount = spell_level + 5;
883 if ( !pPlayer->CanCastSpell(uRequiredMana) )
884 break;
885 if ( skill_level == 1 )
886 {
887 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
888 v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536);
889 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed +
890 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), 1, amount, v111, 0);
891 spell_sound_flag = true;
892 break;
893 }
894 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
895 {
896 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
897 v111 = pOtherOverlayList->_4418B1(10000, pl_id + 310, 0, 65536);
898 pParty->pPlayers[pl_id].pPlayerBuffs[1].Apply(pParty->uTimePlayed +
899 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, v111, 0);
900 }
901 spell_sound_flag = true;
902 break;
903 }
904 case SPELL_SPIRIT_SPIRIT_LASH://Плеть Духа
905 {
906 if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor)
907 {
908 int mon_id = PID_ID(a2);
909 dist_X = abs(pActors[mon_id].vPosition.x - pParty->vPosition.x);
910 dist_Y = abs(pActors[mon_id].vPosition.y - pParty->vPosition.y);
911 dist_Z = abs(pActors[mon_id].vPosition.z - pParty->vPosition.z);
912 int count = int_get_vector_length(dist_X, dist_Y, dist_Z);
913 if ( (double)count <= 307.2 )
914 {
915 v701.x = 0;
916 v701.y = 0;
917 v701.z = 0;
918 pSpellSprite.stru_24.Reset();
919 pSpellSprite.spell_id = pCastSpell->uSpellID;
920 pSpellSprite.spell_level = v723;
921 pSpellSprite.spell_skill = skill_level;
922 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
923 pSpellSprite.uAttributes = 0;
924 pSpellSprite.uSectorID = 0;
925 pSpellSprite.uSpriteFrameID = 0;
926 pSpellSprite.field_60_distance_related_prolly_lod = 0;
927 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
928 pSpellSprite.uFacing = 0;
929 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
930 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
931 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
932 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8);
933 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
934 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v701);
935 spell_sound_flag = true;
936 }
937 else
938 {
939 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//"Не получилось!!!"
940 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
941 pCastSpell->uSpellID = 0;
942 }
943 }
944 break;
945 }
946 case SPELL_AIR_SHIELD://Щит
947 case SPELL_EARTH_STONESKIN://Каменная кожа
948 case SPELL_SPIRIT_HEROISM://Героизм
949 {
950 switch (skill_level)
951 {
952 case 1: duration = 300 * (spell_level + 12); break;
953 case 2: duration = 300 * (spell_level + 12); break;
954 case 3: duration = 900 * (spell_level + 4); break;
955 case 4: duration = 3600 * (spell_level + 1); break;
956 default:
957 assert(false);
958 }
959 switch (pCastSpell->uSpellID)
960 {
961 case SPELL_AIR_SHIELD:
962 amount = 0;
963 buff_resist = PARTY_BUFF_SHIELD;
964 break;
965 case SPELL_EARTH_STONESKIN:
966 amount = spell_level + 5;
967 buff_resist = PARTY_BUFF_STONE_SKIN;
968 break;
969 case SPELL_SPIRIT_HEROISM:
970 amount = spell_level + 5;
971 buff_resist = PARTY_BUFF_HEROISM;
972 break;
973 default:
974 assert(false);
975 continue;
976 }
977 if ( !pPlayer->CanCastSpell(uRequiredMana) )
978 break;
979 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
980 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
981 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
982 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
983 pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed +
984 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
985 spell_sound_flag = true;
986 break;
987 }
988 case SPELL_FIRE_IMMOLATION://Кольцо огня
989 {
990 if ( skill_level == 4 )
991 duration = 600 * spell_level;
992 else
993 duration = 60 * spell_level;
994 if ( !pPlayer->CanCastSpell(uRequiredMana) )
995 break;
996 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
997 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
998 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
999 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
1000 pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed +
1001 (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, spell_level, 0, 0);
1002 spell_sound_flag = true;
1003 break;
1004 }
1005 case SPELL_FIRE_METEOR_SHOWER://Поток метеоров
1006 {
1007 //if (skill_level < 3)//для мастера и магистра
1008 //break;
1009 int meteor_num;
1010 if ( skill_level == 4 )
1011 meteor_num = 20;
1012 else
1013 meteor_num = 16;
1014 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
1015 {
1016 ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors!
1017 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1018 pCastSpell->uSpellID = 0;
1019 continue;
1020 }
1021 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1022 break;
1023 obj_type = PID_TYPE(a2);
1024 mon_id = PID_ID(a2);
1025 if (obj_type == OBJECT_Actor)//если закл поставить на быстрое закл., то можно указывать куда кидать метеоры
1026 {
1027 dist_X = pActors[mon_id].vPosition.x;
1028 dist_Y = pActors[mon_id].vPosition.y;
1029 dist_Z = pActors[mon_id].vPosition.z;
1030 }
1031 else
1032 {
1033 dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY));
1034 dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY));
1035 dist_Z = pParty->vPosition.z;
1036 }
1037 unsigned __int64 k = 0;
1038 int j = 0;
1039 if ( meteor_num > 0 )
1040 {
1041 v730 = obj_type == OBJECT_Actor ? a2 : 0;
1042 for ( meteor_num; meteor_num; meteor_num-- )
1043 {
1044 a2 = rand() % 1000;
1045 if ( sqrt(((double)a2 - 2500) * ((double)a2 - 2500) + j * j + k * k) <= 1.0 )
1046 {
1047 LODWORD(v687) = 0;
1048 HIDWORD(v687) = 0;
1049 }
1050 else
1051 {
1052 HIDWORD(v687) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), (double)a2 - 2500);
1053 LODWORD(v687) = stru_5C6E00->Atan2(j, k);
1054 }
1055 pSpellSprite.stru_24.Reset();
1056 pSpellSprite.spell_id = pCastSpell->uSpellID;
1057 pSpellSprite.spell_level = spell_level;
1058 pSpellSprite.spell_skill = skill_level;
1059 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1060 pSpellSprite.uAttributes = 0;
1061 pSpellSprite.vPosition.x = dist_X;
1062 pSpellSprite.vPosition.y = dist_Y;
1063 pSpellSprite.vPosition.z = a2 + dist_Z;
1064 pSpellSprite.uSectorID = 0;
1065 pSpellSprite.uSpriteFrameID = 0;
1066 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1067 pSpellSprite.spell_target_pid = v730;
1068 pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
1069 pSpellSprite.uFacing = v687;
1070 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1071 if ( pParty->bTurnBasedModeOn == 1 )
1072 pSpellSprite.uAttributes = 4;
1073 if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 && pParty->bTurnBasedModeOn == 1 )
1074 ++pTurnEngine->pending_actions;
1075 j = rand() % 1024 - 512;
1076 k = rand() % 1024 - 512;
1077 }
1078 }
1079 spell_sound_flag = true;
1080 break;
1081 }
1082 case SPELL_FIRE_INFERNO://Адский огонь
1083 {
1084 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
1085 {
1086 ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
1087 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1088 pCastSpell->uSpellID = 0;
1089 continue;
1090 }
1091 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1092 break;
1093 int mon_num = pRenderer->_46А6АС_GetActorsInViewport(4096);
1094 v700.x = 0;
1095 v700.y = 0;
1096 v700.z = 0;
1097 pSpellSprite.stru_24.Reset();
1098 pSpellSprite.spell_id = pCastSpell->uSpellID;
1099 pSpellSprite.spell_level = spell_level;
1100 pSpellSprite.spell_skill = skill_level;
1101 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1102 pSpellSprite.uAttributes = 0;
1103 pSpellSprite.uSectorID = 0;
1104 pSpellSprite.uSpriteFrameID = 0;
1105 pSpellSprite.field_60_distance_related_prolly_lod = 0;
1106 pSpellSprite.uFacing = 0;
1107 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1108 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1109 for ( uint i = 0; i < mon_num; i++ )
1110 {
1111 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.x;
1112 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.y;
1113 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[i]].uActorHeight * -0.8);
1114 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[i]);
1115 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[i], &v700);
1116 pGame->GetStru6()->_4A81CA(&pSpellSprite);
1117 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1E, 0x40);
1118 }
1119 spell_sound_flag = true;
1120 break;
1121 }
1122 case SPELL_AIR_WIZARD_EYE://Око чародея
1123 {
1124 duration = 3600 * spell_level;
1125 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1126 break;
1127 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
1128 v169 = pOtherOverlayList->_4418B1(2000, pl_id + 100, 0, 65536);
1129 pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, v169, 0);
1130 spell_sound_flag = true;
1131 break;
1132 }
1133 case SPELL_AIR_FEATHER_FALL://Падение пера(пёрышком)
1134 {
1135 switch (skill_level)
1136 {
1137 case 1: duration = 300 * spell_level; break;
1138 case 2: duration = 600 * spell_level; break;
1139 case 3: duration = 3600 * spell_level; break;
1140 case 4: duration = 3600 * spell_level; break;
1141 default:
1142 assert(false);
1143 }
1144 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1145 break;
1146 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
1147 pOtherOverlayList->_4418B1(2010, pl_id + 100, 0, 65536);
1148 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
1149 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
1150 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
1151 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
1152
1153 pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed +
1154 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
1155 spell_sound_flag = true;
1156 break;
1157 }
1158 case SPELL_AIR_SPARKS://Искры
1159 {
1160 switch (skill_level)
1161 {
1162 case 1: amount = 3; break;
1163 case 2: amount = 5; break;
1164 case 3: amount = 7; break;
1165 case 4: amount = 9; break;
1166 default:
1167 assert(false);
1168 }
1169 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1170 break;
1171 int _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
1172 pSpellSprite.stru_24.Reset();
1173 pSpellSprite.spell_id = pCastSpell->uSpellID;
1174 pSpellSprite.spell_level = spell_level;
1175 pSpellSprite.spell_skill = skill_level;
1176 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1177 pSpellSprite.vPosition.y = pParty->vPosition.y;
1178 pSpellSprite.vPosition.x = pParty->vPosition.x;
1179 pSpellSprite.uAttributes = 0;
1180 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1181 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y,
1182 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
1183 pSpellSprite.uSpriteFrameID = 0;
1184 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1185 pSpellSprite.spell_target_pid = a2;
1186 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
1187 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1188 if ( pParty->bTurnBasedModeOn == 1 )
1189 LOBYTE(pSpellSprite.uAttributes) |= 4;
1190 v188 = (signed int)_v726 / -2;
1191 v189 = (signed int)_v726 / 2;
1192 while ( v188 <= v189 )
1193 {
1194 pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle);
1195 if ( pSpellSprite.Create((signed __int16)(v188 + LOWORD(v715.uYawAngle)), v715.uPitchAngle,
1196 pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1
1197 && pParty->bTurnBasedModeOn == 1 )
1198 ++pTurnEngine->pending_actions;
1199 v188 += _v726 / (amount - 1);
1200 }
1201 spell_sound_flag = true;
1202 break;
1203 }
1204 case SPELL_AIR_JUMP://Прыжок
1205 {
1206 if ( pParty->uFlags & PARTY_FLAGS_1_FALLING)
1207 {
1208 ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne!
1209 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1210 break;
1211 }
1212 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1213 break;
1214 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
1215 pOtherOverlayList->_4418B1(2040, pl_id + 100, 0, 65536);
1216 pParty->uFlags |= 0x100;
1217 pParty->uFallSpeed = 1000;
1218 spell_sound_flag = true;
1219 break;
1220 }
1221 case SPELL_AIR_INVISIBILITY://Невидимость
1222 {
1223 switch (skill_level)
1224 {
1225 case 1: duration = 600 * spell_level; amount = spell_level; break;
1226 case 2: duration = 600 * spell_level; amount = 2 * spell_level; break;
1227 case 3: duration = 600 * spell_level; amount = 3 * spell_level; break;
1228 case 4: duration = 3600 * spell_level; amount = 4 * spell_level; break;
1229 default:
1230 assert(false);
1231 }
1232 if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW))
1233 {
1234 ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby!
1235 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1236 pCastSpell->uSpellID = 0;
1237 continue;
1238 }
1239 if ( pPlayer->CanCastSpell(uRequiredMana) )
1240 {
1241 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
1242 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
1243 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
1244 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
1245 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed +
1246 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
1247 spell_sound_flag = true;
1248 }
1249 break;
1250 }
1251 case SPELL_AIR_FLY://Полёт
1252 {
1253 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
1254 {
1255 ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors!
1256 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1257 break;
1258 }
1259 if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
1260 {
1261 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1262 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1263 break;
1264 }
1265 if ( skill_level == 1 || skill_level == 2 || skill_level == 3 )
1266 amount = 1;
1267 else
1268 amount = 0;
1269 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1270 break;
1271 for ( uint pl_id = 0; pl_id < 4; pl_id++)
1272 pOtherOverlayList->_4418B1(2090, pl_id + 100, 0, 65536);
1273 v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
1274 pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7)
1275 * 0.033333335), skill_level, amount, v206, pCastSpell->uPlayerID + 1);
1276 spell_sound_flag = true;
1277 break;
1278 }
1279 case SPELL_AIR_STARBURST://Звездопад
1280 {
1281 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
1282 {
1283 ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors!
1284 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1285 pCastSpell->uSpellID = 0;
1286 continue;
1287 }
1288 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1289 break;
1290 obj_type = PID_TYPE(a2);
1291 mon_id = PID_ID(a2);
1292 if ( obj_type == OBJECT_Actor )
1293 {
1294 dist_X = pActors[mon_id].vPosition.x;
1295 dist_Y = pActors[mon_id].vPosition.y;
1296 dist_Z = pActors[mon_id].vPosition.z;
1297 }
1298 else
1299 {
1300 dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY));
1301 dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY));
1302 dist_Z = pParty->vPosition.z;
1303 }
1304 unsigned __int64 k = 0;
1305 int j = 0;
1306 v730 = obj_type == OBJECT_Actor ? a2 : 0;
1307 for ( uint star_num = 20; star_num; star_num-- )
1308 {
1309 a2 = rand() % 1000;
1310 if ( sqrt(((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)) * ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500))
1311 + j * j + k * k) <= 1.0 )
1312 {
1313 LODWORD(v685) = 0;
1314 HIDWORD(v685) = 0;
1315 }
1316 else
1317 {
1318 HIDWORD(v685) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)));
1319 LODWORD(v685) = stru_5C6E00->Atan2(j, k);
1320 }
1321 pSpellSprite.stru_24.Reset();
1322 pSpellSprite.spell_id = pCastSpell->uSpellID;
1323 pSpellSprite.spell_level = spell_level;
1324 pSpellSprite.spell_skill = skill_level;
1325 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1326 pSpellSprite.uAttributes = 0;
1327 pSpellSprite.vPosition.x = dist_X;
1328 pSpellSprite.vPosition.y = dist_Y;
1329 pSpellSprite.vPosition.z = (int)(a2 + (dist_Z + 2500));
1330 pSpellSprite.uSectorID = 0;
1331 pSpellSprite.uSpriteFrameID = 0;
1332 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1333 pSpellSprite.spell_target_pid = v730;
1334 pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
1335 pSpellSprite.uFacing = v685;
1336 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1337 if ( pParty->bTurnBasedModeOn == 1 )
1338 pSpellSprite.uAttributes = 4;
1339 if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
1340 && pParty->bTurnBasedModeOn == 1 )
1341 ++pTurnEngine->pending_actions;
1342 j = rand() % 1024 - 512;
1343 k = rand() % 1024 - 512;
1344 }
1345 spell_sound_flag = true;
1346 break;
1347 }
1348 case SPELL_WATER_AWAKEN://Пробуждение
1349 {
1350 switch (skill_level)
1351 {
1352 case 1: amount = 180 * spell_level; break;
1353 case 2: amount = 3600 * spell_level; break;
1354 case 3: amount = 86400 * spell_level; break;
1355 case 4: amount = 0; break;
1356 default:
1357 assert(false);
1358 }
1359 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1360 break;
1361 for( int i=0; i < 4; i++ )
1362 {
1363 if ( skill_level == 4 )
1364 {
1365 if ( pParty->pPlayers[i].pConditions[Condition_Sleep] )
1366 {
1367 pParty->pPlayers[i].pConditions[Condition_Sleep] = 0;
1368 pParty->pPlayers[i].PlaySound(SPEECH_103, 0);
1369 }
1370 }
1371 else
1372 {
1373 if ( pParty->pPlayers[i].DiscardConditionIfLastsLongerThan(Condition_Sleep, pParty->uTimePlayed -
1374 (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)) )
1375 pParty->pPlayers[i].PlaySound(SPEECH_103, 0);
1376 }
1377 }
1378 spell_sound_flag = true;
1379 break;
1380 }
1381 case SPELL_WATER_POISON_SPRAY://Распыление яда
1382 {
1383 switch (skill_level)
1384 {
1385 case 1: amount = 1; break;
1386 case 2: amount = 3; break;
1387 case 3: amount = 5; break;
1388 case 4: amount = 7; break;
1389 default:
1390 assert(false);
1391 }
1392 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1393 break;
1394 signed int _v733 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
1395 if ( amount == 1 )
1396 {
1397 pSpellSprite.stru_24.Reset();
1398 pSpellSprite.spell_id = pCastSpell->uSpellID;
1399 pSpellSprite.spell_skill = skill_level;
1400 pSpellSprite.spell_level = spell_level;
1401 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1402 pSpellSprite.uAttributes = 0;
1403 pSpellSprite.vPosition.x = pParty->vPosition.x;
1404 pSpellSprite.vPosition.y = pParty->vPosition.y;
1405 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1406 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
1407 pSpellSprite.uSpriteFrameID = 0;
1408 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1409 pSpellSprite.spell_target_pid = a2;
1410 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
1411 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
1412 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1413 if ( pParty->bTurnBasedModeOn == 1 )
1414 LOBYTE(pSpellSprite.uAttributes) |= 4;
1415 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
1416 if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
1417 ++pTurnEngine->pending_actions;
1418 }
1419 else
1420 {
1421 pSpellSprite.stru_24.Reset();
1422 pSpellSprite.spell_id = pCastSpell->uSpellID;
1423 pSpellSprite.spell_level = spell_level;
1424 pSpellSprite.spell_skill = skill_level;
1425 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1426 pSpellSprite.vPosition.y = pParty->vPosition.y;
1427 pSpellSprite.vPosition.x = pParty->vPosition.x;
1428 pSpellSprite.uAttributes = 0;
1429 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1430 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
1431 pSpellSprite.uSpriteFrameID = 0;
1432 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1433 pSpellSprite.spell_target_pid = a2;
1434 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
1435 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1436 if ( pParty->bTurnBasedModeOn == 1 )
1437 LOBYTE(pSpellSprite.uAttributes) |= 4;
1438 v188 = _v733 / -2;
1439 v189 = _v733 / 2;
1440 if ( v188 <= v189 )
1441 {
1442 do
1443 {
1444 pSpellSprite.uFacing = v188 + v715.uYawAngle;
1445 if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
1446 pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
1447 ++pTurnEngine->pending_actions;
1448 v188 += _v733 / (amount - 1);
1449 }
1450 while ( v188 <= v189 );
1451 }
1452 }
1453 spell_sound_flag = true;
1454 break;
1455 }
1456 case SPELL_WATER_WATER_WALK://Хождение по воде
1457 {
1458 if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
1459 {
1460 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1461 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1462 break;
1463 }
1464 switch (skill_level)
1465 {
1466 case 1: //break;
1467 case 2: duration = 600 * spell_level; break;
1468 case 3:
1469 case 4: duration = 3600 * spell_level; break;
1470 default:
1471 assert(false);
1472 }
1473 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1474 break;
1475 v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
1476 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
1477 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
1478 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
1479 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
1480 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(duration << 7) * 0.033333335),
1481 skill_level, amount, v169, pCastSpell->uPlayerID + 1);
1482 if ( skill_level == 4 )
1483 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
1484 spell_sound_flag = true;
1485 break;
1486 }
1487 case SPELL_WATER_RECHARGE_ITEM://Перезарядка
1488 {
1489 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1490 break;
1491 v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
1492 if ( v730c->GetItemEquipType() != 12 || v730c->uAttributes & 2 )
1493 {
1494 _50C9D0_AfterEnchClickEventId = 113;
1495 _50C9D4_AfterEnchClickEventSecondParam = 0;
1496 _50C9D8_AfterEnchClickEventTimeout = 1;
1497 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1498 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1499 pCastSpell->uSpellID = 0;
1500 continue;
1501 }
1502 if ( skill_level == 1 || skill_level == 2 )
1503 v241 = (double)v723 * 0.0099999998 + 0.5;//50 %
1504 else if ( skill_level == 3 )
1505 v241 = (double)v723 * 0.0099999998 + 0.69999999;//30 %
1506 else if ( skill_level == 4 )
1507 v241 = (double)v723 * 0.0099999998 + 0.80000001;//20 %
1508 else
1509 v241 = 0.0;
1510 if ( v241 > 1.0 )
1511 v241 = 1.0;
1512 int uNewCharges = v730c->uMaxCharges * v241;
1513 v730c->uMaxCharges = uNewCharges;
1514 v730c->uNumCharges = uNewCharges;
1515 if ( uNewCharges <= 0 )
1516 {
1517 v730c = 0;
1518 _50C9D0_AfterEnchClickEventId = 113;
1519 _50C9D4_AfterEnchClickEventSecondParam = 0;
1520 _50C9D8_AfterEnchClickEventTimeout = 1;
1521 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//Не получилось!!!
1522 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1523 pCastSpell->uSpellID = 0;
1524 spell_level = v723;
1525 continue;
1526 }
1527 v730c->uAttributes |= 0x40u;
1528 _50C9A8_item_enchantment_timer = 256;
1529 spell_sound_flag = true;
1530 break;
1531 }
1532 case SPELL_WATER_ENCHANT_ITEM://Талисман
1533 {
1534 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1535 break;
1536 uRequiredMana = 0;
1537 amount = 10 * spell_level;
1538 bool item_not_broken = true;
1539 int rnd = rand() % 100;
1540 pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2];
1541 v245 = &pPlayer->pInventoryItemList[a2];
1542 ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID];
1543 if ((skill_level == 1 || skill_level == 2 /*&& _v725->uEquipType > EQUIP_BOW*/ || skill_level == 3 || skill_level == 4) &&
1544 v245->uItemID <= 134 &&
1545 v245->uSpecEnchantmentType == 0 && v245->uEnchantmentType == 0 &&
1546 v245->m_enchantmentStrength== 0 && !v245->IsBroken() ) //требования к предмету
1547 {
1548 if ( (v245->GetValue() < 450 && ( skill_level == 1 || skill_level == 2 ))
1549 || (v245->GetValue() < 450 && (skill_level == 3|| skill_level == 4 ) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW)
1550 || (v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4 )&& _v725->uEquipType > EQUIP_BOW) )//Условия поломки
1551 {
1552 if ( !(v245->uAttributes & 0x200) )// предмет не сломан
1553 {
1554 v245->uAttributes |= 2;//теперь сломан
1555 }
1556 item_not_broken = false;
1557 }
1558 else
1559 {
1560 if ( rnd >= 10 * spell_level )//шанс на срабатывание
1561 {
1562 if ( !(v245->uAttributes & 0x200) )// предмет не сломан
1563 v245->uAttributes |= 2;//теперь сломан
1564 }
1565 else
1566 {
1567 if ( (rnd < 80 && (skill_level == 3 || skill_level == 4 )) || v245->GetValue() < 450 || (v245->GetValue() < 250
1568 && (skill_level == 3 || skill_level == 4) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW))
1569 {
1570 v313 = _v725->uEquipType;
1571 if ( _v725->uEquipType >= EQUIP_ARMOUR && _v725->uEquipType <= EQUIP_AMULET )
1572 {
1573 v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
1574 /*v245->uEnchantmentType = 0;
1575 __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used
1576 for ( kk = pItemsTable->pEnchantments[0].to_item[v245->GetItemEquipType() + 1];
1577 ;
1578 kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[v245->GetItemEquipType() + 1] )
1579 {
1580 ++v245->uEnchantmentType;
1581 if ( kk >= v295 )
1582 break;
1583 }
1584 v255 = 10;//pItemsTable->field_116D8[17];
1585 v256 = 10;//pItemsTable->field_116D8[16];
1586 v245->m_enchantmentStrength = v256 + rand() % (v255 - v256 + 1);*/
1587 v245->uEnchantmentType = v295;
1588 v245->m_enchantmentStrength = pItemsTable->pEnchantments[v295].to_item[_v725->uEquipType - EQUIP_ARMOUR];
1589 v245->uAttributes |= 0x20u;
1590 _50C9A8_item_enchantment_timer = 256;
1591 spell_sound_flag = true;
1592 break;
1593 }
1594 else if ( skill_level == 3 || skill_level == 4)//for master & GM not refactored(для мастера и гранда не отрефакторено)
1595 {
1596 v258 = 0;
1597 v725 = 0;
1598 int _v733;
1599 if ( pItemsTable->pSpecialEnchantments_count > 0 )
1600 {
1601 v730 = (int)&v679;
1602 for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 )
1603 {
1604 v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement);
1605 if ( !v259 || v259 == 1 )
1606 {
1607 v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[v245->GetItemEquipType() + 4] + v258 * 28);
1608 v725 += v260;
1609 if ( v260 )
1610 {
1611 v261 = v730;
1612 v730 += 4;
1613 *(int *)v261 = _v733;
1614 }
1615 }
1616 ++v258;
1617 }
1618 }
1619 v262 = rand() % v725;
1620 v263 = v679;
1621 v245->uSpecEnchantmentType = v679[0];
1622 v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[v245->GetItemEquipType() + 4];
1623 v265 = v262 + 1;
1624 if ( v264 < v265 )
1625 {
1626 for ( ii = v679; ; ii = (int *)v732 )
1627 {
1628 v267 = (int)(ii + 1);
1629 v732 = v267;
1630 v268 = *(int *)v267;
1631 *(int *)(v245 + 12) = v268;
1632 v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[v245->GetItemEquipType() + 4];
1633 if ( v264 >= v265 )
1634 break;
1635 }
1636 }
1637 v278 = 0;
1638 v725 = 0;
1639 if ( pItemsTable->pSpecialEnchantments_count > 0 )
1640 {
1641 int *_v730 = v679;
1642 for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 )
1643 {
1644 v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement);
1645 if ( !v279 || v279 == 1 )
1646 {
1647 v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[v245->GetItemEquipType()]);
1648 _v733 += v280;
1649 if ( v280 )
1650 {
1651 v281 = _v730;
1652 ++_v730;
1653 *v281 = _v733;
1654 }
1655 }
1656 ++v278;
1657 }
1658 }
1659 v282 = rand() % _v733;
1660 v283 = v679;
1661 v245->uSpecEnchantmentType = v679[0];
1662 v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[v245->GetItemEquipType() ];
1663 v285 = v282 + 1;
1664 for ( l = v679; v284 < v285; ++l )
1665 {
1666 v245->uSpecEnchantmentType = *(l+1);
1667 v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[v245->GetItemEquipType()];
1668 }
1669 ++v245->uSpecEnchantmentType;
1670 v245->uAttributes |= 0x20u;
1671 _50C9A8_item_enchantment_timer = 256;
1672 spell_sound_flag = true;
1673 break;
1674 }
1675 }
1676 }
1677 }
1678 }
1679 if ( spell_sound_flag == 0 )
1680 {
1681 v317 = pGlobalTXT_LocalizationStrings[428];//Не получилось!!!
1682 if ( item_not_broken == false )
1683 v317 = pGlobalTXT_LocalizationStrings[585];//Предмет недостаточно высокого качества
1684 ShowStatusBarString(v317, 2);
1685 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1686 //v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
1687 pCastSpell->uSpellID = 0;
1688 pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_43, 0);
1689 }
1690 break;
1691 }
1692 case SPELL_WATER_TOWN_PORTAL://Портал города
1693 {
1694 amount = 10 * spell_level;
1695 if ( pPlayer->sMana < (signed int)uRequiredMana )
1696 break;
1697 if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && skill_level != 4
1698 || rand() % 100 >= amount && skill_level != 4 )
1699 {
1700 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1701 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1702 pCastSpell->uSpellID = 0;
1703 continue;
1704 }
1705 town_portal_caster_id = pCastSpell->uPlayerID;
1706 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastTownPortal, 0, 0);
1707 spell_sound_flag = true;
1708 break;
1709 }
1710 case SPELL_WATER_LLOYDS_BEACON://Маяк Ллойда
1711 {
1712 if ( !_stricmp(pCurrentMapName, "d05.blv") ) // Arena
1713 {
1714 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1715 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1716 pCastSpell->uSpellID = 0;
1717 continue;
1718 }
1719 if ( pPlayer->sMana >= (signed int)uRequiredMana )
1720 {
1721 pEventTimer->Pause();
1722 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastLloydsBeacon, 0, 0);
1723 lloyds_beacon_spell_level = (signed int)(604800 * spell_level);
1724 _506348_current_lloyd_playerid = pCastSpell->uPlayerID;
1725 ::uRequiredMana = uRequiredMana;
1726 ::sRecoveryTime = sRecoveryTime;
1727 lloyds_beacon_sound_id = pCastSpell->sound_id;
1728 lloyds_beacon_spell_id = pCastSpell->uSpellID;
1729 pCastSpell->uFlags |= 0x20u;
1730 }
1731 break;
1732 }
1733 case SPELL_EARTH_STONE_TO_FLESH:
1734 {
1735 switch (skill_level)
1736 {
1737 case 1: amount = 3600 * spell_level; break;
1738 case 2: amount = 3600 * spell_level; break;
1739 case 3: amount = 86400 * spell_level; break;
1740 case 4: break;
1741 default:
1742 assert(false);
1743 }
1744 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1745 break;
1746 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] )
1747 {
1748 if ( skill_level == 4 )//for GM
1749 {
1750 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] = 0;
1751 spell_sound_flag = true;
1752 break;
1753 }
1754 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
1755 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Pertified, v663);
1756 }
1757 spell_sound_flag = true;
1758 break;
1759 }
1760 case SPELL_EARTH_ROCK_BLAST://Взрыв камня
1761 {
1762 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1763 break;
1764 pSpellSprite.stru_24.Reset();
1765 pSpellSprite.spell_id = pCastSpell->uSpellID;
1766 pSpellSprite.spell_level = spell_level;
1767 pSpellSprite.spell_skill = skill_level;
1768 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1769 pSpellSprite.vPosition.y = pParty->vPosition.y;
1770 pSpellSprite.vPosition.x = pParty->vPosition.x;
1771 pSpellSprite.uAttributes = 0;
1772 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1773 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
1774 pSpellSprite.uSpriteFrameID = 0;
1775 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1776 pSpellSprite.spell_target_pid = a2;
1777 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
1778 pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
1779 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1780 if ( pParty->bTurnBasedModeOn == 1 )
1781 LOBYTE(pSpellSprite.uAttributes) |= 4;
1782 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
1783 if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX, v659, pCastSpell->uPlayerID + 1) != -1
1784 && pParty->bTurnBasedModeOn == 1 )
1785 ++pTurnEngine->pending_actions;
1786 spell_sound_flag = true;
1787 break;
1788 }
1789 case SPELL_EARTH_DEATH_BLOSSOM: //Цветок смерти
1790 {
1791 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
1792 {
1793 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
1794 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
1795 pCastSpell->uSpellID = 0;
1796 continue;
1797 }
1798 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1799 break;
1800 pSpellSprite.uType = 4090;
1801 pSpellSprite.stru_24.Reset();
1802 pSpellSprite.spell_id = pCastSpell->uSpellID;
1803 pSpellSprite.spell_level = spell_level;
1804 pSpellSprite.spell_skill = skill_level;
1805 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1806 pSpellSprite.vPosition.x = pParty->vPosition.x;
1807 pSpellSprite.vPosition.y = pParty->vPosition.y;
1808 pSpellSprite.uAttributes = 0;
1809 pSpellSprite.uSectorID = 0;
1810 pSpellSprite.uSpriteFrameID = 0;
1811 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1812 pSpellSprite.field_60_distance_related_prolly_lod = 0;
1813 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1814 pSpellSprite.spell_target_pid = a2;
1815 pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
1816 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1817 if ( pParty->bTurnBasedModeOn == 1 )
1818 pSpellSprite.uAttributes = 4;
1819 v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
1820 if ( pSpellSprite.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1
1821 && pParty->bTurnBasedModeOn == 1 )
1822 ++pTurnEngine->pending_actions;
1823 spell_sound_flag = true;
1824 break;
1825 }
1826 case SPELL_SPIRIT_DETECT_LIFE: // Детектор жизни
1827 {
1828 switch (skill_level)
1829 {
1830 case 1: amount = 600 * spell_level; break;
1831 case 2: amount = 1800 * spell_level; break;
1832 case 3:
1833 case 4: amount = 3600 * spell_level; break;
1834 default:
1835 assert(false);
1836 }
1837 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1838 break;
1839 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
1840 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
1841 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
1842 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
1843 pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed +
1844 (signed int)(signed __int64)((double)(signed int)((int)amount << 7) * 0.033333335), skill_level, 0, 0, 0);
1845 spell_sound_flag = true;
1846 break;
1847 }
1848 case SPELL_SPIRIT_FATE:// Судьба
1849 {
1850 switch (skill_level)
1851 {
1852 case 1: amount = spell_level; break;
1853 case 2: amount = 2 * spell_level; break;
1854 case 3: amount = 4 * spell_level; break;
1855 case 4: amount = 6 * spell_level; break;
1856 default:
1857 assert(false);
1858 }
1859 //LODWORD(v733) = 300;
1860 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1861 break;
1862 if ( pCastSpell->spell_target_pid == 0 )
1863 {
1864 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
1865 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0);
1866 spell_sound_flag = true;
1867 break;
1868 }
1869 if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor)
1870 {
1871 mon_id = PID_ID(pCastSpell->spell_target_pid);
1872 pActors[mon_id].pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0);
1873 pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR;
1874 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0);
1875 }
1876 spell_sound_flag = true;
1877 break;
1878 }
1879 case SPELL_SPIRIT_REMOVE_CURSE:// Снятие порчи
1880 {
1881 switch (skill_level)
1882 {
1883 case 1: amount = 3600 * spell_level; break;
1884 case 2: amount = 3600 * spell_level; break;
1885 case 3: amount = 86400 * spell_level; break;
1886 case 4: amount = 0; break;
1887 default:
1888 assert(false);
1889 }
1890 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1891 break;
1892 if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] )
1893 {
1894 spell_sound_flag = true;
1895 break;
1896 }
1897 if ( skill_level == 4 )//GM
1898 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] = 0;
1899 else
1900 {
1901 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(0,
1902 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
1903 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] )
1904 {
1905 spell_sound_flag = true;
1906 break;
1907 }
1908 }
1909 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
1910 spell_sound_flag = true;
1911 break;
1912 }
1913 case SPELL_SPIRIT_PRESERVATION://Сохранение
1914 {
1915 if ( skill_level == 4 )
1916 duration = 900 * (spell_level + 4);
1917 else
1918 duration = 300 * (spell_level + 12);
1919 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1920 break;
1921 if ( skill_level == 1 || skill_level == 2 )
1922 {
1923 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
1924 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed +
1925 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
1926 spell_sound_flag = true;
1927 break;
1928 }
1929 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
1930 {
1931 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
1932 pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed +
1933 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
1934 }
1935 spell_sound_flag = true;
1936 break;
1937 }
1938 case SPELL_SPIRIT_TURN_UNDEAD://Бег мертвецов
1939 {
1940 if ( skill_level == 1 || skill_level == 2)
1941 duration = 60 * (spell_level + 3);
1942 else
1943 duration = 300 * spell_level + 180;
1944 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1945 break;
1946 int mon_num = pRenderer->_46А6АС_GetActorsInViewport(4096);
1947 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192);
1948 ++pSpellSprite.uType;
1949 pSpellSprite.stru_24.Reset();
1950 pSpellSprite.spell_id = pCastSpell->uSpellID;
1951 pSpellSprite.spell_level = spell_level;
1952 pSpellSprite.spell_skill = skill_level;
1953 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
1954 pSpellSprite.uAttributes = 0;
1955 pSpellSprite.uSectorID = 0;
1956 pSpellSprite.uSpriteFrameID = 0;
1957 pSpellSprite.field_60_distance_related_prolly_lod = 0;
1958 pSpellSprite.uFacing = 0;
1959 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
1960 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
1961 for ( a2 = 0; a2 < mon_num; ++a2 )
1962 {
1963 if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
1964 {
1965 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x;
1966 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y;
1967 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8);
1968 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
1969 pSpellSprite.Create(0, 0, 0, 0);
1970 pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed +
1971 (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
1972 }
1973 }
1974 spell_sound_flag = true;
1975 break;
1976 }
1977 case SPELL_SPIRIT_RAISE_DEAD://Оживление
1978 {
1979 if ( skill_level == 4 )
1980 amount = 0;
1981 else
1982 amount = 86400 * spell_level;
1983 if ( !pPlayer->CanCastSpell(uRequiredMana) )
1984 break;
1985 pOtherOverlayList->_4418B1(5080, pCastSpell->uPlayerID_2 + 100, 0, 65536);
1986 if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] )
1987 {
1988 spell_sound_flag = true;
1989 break;
1990 }
1991 pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1;
1992 if ( skill_level == 4 )
1993 {
1994 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0;
1995 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0;
1996 }
1997 else
1998 {
1999 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Dead,
2000 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2001 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Unconcious,
2002 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2003 }
2004 pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0);
2005 spell_sound_flag = true;
2006 break;
2007 }
2008 case SPELL_SPIRIT_SHARED_LIFE://Общая жизнь
2009 {
2010 if ( skill_level == 4 )
2011 amount = 4 * spell_level;
2012 else
2013 amount = 3 * spell_level;
2014 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2015 break;
2016 int active_pl_num = 0;
2017 signed int shared_life_count = amount;
2018 int mean_life = 0;
2019 int pl_array[4];
2020 for ( uint pl_id = 1; pl_id <= 4; pl_id++ )
2021 {
2022 if ( !pPlayers[pl_id]->pConditions[Condition_Dead] && !pPlayers[pl_id]->pConditions[Condition_Pertified]
2023 && !pPlayers[pl_id]->pConditions[Condition_Eradicated] )
2024 pl_array[active_pl_num++] = pl_id;
2025 }
2026 for ( uint i = 0; i < active_pl_num; i++ )
2027 shared_life_count += pPlayers[pl_array[i]]->sHealth;
2028 mean_life = (signed __int64)((double)shared_life_count / (double)active_pl_num);
2029 for ( uint i = 0; i < active_pl_num; i++ )
2030 {
2031 pPlayers[pl_array[i]]->sHealth = mean_life;
2032 if ( pPlayers[pl_array[i]]->sHealth > pPlayers[pl_array[i]]->GetMaxHealth())
2033 pPlayers[pl_array[i]]->sHealth = pPlayers[pl_array[i]]->GetMaxHealth();
2034 if ( pPlayers[pl_array[i]]->sHealth > 0 )
2035 pPlayers[pl_array[i]]->SetUnconcious(0);
2036 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[i] - 1);
2037 }
2038 spell_sound_flag = true;
2039 break;
2040 }
2041 case SPELL_SPIRIT_RESSURECTION://Воскресение
2042 {
2043 switch (skill_level)
2044 {
2045 case 1: amount = 180 * spell_level; break;
2046 case 2: amount = 10800 * spell_level; break;
2047 case 3: amount = 259200 * spell_level; break;
2048 case 4: amount = 0; break;
2049 default:
2050 assert(false);
2051 }
2052 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2053 break;
2054 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated]
2055 || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] )
2056 {
2057 if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) )
2058 pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0);
2059 if ( skill_level == 4 )
2060 {
2061 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] = 0;
2062 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0;
2063 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0;
2064 }
2065 else
2066 {
2067 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Eradicated,
2068 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2069 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Dead,
2070 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2071 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Unconcious,
2072 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2073 }
2074 pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 1);
2075 pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1;
2076 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2077 }
2078 spell_sound_flag = true;
2079 break;
2080 }
2081 case SPELL_MIND_CURE_PARALYSIS://лечение паралича
2082 {
2083 switch (skill_level)
2084 {
2085 case 1: amount = 3600 * spell_level; break;
2086 case 2: amount = 3600 * spell_level; break;
2087 case 3: amount = 86400 * spell_level; break;
2088 case 4: amount = 0; break;
2089 default:
2090 assert(false);
2091 }
2092 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2093 break;
2094 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2095 if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] )
2096 {
2097 spell_sound_flag = true;
2098 break;
2099 }
2100 if ( skill_level == 4 )
2101 {
2102 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] = 0;
2103 spell_sound_flag = true;
2104 break;
2105 }
2106 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Paralyzed,
2107 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2108 spell_sound_flag = true;
2109 break;
2110 }
2111 case SPELL_MIND_REMOVE_FEAR://Снять страх
2112 {
2113 switch (skill_level)
2114 {
2115 case 1: amount = 180 * spell_level; break;
2116 case 2: amount = 3600 * spell_level; break;
2117 case 3: amount = 86400 * spell_level; break;
2118 case 4: amount = 0; break;
2119 default:
2120 assert(false);
2121 }
2122 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2123 break;
2124 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2125 if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] )
2126 {
2127 spell_sound_flag = true;
2128 break;
2129 }
2130 if ( skill_level == 4 )
2131 {
2132 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] = 0;
2133 spell_sound_flag = true;
2134 break;
2135 }
2136 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Fear,
2137 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2138 spell_sound_flag = true;
2139 break;
2140 }
2141 case SPELL_MIND_TELEPATHY://Телепатия
2142 {
2143 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2144 break;
2145 if (PID_TYPE(a2) == OBJECT_Actor)
2146 {
2147 mon_id = PID_ID(a2);
2148 if ( !pActors[mon_id].ActorHasItem() )
2149 pActors[mon_id].SetRandomGoldIfTheresNoItem();
2150 int gold_num = 0;
2151 if ( pItemsTable->pItems[pActors[mon_id].ActorHasItems[3].uItemID].uEquipType == EQUIP_GOLD )
2152 gold_num = pActors[mon_id].ActorHasItems[3].uSpecEnchantmentType;
2153 ItemGen item;
2154 item.Reset();
2155 if (pActors[mon_id].uCarriedItemID)
2156 item.uItemID = pActors[mon_id].uCarriedItemID;
2157 else
2158 {
2159 for ( uint i = 0; i < 4; ++i )
2160 {
2161 if ( pActors[mon_id].ActorHasItems[i].uItemID > 0 && pItemsTable->pItems[pActors[mon_id].ActorHasItems[i].uItemID].uEquipType != EQUIP_GOLD )
2162 {
2163 memcpy(&item, &pActors[mon_id].ActorHasItems[i], sizeof(item));
2164 spell_level = v723;
2165 }
2166 }
2167 }
2168 if ( gold_num > 0 )
2169 {
2170 if (item.uItemID)
2171 sprintf(pTmpBuf2.data(), "(%s), and %d gold", item.GetDisplayName(), gold_num);
2172 else
2173 sprintf(pTmpBuf2.data(), "%d gold", gold_num);
2174 }
2175 else
2176 {
2177 if (item.uItemID)
2178 sprintf(pTmpBuf2.data(), "(%s)", item.GetDisplayName());
2179 else
2180 {
2181 strcpy(pTmpBuf2.data(), "nothing");
2182 ShowStatusBarString(pTmpBuf2.data(), 2);
2183 }
2184 }
2185 ShowStatusBarString(pTmpBuf2.data(), 2);
2186 pSpellSprite.stru_24.Reset();
2187 pSpellSprite.spell_id = pCastSpell->uSpellID;
2188 pSpellSprite.spell_level = spell_level;
2189 pSpellSprite.spell_skill = skill_level;
2190 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2191 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
2192 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
2193 pSpellSprite.vPosition.z = pActors[mon_id].uActorHeight;
2194 pSpellSprite.uAttributes = 0;
2195 pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
2196 pSpellSprite.uSpriteFrameID = 0;
2197 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2198 pSpellSprite.spell_target_pid = a2;
2199 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
2200 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
2201 LOBYTE(pSpellSprite.uAttributes) |= 0x80;
2202 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2203 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
2204 }
2205 spell_sound_flag = true;
2206 break;
2207 }
2208 case SPELL_MIND_BERSERK://Берсерк
2209 {
2210 switch (skill_level)
2211 {
2212 case 1: amount = 300 * spell_level; break;
2213 case 2: amount = 300 * spell_level; break;
2214 case 3: amount = 600 * spell_level; break;
2215 case 4: amount = 3600; break;
2216 default:
2217 assert(false);
2218 }
2219 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2220 break;
2221 mon_id = PID_ID(a2);
2222 if (PID_TYPE(a2) == OBJECT_Actor)
2223 {
2224 //v730 = 836 * mon_id;
2225 if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) )
2226 {
2227 pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset();
2228 pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset();
2229 pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), skill_level, 0, 0, 0);
2230 pActors[mon_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
2231 }
2232 pSpellSprite.stru_24.Reset();
2233 pSpellSprite.spell_id = pCastSpell->uSpellID;
2234 pSpellSprite.spell_level = spell_level;
2235 pSpellSprite.spell_skill = skill_level;
2236 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2237 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
2238 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
2239 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight;
2240 pSpellSprite.uAttributes = 0;
2241 pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z);
2242 pSpellSprite.uSpriteFrameID = 0;
2243 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2244 pSpellSprite.spell_target_pid = a2;
2245 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
2246 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
2247 LOBYTE(pSpellSprite.uAttributes) |= 0x80;
2248 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2249 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
2250 }
2251 spell_sound_flag = true;
2252 break;
2253 }
2254 case SPELL_MIND_ENSLAVE://Порабощение
2255 {
2256 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2257 break;
2258 amount = 600 * spell_level;
2259 if (PID_TYPE(a2) == OBJECT_Actor)
2260 {
2261 mon_id = PID_ID(a2);
2262 //v730 = 836 * mon_id;
2263 if ( MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
2264 break;
2265 if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) )
2266 {
2267 pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
2268 pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset();
2269 pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
2270 skill_level, 0, 0, 0);
2271 }
2272 pSpellSprite.stru_24.Reset();
2273 pSpellSprite.spell_id = pCastSpell->uSpellID;
2274 pSpellSprite.spell_level = spell_level;
2275 pSpellSprite.spell_skill = skill_level;
2276 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2277 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
2278 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
2279 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight;
2280 pSpellSprite.uAttributes = 0;
2281 pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z);
2282 pSpellSprite.uSpriteFrameID = 0;
2283 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2284 pSpellSprite.spell_target_pid = a2;
2285 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
2286 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
2287 LOBYTE(pSpellSprite.uAttributes) |= 0x80;
2288 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2289 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
2290 }
2291 spell_sound_flag = true;
2292 break;
2293 }
2294 case SPELL_MIND_MASS_FEAR://Массовый страх
2295 {
2296 if ( skill_level == 4 )
2297 amount = 300 * spell_level;
2298 else
2299 amount = 180 * spell_level;
2300 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2301 break;
2302 int mon_num = pRenderer->_46А6АС_GetActorsInViewport(4096);
2303 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0A, 192);
2304 ++pSpellSprite.uType;
2305 pSpellSprite.stru_24.Reset();
2306 pSpellSprite.spell_id = pCastSpell->uSpellID;
2307 pSpellSprite.spell_level = spell_level;
2308 pSpellSprite.spell_skill = skill_level;
2309 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2310 pSpellSprite.uAttributes = 0;
2311 pSpellSprite.uSectorID = 0;
2312 pSpellSprite.uSpriteFrameID = 0;
2313 pSpellSprite.field_60_distance_related_prolly_lod = 0;
2314 pSpellSprite.uFacing = 0;
2315 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2316 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2317 for ( a2 = 0; a2 < mon_num; ++a2 )
2318 {
2319 if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
2320 break;
2321 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x;
2322 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y;
2323 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8);
2324 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
2325 pSpellSprite.Create(0, 0, 0, 0);
2326 if ( pActors[_50BF30_actors_in_viewport_ids[a2]].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) )
2327 {
2328 pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
2329 skill_level, 0, 0, 0);
2330 }
2331 }
2332 spell_sound_flag = true;
2333 break;
2334 }
2335 case SPELL_MIND_CURE_INSANITY://Лечение Безумия
2336 {
2337 if ( skill_level == 4 )
2338 amount = 0;
2339 else
2340 amount = 86400 * spell_level;
2341 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2342 break;
2343 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2344 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] )
2345 {
2346 if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) )
2347 pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0);
2348 if ( skill_level == 4 )
2349 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] = 0;
2350 else
2351 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Insane,
2352 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2353 pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0);
2354 }
2355 spell_sound_flag = true;
2356 break;
2357 }
2358 case SPELL_EARTH_TELEKINESIS://Телекинез
2359 {
2360 switch (skill_level)
2361 {
2362 case 1: amount = 2 * spell_level; break;
2363 case 2: amount = 2 * spell_level; break;
2364 case 3: amount = 3 * spell_level; break;
2365 case 4: amount = 4 * spell_level; break;
2366 default:
2367 assert(false);
2368 }
2369 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2370 break;
2371 int obj_id = PID_ID(a2);
2372 if (PID_TYPE(a2) == OBJECT_Item)
2373 {
2374 if ( pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].uEquipType == EQUIP_GOLD )
2375 {
2376 pParty->PartyFindsGold(pSpriteObjects[obj_id].stru_24.uSpecEnchantmentType, 0);
2377 viewparams->bRedrawGameUI = true;
2378 }
2379 else
2380 {
2381 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].pUnidentifiedName);//Вы нашли ^Pv[%s]!
2382 ShowStatusBarString(pTmpBuf2.data(), 2);
2383 if ( !pParty->AddItemToParty(&pSpriteObjects[obj_id].stru_24) )
2384 pParty->SetHoldingItem(&pSpriteObjects[obj_id].stru_24);
2385 }
2386 SpriteObject::OnInteraction(obj_id);
2387 }
2388 if (PID_TYPE(a2) == OBJECT_Actor)
2389 pActors[obj_id].LootActor();
2390 if (PID_TYPE(a2) == OBJECT_Decoration)
2391 {
2392 OpenedTelekinesis = true;
2393 if ( pLevelDecorations[obj_id].uEventID )
2394 EventProcessor(pLevelDecorations[obj_id].uEventID, a2, 1);
2395 if ( pLevelDecorations[pSpriteObjects[obj_id].stru_24.uItemID].IsInteractive() )
2396 {
2397 activeLevelDecoration = &pLevelDecorations[obj_id];
2398 EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[obj_id]._idx_in_stru123 - 75] + 380, 0, 1);
2399 activeLevelDecoration = nullptr;
2400 }
2401 }
2402 if (PID_TYPE(a2) == OBJECT_BModel)
2403 {
2404 OpenedTelekinesis = true;
2405 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
2406 v448 = pIndoor->pFaceExtras[pIndoor->pFaces[obj_id].uFaceExtraID].uEventID;
2407 else
2408 v448 = pOutdoor->pBModels[a2 >> 9].pFaces[obj_id & 0x3F].sCogTriggeredID;
2409 EventProcessor(v448, a2, 1);
2410 }
2411 spell_sound_flag = true;
2412 break;
2413 }
2414 case SPELL_BODY_CURE_WEAKNESS://Лечить Слабость
2415 {
2416 switch (skill_level)
2417 {
2418 case 1: amount = 180 * spell_level; break;//3 минуты * количество очков навыка
2419 case 2: amount = 3600 * spell_level; break;//1 час * количество очков навыка
2420 case 3: amount = 86400 * spell_level; break;
2421 case 4: amount = 0; break;
2422 default:
2423 assert(false);
2424 }
2425 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2426 break;
2427 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2428 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] )
2429 {
2430 if ( skill_level == 4 )
2431 {
2432 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] = 0;
2433 spell_sound_flag = true;
2434 break;
2435 }
2436 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Weak,
2437 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2438 }
2439 spell_sound_flag = true;
2440 break;
2441 }
2442 case SPELL_BODY_FIRST_AID://Первая помощь
2443 {
2444 switch (skill_level)
2445 {
2446 case 1: amount = 2 * spell_level + 5; break;
2447 case 2: amount = 3 * spell_level + 5; break;
2448 case 3: amount = 4 * spell_level + 5; break;
2449 case 4: amount = 5 * spell_level + 5; break;
2450 default:
2451 assert(false);
2452 }
2453 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2454 break;
2455 if ( !pCastSpell->spell_target_pid )
2456 {
2457 pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount);
2458 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2459 }
2460 if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor)
2461 {
2462 mon_id = PID_ID(pCastSpell->spell_target_pid);
2463 if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying && pActors[mon_id].uAIState != Disabled
2464 && pActors[mon_id].uAIState != Removed )
2465 {
2466 pActors[mon_id].sCurrentHP += amount;
2467 if ( pActors[mon_id].sCurrentHP > pActors[mon_id].pMonsterInfo.uHP )
2468 pActors[mon_id].sCurrentHP = pActors[mon_id].pMonsterInfo.uHP;
2469 }
2470 }
2471 spell_sound_flag = true;
2472 break;
2473 }
2474 case SPELL_BODY_CURE_POISON://Лечение Отравления(Противоядие)
2475 {
2476 switch (skill_level)
2477 {
2478 case 1: amount = 3600 * spell_level; break;
2479 case 2: amount = 3600 * spell_level; break;
2480 case 3: amount = 86400 * spell_level; break;
2481 case 4: amount = 0; break;
2482 default:
2483 assert(false);
2484 }
2485 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2486 break;
2487 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2488 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak]
2489 || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium]
2490 || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] )
2491 {
2492 if ( skill_level == 4 )
2493 {
2494 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak] = 0;
2495 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium] = 0;
2496 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] = 0;
2497 spell_sound_flag = true;
2498 break;
2499 }
2500 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Weak, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2501 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Medium, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2502 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Severe, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2503 }
2504 spell_sound_flag = true;
2505 break;
2506 }
2507 case SPELL_BODY_PROTECTION_FROM_MAGIC://Защита от магии
2508 {
2509 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2510 break;
2511 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
2512 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
2513 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
2514 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
2515 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed +
2516 (signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, 0, 0);
2517 spell_sound_flag = true;
2518 break;
2519 }
2520 case SPELL_BODY_HAMMERHANDS://Руки-Молоты
2521 {
2522 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2523 break;
2524 if ( skill_level == 4 )
2525 {
2526 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
2527 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
2528 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
2529 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
2530 for ( uint pl_id = 0; pl_id < 4; pl_id++)
2531 pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed +
2532 (signed int)(signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) * 0.033333335), 4, spell_level, spell_level, 0);
2533 spell_sound_flag = true;
2534 break;
2535 }
2536 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2537 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed +
2538 (signed int)(signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, spell_level, 0);
2539 spell_sound_flag = true;
2540 break;
2541 }
2542 case SPELL_BODY_CURE_DISEASE://Лечить Болезнь
2543 {
2544 if ( skill_level == 4 )
2545 amount = 0;
2546 else
2547 amount = 86400 * spell_level;
2548 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2549 break;
2550 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2551 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak]
2552 || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium]
2553 || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] )
2554 {
2555 if ( skill_level == 4 )
2556 {
2557 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak] = 0;
2558 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium] = 0;
2559 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] = 0;
2560 }
2561 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Weak,
2562 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2563 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Medium,
2564 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2565 pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Severe,
2566 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
2567 }
2568 spell_sound_flag = true;
2569 break;
2570 }
2571 case SPELL_BODY_POWER_CURE://Исцеление
2572 {
2573 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2574 break;
2575 for ( uint pl_id = 0; pl_id < 4; ++pl_id )
2576 {
2577 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
2578 pParty->pPlayers[pl_id].Heal(5 * spell_level + 10);
2579 }
2580 spell_sound_flag = true;
2581 break;
2582 }
2583 case SPELL_LIGHT_DISPEL_MAGIC://Снятие чар
2584 {
2585 sRecoveryTime -= spell_level;
2586 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2587 break;
2588 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192);
2589 int mon_num = pRenderer->_46А6АС_GetActorsInViewport(4096);
2590 ++pSpellSprite.uType;
2591 v688.x = 0;
2592 v688.y = 0;
2593 v688.z = 0;
2594 pSpellSprite.stru_24.Reset();
2595 pSpellSprite.spell_id = pCastSpell->uSpellID;
2596 pSpellSprite.spell_level = spell_level;
2597 pSpellSprite.spell_skill = skill_level;
2598 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2599 pSpellSprite.uAttributes = 0;
2600 pSpellSprite.uSectorID = 0;
2601 pSpellSprite.uSpriteFrameID = 0;
2602 pSpellSprite.field_60_distance_related_prolly_lod = 0;
2603 pSpellSprite.uFacing = 0;
2604 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2605 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2606 for ( a2 = 0; a2 < mon_num; ++a2 )
2607 {
2608 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x;
2609 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y;
2610 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z -
2611 (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8);
2612 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
2613 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[a2], &v688);
2614 }
2615 for ( a2 = 0; a2 < mon_num; ++a2 )
2616 {
2617 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x;
2618 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y;
2619 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z -
2620 (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8);
2621 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
2622 pSpellSprite.Create(0, 0, 0, 0);
2623 for (int i = 0; i < 22; ++i)
2624 pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[i].Reset();
2625 }
2626 spell_sound_flag = true;
2627 break;
2628 }
2629 case SPELL_LIGHT_SUMMON_ELEMENTAL://Элементал
2630 {
2631 switch (skill_level)
2632 {
2633 case 1: v733 = 300 * spell_level; amount = 1; break;
2634 case 2: v733 = 300 * spell_level; amount = 1; break;
2635 case 3: v733 = 900 * spell_level; amount = 3; break;
2636 case 4: v733 = 900 * spell_level; amount = 5; break;
2637 default:
2638 assert(false);
2639 }
2640 int mon_num = 0;
2641 for ( uint mon_id = 0; mon_id < uNumActors; mon_id++ )
2642 {
2643 if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Removed && pActors[mon_id].uAIState != Disabled
2644 && PID(OBJECT_Player, pCastSpell->uPlayerID) == pActors[mon_id].uSummonerID )
2645 ++mon_num;
2646 }
2647 if ( mon_num >= amount )
2648 {
2649 ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters!
2650 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2651 pCastSpell->uSpellID = 0;
2652 continue;
2653 }
2654 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2655 break;
2656 sub_44FA4C_spawn_light_elemental(pCastSpell->uPlayerID, skill_level, v733);
2657 spell_sound_flag = true;
2658 break;
2659 }
2660 case SPELL_LIGHT_DAY_OF_THE_GODS://День богов
2661 {
2662 switch (skill_level)
2663 {
2664 case 1: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break;
2665 case 2: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break;
2666 case 3: duration = 14400 * spell_level; amount = 4 * spell_level + 10; break;
2667 case 4: duration = 18000 * spell_level; amount = 5 * spell_level + 10; break;
2668 default:
2669 assert(false);
2670 }
2671 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2672 break;
2673 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
2674 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
2675 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
2676 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
2677 pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed +
2678 (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2679 spell_sound_flag = true;
2680 break;
2681 }
2682 case SPELL_LIGHT_PRISMATIC_LIGHT://Свет призмы
2683 {
2684 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
2685 {
2686 ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors!
2687 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2688 pCastSpell->uSpellID = 0;
2689 continue;
2690 }
2691 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2692 break;
2693 int mon_num = pRenderer->_46А6АС_GetActorsInViewport(4096);
2694 ++pSpellSprite.uType;
2695 v694.x = 0;
2696 v694.y = 0;
2697 v694.z = 0;
2698 pSpellSprite.stru_24.Reset();
2699 pSpellSprite.spell_id = pCastSpell->uSpellID;
2700 pSpellSprite.spell_level = spell_level;
2701 pSpellSprite.spell_skill = skill_level;
2702 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2703 pSpellSprite.uAttributes = 0;
2704 pSpellSprite.uSectorID = 0;
2705 pSpellSprite.uSpriteFrameID = 0;
2706 pSpellSprite.field_60_distance_related_prolly_lod = 0;
2707 pSpellSprite.uFacing = 0;
2708 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2709 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2710 for ( uint mon_id = 0; mon_id < mon_num; mon_id++ )
2711 {
2712 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x;
2713 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y;
2714 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z -
2715 (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8);
2716 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]);
2717 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v694);
2718 }
2719 //v537 = pGame->GetStru6();
2720 pGame->GetStru6()->_4A8BFC();
2721 spell_sound_flag = true;
2722 break;
2723 }
2724 case SPELL_LIGHT_DAY_OF_PROTECTION://День защиты
2725 {
2726 switch (skill_level)
2727 {
2728 case 1: duration = 14400 * spell_level; amount = 4 * spell_level; break;
2729 case 2: duration = 14400 * spell_level; amount = 4 * spell_level; break;
2730 case 3: duration = 14400 * spell_level; amount = 4 * spell_level; break;
2731 case 4: duration = 18000 * spell_level; amount = 5 * spell_level; break;
2732 default:
2733 assert(false);
2734 }
2735 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2736 break;
2737 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
2738 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
2739 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
2740 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
2741 pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed +
2742 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2743 pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed +
2744 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2745 pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed +
2746 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2747 pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed +
2748 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2749 pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed +
2750 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2751 pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed +
2752 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0);
2753 pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed +
2754 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2755 pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed +
2756 (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2757 spell_sound_flag = true;
2758 break;
2759 }
2760 case SPELL_LIGHT_HOUR_OF_POWER: //Час могущества
2761 {
2762 switch (skill_level)
2763 {
2764 case 1: duration = 4; amount = 4; break;
2765 case 2: duration = 4; amount = 4; break;
2766 case 3: duration = 12; amount = 12; break;
2767 case 4: duration = 20; amount = 15; break;
2768 default:
2769 assert(false);
2770 }
2771 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2772 break;
2773 bool player_weak = false;
2774 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
2775 {
2776 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
2777 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
2778 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
2779 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
2780 pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed +
2781 (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2782 if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] )
2783 player_weak = true;
2784 }
2785 pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply(pParty->uTimePlayed +
2786 (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2787 pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply(pParty->uTimePlayed +
2788 (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, 0, 0, 0);
2789 pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply(pParty->uTimePlayed +
2790 (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2791 if ( !player_weak )
2792 pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed +
2793 (signed __int64)((double)((60 * (spell_level * duration + 60)) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0);
2794 spell_sound_flag = true;
2795 break;
2796 }
2797 case SPELL_LIGHT_DIVINE_INTERVENTION://Божественное вмешательство
2798 {
2799 //amount = 3;
2800 if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3 )
2801 {
2802 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
2803 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2804 pCastSpell->uSpellID = 0;
2805 continue;
2806 }
2807 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2808 break;
2809 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
2810 {
2811 for ( uint buff_id = 0; buff_id <= 19; buff_id++ )
2812 pParty->pPlayers[pl_id].pConditions[buff_id] = 0;
2813 pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth();
2814 pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana();
2815 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
2816 }
2817 if ( pPlayer->sAgeModifier + 10 >= 120 )
2818 pPlayer->sAgeModifier = 120;
2819 else
2820 pPlayer->sAgeModifier = pPlayer->sAgeModifier + 10;
2821 sRecoveryTime += -5 * spell_level;
2822 ++pPlayer->uNumDivineInterventionCastsThisDay;
2823 spell_sound_flag = true;
2824 break;
2825 }
2826 case SPELL_DARK_REANIMATE: //Реанимация
2827 {
2828 switch (skill_level)
2829 {
2830 case 1: amount = 2 * spell_level; break;
2831 case 2: amount = 3 * spell_level; break;
2832 case 3: amount = 4 * spell_level; break;
2833 case 4: amount = 5 * spell_level; break;
2834 default:
2835 assert(false);
2836 }
2837 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2838 break;
2839 if (!pCastSpell->spell_target_pid)
2840 {
2841 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
2842 if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] )
2843 {
2844 pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Zombie, 1);
2845 ReloadPlayerPortraits(pCastSpell->uPlayerID_2, (pParty->pPlayers[pCastSpell->uPlayerID_2].GetSexByVoice() != 0) + 23);
2846 pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Zombie] = pParty->uTimePlayed;
2847 }
2848 break;
2849 }
2850 mon_id = PID_ID(pCastSpell->spell_target_pid);
2851 if ( mon_id == -1 )
2852 {
2853 ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists!
2854 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2855 pCastSpell->uSpellID = 0;
2856 continue;
2857 }
2858 if ( pActors[mon_id].sCurrentHP > 0
2859 || pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying )
2860 {
2861 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
2862 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2863 pCastSpell->uSpellID = 0;
2864 continue;
2865 }
2866 ++pSpellSprite.uType;
2867 pSpellSprite.stru_24.Reset();
2868 pSpellSprite.spell_id = pCastSpell->uSpellID;
2869 pSpellSprite.spell_level = spell_level;
2870 pSpellSprite.spell_skill = skill_level;
2871 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2872 pSpellSprite.uAttributes = 0;
2873 pSpellSprite.uSectorID = 0;
2874 pSpellSprite.uSpriteFrameID = 0;
2875 pSpellSprite.field_60_distance_related_prolly_lod = 0;
2876 pSpellSprite.uFacing = 0;
2877 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2878 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2879 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
2880 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
2881 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z -
2882 (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8);
2883 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id);
2884 pSpellSprite.Create(0, 0, 0, 0);
2885 if ( pActors[mon_id].pMonsterInfo.uLevel > amount )
2886 break;
2887 Actor::Resurrect(mon_id);
2888 pActors[mon_id].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0;
2889 pActors[mon_id].pMonsterInfo.uTreasureDropChance = 0;
2890 pActors[mon_id].pMonsterInfo.uTreasureDiceRolls = 0;
2891 pActors[mon_id].pMonsterInfo.uTreasureDiceSides = 0;
2892 pActors[mon_id].pMonsterInfo.uTreasureLevel = 0;
2893 pActors[mon_id].pMonsterInfo.uTreasureType = 0;
2894 pActors[mon_id].uAlly = 9999;
2895 pActors[mon_id].ResetAggressor();//~0x80000
2896 pActors[mon_id].uGroup = 0;
2897 pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
2898 pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset();
2899 pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset();
2900 if ( pActors[mon_id].sCurrentHP > 10 * amount )
2901 pActors[mon_id].sCurrentHP = 10 * amount;
2902 spell_sound_flag = true;
2903 break;
2904 }
2905 case SPELL_DARK_VAMPIRIC_WEAPON:// Оружие-вампир
2906 {
2907 amount = 16;
2908 if ( skill_level == 4 )
2909 duration = 0;
2910 else
2911 duration = 3600 * spell_level;
2912 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2913 break;
2914 ItemGen *item = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
2915 item->UpdateTempBonus(pParty->uTimePlayed);
2916 if ( item->uItemID >= 64 && item->uItemID <= 65//blasters
2917 || LOBYTE(item->uAttributes) & 2
2918 || item->uSpecEnchantmentType != 0
2919 || item->uEnchantmentType != 0
2920 || pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_SINGLE_HANDED
2921 && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_TWO_HANDED
2922 && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_BOW
2923 || pItemsTable->IsMaterialNonCommon(item) )
2924 {
2925 _50C9D0_AfterEnchClickEventId = 113;
2926 _50C9D4_AfterEnchClickEventSecondParam = 0;
2927 _50C9D8_AfterEnchClickEventTimeout = 1;
2928 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
2929 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
2930 pCastSpell->uSpellID = 0;
2931 continue;
2932 }
2933 item->uSpecEnchantmentType = 16;
2934 if ( skill_level != 4 )
2935 {
2936 item->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335);
2937 item->uAttributes |= 8;
2938 }
2939 LOBYTE(item->uAttributes) |= 0x80;
2940 _50C9A8_item_enchantment_timer = 256;
2941 spell_sound_flag = true;
2942 break;
2943 }
2944 case SPELL_DARK_SHARPMETAL://Шрапнель
2945 {
2946 switch (skill_level)
2947 {
2948 case 1: amount = 5; break;
2949 case 2: amount = 5; break;
2950 case 3: amount = 7; break;
2951 case 4: amount = 9; break;
2952 default:
2953 assert(false);
2954 }
2955 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2956 break;
2957 signed int _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360);
2958 pSpellSprite.stru_24.Reset();
2959 pSpellSprite.spell_id = pCastSpell->uSpellID;
2960 pSpellSprite.spell_level = spell_level;
2961 pSpellSprite.spell_skill = skill_level;
2962 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
2963 pSpellSprite.vPosition.x = pParty->vPosition.x;
2964 pSpellSprite.vPosition.y = pParty->vPosition.y;
2965 pSpellSprite.uAttributes = 0;
2966 pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
2967 pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y,
2968 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
2969 pSpellSprite.uSpriteFrameID = 0;
2970 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
2971 pSpellSprite.spell_target_pid = a2;
2972 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
2973 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
2974 if ( pParty->bTurnBasedModeOn == 1 )
2975 LOBYTE(pSpellSprite.uAttributes) |= 4;
2976 v188 = (signed int)_v726 / -2;
2977 v189 = (signed int)_v726 / 2;
2978 if ( v188 <= v189 )
2979 {
2980 do
2981 {
2982 pSpellSprite.uFacing = v188 + v715.uYawAngle;
2983 if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle,
2984 pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1
2985 && pParty->bTurnBasedModeOn == 1 )
2986 ++pTurnEngine->pending_actions;
2987 v188 += _v726 / (amount - 1);
2988 }
2989 while ( v188 <= v189 );
2990 }
2991 spell_sound_flag = true;
2992 break;
2993 }
2994 case SPELL_DARK_CONTROL_UNDEAD://Глава нежити
2995 {
2996 if ( !pPlayer->CanCastSpell(uRequiredMana) )
2997 break;
2998 switch (skill_level)
2999 {
3000 case 1: duration = 180 * spell_level; break;
3001 case 2: duration = 180 * spell_level; break;
3002 case 3: duration = 300 * spell_level; break;
3003 case 4: duration = 29030400; break;
3004 default:
3005 assert(false);
3006 }
3007 if (PID_TYPE(a2) == OBJECT_Actor)
3008 {
3009 mon_id = PID_ID(a2);
3010 if ( !MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
3011 break;
3012 if ( !pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)10) )
3013 {
3014 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
3015 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
3016 pCastSpell->uSpellID = 0;
3017 continue;
3018 }
3019 pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
3020 pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset();
3021 pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed +
3022 (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0);
3023 pSpellSprite.stru_24.Reset();
3024 pSpellSprite.spell_id = pCastSpell->uSpellID;
3025 pSpellSprite.spell_level = spell_level;
3026 pSpellSprite.spell_skill = skill_level;
3027 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
3028 pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
3029 pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
3030 pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight;
3031 pSpellSprite.uAttributes = 0;
3032 pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z);
3033 pSpellSprite.uSpriteFrameID = 0;
3034 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
3035 pSpellSprite.spell_target_pid = a2;
3036 pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3037 pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
3038 LOBYTE(pSpellSprite.uAttributes) |= 0x80;
3039 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
3040 pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
3041 }
3042 spell_sound_flag = true;
3043 break;
3044 }
3045 case SPELL_DARK_SACRIFICE://Жертва
3046 {
3047 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3048 break;
3049 int hired_npc = 0;
3050 memset(&achieved_awards, 0, 4000);
3051 for ( uint npc_id = 0; npc_id < 2; npc_id++ ) //количество нанятых НПС
3052 {
3053 if ( pParty->pHirelings[npc_id].pName != 0)
3054 achieved_awards[hired_npc++] = (AwardType)(npc_id + 1);
3055 }
3056 /*if ( (signed int)pNPCStats->uNumNewNPCs > 0)
3057 {
3058 //AwardType *_v734 = &achieved_awards[_v733];
3059 for ( int npc_id = 0; npc_id < pNPCStats->uNumNewNPCs; ++npc_id )
3060 {
3061 if ( pNPCStats->pNewNPCData[npc_id].uFlags & 0x80//hired(наёмный)
3062 && (!pParty->pHirelings[0].pName
3063 || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[0].pName))
3064 && (!pParty->pHirelings[1].pName
3065 || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[1].pName)) )
3066 {
3067 //v607 = _v734;
3068 //++_v734;
3069 achieved_awards[hired_npc++] = (AwardType)(npc_id + 3);
3070 }
3071 }
3072 }*/
3073 if ( pCastSpell->uPlayerID_2 != 4 && pCastSpell->uPlayerID_2 != 5
3074 || achieved_awards[pCastSpell->uPlayerID_2 - 4] <= 0 || achieved_awards[pCastSpell->uPlayerID_2 - 4] >= 3 )
3075 {
3076 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
3077 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
3078 pCastSpell->uSpellID = 0;
3079 continue;
3080 }
3081 pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_A = 1;
3082 pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_B = 0;
3083 pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_C = pIconsFrameTable->GetIconAnimLength(pIconsFrameTable->FindIcon("spell96"));
3084 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
3085 {
3086 pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth();
3087 pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana();
3088 }
3089 v613 = &pOutdoor->ddm;
3090 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
3091 v613 = &pIndoor->dlv;
3092 v613->uReputation += 15;
3093 if ( v613->uReputation > 10000 )
3094 v613->uReputation = 10000;
3095 spell_sound_flag = true;
3096 break;
3097 }
3098 case SPELL_DARK_PAIN_REFLECTION://Отражение боли
3099 {
3100 switch (skill_level)
3101 {
3102 case 1: duration = 300 * (spell_level + 12); break;
3103 case 2: duration = 300 * (spell_level + 12); break;
3104 case 3: duration = 300 * (spell_level + 12); break;
3105 case 4: duration = 900 * (spell_level + 4); break;
3106 default:
3107 assert(false);
3108 }
3109 amount = spell_level + 5;
3110 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3111 break;
3112 if ( skill_level != 3 && skill_level != 4 )
3113 {
3114 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
3115 pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed +
3116 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
3117 spell_sound_flag = true;
3118 break;
3119 }
3120 for ( uint pl_id = 0; pl_id < 4; pl_id++ )
3121 {
3122 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
3123 pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed +
3124 (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
3125 }
3126 spell_sound_flag = true;
3127 break;
3128 }
3129 case SPELL_DARK_SOULDRINKER://Испить душу
3130 {
3131 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3132 break;
3133 pGame->GetIndoorCamera();
3134 int mon_num = pRenderer->_46А6АС_GetActorsInViewport((signed __int64)pGame->pIndoorCameraD3D->GetPickDepth());
3135 v707.x = 0;
3136 v707.y = 0;
3137 v707.z = 0;
3138 pSpellSprite.stru_24.Reset();
3139 pSpellSprite.spell_id = pCastSpell->uSpellID;
3140 pSpellSprite.spell_level = spell_level;
3141 pSpellSprite.spell_skill = skill_level;
3142 pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
3143 pSpellSprite.uAttributes = 0;
3144 pSpellSprite.uSectorID = 0;
3145 pSpellSprite.uSpriteFrameID = 0;
3146 pSpellSprite.field_60_distance_related_prolly_lod = 0;
3147 pSpellSprite.uFacing = 0;
3148 pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
3149 pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
3150 amount = 0;
3151 if ( mon_num > 0 )
3152 {
3153 amount = (mon_num * (7 * spell_level + 25));
3154 for ( uint mon_id = 0; mon_id < mon_num; mon_id++ )
3155 {
3156 pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x;
3157 pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y;
3158 pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z -
3159 (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8);
3160 pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]);
3161 Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v707);
3162 }
3163 }
3164 int pl_num = 0;
3165 int pl_array[4];
3166 for ( uint pl_id = 1; pl_id <= 4; ++pl_id )
3167 {
3168 if ( !pPlayers[pl_id]->pConditions[Condition_Sleep] && !pPlayers[pl_id]->pConditions[Condition_Paralyzed]
3169 && !pPlayers[pl_id]->pConditions[Condition_Unconcious] && !pPlayers[pl_id]->pConditions[Condition_Dead]
3170 && !pPlayers[pl_id]->pConditions[Condition_Pertified] && !pPlayers[pl_id]->pConditions[Condition_Eradicated] )
3171 {
3172 pl_array[pl_num++] = pl_id;
3173 }
3174 }
3175 for ( uint j = 0; j < pl_num; j++ )
3176 {
3177 pPlayers[pl_array[j]]->sHealth += (signed __int64)((double)(signed int)amount / (double)pl_num);
3178 if ( pPlayers[pl_array[j]]->sHealth > pPlayers[pl_array[j]]->GetMaxHealth())
3179 pPlayers[pl_array[j]]->sHealth = pPlayers[pl_array[j]]->GetMaxHealth();
3180 pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[j]);
3181 }
3182 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 64);
3183 spell_sound_flag = true;
3184 break;
3185 }
3186 case SPELL_DARK_ARMAGEDDON://Армагеддон
3187 {
3188 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
3189 {
3190 ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors!
3191 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
3192 pCastSpell->uSpellID = 0;
3193 continue;
3194 }
3195 if ( skill_level == 4)
3196 amount = 4;
3197 else
3198 amount = 3;
3199 if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 )
3200 {
3201 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
3202 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
3203 pCastSpell->uSpellID = 0;
3204 continue;
3205 }
3206 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3207 break;
3208 pParty->armageddon_timer = 256;
3209 pParty->armageddonDamage = spell_level;
3210 ++pPlayer->uNumArmageddonCasts;
3211 if ( pParty->bTurnBasedModeOn == 1 )
3212 ++pTurnEngine->pending_actions;
3213 for ( uint i = 0; i < 50; i++ )
3214 {
3215 v642 = rand() % 4096 - 2048;
3216 v643 = rand();
3217 v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), &v710, 0);
3218 SpriteObject::sub_42F7EB_DropItemAt(4070, v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), v732 + 16, rand() % 500 + 500, 1, 0, 0, 0);
3219 }
3220 spell_sound_flag = true;
3221 break;
3222 }
3223 default:
3224 break;
3225 }
3226 if ( pCastSpell->uFlags & 0x20 )
3227 {
3228 if ( spell_sound_flag )
3229 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0);
3230 }
3231 else
3232 {
3233 if ( sRecoveryTime < 0 )
3234 sRecoveryTime = 0;
3235 if ( pParty->bTurnBasedModeOn )
3236 {
3237 //v645 = sRecoveryTime;
3238 pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime;
3239 pPlayer->SetRecoveryTime(sRecoveryTime);
3240 if ( !some_active_character )
3241 pTurnEngine->ApplyPlayerAction();
3242 }
3243 else
3244 pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
3245 if ( spell_sound_flag )
3246 {
3247 pPlayer->PlaySound(SPEECH_49, 0);
3248 //if ( spell_sound_flag )
3249 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0);
3250 }
3251 }
3252 pCastSpell->uSpellID = 0;
3253 spell_level = v723;
3254 continue;
3255 }
3256
3257 }
3258 //----- (00427DA0) --------------------------------------------------------
3259 size_t PushCastSpellInfo(uint16_t uSpellID, uint16_t uPlayerID, __int16 skill_level, uint16_t uFlags, int spell_sound_id)
3260 {
3261 for (size_t i = 0; i < CastSpellInfoCount; i++)
3262 {
3263 if (!pCastSpellInfo[i].uSpellID)
3264 {
3265 pCastSpellInfo[i].uSpellID = uSpellID;
3266 pCastSpellInfo[i].uPlayerID = uPlayerID;
3267 if (uFlags & 0x10)
3268 pCastSpellInfo[i].uPlayerID_2 = uPlayerID;
3269 pCastSpellInfo[i].field_6 = 0;
3270 pCastSpellInfo[i].spell_target_pid = 0;
3271 pCastSpellInfo[i].uFlags = uFlags;
3272 pCastSpellInfo[i].forced_spell_skill_level = skill_level;
3273 pCastSpellInfo[i].sound_id = spell_sound_id;
3274 return i;
3275 }
3276 }
3277 return -1;
3278 }
3279 //----- (00427D48) --------------------------------------------------------
3280 void CastSpellInfoHelpers::_427D48()
3281 {
3282 for (size_t i = 0; i < CastSpellInfoCount; i++)
3283 {
3284 if (pCastSpellInfo[i].uSpellID && pCastSpellInfo[i].uFlags & 0x3CA)
3285 {
3286 pCastSpellInfo[i].uSpellID = 0;
3287 pGUIWindow_Settings->Release();
3288 pGUIWindow_Settings = 0;
3289 pMouse->SetCursorBitmap("MICON1");
3290 GameUI_Footer_TimeLeft = 0;
3291 _50C9A0_IsEnchantingInProgress = 0;
3292 back_to_game();
3293 }
3294 }
3295 }
3296 //----- (0042777D) --------------------------------------------------------
3297 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6)
3298 {
3299 unsigned __int16 v9; // cx@16
3300 unsigned int v10; // eax@18
3301 unsigned __int8 v11; // sf@18
3302 unsigned __int8 v12; // of@18
3303 unsigned __int16 v13; // cx@21
3304 unsigned int v14; // eax@23
3305
3306 //if ( pParty->bTurnBasedModeOn != 1
3307 // || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 )
3308 if (pParty->bTurnBasedModeOn)
3309 {
3310 if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT )
3311 return;
3312 }
3313
3314
3315 //v6 = a5;
3316 //v7 = &pParty->pPlayers[uPlayerID];
3317 assert(uPlayerID < 4);
3318 Player* player = &pParty->pPlayers[uPlayerID];
3319 if ( !(a5 & 0x10) )
3320 {
3321 switch ( a1 )
3322 {
3323 case SPELL_SPIRIT_FATE:
3324 case SPELL_BODY_FIRST_AID:
3325 case SPELL_DARK_REANIMATE:
3326 //HIBYTE(v6) = HIBYTE(a5) | 1;
3327 a5 |= 0x0100;
3328 break;
3329
3330 case SPELL_FIRE_FIRE_AURA:
3331 case SPELL_WATER_RECHARGE_ITEM:
3332 case SPELL_WATER_ENCHANT_ITEM:
3333 case SPELL_DARK_VAMPIRIC_WEAPON:
3334 //LOBYTE(v6) = a5 | 0x80;
3335 a5 |= 0x0080;
3336 break;
3337
3338 case SPELL_FIRE_FIRE_BOLT:
3339 case SPELL_FIRE_FIREBALL:
3340 case SPELL_FIRE_INCINERATE:
3341 case SPELL_AIR_LIGHNING_BOLT:
3342 case SPELL_AIR_IMPLOSION:
3343 case SPELL_WATER_POISON_SPRAY:
3344 case SPELL_WATER_ICE_BOLT:
3345 case SPELL_WATER_ACID_BURST:
3346 case SPELL_WATER_ICE_BLAST:
3347 case SPELL_EARTH_STUN:
3348 case SPELL_EARTH_SLOW:
3349 case SPELL_EARTH_DEADLY_SWARM:
3350 case SPELL_EARTH_BLADES:
3351 case SPELL_EARTH_MASS_DISTORTION:
3352 case SPELL_SPIRIT_SPIRIT_LASH:
3353 case SPELL_MIND_MIND_BLAST:
3354 case SPELL_MIND_CHARM:
3355 case SPELL_MIND_PSYCHIC_SHOCK:
3356 case SPELL_BODY_HARM:
3357 case SPELL_BODY_FLYING_FIST:
3358 case SPELL_LIGHT_LIGHT_BOLT:
3359 case SPELL_LIGHT_DESTROY_UNDEAD:
3360 case SPELL_LIGHT_SUNRAY:
3361 case SPELL_DARK_TOXIC_CLOUD:
3362 case SPELL_DARK_SHRINKING_RAY:
3363 case SPELL_DARK_SHARPMETAL:
3364 case SPELL_DARK_DRAGON_BREATH:
3365 if ( !a6 )
3366 a5 |= 0x0008;
3367 break;
3368 case SPELL_MIND_TELEPATHY:
3369 case SPELL_MIND_BERSERK:
3370 case SPELL_MIND_ENSLAVE:
3371 case SPELL_LIGHT_PARALYZE:
3372 case SPELL_DARK_CONTROL_UNDEAD:
3373 //LABEL_9:
3374 //v6 = a5 | 8;
3375 a5 |= 0x0008;
3376 break;
3377
3378 case SPELL_EARTH_TELEKINESIS:
3379 a5 |= 0x0040;
3380 break;
3381
3382 case SPELL_SPIRIT_BLESS:
3383 if (a4 && ~a4 & 0x01C0)
3384 //goto LABEL_25;
3385 {
3386 a5 |= 0x0002;
3387 break;
3388 }
3389 else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0)
3390 //goto LABEL_25;
3391 {
3392 a5 |= 0x0002;
3393 break;
3394 }
3395 break;
3396
3397 case SPELL_SPIRIT_PRESERVATION:
3398 v9 = a4;
3399 if ( !a4 )
3400 v9 = player->pActiveSkills[PLAYER_SKILL_SPIRIT];
3401 //goto LABEL_18;
3402 v10 = SkillToMastery(v9);
3403 v12 = __OFSUB__(v10, 3);
3404 v11 = ((v10 - 3) & 0x80000000u) != 0;
3405 //goto LABEL_24;
3406 if ( v11 ^ v12 )
3407 {
3408 a5 |= 0x0002;
3409 break;
3410 }
3411 break;
3412
3413 case SPELL_DARK_PAIN_REFLECTION:
3414 v9 = a4;
3415 if ( !a4 )
3416 v9 = player->pActiveSkills[PLAYER_SKILL_DARK];
3417 //LABEL_18:
3418 v10 = SkillToMastery(v9);
3419 v12 = __OFSUB__(v10, 3);
3420 v11 = ((v10 - 3) & 0x80000000u) != 0;
3421 //goto LABEL_24;
3422 if ( v11 ^ v12 )
3423 {
3424 a5 |= 0x0002;
3425 break;
3426 }
3427 break;
3428
3429 case SPELL_BODY_HAMMERHANDS:
3430 v13 = a4;
3431 if ( !a4 )
3432 v13 = player->pActiveSkills[PLAYER_SKILL_BODY];
3433 v14 = SkillToMastery(v13);
3434 v12 = __OFSUB__(v14, 4);
3435 v11 = ((v14 - 4) & 0x80000000u) != 0;
3436 //LABEL_24:
3437 if ( v11 ^ v12 )
3438 //goto LABEL_25;
3439 {
3440 a5 |= 0x0002;
3441 break;
3442 }
3443 break;
3444
3445 case SPELL_EARTH_STONE_TO_FLESH:
3446 case SPELL_SPIRIT_REMOVE_CURSE:
3447 case SPELL_SPIRIT_RAISE_DEAD:
3448 case SPELL_SPIRIT_RESSURECTION:
3449 case SPELL_MIND_REMOVE_FEAR:
3450 case SPELL_MIND_CURE_PARALYSIS:
3451 case SPELL_MIND_CURE_INSANITY:
3452 case SPELL_BODY_CURE_WEAKNESS:
3453 case SPELL_BODY_REGENERATION:
3454 case SPELL_BODY_CURE_POISON:
3455 case SPELL_BODY_CURE_DISEASE:
3456 //LABEL_25:
3457 //v6 = a5 | 2;
3458 a5 |= 0x0002;
3459 break;
3460
3461 case SPELL_DARK_SACRIFICE:
3462 //HIBYTE(v6) = HIBYTE(a5) | 2;
3463 a5 |= 0x0200;
3464 break;
3465 default:
3466 break;
3467 }
3468 }
3469
3470
3471 if (a5 & 0x3CA)
3472 {
3473 for (uint i = 0; i < CastSpellInfoCount; ++i)
3474 if (pCastSpellInfo[i].uFlags & 0x3CA)
3475 {
3476 pCastSpellInfo[i].uSpellID = 0;
3477 break;
3478 }
3479 }
3480
3481 for (uint i = 0; i < CastSpellInfoCount; ++i)
3482 {
3483 CastSpellInfo* spell = &pCastSpellInfo[i];
3484 if (!spell->uSpellID)
3485 continue;
3486
3487 spell->uSpellID = 0;
3488 if (spell->uFlags & 0x3CA)
3489 {
3490 pGUIWindow_Settings->Release();
3491 pGUIWindow_Settings = nullptr;
3492 pMouse->SetCursorBitmap("MICON1");
3493 GameUI_Footer_TimeLeft = 0;
3494 _50C9A0_IsEnchantingInProgress = 0;
3495 back_to_game();
3496 }
3497 }
3498
3499 int result = PushCastSpellInfo(a1, uPlayerID, a4, a5, a6);
3500 if ( result != -1 )
3501 {
3502 if ( a5 & 2 )
3503 {
3504 if ( pGUIWindow_Settings )
3505 return;
3506 pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
3507 pGUIWindow_Settings->CreateButton(52, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 0, 49, "", 0);
3508 pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0);
3509 pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0);
3510 pGUIWindow_Settings->CreateButton(390, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 3, 52, "", 0);
3511 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
3512 return;
3513 }
3514 if ( a5 & 8 )
3515 {
3516 if ( pGUIWindow_Settings )
3517 return;
3518
3519 pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
3520 pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0);
3521 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
3522 return;
3523 }
3524 if ( a5 & 0x40 )
3525 {
3526 if ( pGUIWindow_Settings )
3527 return;
3528
3529 pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
3530 pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0);
3531 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
3532 return;
3533 }
3534 if ( (char)a5 < 0 )
3535 {
3536 if ( pGUIWindow_Settings )
3537 return;
3538 ++pIcons_LOD->uTexturePacksCount;
3539 if ( !pIcons_LOD->uNumPrevLoadedFiles )
3540 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
3541 pGUIWindow_Settings = pCastSpellInfo[result].GetCastSpellInInventoryWindow();
3542 _50C9A0_IsEnchantingInProgress = 1;
3543 some_active_character = uActiveCharacter;
3544 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
3545 return;
3546 }
3547 if ( HIBYTE(a5) & 1 )
3548 {
3549 if ( pGUIWindow_Settings )
3550 return;
3551 pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
3552 pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 0, 0x31u, "", 0);
3553 pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 1, 0x32u, "", 0);
3554 pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0);
3555 pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 3, 0x34u, "", 0);
3556 pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Monster_Improvement, 0, 0, "", NULL);
3557 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
3558 }
3559 if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings )
3560 {
3561 pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
3562 pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178,
3563 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
3564 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
3565 1, 0, UIMSG_ScrollNPCPanel, 0, 0, "",
3566 pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
3567 pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178,
3568 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth,
3569 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight,
3570 1, 0, UIMSG_ScrollNPCPanel, 1, 0, "",
3571 pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
3572 pGUIWindow_Settings->CreateButton(491, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 4, 0x35u, "", 0);
3573 pGUIWindow_Settings->CreateButton(561, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 5, 0x36u, "", 0);
3574 }
3575 }
3576 }