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