changeset 2182:e1e4a8a20b5f

_46А6АС_GetActorsInViewport
author Ritor1
date Thu, 23 Jan 2014 17:31:12 +0600
parents 17b3e40daedc
children 172cfb4ee150
files CastSpellInfo.cpp Chest.cpp Indoor.cpp Player.cpp Render.cpp Render.h UI/UIShops.cpp UI/UiGame.cpp _deleted.cpp mm7_3.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 13 files changed, 530 insertions(+), 599 deletions(-) [+]
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/CastSpellInfo.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -46,12 +46,11 @@
   double v90; // st7@245
   Player *v92; // eax@255
   int v105; // edi@271
-  __int16 v108; // ST1C_2@274
-  __int16 v109; // ST18_2@274
-  stru6 *v110; // eax@274
   int v111; // eax@274
   Actor *v112; // esi@278
-  int v113; // eax@278
+  int dist_X; // eax@278
+  int new_dist_Y;
+  int dist_Z;
   int v114; // ebx@278
   unsigned int v115; // ecx@278
   int v116; // edx@279
@@ -261,15 +260,17 @@
   int v713; // [sp+D9Ch] [bp-E8h]@324
   int n; // [sp+DA0h] [bp-E4h]@1
   AIDirection v715; // [sp+DA4h] [bp-E0h]@21
-  int v716; // [sp+DC0h] [bp-C4h]@272
   __int64 v717; // [sp+DC4h] [bp-C0h]@271
   float v718; // [sp+DCCh] [bp-B8h]@176
   signed int sRecoveryTime; // [sp+DD0h] [bp-B4h]@53
   char *y; // [sp+DD4h] [bp-B0h]@325
-  int v721; // [sp+DD8h] [bp-ACh]@163
+  int v721;
+  int mon_id;
+  int dist_Y; // [sp+DD8h] [bp-ACh]@163
   int v723; // [sp+E4Ch] [bp-38h]@1
   ItemGen *_this; // [sp+E50h] [bp-34h]@23
   float v725; // [sp+E54h] [bp-30h]@23
+  int buff_resist;
   Player *v726; // [sp+E58h] [bp-2Ch]@131
   float v727; // [sp+E5Ch] [bp-28h]@1
   unsigned int uRequiredMana; // [sp+E60h] [bp-24h]@53
@@ -280,6 +281,7 @@
   int skill_level; // [sp+E6Ch] [bp-18h]@48
   signed int v732; // [sp+E70h] [bp-14h]@325
   unsigned __int64 v733; // [sp+E74h] [bp-10h]@1
+  int duration;
   signed int a2; // [sp+E7Ch] [bp-8h]@14
   int amount; // [sp+E80h] [bp-4h]@1
 
@@ -559,6 +561,7 @@
       }
       case SPELL_AIR_IMPLOSION:// 
       {
+        mon_id = PID_ID(a2);
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
         if (!a2)
@@ -585,23 +588,23 @@
           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));
-          int obj_id = pSpellSprite.Create(0, 0, 0, 0);
-          DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
+          pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
+          pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z;
+          pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
+          pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id);
+          DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v697);
         }
         LODWORD(v727) = 1;
         break;
       }
       case SPELL_EARTH_MASS_DISTORTION:// 
       {
+        mon_id = PID_ID(a2);
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
-        if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3) )
+        if ( stru_50C198.GetMagicalResistance(&pActors[mon_id], 3) )
         {
-          pActors[PID_ID(a2)].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
+          pActors[mon_id].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0);
           v704.x = 0;
           v704.y = 0;
           v704.z = 0;
@@ -617,12 +620,11 @@
           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, PID_ID(a2));
-          int obj_id = pSpellSprite.Create(0, 0, 0, 0);
-          DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704);
+          pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
+          pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
+          pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z;
+          pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id);
+          DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v704);
         }
         LODWORD(v727) = 1;
         break;
@@ -782,15 +784,15 @@
       {
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
-        v721 = PID_ID(a2);
-        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[v721], 9) )
+        mon_id = PID_ID(a2);
+        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[mon_id], 9) )
         {
           Actor::AI_Stand(PID_ID(a2), 4, 0x80, 0);
-          pActors[v721].pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, 0, 0, 0);
-          BYTE2(pActors[v721].uAttributes) |= 8;
-          pActors[v721].vVelocity.x = 0;
-          pActors[v721].vVelocity.y = 0;
-          pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[v721], 0);
+          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);
+          pActors[mon_id].uAttributes |= 0x80000;
+          pActors[mon_id].vVelocity.x = 0;
+          pActors[mon_id].vVelocity.y = 0;
+          pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0);
         }
         LODWORD(v727) = 1;
         break;
@@ -799,7 +801,7 @@
       {
         switch (skill_level)
         {
-          case 1: LODWORD(v733) = 180 * spell_level; amount = 2; break;
+          case 1: LODWORD(v733) = 180 * spell_level; amount = 2; break;//LODWORD(v733)???  
           case 2: LODWORD(v733) = 300 * spell_level; amount = 2; break;
           case 3: LODWORD(v733) = 300 * spell_level; amount = 4; break;
           case 4: LODWORD(v733) = 300 * spell_level; amount = 8; break;
@@ -809,12 +811,12 @@
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
         //v721 = 836 * PID_ID(a2);
-        v721 = PID_ID(a2);
-        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[v721], 3) )
+        mon_id = PID_ID(a2);
+        if (PID_TYPE(a2) == OBJECT_Actor && stru_50C198.GetMagicalResistance(&pActors[mon_id], 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);
+          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);
+          pActors[mon_id].uAttributes |= 0x80000;
+          pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0);
         }
         LODWORD(v727) = 1;
         break;
@@ -889,10 +891,10 @@
       {
         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;
+          case 1: duration = 3600 * spell_level; amount = 10; break; //
+          case 2: duration = 3600 * spell_level; amount = 11; break; // 
+          case 3: duration = 3600 * spell_level; amount = 12; break;
+          case 4: duration = 0; amount = 12; break;
           default:
             assert(false);
         }
@@ -911,7 +913,7 @@
           v730c->uSpecEnchantmentType = amount;
           if ( skill_level != 4 )
           {
-            v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
+            v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335);
             v730c->uAttributes |= ITEM_TEMP_BONUS;
           }
           v730c->uAttributes |= ITEM_AURA_EFFECT_RED;
@@ -931,438 +933,381 @@
       {
         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;
+          case 1: amount = 1; break;
+          case 2: amount = 1; break;
+          case 3: amount = 3; break;
+          case 4: amount = 10; break;
+          default:
+            assert(false);
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
+        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);
+        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://  
+      {
+        switch (skill_level)
+        {
+          case 1:
+          case 2:
+          case 3: 
+          case 4: amount = skill_level * spell_level; break;
+          default:
+            assert(false);
+        }
+        switch (pCastSpell->uSpellID)
+        {
+          case SPELL_FIRE_PROTECTION_FROM_FIRE:
+            buff_resist = PARTY_BUFF_RESIST_FIRE;
+            break;
+          case SPELL_AIR_PROTECTION_FROM_AIR:
+            buff_resist = PARTY_BUFF_RESIST_AIR;
+            break;
+          case SPELL_WATER_PROTECTION_FROM_WATER:
+            buff_resist = PARTY_BUFF_RESIST_WATER;
+            break;
+          case SPELL_EARTH_PROTECTION_FROM_EARTH:
+            buff_resist = PARTY_BUFF_RESIST_EARTH;
+            break;
+          case SPELL_MIND_PROTECTION_FROM_MIND:
+            buff_resist = PARTY_BUFF_RESIST_MIND;
+            break;
+          case SPELL_BODY_PROTECTION_FROM_BODY:
+            buff_resist = PARTY_BUFF_RESIST_BODY;
+            break;
+          default:
+            assert(false);
+          continue;
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
+        //v90 = (double)(signed int)(3600 * spell_level) * 4.2666669;
+        pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0);
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_HASTE://
+      {
+        switch (skill_level)
+        {
+          case 1: duration = 60 * (spell_level + 60); break;
+          case 2: duration = 60 * (spell_level + 60); break;
+          case 3: duration = 180 * (spell_level + 20); break;
+          case 4: duration = 240 * (spell_level + 15); break;
+          default:
+            assert(false);
+        }
+        if ( pPlayer->CanCastSpell(uRequiredMana) )
+        {
+          LODWORD(v727) = 1;
+          for ( uint pl_id = 0; pl_id < 4; pl_id++ )
+          {
+            if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] )
+              LODWORD(v727) = 0;
+          }
+          if (LODWORD(v727))
+          {
+            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);
+            pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
+            pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
+            pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
+            pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
+          }
+        }
+        break;
+      }
+      case SPELL_SPIRIT_BLESS://
+      {
+        switch (skill_level)
+        {
+          case 1: duration = 300 * (spell_level + 12); break;
+          case 2: duration = 300 * (spell_level + 12); break;
+          case 3: duration = 900 * (spell_level + 4); break;
+          case 4: duration = 3600 * (spell_level + 1); break;
           default:
             assert(false);
         }
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
-
-			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)v733 * 4.2666669), skill_level, 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:
+        amount = spell_level + 5;
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        if ( skill_level == 1 )
+        {
+          pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
+          v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536);
+          pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed +
+                                (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), 1, amount, v111, 0);
+          LODWORD(v727) = 1;
+          break;
+        }
+        for ( uint pl_id = 0; pl_id < 4; pl_id++ )
+        {
+          pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
+          v111 = pOtherOverlayList->_4418B1(10000, pl_id + 310, 0, 65536);
+          pParty->pPlayers[pl_id].pPlayerBuffs[1].Apply(pParty->uTimePlayed +
+                             (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, v111, 0);
+        }
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_SPIRIT_SPIRIT_LASH:// 
+      {
+        if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor)
+        {
+          int mon_id = PID_ID(a2);
+          dist_X = abs(pActors[mon_id].vPosition.x - pParty->vPosition.x);
+          dist_Y = abs(pActors[mon_id].vPosition.y - pParty->vPosition.y);
+          dist_Z = abs(pActors[mon_id].vPosition.z - pParty->vPosition.z);
+          int count = dist_X;
+          new_dist_Y = dist_Y;
+          if ( dist_X < dist_Y )
+          {
+            v116 = dist_X;
+            dist_X = dist_Y;
+            new_dist_Y = v116;
+          }
+          if ( dist_X < dist_Z )
+          {
+            v117 = dist_X;
+            dist_X = dist_Z;
+            dist_Z = v117;
+          }
+          if ( new_dist_Y < dist_Z )
+          {
+            v118 = dist_Z;
+            dist_Z = new_dist_Y;
+            new_dist_Y = v118;
+          }
+          count = ((unsigned int)(11 * new_dist_Y) >> 5) + (dist_Z >> 2) + dist_X;
+          if ( (double)count <= 307.2 )
+          {
+            v701.x = 0;
+            v701.y = 0;
+            v701.z = 0;
+            pSpellSprite.stru_24.Reset();
+            pSpellSprite.spell_id = pCastSpell->uSpellID;
+            pSpellSprite.spell_level = v723;
+            pSpellSprite.spell_skill = skill_level;
+            pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+            pSpellSprite.uAttributes = 0;
+            pSpellSprite.uSectorID = 0;
+            pSpellSprite.uSpriteFrameID = 0;
+            pSpellSprite.field_60_distance_related_prolly_lod = 0;
+            pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+            pSpellSprite.uFacing = 0;
+            pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+            pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x;
+            pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y;
+            pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8);
+            pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
+            DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v701);
+            LODWORD(v727) = 1;
+          }
+          else
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//" !!!"
+            pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+            pCastSpell->uSpellID = 0;
+          }
+        }
+        break;
+      }
+      case SPELL_AIR_SHIELD://
+      case SPELL_EARTH_STONESKIN:// 
+      case SPELL_SPIRIT_HEROISM://
+      {
+        switch (skill_level)
+        {
+          case 1: duration = 300 * (spell_level + 12); break;
+          case 2: duration = 300 * (spell_level + 12); break;
+          case 3: duration = 900 * (spell_level + 4); break;
+          case 4: duration = 3600 * (spell_level + 1); break;
+          default:
+            assert(false);
+        }
+        switch (pCastSpell->uSpellID)
+        {
+          case SPELL_AIR_SHIELD:
+            amount = 0;
+            buff_resist = PARTY_BUFF_SHIELD;
+            break;
+          case SPELL_EARTH_STONESKIN:
+            amount = spell_level + 5;
+            buff_resist = PARTY_BUFF_STONE_SKIN;
+            break;
+          case SPELL_SPIRIT_HEROISM:
+            amount = spell_level + 5;
+            buff_resist = PARTY_BUFF_HEROISM;
+            break;
+          default:
+            assert(false);
+          continue;
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
+        pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed +
+                       (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0);
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_IMMOLATION:// 
+      {
+        if ( skill_level == 4 )
+          duration = 600 * spell_level;
+        else
+          duration = 60 * spell_level;
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
+        pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + 
+                               (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, spell_level, 0, 0);
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_METEOR_SHOWER:// 
+      {
+        //if (skill_level < 3)//   
+          //break;
+        int meteor_num;
+        if ( skill_level == 4 )
+          meteor_num = 20;
+        else
+          meteor_num = 16;
+        if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2);  // Can't cast Meteor Shower indoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          continue;
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        int obj_type = PID_TYPE(a2);
+        mon_id = PID_ID(a2);
+        if (obj_type == OBJECT_Actor)//     .,      
+        {
+          dist_X = pActors[mon_id].vPosition.x;
+          dist_Y = pActors[mon_id].vPosition.y;
+          dist_Z = pActors[mon_id].vPosition.z;
+        }
+        else
+        {
+          dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY));
+          dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY));
+          dist_Z = pParty->vPosition.z;
+        }
+        unsigned __int64 k = 0;
+        int j = 0;
+        if ( meteor_num > 0 )
+        {
+          v730 = obj_type == OBJECT_Actor ? a2 : 0;
+          for ( meteor_num; meteor_num; meteor_num-- )
+          {
+            a2 = rand() % 1000;
+            if ( sqrt((double)(rand() % 1000) - 2500 * (double)(rand() % 1000) - 2500 + j * j + k * k) <= 1.0 )
+            {
+              LODWORD(v687) = 0;
+              HIDWORD(v687) = 0;
+            }
+            else
+            {
+              HIDWORD(v687) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), (double)(rand() % 1000) - 2500);
+              LODWORD(v687) = stru_5C6E00->Atan2(j, k);
+            }
+            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.uAttributes = 0;
+            pSpellSprite.vPosition.x = dist_X;
+            pSpellSprite.vPosition.y = dist_Y;
+            pSpellSprite.uSectorID = 0;
+            pSpellSprite.vPosition.z = a2 + dist_Z;
+            pSpellSprite.uSpriteFrameID = 0;
+            pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+            pSpellSprite.spell_target_pid = v730;
+            pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
+            pSpellSprite.uFacing = v687;
+            pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+            if ( pParty->bTurnBasedModeOn == 1 )
+              pSpellSprite.uAttributes = 4;
+            if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 && pParty->bTurnBasedModeOn == 1 )
+              ++pTurnEngine->pending_actions;
+            j = rand() % 1024 - 512;
+            k = rand() % 1024 - 512;
+          }
+        }
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_INFERNO:// 
+      {
+        if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          continue;
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        int mon_num = pRenderer->_466_GetActorsInViewport(4096);
+        v700.x = 0;
+        v700.y = 0;
+        v700.z = 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.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);
+        for ( uint i = 0; i < mon_num; i++ )
+        {
+          pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.x;
+          pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.y;
+          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);
+          pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[i]);
+          DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[i], &v700);
+          pGame->GetStru6()->_4A81CA(&pSpellSprite);
+          pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1E, 0x40);
+        }
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_AIR_WIZARD_EYE:
 		{
-			switch (skill_level)
-			{
-				case 1: 
-				case 2: 
-				case 3: 
-				case 4: LODWORD(v733) = 3600 * spell_level; amount = skill_level * spell_level; break;
-				default:
-				assert(false);
-			}
-
-			switch (pCastSpell->uSpellID)
-			{
-			  case SPELL_FIRE_PROTECTION_FROM_FIRE:
-				LODWORD(v725) = PARTY_BUFF_RESIST_FIRE;
-				break;
-			  case SPELL_AIR_PROTECTION_FROM_AIR:
-				LODWORD(v725) = PARTY_BUFF_RESIST_AIR;
-				break;
-			  case SPELL_WATER_PROTECTION_FROM_WATER:
-				LODWORD(v725) = PARTY_BUFF_RESIST_WATER;
-				break;
-			  case SPELL_EARTH_PROTECTION_FROM_EARTH:
-				LODWORD(v725) = PARTY_BUFF_RESIST_EARTH;
-				break;
-			  case SPELL_MIND_PROTECTION_FROM_MIND:
-				LODWORD(v725) = PARTY_BUFF_RESIST_MIND;
-				break;
-			  case SPELL_BODY_PROTECTION_FROM_BODY:
-				LODWORD(v725) = PARTY_BUFF_RESIST_BODY;
-				break;
-			  default:
-				assert(false);
-				continue;
-			}
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-			  break;
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
-			v90 = (double)(signed int)v733 * 4.2666669;
-			pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, skill_level, amount, 0, 0);
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_FIRE_HASTE:
-		{
-			switch (skill_level)
-			{
-				case 1: LODWORD(v733) = 60 * (spell_level + 60); break;
-				case 2: LODWORD(v733) = 60 * (spell_level + 60); break;
-				case 3: LODWORD(v733) = 180 * (spell_level + 20); break;
-				case 4: LODWORD(v733) = 240 * (spell_level + 15); break;
-				default:
-				assert(false);
-			}
-			if ( pPlayer->CanCastSpell(uRequiredMana) )
-			{
-				v92 = pParty->pPlayers.data();//[0].pConditions[1];
-				LODWORD(v727) = 1;
-				do
-				{
-					if ( v92->pConditions[Condition_Weak] )
-						LODWORD(v727) = 0;
-					++v92;
-				}
-				while ( v92 <= &pParty->pPlayers[3] );
-				if (LODWORD(v727))
-				{
-					pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, 0, 0, 0);
-
-					pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
-					pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
-					pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
-					pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
-				}
-			}
-			break;
-		}
-		case SPELL_SPIRIT_BLESS:
-		{
-			switch (skill_level)
-			{
-				case 1: LODWORD(v733) = 300 * (spell_level + 12); break;
-				case 2: LODWORD(v733) = 300 * (spell_level + 12); break;
-				case 3: LODWORD(v733) = 900 * (spell_level + 4); break;
-				case 4: LODWORD(v733) = 3600 * (spell_level + 1); break;
-				default:
-				assert(false);
-			}
-			amount = spell_level + 5;
+			duration = 3600 * spell_level;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			if ( skill_level == 1 )
-			{
-				v108 = pCastSpell->uPlayerID_2;
-				v109 = pCastSpell->uSpellID;
-				v110 = pGame->GetStru6();
-				pGame->GetStru6()->SetPlayerBuffAnim(v109, v108);
-				v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536);
-				//v668 = 0;
-				v716 = v111;
-				//v658 = v111;
-				//v653 = amount;
-				//v651 = 1;
-				//v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
-				//v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS];
-		//LABEL_103:
-				//HIDWORD(v650) = HIDWORD(v28);
-		//LABEL_104:
-				//LODWORD(v650) = v28;
-				pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0);
-				LODWORD(v727) = 1;
-				break;
-			}
-			v105 = 0;
-			v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
-			v730b = pParty->pPlayers.data();//[0].pPlayerBuffs[1];
-			do
-			{
-				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, v105);
-				v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536);
-				v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, skill_level, amount, v716, 0);
-				++v730b;
-				++v105;
-			}
-			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;
-				v112 = &pActors[PID_ID(a2)];
-				//v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z);
-				v721 = abs(v112->vPosition.y - pParty->vPosition.y);
-				v113 = abs(v112->vPosition.x - pParty->vPosition.x);
-				_this = (ItemGen *)v113;
-				v114 = v721;
-				v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z);
-				if ( v113 < v721 )
-				{
-					v116 = v113;
-					v113 = v721;
-					v114 = v116;
-				}
-				if ( v113 < (signed int)v115 )
-				{
-					v117 = v113;
-					v113 = (int)v115;
-					v115 = v117;
-				}
-				if ( v114 < (signed int)v115 )
-				{
-					v118 = v115;
-					v115 = v114;
-					v114 = v118;
-				}
-				_this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113);
-				if ( (double)(signed int)_this <= 307.2 )
-				{
-					v701.x = 0;
-					v701.y = 0;
-					v701.z = 0;
-					pSpellSprite.stru_24.Reset();
-					pSpellSprite.spell_id = pCastSpell->uSpellID;
-					pSpellSprite.spell_level = v723;
-					pSpellSprite.spell_skill = skill_level;
-					pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-					pSpellSprite.uAttributes = 0;
-					pSpellSprite.uSectorID = 0;
-					pSpellSprite.uSpriteFrameID = 0;
-					pSpellSprite.field_60_distance_related_prolly_lod = 0;
-					pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-					pSpellSprite.uFacing = 0;
-					pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-					pSpellSprite.vPosition.x = v112->vPosition.x;
-					pSpellSprite.vPosition.y = v112->vPosition.y;
-					pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)v112->uActorHeight * -0.8);
-					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
-					v122 = pSpellSprite.Create(0, 0, 0, 0);
-					DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701);
-					LODWORD(v727) = 1;
-				}
-				else
-				{
-					ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
-					pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-					pCastSpell->uSpellID = 0;
-				}
-				//pCastSpell = (CastSpellInfo *)HIDWORD(v733);
-			}
-			break;
-		}
-		case SPELL_AIR_SHIELD:
-		case SPELL_EARTH_STONESKIN:
-		case SPELL_SPIRIT_HEROISM:
-		{
-			switch (skill_level)
-			{
-				case 1: LODWORD(v733) = 300 * (spell_level + 12); break;
-				case 2: LODWORD(v733) = 300 * (spell_level + 12); break;
-				case 3: LODWORD(v733) = 900 * (spell_level + 4); break;
-				case 4: LODWORD(v733) = 3600 * (spell_level + 1); break;
-				default:
-				assert(false);
-			}
-			v127 = pCastSpell->uSpellID;
-			if ( v127 == 17 )
-			{
-				amount = 0;
-				LODWORD(v725) = 14;
-			}
-			else
-			{
-				if ( v127 == 38 )
-				{
-					LODWORD(v725) = 15;
-					amount = spell_level + 5;
-				}
-				else
-				{
-					if ( v127 != 51 )
-						continue;
-					LODWORD(v725) = 9;
-					amount = spell_level + 5;
-				}
-			}
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
-			v90 = (double)(signed int)((int)v733 << 7) * 0.033333335;
-	//LABEL_304:
-			pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, skill_level, amount, 0, 0);
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_FIRE_IMMOLATION:
-		{
-			if ( skill_level == 4 )
-				LODWORD(v733) = 600 * spell_level;
-			else
-				LODWORD(v733) = 60 * spell_level;
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
+			for ( uint pl_id = 0; pl_id < 4; pl_id++ )
+				v169 = pOtherOverlayList->_4418B1(2000, pl_id + 100, 0, 65536);
 
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
-
-			pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, spell_level, 0, 0);
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_FIRE_METEOR_SHOWER:
-		{
-			//v149 = skill_level - 1;
-			//if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 )
-			int i;
-			if ( skill_level == 4 )
-				i = 20;
-			else
-				i = 16;
-			if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2);  // Can't cast Meteor Shower indoors!
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				continue;
-			}
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			LODWORD(v725) = PID_TYPE(a2);
-			if (PID_TYPE(a2) == OBJECT_Actor)
-			{
-				uRequiredMana = pActors[PID_ID(a2)].vPosition.x;
-				v153 = pActors[PID_ID(a2)].vPosition.y;
-				v154 = pActors[PID_ID(a2)].vPosition.z;
-				LODWORD(v727) = v153;
-			}
-			else
-			{
-				v155 = stru_5C6E00->Cos(pParty->sRotationY);
-				uRequiredMana = pParty->vPosition.x + fixpoint_mul(2048, v155);
-				v156 = stru_5C6E00->Sin(pParty->sRotationY);
-				LODWORD(v727) = pParty->vPosition.y + fixpoint_mul(2048, v156);
-				v154 = pParty->vPosition.z;
-			}
-			unsigned __int64 k = 0;
-			int j = 0;
-			if ( (signed int)i > 0 )
-			{
-				v730 = LODWORD(v725) == 3 ? a2 : 0;
-				do
-				{
-					a2 = rand() % 1000;
-					if ( sqrt((double)(rand() % 1000) - 2500 * 
-								(double)(rand() % 1000) - 2500 + 
-								j * j + k * k) <= 1.0 )
-					{
-						LODWORD(v687) = 0;
-						HIDWORD(v687) = 0;
-					}
-					else
-					{
-						v687 = __PAIR__(
-								stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), 
-													(double)(rand() % 1000) - 2500),
-													stru_5C6E00->Atan2(j, k));
-					}
-					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.uAttributes = 0;
-					pSpellSprite.vPosition.x = uRequiredMana;
-					pSpellSprite.vPosition.y = LODWORD(v727);
-					pSpellSprite.uSectorID = 0;
-					pSpellSprite.vPosition.z = a2 + v154;
-					pSpellSprite.uSpriteFrameID = 0;
-					pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
-					pSpellSprite.spell_target_pid = v730;
-					pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
-					pSpellSprite.uFacing = v687;
-					pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
-					if ( pParty->bTurnBasedModeOn == 1 )
-						pSpellSprite.uAttributes = 4;
-					if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
-						&& pParty->bTurnBasedModeOn == 1 )
-						++pTurnEngine->pending_actions;
-					j = rand() % 1024 - 512;
-					k = rand() % 1024 - 512;
-				}
-				while ( i-- != 1 );
-			}
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_FIRE_INFERNO:
-		{
-			//v67 = 2;
-			if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				continue;
-			}
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
-			v700.z = 0;
-			v700.y = 0;
-			v700.x = 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.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);
-			a2 = 0;
-			if ( (signed int)_v726 > 0 )
-			{
-				do
-				{
-					v162 = dword_50BF30[a2];
-					pSpellSprite.vPosition.x = pActors[v162].vPosition.x;
-					pSpellSprite.vPosition.y = pActors[v162].vPosition.y;
-					pSpellSprite.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * -0.8);
-					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-					v164 = pSpellSprite.Create(0, 0, 0, 0);
-					v165 = a2;
-					DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700);
-					pGame->GetStru6()->_4A81CA(&pSpellSprite);
-					pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u);
-					a2 = v165 + 1;
-				}
-				while ( v165 + 1 < (signed int)_v726 );
-			}
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_AIR_WIZARD_EYE:
-		{
-			LODWORD(v733) = 3600 * spell_level;
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			v168 = 0;
-			do
-			{
-				v169 = pOtherOverlayList->_4418B1(2000, v168++ + 100, 0, 65536);
-				v716 = v169;
-			}
-			while ( v168 < 4 );
-
-			pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, 0, 0, 0);
+			pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, v169, 0);
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -1513,13 +1458,10 @@
 				amount = 0;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			v205 = 0;
-			do
-				pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536);
-			while ( v205 < 4 );
+			for ( uint pl_id = 0; pl_id < 4; pl_id++)
+				pOtherOverlayList->_4418B1(2090, pl_id + 100, 0, 65536);
 			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), skill_level, amount, v206, v207);
 			LODWORD(v727) = 1;
@@ -1749,14 +1691,14 @@
 			LODWORD(v733) = v229;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
+			v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
 			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
 			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
 			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
 			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
 
 			pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335),
-				skill_level, amount, v716, pCastSpell->uPlayerID + 1);
+				skill_level, amount, v169, pCastSpell->uPlayerID + 1);
 			if ( skill_level == 4 )
 				pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
 			LODWORD(v727) = 1;
@@ -2265,7 +2207,7 @@
 				LODWORD(v733) = 300 * spell_level + 180;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			int _v726 = pRenderer->_466_GetActorsInViewport(4096);
 			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192);
 			++pSpellSprite.uType;
 			pSpellSprite.stru_24.Reset();
@@ -2282,14 +2224,14 @@
 			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
 			{
-				v369 = &pActors[dword_50BF30[a2]];
+				v369 = &pActors[_50BF30_actors_in_viewport_ids[a2]];
 				if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
 				{
 					pSpellSprite.vPosition.x = v369->vPosition.x;
 					pSpellSprite.vPosition.y = v369->vPosition.y;
 					pSpellSprite.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * -0.8);
 
-					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 					pSpellSprite.Create(0, 0, 0, 0);
 					v369->pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
 						skill_level, 0, 0, 0);
@@ -2717,7 +2659,7 @@
 				amount = 180 * spell_level;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			int _v726 = pRenderer->_466_GetActorsInViewport(4096);
 			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 192);
 			++pSpellSprite.uType;
 			pSpellSprite.stru_24.Reset();
@@ -2734,14 +2676,14 @@
 			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
 			{
-				v433 = &pActors[dword_50BF30[a2]];
+				v433 = &pActors[_50BF30_actors_in_viewport_ids[a2]];
 				if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
 					break;
 				pSpellSprite.vPosition.x = v433->vPosition.x;
 				pSpellSprite.vPosition.y = v433->vPosition.y;
 				pSpellSprite.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * -0.8);
 
-				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 				pSpellSprite.Create(0, 0, 0, 0);
 				if ( stru_50C198.GetMagicalResistance(v433, 7u) )
 				{
@@ -3106,7 +3048,7 @@
 				break;
 
 			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192);
-			v505 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			v505 = pRenderer->_466_GetActorsInViewport(4096);
 			++pSpellSprite.uType;
 			//signed int _v733 = v505;
 			v688.x = 0;
@@ -3127,21 +3069,21 @@
 			a2 = 0;
 			for ( a2 = 0; a2 < v505; ++a2 )
 			{
-				v507 = dword_50BF30[a2];
+				v507 = _50BF30_actors_in_viewport_ids[a2];
 				pSpellSprite.vPosition.x = pActors[v507].vPosition.x;
 				pSpellSprite.vPosition.y = pActors[v507].vPosition.y;
 				pSpellSprite.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * -0.8);
-				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 				v509 = pSpellSprite.Create(0, 0, 0, 0);
-				DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], &v688);
+				DamageMonsterFromParty(PID(OBJECT_Item, v509), _50BF30_actors_in_viewport_ids[a2], &v688);
 			}
 			for ( a2 = 0; a2 < v505; ++a2 )
 			{
-				pActor = &pActors[dword_50BF30[a2]];
+				pActor = &pActors[_50BF30_actors_in_viewport_ids[a2]];
 				pSpellSprite.vPosition.x = pActor->vPosition.x;
 				pSpellSprite.vPosition.y = pActor->vPosition.y;
 				pSpellSprite.vPosition.z = pActor->vPosition.z - (unsigned int)(signed __int64)((double)pActor->uActorHeight * -0.8);
-				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 				pSpellSprite.Create(0, 0, 0, 0);
 				for (int i = 0; i < 22; ++i)
 				{
@@ -3226,7 +3168,7 @@
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			v531 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			v531 = pRenderer->_466_GetActorsInViewport(4096);
 			++pSpellSprite.uType;
 			v694.x = 0;
 			v694.y = 0;
@@ -3248,14 +3190,14 @@
 			{
 				do
 				{
-					v533 = dword_50BF30[a2];
+					v533 = _50BF30_actors_in_viewport_ids[a2];
 					pSpellSprite.vPosition.x = pActors[v533].vPosition.x;
 					pSpellSprite.vPosition.y = pActors[v533].vPosition.y;
 					pSpellSprite.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * -0.8);
-					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 					v535 = pSpellSprite.Create(0, 0, 0, 0);
 					v536 = a2;
-					DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694);
+					DamageMonsterFromParty(PID(OBJECT_Item, v535), _50BF30_actors_in_viewport_ids[a2], &v694);
 					a2 = v536 + 1;
 				}
 				while ( v536 + 1 < (signed int)v531 );
@@ -3718,21 +3660,16 @@
 			if ( skill_level != 3 && skill_level != 4 )
 			{
 				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
-				pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, amount, v716, 0);
+				pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, amount, 0, 0);
 				LODWORD(v727) = 1;
 				break;
 			}
-			a2 = 0;
-			v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
-			v619 = pParty->pPlayers.data();//[0].pPlayerBuffs[10];
-			do
+			for ( uint pl_id = 0; pl_id , 4; pl_id++ )
 			{
-				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2);
-				v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, skill_level, amount, v716, 0);
-				++a2;
-				++v619;
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id);
+				pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + 
+                            (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), skill_level, amount, 0, 0);
 			}
-			while ( v619 <= &pParty->pPlayers[3] );
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -3742,7 +3679,7 @@
 				break;
 			pGame->GetIndoorCamera();
 			v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth();
-			signed int _v733 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, v623);
+			signed int _v733 = pRenderer->_466_GetActorsInViewport(v623);
 			v707.x = 0;
 			v707.y = 0;
 			v707.z = 0;
@@ -3765,15 +3702,15 @@
 				_v726 = (_v733 * (7 * spell_level + 25));
 				do
 				{
-					v625 = dword_50BF30[a2];
+					v625 = _50BF30_actors_in_viewport_ids[a2];
 					pSpellSprite.vPosition.x = pActors[v625].vPosition.x;
 					pSpellSprite.vPosition.y = pActors[v625].vPosition.y;
 					//v732 = pActors[v625].uActorHeight;
 					pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * -0.8);
-					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]);
 					v627 = pSpellSprite.Create(0, 0, 0, 0);
 					v628 = a2;
-					DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707);
+					DamageMonsterFromParty(PID(OBJECT_Item, v627), _50BF30_actors_in_viewport_ids[a2], &v707);
 					a2 = v628 + 1;
 				}
 				while ( v628 + 1 < _v733 );
--- a/Chest.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/Chest.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -162,9 +162,9 @@
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
       pSpellObject.ExplosionTraps();
       chest->uFlags &= 0xFEu;
-      if ( uActiveCharacter && !qword_A750D8 && !OpenedTelekinesis )
+      if ( uActiveCharacter && !_A750D8_player_speech_timer && !OpenedTelekinesis )
       {
-        qword_A750D8 = 256i64;
+        _A750D8_player_speech_timer = 256i64;
         PlayerSpeechID = SPEECH_5;
         uSpeakingCharacter = uActiveCharacter;
       }
--- a/Indoor.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/Indoor.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -3167,8 +3167,8 @@
   pPaletteManager->pPalette_tintColor[1] = 0;
   pPaletteManager->pPalette_tintColor[2] = 0;
   pPaletteManager->RecalculateAll();
-  if ( qword_A750D8 )
-    qword_A750D8 = 0i64;
+  if ( _A750D8_player_speech_timer )
+    _A750D8_player_speech_timer = 0i64;
   map_id = pMapStats->GetMapInfo(pCurrentMapName);
   if ( map_id )
   {
@@ -3376,7 +3376,7 @@
     {
       if ( pDest )
       {
-        qword_A750D8 = 256i64;
+        _A750D8_player_speech_timer = 256i64;
         PlayerSpeechID = SPEECH_46;
         uSpeakingCharacter = v34[rand() % v30];
       }
--- a/Player.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/Player.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -7405,9 +7405,9 @@
         v69 = 0;
       }
       playerPtr->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
-      if ( uActorType == OBJECT_Player && !qword_A750D8 )
+      if ( uActorType == OBJECT_Player && !_A750D8_player_speech_timer )
       {
-        qword_A750D8 = 256i64;
+        _A750D8_player_speech_timer = 256i64;
         PlayerSpeechID = SPEECH_44;
         uSpeakingCharacter = uActorID + 1;
       }
--- a/Render.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/Render.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -9137,69 +9137,66 @@
 
   v3 = pPixels;
 
-    BeginSceneD3D();
-
-    if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      pIndoor->Draw();
-    else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-      pOutdoor->Draw();
-
-    DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
-    memset(&Dst, 0, 0x7C);
-    Dst.dwSize = sizeof(Dst);
-
-    if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
-    {
-      for (uint y = 0; y < height; ++y)
-      {
-        for (uint x = 0; x < width; ++x)
+  BeginSceneD3D();
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    pIndoor->Draw();
+  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    pOutdoor->Draw();
+  DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
+  memset(&Dst, 0, 0x7C);
+  Dst.dwSize = sizeof(Dst);
+
+  if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
+  {
+    for (uint y = 0; y < height; ++y)
+    {
+      for (uint x = 0; x < width; ++x)
+      {
+        //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)];
+        if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
         {
-          //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)];
-
-          if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
-          {
-            auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
-            *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
-          }
-          else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
-          {
-            auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
-            *v3 = *p;
-          }
-          else __debugbreak();
-          ++v3;
+          auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
+          *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
+        }
+        else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
+        {
+          auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
+          *v3 = *p;
         }
-      }
-      ErrD3D(pBackBuffer4->Unlock(0));
-    }
-    else
-    {
-      __debugbreak(); // unrefactored - black screenshot
-      v4 = height;
-      if ( height > 0 )
-      {
-        do
+        else __debugbreak();
+        ++v3;
+      }
+    }
+    ErrD3D(pBackBuffer4->Unlock(0));
+  }
+  else
+  {
+    __debugbreak(); // unrefactored - black screenshot
+    v4 = height;
+    if ( height > 0 )
+    {
+      do
+      {
+        if ( width > 0 )
         {
-          if ( width > 0 )
+          v5 = width & 1;
+          v6 = (unsigned int)width / 2;
+          memset(v3, 0, 4 * ((unsigned int)width / 2));
+          v7 = &v3[2 * v6];
+          for ( j = v5; j; --j )
           {
-            v5 = width & 1;
-            v6 = (unsigned int)width >> 1;
-            memset(v3, 0, 4 * ((unsigned int)width >> 1));
-            v7 = &v3[2 * v6];
-            for ( j = v5; j; --j )
-            {
-              *v7 = 0;
-              ++v7;
-            }
-            v3 += width;
+            *v7 = 0;
+            ++v7;
           }
-          --v4;
+          v3 += width;
         }
-        while ( v4 );
-      }
-    }
-
-    
+        --v4;
+      }
+      while ( v4 );
+    }
+  }
+
   /*if (!pRenderer->pRenderD3D)
   {
     pRenderer->BeginScene();
@@ -9273,17 +9270,16 @@
 
 
 //----- (0046A7C8) --------------------------------------------------------
-int Render::_46A6AC_spell_render_d3d(int a1, int a2, int a3)
-{
-  unsigned int v3; // eax@2
+int Render::_466_GetActorsInViewport(int pDepth)
+{
+  unsigned int v3; // eax@2        -       id  
   unsigned int v5; // eax@2
   unsigned int v6; // eax@4
-  int v10; // ecx@11
   unsigned int v12; // [sp+10h] [bp-14h]@1
-  int v15; // [sp+1Ch] [bp-8h]@1
+  int mon_num; // [sp+1Ch] [bp-8h]@1
   unsigned int a1a; // [sp+20h] [bp-4h]@1
 
-  v15 = 0;
+  mon_num = 0;
   v12 = GetBillboardDrawListSize();
   if ( (signed int)GetBillboardDrawListSize() > 0 )
   {
@@ -9293,19 +9289,18 @@
       v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
       if ( PID_TYPE(v5) == OBJECT_Actor)
       {
-        if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) )
+        if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) )
         {
           v6 = PID_ID(v5);
           if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
             && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
           {
-            if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) )
+            if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) )
             {
-              if ( v15 < a2 - 1 )
+              if ( mon_num < 100 )
               {
-                __debugbreak();// *(int *)(a1 + 4 * v10) = v6;   ?
-                v10 = v15++;
-                *(int *)(a1 + 4 * v10) = v6;
+                _50BF30_actors_in_viewport_ids[mon_num] = v6;
+                mon_num++;
               }
             }
           }
@@ -9313,7 +9308,7 @@
       }
     }
   }
-  return v15;
+  return mon_num;
 }
 
 
--- a/Render.h	Thu Jan 23 00:18:05 2014 +0600
+++ b/Render.h	Thu Jan 23 17:31:12 2014 +0600
@@ -371,8 +371,7 @@
   bool IsGammaSupported();
   void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height);
   void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size);
-  int _46A6AC_spell_render_d3d(int a1, int a2, int a3);
-
+  int _466_GetActorsInViewport(int pDepth);
   void BeginLightmaps();
   void EndLightmaps();  
   void BeginLightmaps2();
--- a/UI/UIShops.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/UI/UIShops.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -1826,7 +1826,7 @@
         return;
       }
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)(dword_F8B1E4 + 3));
-      if ( !dword_F8B1E4 && !qword_A750D8 )
+      if ( !dword_F8B1E4 && !_A750D8_player_speech_timer )
       {
         v5 = 0;
         for ( uint i = 1; i <= 4; ++i )
@@ -1836,7 +1836,7 @@
         }
         if ( v5 )
         {
-          qword_A750D8 = 256i64;
+          _A750D8_player_speech_timer = 256i64;
           PlayerSpeechID = SPEECH_80;
           uSpeakingCharacter = v7[rand() % v5];
           return;
@@ -1845,7 +1845,7 @@
     }
     else
     {
-      if ( !qword_A750D8 )
+      if ( !_A750D8_player_speech_timer )
       {
         v2 = 0;
         for ( uint i = 1; i <= 4; ++i )
@@ -1855,7 +1855,7 @@
         }
         if ( v2 )
         {
-          qword_A750D8 = 256i64;
+          _A750D8_player_speech_timer = 256i64;
           PlayerSpeechID = SPEECH_80;
           uSpeakingCharacter = v7[rand() % v2];
           return;
--- a/UI/UiGame.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/UI/UiGame.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -1701,14 +1701,14 @@
   int pTextureID; // eax@57
   Texture *pPortrait; // [sp-4h] [bp-1Ch]@27
 
-  if ( qword_A750D8 )
+  if ( _A750D8_player_speech_timer )
   {
-    qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
-    if ( qword_A750D8 <= 0 )
+    _A750D8_player_speech_timer -= (signed int)pMiscTimer->uTimeElapsed;
+    if ( _A750D8_player_speech_timer <= 0 )
     {
       if ( pPlayers[uSpeakingCharacter]->CanAct() )
         pPlayers[uSpeakingCharacter]->PlaySound(PlayerSpeechID, 0);
-      qword_A750D8 = 0i64;
+      _A750D8_player_speech_timer = 0i64;
     }
   }
 
--- a/_deleted.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/_deleted.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -14591,7 +14591,7 @@
 
   if ( pRenderer->pRenderD3D )
   {
-    result = _46A6AC_spell_render_d3d(a1, a2, a3);
+    result = _466_GetActorsInViewport(a3);
   }
   else
   {
--- a/mm7_3.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/mm7_3.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -2697,8 +2697,8 @@
   pRenderer->ClearZBuffer(0, 479);
   thisa = (ODMRenderParams *)1;
   GetAlertStatus();
-  if ( qword_A750D8 )
-    qword_A750D8 = 0;
+  if ( _A750D8_player_speech_timer )
+    _A750D8_player_speech_timer = 0;
   v2 = pMapStats->GetMapInfo(pCurrentMapName);
   v3 = 0;
   if ( v2 )
--- a/mm7_4.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/mm7_4.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -846,9 +846,9 @@
       pParty->pPlayers[i].SetCondition(1, 0);
   }
 
-  for (uint i = 0; i < 2; ++i)
+  for (uint i = 0; i < 2; ++i)//            
   {
-    SpellBuff* pBuf = &pParty->pPartyBuffs[dword_4EE07C[i]];
+    SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]];
     if (pBuf->uExpireTime == 0)
       continue;
 
@@ -857,7 +857,7 @@
       if (!pPlayers[pBuf->uCaster]->CanAct())
       {
         pBuf->Reset();
-        if (dword_4EE07C[i] == PARTY_BUFF_FLY )
+        if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY )
           pParty->bFlying = false;
       }
     }
--- a/mm7_data.cpp	Thu Jan 23 00:18:05 2014 +0600
+++ b/mm7_data.cpp	Thu Jan 23 17:31:12 2014 +0600
@@ -673,7 +673,7 @@
 }};
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX = {489, 559};
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY = {152, 152};
-std::array<int, 2> dword_4EE07C; // weak
+std::array<int, 2> Party_Spec_Motion_status_ids = {7, 18}; //dword_4EE07C
 std::array<__int16, 101> word_4EE088_sound_ids =
 {{
       0, 10000, 10010, 10020, 10030, 10040, 10050, 10060, 10070, 10080,
@@ -845,7 +845,7 @@
 stru367 PortalFace;
 std::array<int, 100> dword_50BC10; // weak
 std::array<int, 100> dword_50BDA0; // weak
-std::array<int, 100> dword_50BF30; // weak
+std::array<int, 100> _50BF30_actors_in_viewport_ids; // weak
 char town_portal_caster_id; // weak
 int some_active_character; // weak
 std::array<unsigned int, 5> pIconIDs_Turn;
@@ -1097,7 +1097,7 @@
 struct Texture *pTexture_PlayerFaceEradicated;
 struct Texture *pTexture_PlayerFaceDead;
 std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces;
-__int64 qword_A750D8; // weak
+__int64 _A750D8_player_speech_timer; // qword_A750D8
 enum PlayerSpeech PlayerSpeechID;
 int uSpeakingCharacter; // weak
 std::array<const char *, 36> pClassNames;
--- a/mm7_data.h	Thu Jan 23 00:18:05 2014 +0600
+++ b/mm7_data.h	Thu Jan 23 17:31:12 2014 +0600
@@ -362,7 +362,7 @@
 extern std::array< std::array<char, 37>, 36> byte_4ED970_skill_learn_ability_by_class_table;
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX;
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY;
-extern std::array<int, 2> dword_4EE07C; // weak
+extern std::array<int, 2> Party_Spec_Motion_status_ids; //dword_4EE07C
 extern std::array<__int16, 101> word_4EE088_sound_ids; // weak
 extern std::array<short, 28> word_4EE150;
 extern int ScreenshotFileNumber; // dword_4EFA80
@@ -469,7 +469,7 @@
 extern struct stru367 PortalFace;
 extern std::array<int, 100> dword_50BC10; // weak
 extern std::array<int, 100> dword_50BDA0; // weak
-extern std::array<int, 100> dword_50BF30; // weak
+extern std::array<int, 100> _50BF30_actors_in_viewport_ids; // weak
 extern char town_portal_caster_id; // weak
 extern int some_active_character; // weak
 extern std::array<unsigned int, 5> pIconIDs_Turn;
@@ -748,7 +748,7 @@
 extern struct Texture *pTexture_PlayerFaceEradicated;
 extern struct Texture *pTexture_PlayerFaceDead;
 extern std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces;
-extern __int64 qword_A750D8; // weak
+extern __int64 _A750D8_player_speech_timer; // qword_A750D8
 extern enum PlayerSpeech PlayerSpeechID;
 extern int uSpeakingCharacter; // weak
 extern std::array<const char *, 36> pClassNames;