changeset 2181:17b3e40daedc

_427E01_cast_spell continue
author Ritor1
date Thu, 23 Jan 2014 00:18:05 +0600
parents 147ee4591b76
children e1e4a8a20b5f
files CastSpellInfo.cpp LOD.cpp SaveLoad.cpp
diffstat 3 files changed, 160 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Wed Jan 22 18:53:47 2014 +0600
+++ b/CastSpellInfo.cpp	Thu Jan 23 00:18:05 2014 +0600
@@ -36,16 +36,13 @@
   CastSpellInfo *pCastSpell; // ebx@2
   signed int v6; // eax@14
   unsigned __int16 v11; // cx@45
-  unsigned __int8 v14; // zf@53
   signed int i; // esi@76
   __int16 v23; // ax@88
   signed __int64 v54; // qax@164
-  //Actor *v55; // edi@164
   signed __int64 v58; // qax@177
   Actor *pActor; // edi@177
   unsigned __int16 v60; // ax@184
   int v61; // ecx@184
-  ItemGen *v69; // esi@211
   double v90; // st7@245
   Player *v92; // eax@255
   int v105; // edi@271
@@ -90,11 +87,9 @@
   double v217; // st6@415
   signed __int64 v218; // qtt@423
   char v223; // al@438
-
   int v227; // esi@453
   unsigned int v228; // edi@454
   int v229; // edi@466
-
   ItemGen *v240; // ecx@472
   double v241; // st7@478
   ItemGen *v245; // edi@492
@@ -168,8 +163,6 @@
   int v440; // eax@843
   int v441; // eax@847
   signed int v445; // edi@857
-  //int v446; // ecx@862
-  //LevelDecoration *v447; // edi@864
   __int16 v448; // ax@864
   char *v449; // esi@870
   int v450; // eax@870
@@ -187,7 +180,6 @@
   int v505; // eax@943
   int v507; // edi@944
   signed int v509; // eax@944
-  //signed int v510; // edi@944
   Actor *v518; // edx@957
   __int16 v519; // cx@958
   int v531; // eax@982
@@ -217,10 +209,6 @@
   ItemGen *v592; // esi@1052
   int v596; // esi@1066
   unsigned int v597; // edi@1067
-  int v600; // edi@1086
-  int v601; // edx@1086
-  int v602; // eax@1086
-  int v603; // ecx@1086
   NPCData *pNPCData; // eax@1089
   int v606; // edx@1091
   AwardType *v607; // ecx@1100
@@ -245,16 +233,13 @@
   int v644; // eax@1156
   signed int v645; // eax@1158
   unsigned int v656; // [sp-4h] [bp-E88h]@639
-  int v657; // [sp-4h] [bp-E88h]@807
   int v659; // [sp+0h] [bp-E84h]@123
   Actor *v661; // [sp+0h] [bp-E84h]@164
   unsigned __int64 v663; // [sp+0h] [bp-E84h]@639
   const char *v664; // [sp+0h] [bp-E84h]@802
-  int v665; // [sp+0h] [bp-E84h]@807
   int v666; // [sp+4h] [bp-E80h]@12
   PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25
   int v675; // [sp+4h] [bp-E80h]@800
-  int v676; // [sp+4h] [bp-E80h]@807
   int v679[800]; // [sp+14h] [bp-E70h]@515
   AIDirection a3; // [sp+C94h] [bp-1F0h]@21
   int v681[4]; // [sp+CB0h] [bp-1D4h]@1137
@@ -823,168 +808,136 @@
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
-        v721 = 836 * PID_ID(a2);
-        LODWORD(v718) = (int)&pActors[PID_ID(a2)];
-        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3) )
+        //v721 = 836 * PID_ID(a2);
+        v721 = PID_ID(a2);
+        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[v721], 3) )
+        {
+          pActors[v721].pActorBuffs[ACTOR_BUFF_SLOWED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, amount, 0, 0);
+          pActors[v721].uAttributes |= 80000;
+          pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[v721], 0);
+        }
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_MIND_CHARM:// Очарование
+      {
+        v61 = PID_ID(a2);
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        if ( stru_50C198.GetMagicalResistance(&pActors[v61], 7) )
         {
-          pActor = &pActors[PID_ID(a2)];
-          pActor->pActorBuffs[ACTOR_BUFF_SLOWED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, amount, 0, 0);
-          BYTE2(pActor->uAttributes) |= 8;
-          v661 = (Actor *)LODWORD(v718);
-          pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, 0);
+          uint power = 300 * spell_level;
+          if ( skill_level == 2 )
+            power = 600 * spell_level;
+          else if ( skill_level == 3 )
+            power  = 29030400;
+
+          pActors[v61].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
+          pActors[v61].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset();
+          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);
+          pSpellSprite.stru_24.Reset();
+          pSpellSprite.spell_id = pCastSpell->uSpellID;
+          pSpellSprite.spell_level = spell_level;
+          pSpellSprite.spell_skill = skill_level;
+          pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+          pSpellSprite.vPosition.x = pActors[v61].vPosition.x;
+          pSpellSprite.vPosition.y = pActors[v61].vPosition.y;
+          pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight;
+          pSpellSprite.uAttributes = 0;
+          pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].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);
+          LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
+          pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+          pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
         }
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_MIND_CHARM:
-		{
-		if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			break;
-
-		if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) )
-		{
-			LODWORD(v727) = 1;
-			break;
-		}
-
-		uint power = 300 * spell_level;
-		if ( skill_level == 2 )
-		{
-			power = 600 * spell_level;
-		}
-		else if ( skill_level == 3 )
-			power  = 29030400;
-
-		//((SpellBuff *)((char *)&pActors[0].pActorBuffs[ACTOR_BUFF_BERSERK] + v730))->Reset();
-		pActors[PID_ID(a2)].pActorBuffs[ACTOR_BUFF_BERSERK].Reset();
-		//((SpellBuff *)((char *)&pActors[0].pActorBuffs[ACTOR_BUFF_ENSLAVED] + v730))->Reset();
-		pActors[PID_ID(a2)].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset();
-		//((SpellBuff *)((char *)&pActors[0].pActorBuffs[ACTOR_BUFF_CHARM] + v730))->Apply(
-		pActors[PID_ID(a2)].pActorBuffs[ACTOR_BUFF_CHARM].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335),
-			skill_level, 0, 0, 0);
-		pSpellSprite.stru_24.Reset();
-		pSpellSprite.spell_id = pCastSpell->uSpellID;
-		pSpellSprite.spell_level = spell_level;
-		pSpellSprite.spell_skill = skill_level;
-		v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-		v61 = PID_ID(a2);
-			v600 = pActors[v61].vPosition.y;
-			v601 = pActors[v61].vPosition.x;
-			pSpellSprite.uObjectDescID = v60;
-			pSpellSprite.vPosition.x = v601;
-			v602 = pActors[v61].uActorHeight;
-			v603 = pActors[v61].vPosition.z;
-			pSpellSprite.vPosition.y = v600;
-			v676 = v603 + v602;
-			v665 = v600;
-			pSpellSprite.vPosition.z = v603 + v602;
-			v657 = v601;
-			pSpellSprite.uAttributes = 0;
-			pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
-			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);
-			LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
-			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-			pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_DARK_SHRINKING_RAY:
-		{
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			pSpellSprite.stru_24.Reset();
-			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-			pSpellSprite.vPosition.x = pParty->vPosition.x;
-			pSpellSprite.vPosition.y = pParty->vPosition.y;
-			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);
-			pSpellSprite.spell_skill = skill_level;
-			pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
-			pSpellSprite.spell_level = 300 * spell_level;
-				if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(pSpellSprite.uAttributes) |= 4;
-
-				v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
-
-				if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
-				++pTurnEngine->pending_actions;
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_FIRE_FIRE_AURA:
-		{
-			switch (skill_level)
-			{
-				case 1: LODWORD(v733) = 3600 * spell_level; amount = 10; break;
-				case 2: LODWORD(v733) = 3600 * spell_level; amount = 11; break;
-				case 3: LODWORD(v733) = 3600 * spell_level; amount = 12; break;
-				case 4: LODWORD(v733) = 0; amount = 12; break;
-				default:
-				assert(false);
-			}
-			
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
-			ItemDesc* _itm = &pItemsTable->pItems[v730c->uItemID];
-			v730c->UpdateTempBonus(pParty->uTimePlayed);
-			if ( v730c->uItemID < 64 || v730c->uItemID > 65 
-				&& !v730c->IsBroken()
-				&& !v730c->uSpecEnchantmentType
-				&& !v730c->uEnchantmentType
-				&& ( _itm->uEquipType == 0 || _itm->uEquipType == 1 || _itm->uEquipType == 2)
-				&& !pItemsTable->IsMaterialNonCommon(v730c) )
-			{
-				v69 = v730c;
-				v14 = skill_level == 4;
-				v730c->uSpecEnchantmentType = amount;
-				if ( !v14 )
-				{
-					v69->uExpireTime = pParty->uTimePlayed
-										+ (signed int)(signed __int64)((double)(signed int)((int)v733 << 7)
-																		* 0.033333335);
-					v69->uAttributes |= 8u;
-				}
-				v69->uAttributes |= 0x10u;
-				_50C9A8_item_enchantment_timer = 256;
-				LODWORD(v727) = 1;
-				break;
-			}
-
-			_50C9D0_AfterEnchClickEventId = 113;
-			_50C9D4_AfterEnchClickEventSecondParam = 0;
-			_50C9D8_AfterEnchClickEventTimeout = 1;
-
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			pCastSpell->uSpellID = 0;
-			continue;
-		}
-		case SPELL_BODY_REGENERATION:
-		{
-			switch (skill_level)
-			{
-				case 1: LODWORD(v733) = 3600 * spell_level; amount = 1; break;
-				case 2: LODWORD(v733) = 3600 * spell_level; amount = 1; break;
-				case 3: LODWORD(v733) = 3600 * spell_level; amount = 3; break;
-				case 4: LODWORD(v733) = 3600 * spell_level; amount = 10; break;
-				default:
-				assert(false);
-			}
+      case SPELL_DARK_SHRINKING_RAY://Сжимающий луч
+      {
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pSpellSprite.stru_24.Reset();
+        pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+        pSpellSprite.vPosition.x = pParty->vPosition.x;
+        pSpellSprite.vPosition.y = pParty->vPosition.y;
+        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);
+        pSpellSprite.spell_skill = skill_level;
+        pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
+        pSpellSprite.spell_level = 300 * spell_level;
+        if ( pParty->bTurnBasedModeOn == 1 )
+          LOBYTE(pSpellSprite.uAttributes) |= 4;
+        v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+        if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+          ++pTurnEngine->pending_actions;
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_FIRE_AURA: //Наколить
+      {
+        switch (skill_level)
+        {
+          case 1: LODWORD(v733) = 3600 * spell_level; amount = 10; break; //Огня
+          case 2: LODWORD(v733) = 3600 * spell_level; amount = 11; break; //Огненного жара
+          case 3: LODWORD(v733) = 3600 * spell_level; amount = 12; break;
+          case 4: LODWORD(v733) = 0; amount = 12; break;
+          default:
+            assert(false);
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
+        ItemDesc* _item = &pItemsTable->pItems[v730c->uItemID];
+        v730c->UpdateTempBonus(pParty->uTimePlayed);
+        if ( v730c->uItemID < 64 || v730c->uItemID > 65 
+         && !v730c->IsBroken()
+         && !v730c->uSpecEnchantmentType
+         && !v730c->uEnchantmentType
+         && ( _item->uEquipType == EQUIP_SINGLE_HANDED || _item->uEquipType == EQUIP_TWO_HANDED || _item->uEquipType == EQUIP_BOW)
+         && !pItemsTable->IsMaterialNonCommon(v730c) )
+        {
+          v730c->uSpecEnchantmentType = amount;
+          if ( skill_level != 4 )
+          {
+            v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
+            v730c->uAttributes |= ITEM_TEMP_BONUS;
+          }
+          v730c->uAttributes |= ITEM_AURA_EFFECT_RED;
+          _50C9A8_item_enchantment_timer = 256;
+          LODWORD(v727) = 1;
+          break;
+        }
+        _50C9D0_AfterEnchClickEventId = 113;
+        _50C9D4_AfterEnchClickEventSecondParam = 0;
+        _50C9D8_AfterEnchClickEventTimeout = 1;
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+        pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+        pCastSpell->uSpellID = 0;
+        continue;
+      }
+      case SPELL_BODY_REGENERATION://Регенерация
+      {
+        switch (skill_level)
+        {
+          case 1: LODWORD(v733) = 3600 * spell_level; amount = 1; break;
+          case 2: LODWORD(v733) = 3600 * spell_level; amount = 1; break;
+          case 3: LODWORD(v733) = 3600 * spell_level; amount = 3; break;
+          case 4: LODWORD(v733) = 3600 * spell_level; amount = 10; break;
+          default:
+            assert(false);
+        }
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 
@@ -1610,8 +1563,7 @@
 			v721 = 0;
 			*(float *)&y = (double)(v211 + 2500);
 			v730 = v208 == 3 ? a2 : 0;
-			a2 = 20;
-			do
+			for ( a2 = 20; a2; a2--)
 			{
 				v215 = rand();
 				v216 = (double)v721;
@@ -1657,10 +1609,10 @@
 				  ++pTurnEngine->pending_actions;
 				v721 = rand() % 1024 - 512;
 				v218 = rand();
-				v14 = a2-- == 1;
+				//v14 = a2-- == 1;
 				_v733 = (unsigned __int64)(v218 % 1024) - 512;
 			}
-			while ( !v14 );
+			//while ( !v14 );
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -2361,9 +2313,9 @@
 				LODWORD(v727) = 1;
 				break;
 			}
-			v14 = skill_level == 4;
+			//v14 = skill_level == 4;
 			pParty->pPlayers[v373].sHealth = 1;
-			if ( v14 )
+			if ( skill_level == 4 )
 			{
 				v374 = pCastSpell->uPlayerID_2;
 				LODWORD(pParty->pPlayers[v374].pConditions[14]) = 0;
@@ -2637,10 +2589,10 @@
 				else
 				{
 					strcpy(pTmpBuf2.data(), "nothing");
-					ShowStatusBarString(pTmpBuf2.data(), 2u);
+					ShowStatusBarString(pTmpBuf2.data(), 2);
 				}
 			}
-			ShowStatusBarString(pTmpBuf2.data(), 2u);
+			ShowStatusBarString(pTmpBuf2.data(), 2);
 			pSpellSprite.stru_24.Reset();
 			pSpellSprite.spell_id = pCastSpell->uSpellID;
 			pSpellSprite.spell_level = spell_level;
@@ -2648,12 +2600,9 @@
 			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 			pSpellSprite.vPosition.x = _v730->vPosition.x;
 			pSpellSprite.vPosition.y = _v730->vPosition.y;
-			v676 = _v730->uActorHeight;
-			v665 = pSpellSprite.vPosition.y;
 			pSpellSprite.vPosition.z = _v730->uActorHeight;
-			v657 = pSpellSprite.vPosition.x;
 			pSpellSprite.uAttributes = 0;
-			pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
+			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;
@@ -2700,19 +2649,12 @@
 			pSpellSprite.spell_skill = skill_level;
 			v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 			v61 = v426;
-			v600 = pActors[v61].vPosition.y;
-			v601 = pActors[v61].vPosition.x;
 			pSpellSprite.uObjectDescID = v60;
-			pSpellSprite.vPosition.x = v601;
-			v602 = pActors[v61].uActorHeight;
-			v603 = pActors[v61].vPosition.z;
-			pSpellSprite.vPosition.y = v600;
-			v676 = v603 + v602;
-			v665 = v600;
-			pSpellSprite.vPosition.z = v603 + v602;
-			v657 = v601;
+			pSpellSprite.vPosition.x = pActors[v61].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v61].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight;
 			pSpellSprite.uAttributes = 0;
-			pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
+			pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].vPosition.y, pSpellSprite.vPosition.z);
 			pSpellSprite.uSpriteFrameID = 0;
 			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
 			pSpellSprite.spell_target_pid = a2;
@@ -2750,19 +2692,12 @@
 			pSpellSprite.spell_skill = skill_level;
 			v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 			v61 = PID_ID(a2);
-			v600 = pActors[v61].vPosition.y;
-			v601 = pActors[v61].vPosition.x;
 			pSpellSprite.uObjectDescID = v60;
-			pSpellSprite.vPosition.x = v601;
-			v602 = pActors[v61].uActorHeight;
-			v603 = pActors[v61].vPosition.z;
-			pSpellSprite.vPosition.y = v600;
-			v676 = v603 + v602;
-			v665 = v600;
-			pSpellSprite.vPosition.z = v603 + v602;
-			v657 = v601;
+			pSpellSprite.vPosition.x = pActors[v61].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v61].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight;
 			pSpellSprite.uAttributes = 0;
-			pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
+			pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].vPosition.y, pSpellSprite.vPosition.z);
 			pSpellSprite.uSpriteFrameID = 0;
 			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
 			pSpellSprite.spell_target_pid = a2;
@@ -3566,9 +3501,9 @@
 				continue;
 			}
 			v592 = _v733;
-			v14 = skill_level == 4;
+			//v14 = skill_level == 4;
 			_v733->uSpecEnchantmentType = 16;
-			if ( !v14 )
+			if ( skill_level != 4 )
 			{
 				v732 = (int)v733 << 7;
 				v592->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
@@ -3673,19 +3608,12 @@
 			pSpellSprite.spell_skill = skill_level;
 			v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 			
-			v600 = pActor->vPosition.y;
-			v601 = pActor->vPosition.x;
 			pSpellSprite.uObjectDescID = v60;
-			pSpellSprite.vPosition.x = v601;
-			v602 = pActor->uActorHeight;
-			v603 = pActor->vPosition.z;
-			pSpellSprite.vPosition.y = v600;
-			v676 = v603 + v602;
-			v665 = v600;
-			pSpellSprite.vPosition.z = v603 + v602;
-			v657 = v601;
+			pSpellSprite.vPosition.x = pActor->vPosition.x;
+			pSpellSprite.vPosition.y = pActor->vPosition.y;
+			pSpellSprite.vPosition.z = pActor->vPosition.z + pActor->uActorHeight;
 			pSpellSprite.uAttributes = 0;
-			pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
+			pSpellSprite.uSectorID = pIndoor->GetSector(pActor->vPosition.x, pActor->vPosition.y, pSpellSprite.vPosition.z);
 			pSpellSprite.uSpriteFrameID = 0;
 			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
 			pSpellSprite.spell_target_pid = a2;
--- a/LOD.cpp	Wed Jan 22 18:53:47 2014 +0600
+++ b/LOD.cpp	Thu Jan 23 00:18:05 2014 +0600
@@ -2579,7 +2579,7 @@
   if (!pFile)
     return -1;
   v8 = pOutTex;
-  fread(pOutTex, 1u, 0x30u, pFile);
+  fread(pOutTex, 1, 0x30, pFile);
   strcpy(v8->pName, pContainer);
   if (/*pRenderer->pRenderD3D &&*/ v8->pBits & 2)
   {
@@ -2605,11 +2605,7 @@
         pRenderer->hd_water_tile_id = uNumLoadedFiles;
         v14 = uNumLoadedFiles;
       }
-      v13 = pRenderer->LoadTexture(
-              pContainer,
-              v8->palette_id1,
-              (IDirectDrawSurface4 **)&pHardwareSurfaces[v14],
-              &pHardwareTextures[v14]);
+      v13 = pRenderer->LoadTexture(pContainer, v8->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]);
     }
     else
     {
@@ -2618,11 +2614,8 @@
       eTextureType = v12;
       *(char *)v12 = 104;
       strcpy((char *)(v12 + 1), pContainer);
-      v13 = pRenderer->LoadTexture(
-              (const char *)eTextureType,
-              v8->palette_id1,
-              (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles],
-              &pHardwareTextures[uNumLoadedFiles]);
+      v13 = pRenderer->LoadTexture((const char *)eTextureType, v8->palette_id1,
+              (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], &pHardwareTextures[uNumLoadedFiles]);
       free((void *)eTextureType);
     }
     return v13;
@@ -2634,7 +2627,7 @@
   {
     v32 = malloc(v15);
     v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v32;
-    fread(v32, 1u, (size_t)pOutTex, pFile);
+    fread(v32, 1, (size_t)pOutTex, pFile);
   }
   else
   {
@@ -2656,15 +2649,15 @@
       v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight];
       v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v21;
       memcpy(v21, v23, v22);
-      v8->uTextureWidth = (signed __int16)v8->uTextureWidth >> 1;
-      v24 = v8->uTextureWidth;
-      v8->uTextureHeight = (signed __int16)v8->uTextureHeight >> 1;
+      v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2;
+      //v24 = v8->uTextureWidth;
+      v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2;
       v25 = v8->uTextureHeight;
       --v8->uWidthLn2;
       --v8->uHeightLn2;
-      v8->uWidthMinus1 = v24 - 1;
+      v8->uWidthMinus1 = v8->uTextureWidth - 1;
       v26 = v25 - 1;
-      v27 = (signed __int16)v24 * (signed __int16)v25;
+      v27 = (signed __int16)v8->uTextureWidth * (signed __int16)v25;
       v28 = pOutTex;
       v8->uHeightMinus1 = v26;
       v8->uSizeOfMaxLevelOfDetail = v27;
@@ -2850,8 +2843,10 @@
   areWeLoadingTexture = 1;
 
   for (uint i = 0; i < uNumLoadedFiles; ++i)
+  {
     if (!_stricmp(pContainer, pTextures[i].pName))
       return i;
+  }
 
 //  if (!uNumLoadedFiles)
 //  {
--- a/SaveLoad.cpp	Wed Jan 22 18:53:47 2014 +0600
+++ b/SaveLoad.cpp	Thu Jan 23 00:18:05 2014 +0600
@@ -538,7 +538,7 @@
 //----- (0045E297) --------------------------------------------------------
 void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
-  //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: вызывает затирание(ведётся работа)
+  //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: вызывает затирание
   pSavegameList->Reset();
   uNumSavegameFiles = 0;