changeset 1007:7e4045b6f191

Merge
author Gloval
date Sat, 18 May 2013 22:01:42 +0400
parents e865f349aa41 (current diff) 8073f9a70e8b (diff)
children 446175a32a15
files
diffstat 1 files changed, 538 insertions(+), 612 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_6.cpp	Sat May 18 22:01:26 2013 +0400
+++ b/mm7_6.cpp	Sat May 18 22:01:42 2013 +0400
@@ -2464,11 +2464,11 @@
   __int16 v52; // ax@153
   //int v53; // eax@153
   signed __int64 v54; // qax@164
-  int v55; // edi@164
+  Actor *v55; // edi@164
   //stru6 *v56; // eax@165
   int v57; // eax@169
   signed __int64 v58; // qax@177
-  int v59; // edi@177
+  Actor *pActor; // edi@177
   unsigned __int16 v60; // ax@184
   int v61; // ecx@184
   //int v62; // eax@186
@@ -3081,7 +3081,7 @@
   //int v669; // [sp+4h] [bp-E80h]@123
   //Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133
   int v671; // [sp+4h] [bp-E80h]@146
-  unsigned int v672; // [sp+4h] [bp-E80h]@164
+  //unsigned int v672; // [sp+4h] [bp-E80h]@164
   //unsigned __int8 v673; // [sp+4h] [bp-E80h]@304
   //__int16 v674; // [sp+4h] [bp-E80h]@684
   const char *v675; // [sp+4h] [bp-E80h]@800
@@ -3297,50 +3297,49 @@
 
     switch ( pCastSpell->spellnum )
     {
-      case SPELL_101:
-        assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
-      case SPELL_BOW_ARROW:
-      {
-        //v17 = pPlayer;
-        _this = (ItemGen *)1;
-        if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
-          _this = (ItemGen *)2;
-        sRecoveryTime = pPlayer->GetAttackRecoveryTime(true);
-        pSpellSprite.stru_24.Reset();
-        pSpellSprite.spell_level = v2;
-        pSpellSprite.spell_id = pCastSpell->spellnum;
-        pSpellSprite.spell_skill = v731;
-        pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-        if ( pPlayer->WearsItem(510, 2) )
-          pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
-        pSpellSprite.vPosition.x = pParty->vPosition.x;
-        pSpellSprite.vPosition.y = pParty->vPosition.y;
-        pSpellSprite.uAttributes = 0;
-        pSpellSprite.uSpriteFrameID = 0;
-        pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-        pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-        pSpellSprite.spell_target_pid = a2;
-        pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-        pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
-        pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-        v20 = &pParty->pPlayers[pCastSpell->uPlayerID];
-        memcpy(&pSpellSprite.stru_24, &v20[v20->pEquipment.uBow], sizeof(pSpellSprite.stru_24));
-        pSpellSprite.uAttributes = 256;
-        if ( pParty->bTurnBasedModeOn == 1 )
-          pSpellSprite.uAttributes = 260;
-        for ( i = 0; i < (signed int)_this; ++i )
-        {
-          if ( i )
-            pSpellSprite.vPosition.z += 32;
-          pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
-          if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
-               pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
-            ++pTurnEngine->field_1C;
-        }
-        break;
-      }
-      case SPELL_LASER_PROJECTILE:
-      {
+		case SPELL_101:
+			assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
+		case SPELL_BOW_ARROW:
+		{
+			amount = 1;
+			if ( SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
+				amount = 2;
+			sRecoveryTime = pPlayer->GetAttackRecoveryTime(true);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			if ( pPlayer->WearsItem(510, 2) )
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
+			memcpy(&pSpellSprite.stru_24, &pPlayer[pPlayer->pEquipment.uBow], sizeof(pSpellSprite.stru_24));
+			pSpellSprite.uAttributes = 256;
+			if ( pParty->bTurnBasedModeOn == 1 )
+				pSpellSprite.uAttributes = 260;
+			for ( i = 0; i < amount; ++i )
+			{
+				if ( i )
+					pSpellSprite.vPosition.z += 32;
+				pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
+				if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+					pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+				++pTurnEngine->field_1C;
+			}
+			break;
+		}
+		case SPELL_LASER_PROJECTILE:
+		{
 			sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
 			pSpellSprite.stru_24.Reset();
 			pSpellSprite.spell_id = pCastSpell->spellnum;
@@ -3357,9 +3356,10 @@
 			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
 			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
 			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-			memcpy(&pSpellSprite.stru_24,
-				&pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
-					* pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], sizeof(pSpellSprite.stru_24));
+			pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
+			memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uMainHand-1],sizeof(pSpellSprite.stru_24));
+			//	&pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
+			//		* pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], );
 			v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
 			HIBYTE(pSpellSprite.uAttributes) |= 1u;
 			pSpellSprite.uSectorID = v23;
@@ -3369,11 +3369,9 @@
 					pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 				++pTurnEngine->field_1C;
 			break;
-      }
-      case SPELL_FIRE_TORCH_LIGHT:
-      {
-			LODWORD(v733) = 3600 * v2;
-
+		}
+		case SPELL_FIRE_TORCH_LIGHT:
+		{
 			switch (v731)
 			{
 				case 1: amount = 2; break;
@@ -3388,210 +3386,200 @@
 			pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-      }
-      case SPELL_FIRE_FIRE_SPIKE:
-      {
-		v29 = v731 - 2;
-		if ( v29 )
-		{
-			v30 = v29 - 1;
-			if ( v30 )
-			{
-			if ( v30 == 1 )
-				amount = 9;
-			else
-				amount = 3;
-			}
-			else
-			{
-			amount = 7;
-			}
-		}
-		else
-		{
-			amount = 5;
-		}
-		//v31 = v3->uPlayerID;
-		//v32 = 8 * v31;
-		//LOBYTE(v32) = v32 | OBJECT_Player;
-
-		//if ( (signed int)uNumSpriteObjects > 0 )
-		int _v733 = 0;
-		for (uint i = 0; i < uNumSpriteObjects; ++i)
-		{
-			auto object = pSpriteObjects + i;
-			if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID))
-			++_v733;
-			/*v33 = (char *)&pSpriteObjects[0].field_48;
-			v730 = uNumSpriteObjects;
-			do
-			{
-			if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 )
-				++HIDWORD(v733);
-			v33 += 112;
-			--v730;
-			}
-			while ( v730 );*/
-		}
-		if (_v733 > amount)
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			pCastSpell->spellnum = 0;
-			continue;
-		}
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->spellnum;
-		pSpellSprite.spell_level = v2;
-		pSpellSprite.spell_skill = v731;
-		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		pSpellSprite.vPosition.y = pParty->vPosition.y;
-		pSpellSprite.vPosition.x = pParty->vPosition.x;
-		pSpellSprite.uAttributes = 0;
-		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-		pSpellSprite.uSpriteFrameID = 0;
-		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-		pSpellSprite.spell_target_pid = a2;
-		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
-		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(pSpellSprite.uAttributes) |= 4u;
-		v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
-		if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
-			++pTurnEngine->field_1C;
-		LODWORD(v727) = 1;
-		break;
-      }
-      case SPELL_AIR_IMPLOSION:
-      {
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-		if (!a2)
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			pCastSpell->spellnum = 0;
-			continue;
-		}
-		if (PID_TYPE(a2) != OBJECT_Actor)
-		{
+		}
+		case SPELL_FIRE_FIRE_SPIKE:
+		{
+			switch (v731)
+			{
+				case 1: amount = 3; break;
+				case 2: amount = 5; break;
+				case 3: amount = 7; break;
+				case 4: amount = 9; break;
+				default:
+				assert(false);
+			}
+
+			//v31 = v3->uPlayerID;
+			//v32 = 8 * v31;
+			//LOBYTE(v32) = v32 | OBJECT_Player;
+
+			//if ( (signed int)uNumSpriteObjects > 0 )
+			int _v733 = 0;
+			for (uint i = 0; i < uNumSpriteObjects; ++i)
+			{
+				auto object = pSpriteObjects + i;
+				if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID))
+				++_v733;
+				/*v33 = (char *)&pSpriteObjects[0].field_48;
+				v730 = uNumSpriteObjects;
+				do
+				{
+				if ( *((short *)v33 - 36) && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 )
+					++HIDWORD(v733);
+				v33 += 112;
+				--v730;
+				}
+				while ( v730 );*/
+			}
+			if (_v733 > amount)
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				pCastSpell->spellnum = 0;
+				continue;
+			}
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+			pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			if ( pParty->bTurnBasedModeOn == 1 )
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
+			v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+			if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+				++pTurnEngine->field_1C;
 			LODWORD(v727) = 1;
 			break;
 		}
-		v697.x = 0;
-		v697.y = 0;
-		v697.z = 0;
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->spellnum;
-		pSpellSprite.spell_level = v2;
-		pSpellSprite.spell_skill = v731;
-		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		pSpellSprite.uAttributes = 0;
-		pSpellSprite.uSectorID = 0;
-		pSpellSprite.uSpriteFrameID = 0;
-		pSpellSprite.field_60_distance_related_prolly_lod = 0;
-		pSpellSprite.uFacing = 0;
-		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		pSpellSprite.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
-		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
-		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
-		LODWORD(v727) = 1;
-		break;
-      }
-      case SPELL_EARTH_MASS_DISTORTION:
-      {
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-		if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) )
-		{
+		case SPELL_AIR_IMPLOSION:
+		{
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			if (!a2)
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				pCastSpell->spellnum = 0;
+				continue;
+			}
+			if (PID_TYPE(a2) != OBJECT_Actor)
+			{
+				LODWORD(v727) = 1;
+				break;
+			}
+			v697.x = 0;
+			v697.y = 0;
+			v697.z = 0;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.uSectorID = 0;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.field_60_distance_related_prolly_lod = 0;
+			pSpellSprite.uFacing = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+			pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+			pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
+			auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
+			DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
 			LODWORD(v727) = 1;
 			break;
 		}
-		pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
-		v704.x = 0;
-		v704.y = 0;
-		v704.z = 0;
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->spellnum;
-		pSpellSprite.spell_level = v2;
-		pSpellSprite.spell_skill = v731;
-		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		pSpellSprite.uAttributes = 0;
-		pSpellSprite.uSectorID = 0;
-		pSpellSprite.uSpriteFrameID = 0;
-		pSpellSprite.field_60_distance_related_prolly_lod = 0;
-		pSpellSprite.uFacing = 0;
-		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v726);
-		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
-		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704);
-		LODWORD(v727) = 1;
-		break;
-      }
-      case SPELL_LIGHT_DESTROY_UNDEAD:
-      {
-		if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor)
+		case SPELL_EARTH_MASS_DISTORTION:
+		{
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) )
+			{
+				LODWORD(v727) = 1;
+				break;
+			}
+			pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
+			v704.x = 0;
+			v704.y = 0;
+			v704.z = 0;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.uSectorID = 0;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.field_60_distance_related_prolly_lod = 0;
+			pSpellSprite.uFacing = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v726);
+			auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
+			DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704);
+			LODWORD(v727) = 1;
 			break;
-		//v730 = a2 >> 3;
-		//HIDWORD(v733) = (int)&pActors[PID_ID(a2)];
-		v691.x = 0;
-		v691.y = 0;
-		v691.z = 0;
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->spellnum;
-		pSpellSprite.spell_level = v2;
-		pSpellSprite.spell_skill = v731;
-		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		pSpellSprite.uAttributes = 0;
-		pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
-		pSpellSprite.uSpriteFrameID = 0;
-		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-		pSpellSprite.spell_target_pid = a2;
-		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
-		pSpellSprite.uAttributes |= 0x80u;
-		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
-		if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) )
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			pCastSpell->spellnum = 0;
-			continue;
-		}
-		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691);
-		LODWORD(v727) = 1;
-		break;
-      }
-      case SPELL_FIRE_FIRE_BOLT:
-      case SPELL_FIRE_FIREBALL:
-      case SPELL_FIRE_INCINERATE:
-      case SPELL_AIR_LIGHNING_BOLT:
-      case SPELL_WATER_ICE_BOLT:
-      case SPELL_WATER_ICE_BLAST:
-      case SPELL_EARTH_STUN:
-      case SPELL_EARTH_DEADLY_SWARM:
-      case SPELL_MIND_MIND_BLAST:
-      case SPELL_MIND_PSYCHIC_SHOCK:
-      case SPELL_BODY_HARM:
-      case SPELL_LIGHT_LIGHT_BOLT:
-      case SPELL_DARK_DRAGON_BREATH:
-      {
+		}
+		case SPELL_LIGHT_DESTROY_UNDEAD:
+		{
+			if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor)
+				break;
+			//v730 = a2 >> 3;
+			//HIDWORD(v733) = (int)&pActors[PID_ID(a2)];
+			v691.x = 0;
+			v691.y = 0;
+			v691.z = 0;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uAttributes |= 0x80u;
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
+			if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) )
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				pCastSpell->spellnum = 0;
+				continue;
+			}
+			DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691);
+			LODWORD(v727) = 1;
+			break;
+		}
+		case SPELL_FIRE_FIRE_BOLT:
+		case SPELL_FIRE_FIREBALL:
+		case SPELL_FIRE_INCINERATE:
+		case SPELL_AIR_LIGHNING_BOLT:
+		case SPELL_WATER_ICE_BOLT:
+		case SPELL_WATER_ICE_BLAST:
+		case SPELL_EARTH_STUN:
+		case SPELL_EARTH_DEADLY_SWARM:
+		case SPELL_MIND_MIND_BLAST:
+		case SPELL_MIND_PSYCHIC_SHOCK:
+		case SPELL_BODY_HARM:
+		case SPELL_LIGHT_LIGHT_BOLT:
+		case SPELL_DARK_DRAGON_BREATH:
+		{
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 			pSpellSprite.stru_24.Reset();
@@ -3622,12 +3610,12 @@
 				++pTurnEngine->field_1C;
 			LODWORD(v727) = 1;
 			break;
-      }
-      case SPELL_WATER_ACID_BURST:
-      case SPELL_EARTH_BLADES:
-      case SPELL_BODY_FLYING_FIST:
-      case SPELL_DARK_TOXIC_CLOUD:
-      {
+		}
+		case SPELL_WATER_ACID_BURST:
+		case SPELL_EARTH_BLADES:
+		case SPELL_BODY_FLYING_FIST:
+		case SPELL_DARK_TOXIC_CLOUD:
+		{
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 			pSpellSprite.stru_24.Reset();
@@ -3658,8 +3646,8 @@
 			LODWORD(v727) = 1;
 			break;
       }
-      case SPELL_LIGHT_SUNRAY:
-      {
+		case SPELL_LIGHT_SUNRAY:
+		{
 			if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
 				|| uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) )
 			{
@@ -3698,54 +3686,41 @@
 				LODWORD(v727) = 1;
 			}
 			break;
-      }
-      case SPELL_LIGHT_PARALYZE:
-      {
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
+		}
+		case SPELL_LIGHT_PARALYZE:
+		{
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)],
+					!stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9)) )
+			{
+				LODWORD(v727) = 1;
+				break;
+			}
+			Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0);
+			v54 = (signed __int64)((double)(23040 * v2) * 0.033333335);
+			v55 = &pActors[PID_ID(a2)];
+			v55->pActorBuffs[6].Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0);
+			BYTE2(v55->uAttributes) |= 8u;
+			v55->vVelocity.x = 0;
+			//v672 = 0;
+			v55->vVelocity.y = 0;
+			v661 = v55;
+			pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
+			LODWORD(v727) = 1;
 			break;
-		if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)],
-				!stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9)) )
-		{
-		LODWORD(v727) = 1;
-		break;
-		}
-		Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0);
-		v54 = (signed __int64)((double)(23040 * v2) * 0.033333335);
-		v55 = v721;
-		((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0);
-		*(char *)(v55 + 38) |= 8u;
-		*(short *)(v55 + 148) = 0;
-		v672 = 0;
-		*(short *)(v55 + 150) = 0;
-		v661 = (Actor *)v55;
-		pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672);
-		LODWORD(v727) = 1;
-		break;
-      }
-      case SPELL_EARTH_SLOW:
-      {
-			if ( v731 == 2 )
-			{
-				v57 = 300 * v2;
-				amount = 2;
-			}
-			else if ( v731 == 3 )
-			{
-				amount = 4;
-				v57 = 300 * v2;
-			}
-			else if ( v731 == 4 )
-			{
-				v57 = 300 * v2;
-				amount = 8;
-			}
-			else
-			{
-				v57 = 180 * v2;
-				amount = 2;
-			}
-//	LABEL_174:
-			LODWORD(v733) = v57;
+		}
+		case SPELL_EARTH_SLOW:
+		{
+			switch (v731)
+			{
+				case 1: LODWORD(v733) = 180 * v2; amount = 2; break;
+				case 2: LODWORD(v733) = 300 * v2; amount = 2; break;
+				case 3: LODWORD(v733) = 300 * v2; amount = 4; break;
+				case 4: LODWORD(v733) = 300 * v2; amount = 8; break;
+				default:
+				assert(false);
+			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 			if (PID_TYPE(a2) != OBJECT_Actor
@@ -3757,22 +3732,20 @@
 				break;
 			}
 			v58 = (signed __int64)((double)(23040 * v2) * 0.033333335);
-			v59 = v721;
+			//v59 = v721;
+			pActor = &pActors[PID_ID(a2)];
 			//((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
-			pActors[PID_ID(a2)].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58,
-				v731,
-				amount,
-				0,
-				0);
-			*((char *)&pActors[0].uAttributes + v59 + 2) |= 8u;
-			v672 = 0;
+			pActor->pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58,	v731, amount, 0, 0);
+			//*((char *)&pActors[0].uAttributes + v59 + 2) |= 8u;
+			BYTE2(pActor->uAttributes) |= 8u;
+			//v672 = 0;
 			v661 = (Actor *)LODWORD(v718);
-			pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672);
+			pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
 			LODWORD(v727) = 1;
 			break;
       }
-      case SPELL_MIND_CHARM:
-      {
+		case SPELL_MIND_CHARM:
+		{
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
@@ -3826,9 +3799,9 @@
 			pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
 			LODWORD(v727) = 1;
 			break;
-      }
-      case SPELL_DARK_SHRINKING_RAY:
-      {
+		}
+		case SPELL_DARK_SHRINKING_RAY:
+		{
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 			pSpellSprite.stru_24.Reset();
@@ -3859,9 +3832,9 @@
 				++pTurnEngine->field_1C;
 			LODWORD(v727) = 1;
 			break;
-      }
-      case SPELL_FIRE_FIRE_AURA:
-      {
+		}
+		case SPELL_FIRE_FIRE_AURA:
+		{
 			v63 = v731 - 1;
 			if ( !v63 )
 			{
@@ -3929,9 +3902,9 @@
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
 			pCastSpell->spellnum = 0;
 			continue;
-      }
-      case SPELL_BODY_REGENERATION:
-      {
+		}
+		case SPELL_BODY_REGENERATION:
+		{
 		v70 = v731 - 1;
 		LODWORD(v733) = 3600 * v2;
 		if ( v70 && (v71 = v70 - 1) != 0 )
@@ -3959,14 +3932,14 @@
 		pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0);
 		LODWORD(v727) = 1;
 		break;
-      }
-      case SPELL_FIRE_PROTECTION_FROM_FIRE:
-      case SPELL_AIR_PROTECTION_FROM_AIR:
-      case SPELL_WATER_PROTECTION_FROM_WATER:
-      case SPELL_EARTH_PROTECTION_FROM_EARTH:
-      case SPELL_MIND_PROTECTION_FROM_MIND:
-      case SPELL_BODY_PROTECTION_FROM_BODY:
-      {
+		}
+		case SPELL_FIRE_PROTECTION_FROM_FIRE:
+		case SPELL_AIR_PROTECTION_FROM_AIR:
+		case SPELL_WATER_PROTECTION_FROM_WATER:
+		case SPELL_EARTH_PROTECTION_FROM_EARTH:
+		case SPELL_MIND_PROTECTION_FROM_MIND:
+		case SPELL_BODY_PROTECTION_FROM_BODY:
+		{
         LODWORD(v733) = 3600 * v2;
 		if ( v731 > 0 && v731 <= 4)
 		{
@@ -4008,9 +3981,9 @@
         pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
         LODWORD(v727) = 1;
         break;
-      }
-      case SPELL_FIRE_HASTE:
-      {
+		}
+		case SPELL_FIRE_HASTE:
+		{
 			if ( v731 == 1 || v731 == 2 )
 			{
 				LODWORD(v733) = 60 * (v2 + 60);
@@ -4045,9 +4018,9 @@
 				}
 			}
 			break;
-      }
-      case SPELL_SPIRIT_BLESS:
-      {
+		}
+		case SPELL_SPIRIT_BLESS:
+		{
 			if ( v731 == 1 || v731 == 2 )
 			{
 				LODWORD(v733) = 300 * (v2 + 12);
@@ -4100,9 +4073,9 @@
 			while ( v730b <= &pParty->pPlayers[3] );
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_SPIRIT_SPIRIT_LASH:
-			{
+		{
 			if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor)
 			{
 				//v730 = a2 >> 3;
@@ -4218,9 +4191,9 @@
 			pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_FIRE_IMMOLATION:
-			{
+		{
 			if ( v731 == 4  && v139 == 1 )
 				LODWORD(v733) = 600 * v2;
 			else
@@ -4236,9 +4209,9 @@
 			pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_FIRE_METEOR_SHOWER:
-			{
+		{
 			v149 = v731 - 1;
 			if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 )
 			{
@@ -4407,22 +4380,17 @@
 			pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_AIR_FEATHER_FALL:
-			{
-			if ( v731 == 1 )
-			{
-				LODWORD(v733) = 300 * v2;
-			}
-			else if ( v731 == 2 )
-			{
-				LODWORD(v733) = 600 * v2;
-			}
-			else if ( v731 == 3 || v731 == 4 )
-			{
-				LODWORD(v733) = 3600 * v2;
-	//LABEL_353:
-				//LODWORD(v733) = v173;
+		{
+			switch (v731)
+			{
+				case 1: LODWORD(v733) = 300 * v2; break;
+				case 2: LODWORD(v733) = 600 * v2; break;
+				case 3: 
+				case 4: LODWORD(v733) = 3600 * v2; break;
+				default:
+				assert(false);
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
@@ -4438,78 +4406,60 @@
 			pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_AIR_SPARKS:
 		{
-		v184 = v731 - 1;
-		if ( v184 )
-		{
-			v185 = v184 - 1;
-			if ( v185 )
-			{
-			v186 = v185 - 1;
-			if ( v186 )
-			{
-				if ( v186 == 1 )
-				amount = 9;
-			}
-			else
-			{
-				amount = 7;
-			}
-			}
-			else
-			{
-			amount = 5;
-			}
-		}
-		else
-		{
-			amount = 3;
-		}
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
+			switch (v731)
+			{
+				case 1: amount = 3; break;
+				case 2: amount = 5; break;
+				case 3: amount = 7; break;
+				case 4: amount = 9; break;
+				default:
+				assert(false);
+			}
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+			pSpellSprite.uSectorID = pIndoor->GetSector(
+								pParty->vPosition.x,
+								pParty->vPosition.y,
+								pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			if ( pParty->bTurnBasedModeOn == 1 )
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
+			v188 = (signed int)_v726 / -2;
+			v189 = (signed int)_v726 / 2;
+			while ( v188 <= v189 )
+			{
+				pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle);
+				if ( pSpellSprite.Create(
+						(signed __int16)(v188 + LOWORD(v715.uYawAngle)),
+						v715.uPitchAngle,
+						pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+						pCastSpell->uPlayerID + 1) != -1
+				&& pParty->bTurnBasedModeOn == 1 )
+				++pTurnEngine->field_1C;
+				v188 += _v726 / (amount - 1);
+			}
+			LODWORD(v727) = 1;
 			break;
-		auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->spellnum;
-		pSpellSprite.spell_level = v2;
-		pSpellSprite.spell_skill = v731;
-		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		pSpellSprite.vPosition.y = pParty->vPosition.y;
-		pSpellSprite.vPosition.x = pParty->vPosition.x;
-		pSpellSprite.uAttributes = 0;
-		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		pSpellSprite.uSectorID = pIndoor->GetSector(
-							pParty->vPosition.x,
-							pParty->vPosition.y,
-							pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-		pSpellSprite.uSpriteFrameID = 0;
-		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-		pSpellSprite.spell_target_pid = a2;
-		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(pSpellSprite.uAttributes) |= 4u;
-		v188 = (signed int)_v726 / -2;
-		v189 = (signed int)_v726 / 2;
-		while ( v188 <= v189 )
-		{
-			pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle);
-			if ( pSpellSprite.Create(
-					(signed __int16)(v188 + LOWORD(v715.uYawAngle)),
-					v715.uPitchAngle,
-					pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
-					pCastSpell->uPlayerID + 1) != -1
-			&& pParty->bTurnBasedModeOn == 1 )
-			++pTurnEngine->field_1C;
-			v188 += _v726 / (amount - 1);
-		}
-		LODWORD(v727) = 1;
-		break;
-		}
-
+		}
 		case SPELL_AIR_JUMP:
-			{
+		{
 			if ( pParty->uFlags & PARTY_FLAGS_1_FALLING)
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2);  // Can't cast Jump while airborne!
@@ -4526,36 +4476,18 @@
 			pParty->uFallSpeed = 1000;
 			LODWORD(v727) = 1;
 			break;
-			}
+		}
 		case SPELL_AIR_INVISIBILITY:
-			{
-			v192 = v731 - 1;
-			if ( v731 == 1 )
-			{
-				amount = v2;
-				LODWORD(v733) = 600 * v2;
-			}
-			else if ( v731 == 2 )
-			{
-				v196 = 2 * v2;
-				amount = v196;
-				LODWORD(v733) = 600 * v2;
-			}
-			else if ( v731 == 3 )
-			{
-				v196 = 3 * v2;
-				//goto LABEL_389;
-				amount = v196;
-				LODWORD(v733) = 600 * v2;
-			}
-			else if ( v731 == 4 )
-			{
-			amount = 4 * v2;
-			v195 = 3600 * v2;
-//	LABEL_392:
-			LODWORD(v733) = v195;
-			}
-//	LABEL_393:
+		{
+			switch (v731)
+			{
+				case 1: LODWORD(v733) = 600 * v2; amount = v2; break;
+				case 2: LODWORD(v733) = 600 * v2; amount = 2 * v2; break;
+				case 3: LODWORD(v733) = 600 * v2; amount = 3 * v2; break;
+				case 4: LODWORD(v733) = 3600 * v2; amount = 4 * v2; break;
+				default:
+				assert(false);
+			}
 			if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW))
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2);  // There are hostile creatures nearby!
@@ -4574,177 +4506,171 @@
 				LODWORD(v727) = 1;
 			}
 			break;
-			}
+		}
 		case SPELL_AIR_FLY:
 		{
-		if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2);  // Can not cast Fly indoors!
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			break;
-		}
-		if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+			if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2);  // Can not cast Fly indoors!
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				break;
+			}
+			if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				break;
+			}
+			LODWORD(v733) = 3600 * v2;
+			if ( v731 == 2 || v731 == 3 || (amount = 0, v731 != 4) )
+				amount = 1;
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			v205 = 0;
+			do
+				pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536);
+			while ( v205 < 4 );
+			v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
+			v207 = pCastSpell->uPlayerID + 1;
+			v716 = v206;
+
+			pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207);
+			LODWORD(v727) = 1;
 			break;
 		}
-		LODWORD(v733) = 3600 * v2;
-		if ( v731 == 2 || v731 == 3 || (amount = 0, v731 != 4) )
-			amount = 1;
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-		v205 = 0;
-		do
-			pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536);
-		while ( v205 < 4 );
-		v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
-		v207 = pCastSpell->uPlayerID + 1;
-		v716 = v206;
-
-		pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207);
-		LODWORD(v727) = 1;
-		break;
-		}
-
 		case SPELL_AIR_STARBURST:
 		{
-		//v67 = 2;
-		if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-		{
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2);  // Can't cast Starburst indoors!
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			pCastSpell->spellnum = 0;
-			continue;
-		}
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-		v208 = PID_TYPE(a2);
-		LODWORD(v725) = PID_TYPE(a2);
-		if ( v208 == 3 )
-		{
-			v209 = PID_ID(a2);
-			LODWORD(v718) = pActors[v209].vPosition.x;
-			v210 = pActors[v209].vPosition.y;
-			v211 = pActors[v209].vPosition.z;
-			v713 = v210;
-		}
-		else
-		{
-			v212 = stru_5C6E00->Cos(pParty->sRotationY);
-			LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
-			v213 = stru_5C6E00->Sin(pParty->sRotationY);
-			v214 = sub_42EBBE(2048, v213);
-			v211 = pParty->vPosition.z;
-			v713 = pParty->vPosition.y + v214;
-			v208 = LODWORD(v725);
-		}
-		HIDWORD(v733) = 0;
-		*(float *)&v732 = (double)v211;
-		LODWORD(v725) = v211 + 2500;
-		v721 = 0;
-		*(float *)&y = (double)(v211 + 2500);
-		v730 = v208 == 3 ? a2 : 0;
-		a2 = 20;
-		do
-		{
-			v215 = rand();
-			v216 = (double)v721;
-			v217 = (double)SHIDWORD(v733);
-			*(float *)&uRequiredMana = v217;
-			_this = (ItemGen *)(v215 % 1000);
-			*((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y;
-			*(float *)&v721 = v217 * v217;
-			//*(float *)&v726 = v216 * v216;
-			if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 )
-			{
-			LODWORD(v685) = 0;
-			HIDWORD(v685) = 0;
+			//v67 = 2;
+			if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2);  // Can't cast Starburst indoors!
+				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+				pCastSpell->spellnum = 0;
+				continue;
+			}
+			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+				break;
+			v208 = PID_TYPE(a2);
+			LODWORD(v725) = PID_TYPE(a2);
+			if ( v208 == 3 )
+			{
+				v209 = PID_ID(a2);
+				LODWORD(v718) = pActors[v209].vPosition.x;
+				v210 = pActors[v209].vPosition.y;
+				v211 = pActors[v209].vPosition.z;
+				v713 = v210;
 			}
 			else
 			{
-			v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721);
-			v685 = __PAIR__(
-						stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)),
-						stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana));
-			}
-			pSpellSprite.stru_24.Reset();
-			pSpellSprite.spell_id = pCastSpell->spellnum;
-			pSpellSprite.spell_level = v2;
-			pSpellSprite.spell_skill = v731;
-			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-			pSpellSprite.uAttributes = 0;
-			pSpellSprite.vPosition.x = LODWORD(v718);
-			pSpellSprite.vPosition.y = v713;
-			pSpellSprite.uSectorID = 0;
-			pSpellSprite.vPosition.z = (int)((char *)_this + LODWORD(v725));
-			pSpellSprite.uSpriteFrameID = 0;
-			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-			pSpellSprite.spell_target_pid = v730;
-			//__debugbreak();//звездопад
-			pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
-			pSpellSprite.uFacing = v685;
-			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-			if ( pParty->bTurnBasedModeOn == 1 )
-			pSpellSprite.uAttributes = 4;
-			if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
-                   && pParty->bTurnBasedModeOn == 1 )
-              ++pTurnEngine->field_1C;
-			v721 = rand() % 1024 - 512;
-			v218 = rand();
-			v14 = a2-- == 1;
-			HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512;
-		}
-		while ( !v14 );
-		LODWORD(v727) = 1;
-		break;
-		}
-
+				v212 = stru_5C6E00->Cos(pParty->sRotationY);
+				LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
+				v213 = stru_5C6E00->Sin(pParty->sRotationY);
+				v214 = sub_42EBBE(2048, v213);
+				v211 = pParty->vPosition.z;
+				v713 = pParty->vPosition.y + v214;
+				v208 = LODWORD(v725);
+			}
+			HIDWORD(v733) = 0;
+			*(float *)&v732 = (double)v211;
+			LODWORD(v725) = v211 + 2500;
+			v721 = 0;
+			*(float *)&y = (double)(v211 + 2500);
+			v730 = v208 == 3 ? a2 : 0;
+			a2 = 20;
+			do
+			{
+				v215 = rand();
+				v216 = (double)v721;
+				v217 = (double)SHIDWORD(v733);
+				*(float *)&uRequiredMana = v217;
+				_this = (ItemGen *)(v215 % 1000);
+				*((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y;
+				*(float *)&v721 = v217 * v217;
+				//*(float *)&v726 = v216 * v216;
+				if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 )
+				{
+				LODWORD(v685) = 0;
+				HIDWORD(v685) = 0;
+				}
+				else
+				{
+				v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721);
+				v685 = __PAIR__(
+							stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)),
+							stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana));
+				}
+				pSpellSprite.stru_24.Reset();
+				pSpellSprite.spell_id = pCastSpell->spellnum;
+				pSpellSprite.spell_level = v2;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.uAttributes = 0;
+				pSpellSprite.vPosition.x = LODWORD(v718);
+				pSpellSprite.vPosition.y = v713;
+				pSpellSprite.uSectorID = 0;
+				pSpellSprite.vPosition.z = (int)((char *)_this + LODWORD(v725));
+				pSpellSprite.uSpriteFrameID = 0;
+				pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+				pSpellSprite.spell_target_pid = v730;
+				//__debugbreak();//звездопад
+				pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
+				pSpellSprite.uFacing = v685;
+				pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+				if ( pParty->bTurnBasedModeOn == 1 )
+				pSpellSprite.uAttributes = 4;
+				if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
+					   && pParty->bTurnBasedModeOn == 1 )
+				  ++pTurnEngine->field_1C;
+				v721 = rand() % 1024 - 512;
+				v218 = rand();
+				v14 = a2-- == 1;
+				HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512;
+			}
+			while ( !v14 );
+			LODWORD(v727) = 1;
+			break;
+		}
 		case SPELL_WATER_AWAKEN:
 		{
-			if ( v731 == 1 )
-				amount = 180 * v2;
-			else if ( v731 == 2)
-				amount = 3600 * v2;
-			else if ( v731 == 3 )
-				amount = 86400 * v2;
-			else if ( v731 == 4 )
-				amount = 0;
-//	LABEL_433:
+			switch (v731)
+			{
+				case 1: amount = 180 * v2; break;
+				case 2: amount = 3600 * v2; break;
+				case 3: amount = 86400 * v2; break;
+				case 4: amount = 0; break;
+				default:
+				assert(false);
+			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 			v222 = pParty->pPlayers;
-			HIDWORD(v733) = (int)(char *)&pParty + 2508;
-			while ( 2 )
-			{
+			HIDWORD(v733) = (int)pParty->pPlayers;//(int)(char *)&pParty + 2508;
+			//while ( 2 )
+			for( int i=0; i < 4; i++ )
+			{
+				pPlayer = &pParty->pPlayers[i];
 				if ( v731 == 4 )
 				{
-				if ( v222->pConditions[2] )
-				{
-					//*((int *)v222 + 4) = 0;
-					//*((int *)v222 + 5) = 0;
-					v222->pConditions[2] = 0;
-					v222->PlaySound(SPEECH_103, 0);
-				}
+					if ( pPlayer->pConditions[2] )
+					{
+						//*((int *)v222 + 4) = 0;
+						//*((int *)v222 + 5) = 0;
+						pPlayer->pConditions[2] = 0;
+						pPlayer->PlaySound(SPEECH_103, 0);
+					}
 				}
 				else
 				{
-				v223 = v222->DiscardConditionIfLastsLongerThan(
-							2u,
-							pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335));
-				v222 = (Player *)HIDWORD(v733);
-				if ( v223 )
-					v222->PlaySound(SPEECH_103, 0);
+					v223 = pPlayer->DiscardConditionIfLastsLongerThan(
+								2u,
+								pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335));
+					if ( v223 )
+						pPlayer->PlaySound(SPEECH_103, 0);
 				}
-				++v222;// += 6972;
-				HIDWORD(v733) = (int)v222;
-				if ( v222 >= &pParty->pPlayers[3] )
-				{
-					LODWORD(v727) = 1;
-					break;
-				}
-			}
-			}
+			}
+			LODWORD(v727) = 1;
+			break;
+		}
 		case SPELL_WATER_POISON_SPRAY:
 		{
 			if ( v731 == 1 )
@@ -5650,10 +5576,10 @@
 			LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280;
 			pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0);
 			BYTE2(pActors[v343].uAttributes) |= 8u;
-			v672 = 0;
+			//v672 = 0;
 			v661 = &pActors[v343];
 //LABEL_165:
-			pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672);
+			pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
 		}
 		LODWORD(v727) = 1;
 		break;