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