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