changeset 1336:3358b59b8fe8

m
author Ritor1
date Thu, 04 Jul 2013 09:21:40 +0600
parents ee2672b14d75
children c6695ebd8fe6
files Actor.cpp mm7_4.cpp mm7_5.cpp
diffstat 3 files changed, 304 insertions(+), 379 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed Jul 03 09:37:49 2013 +0600
+++ b/Actor.cpp	Thu Jul 04 09:21:40 2013 +0600
@@ -1618,243 +1618,198 @@
 AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4)
 {
   signed int v4; // eax@1
-  unsigned int v5; // ecx@1
-  unsigned int v6; // ebx@1
+  signed int v5; // ecx@1
+  //unsigned int v6; // ebx@1
   int v7; // ecx@2
   int v8; // ecx@3
   int v9; // ecx@4
-  BLVFace *v10; // eax@8
-  unsigned int v11; // ecx@8
-  signed int v12; // eax@9
-  int v13; // ecx@9
-  int v14; // eax@9
+  //BLVFace *v10; // eax@8
+  //unsigned int v11; // ecx@8
+  //signed int v12; // eax@9
+  //int v13; // ecx@9
+  //int v14; // eax@9
   int v15; // eax@11
   int v16; // eax@12
   int v17; // eax@13
   int v18; // edx@15
-  signed int v19; // eax@25
-  signed int v20; // eax@28
-  int v21; // ebx@28
-  signed int v22; // eax@28
-  BLVFace *v23; // eax@35
-  int v24; // edx@35
-  unsigned int v25; // ecx@35
-  signed int v26; // eax@36
-  int v27; // ecx@36
-  int v28; // eax@36
-  int v29; // eax@37
-  signed int v30; // eax@42
+  //signed int v19; // eax@25
+  //signed int v20; // eax@28
+  //int v21; // ebx@28
+  //signed int v22; // eax@28
+  //BLVFace *v23; // eax@35
+  //int v24; // edx@35
+  //unsigned int v25; // ecx@35
+  //signed int v26; // eax@36
+  //int v27; // ecx@36
+  //int v28; // eax@36
+  //int v29; // eax@37
+  //signed int v30; // eax@42
   double v31; // st7@45
   double v32; // st6@45
   double v33; // st7@45
   AIDirection *result; // eax@48
-  int v35; // [sp-18h] [bp-64h]@17
-  int v36; // [sp-14h] [bp-60h]@17
+  //int v35; // [sp-18h] [bp-64h]@17
+  //int v36; // [sp-14h] [bp-60h]@17
   Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15
-  int *v38; // [sp-4h] [bp-50h]@15
-  int *v39; // [sp+0h] [bp-4Ch]@15
-  int *v40; // [sp+4h] [bp-48h]@15
+  //int *v38; // [sp-4h] [bp-50h]@15
+  //int *v39; // [sp+0h] [bp-4Ch]@15
+  //int *v40; // [sp+4h] [bp-48h]@15
   AIDirection v41; // [sp+14h] [bp-38h]@46
   float v42; // [sp+30h] [bp-1Ch]@23
   float v43; // [sp+34h] [bp-18h]@45
-  float v44; // [sp+38h] [bp-14h]@33
-  float v45; // [sp+3Ch] [bp-10h]@33
+  float outy2; // [sp+38h] [bp-14h]@33
+  float outx2; // [sp+3Ch] [bp-10h]@33
   int outz; // [sp+40h] [bp-Ch]@6
   int outy; // [sp+44h] [bp-8h]@6
   int outx; // [sp+48h] [bp-4h]@6
   float a4a; // [sp+58h] [bp+Ch]@45
 
   v4 = PID_ID(uObj1ID);
-  v5 = PID_TYPE(uObj1ID);
-  v6 = uObj2ID;
-  switch(v5)
+  //v6 = uObj2ID;
+  v5 = PID_ID(uObj2ID);
+  switch( PID_TYPE(uObj1ID) )
   {
-	case OBJECT_Item:
-		{
-		v19 = v4;
-		outx = pSpriteObjects[v19].vPosition.x;
-		v13 = pSpriteObjects[v19].vPosition.y;
-		v14 = pSpriteObjects[v19].vPosition.z;
-		outy = v13;
-		outz = v14;
-		break;
-	    }
-	case OBJECT_Actor:
-		{
-		outx = pActors[v4].vPosition.x;
-		outy = pActors[v4].vPosition.y;
-		LODWORD(v42) = pActors[v4].uActorHeight;
-		v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75);
-		outz = v11;
-		break;
-		}
-	case OBJECT_Player:
-		{
-		if ( !v4 )
-		{
-			outx = pParty->vPosition.x;
-			outy = pParty->vPosition.y;
-			v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			outz = v14;
-			break;;
-		}
-		if ( v4 == 4 )
-		{
-			v40 = &outz;
-			v39 = &outy;
-			v38 = &outx;
-			v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-			v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			*(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
-			v36 = 0;
-			v35 = 24;
-			Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40);
-			break;
-		}
-		if ( v4 == 3 )
-		{
-			v40 = &outz;
-			v39 = &outy;
-			v38 = &outx;
-			v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-			v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			*(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
-			v36 = 0;
-			v35 = 8;
-			Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40);
-			break;
-		}
-		if ( v4 == 2 )
-		{
-			v40 = &outz;
-			v39 = &outy;
-			v38 = &outx;
-			v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
-			*(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
-			v36 = 0;
-			v35 = 8;
-			Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40);
-			break;
-		}
-		if ( v4 == 1 )
-		{
-			v40 = &outz;
-			v39 = &outy;
-			v38 = &outx;
-			v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
-			*(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
-			v36 = 0;
-			v35 = 24;
-			Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40);
-			break;
-		}
-		}
-	case OBJECT_Decoration:
-		{
-		v12 = v4;
-		outx = pLevelDecorations[v12].vPosition.x;
-		v13 = pLevelDecorations[v12].vPosition.y;
-		v14 = pLevelDecorations[v12].vPosition.z;
-		outy = v13;
-		outz = v14;
-		break;
-		}
-	default:
-		{
-		outz = 0;
-		outy = 0;
-		outx = 0;
-		break;
-		}
-	case OBJECT_BModel:
-		{
-		if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-		{
-			v10 = &pIndoor->pFaces[v4];
-			outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1;
-			outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1;
-			v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1;
-			outz = v11;
-		}
-		break;
-		}
+    case OBJECT_Item:
+    {
+      outx = pSpriteObjects[v4].vPosition.x;
+      outy = pSpriteObjects[v4].vPosition.y;
+      outz = pSpriteObjects[v4].vPosition.z;
+      break;
+    }
+    case OBJECT_Actor:
+    {
+      outx = pActors[v4].vPosition.x;
+      outy = pActors[v4].vPosition.y;
+      outz = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v4].uActorHeight * -0.75);
+      break;
+    }
+    case OBJECT_Player:
+    {
+      if ( !v4 )
+      {
+        outx = pParty->vPosition.x;
+        outy = pParty->vPosition.y;
+        outz = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        break;
+      }
+      if ( v4 == 4 )
+      {
+        v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
+        Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
+        break;
+      }
+      if ( v4 == 3 )
+      {
+        v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
+        Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
+        break;
+      }
+      if ( v4 == 2 )
+      {
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
+        *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
+        Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
+        break;
+      }
+      if ( v4 == 1 )
+      {
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
+        *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
+        Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
+        break;
+      }
+    }
+    case OBJECT_Decoration:
+    {
+      outx = pLevelDecorations[v4].vPosition.x;
+      outy = pLevelDecorations[v4].vPosition.y;
+      outz = pLevelDecorations[v4].vPosition.z;
+      break;
+    }
+    default:
+    {
+      outz = 0;
+      outy = 0;
+      outx = 0;
+      break;
+    }
+    case OBJECT_BModel:
+    {
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      {
+        outx = (pIndoor->pFaces[v4].pBounding.x1 + pIndoor->pFaces[v4].pBounding.x2) >> 1;
+        outy = (pIndoor->pFaces[v4].pBounding.y1 + pIndoor->pFaces[v4].pBounding.y2) >> 1;
+        outz = (pIndoor->pFaces[v4].pBounding.z1 + pIndoor->pFaces[v4].pBounding.z2) >> 1;
+      }
+      break;
+    }
   }
-  v20 = v6;
-  v21 = PID_TYPE(v6);
-  v22 = PID_ID(v20);
-  switch(v21)
+
+  switch( PID_TYPE(uObj2ID) )
   {
-	case OBJECT_Item:
-		{
-		v30 = v22;
-		LODWORD(v45) = pSpriteObjects[v30].vPosition.x;
-		v27 = pSpriteObjects[v30].vPosition.y;
-		v28 = pSpriteObjects[v30].vPosition.z;
-		LODWORD(v44) = v27;
-		a4 = v28;
-		break;
-	    }
-	case OBJECT_Actor:
-		{
-		LODWORD(v45) = pActors[v22].vPosition.x;
-		LODWORD(v44) = pActors[v22].vPosition.y;
-		v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75);
-		a4 = v25;
-		break;
-		}
-	case OBJECT_Player:
-		{
-		LODWORD(v45) = pParty->vPosition.x;
-		LODWORD(v44) = pParty->vPosition.y;
-		v29 = a4;
-		if ( !a4 )
-		  v29 = pParty->sEyelevel;
-		v28 = pParty->vPosition.z + v29;
-		a4 = v28;
-		break;
-		}
-	case OBJECT_Decoration:
-		{
-	    v26 = v22;
-		LODWORD(v45) = pLevelDecorations[v26].vPosition.x;
-		v27 = pLevelDecorations[v26].vPosition.y;
-		v28 = pLevelDecorations[v26].vPosition.z;
-		LODWORD(v44) = v27;
-		a4 = v28;
-		break;
-		}
-	default:
-		{
-		a4 = 0;
-		v44 = 0.0;
-		v45 = 0.0;
-		break;
-		}
-	case OBJECT_BModel:
-		{
-		if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-		{
-			v23 = &pIndoor->pFaces[v22];
-			v24 = v23->pBounding.y1;
-			LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1;
-			LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1;
-			v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1;
-			a4 = v25;
-		}
-		break;
-		}
+    case OBJECT_Item:
+    {
+      outx2 = pSpriteObjects[v5].vPosition.x;
+      outy2 = pSpriteObjects[v5].vPosition.y;
+      a4 = pSpriteObjects[v5].vPosition.z;
+      break;
+    }
+    case OBJECT_Actor:
+    {
+      outx2 = pActors[v5].vPosition.x;
+      outy2 = pActors[v5].vPosition.y;
+      a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75);
+      break;
+    }
+    case OBJECT_Player:
+    {
+      outx2 = pParty->vPosition.x;
+      outy2 = pParty->vPosition.y;
+      if ( !a4 )
+        a4 = pParty->sEyelevel;
+      a4 = pParty->vPosition.z + a4;
+      break;
+    }
+    case OBJECT_Decoration:
+    {
+      outx2 = pLevelDecorations[v5].vPosition.x;
+      outy2 = pLevelDecorations[v5].vPosition.y;
+      a4 = pLevelDecorations[v5].vPosition.z;
+      break;
+    }
+    default:
+    {
+      outx2 = 0.0;
+      outy2 = 0.0;
+      a4 = 0;
+      break;
+    }
+    case OBJECT_BModel:
+    {
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      {
+        outx2 = (pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1;
+        outy2 = (pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1;
+        a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1;
+      }
+      break;
+    }
   }
   
-  v31 = (double)SLODWORD(v45) - (double)outx;
+  v31 = (double)outx2 - (double)outx;
   v42 = v31;
-  v32 = (double)SLODWORD(v44) - (double)outy;
+  v32 = (double)outy2 - (double)outy;
   v43 = v32;
   a4a = (double)a4 - (double)outz;
-  v45 = v32 * v32;
-  v44 = v31 * v31;
-  v33 = sqrt(a4a * a4a + v44 + v45);
+  outx2 = v32 * v32;
+  outy2 = v31 * v31;
+  v33 = sqrt(a4a * a4a + outy2 + outx2);
   if ( v33 <= 1.0 )
   {
     v41.vDirection.x = 65536;
@@ -1871,12 +1826,12 @@
     v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0);
     v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0);
     v41.uDistance = (signed __int64)v33;
-    v41.uDistanceXZ = (signed __int64)sqrt(v44 + v45);
+    v41.uDistanceXZ = (signed __int64)sqrt(outy2 + outx2);
     v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43);
     v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
   }
   result = pOut;
-  memcpy(pOut, &v41, 0x1Cu);
+  memcpy(pOut, &v41, sizeof(AIDirection));
   return result;
 }
 
--- a/mm7_4.cpp	Wed Jul 03 09:37:49 2013 +0600
+++ b/mm7_4.cpp	Thu Jul 04 09:21:40 2013 +0600
@@ -6365,161 +6365,153 @@
 //----- (00405E14) --------------------------------------------------------
 void stru262_TurnBased::_405E14()
 {
-  stru262_TurnBased *v1; // esi@1
-  int v2; // ecx@1
-  SpellBuff *v3; // edi@2
-  Actor *v4; // ebx@3
-  signed int v5; // edx@20
+  //stru262_TurnBased *v1; // esi@1
+  //int v2; // ecx@1
+  //SpellBuff *v3; // edi@2
+  //Actor *v4; // ebx@3
+  //signed int v5; // edx@20
   AIDirection *v6; // esi@21
-  int v7; // eax@21
-  int v8; // eax@21
+  //int v7; // eax@21
+  //int v8; // eax@21
   int v9; // eax@22
   int v10; // eax@23
-  int v11; // eax@37
-  int v12; // eax@44
+  //int v11; // eax@37
+  //int v12; // eax@44
   AIDirection a3; // [sp+4h] [bp-68h]@21
   AIDirection v14; // [sp+20h] [bp-4Ch]@21
   AIDirection v15; // [sp+3Ch] [bp-30h]@21
-  Actor *v16; // [sp+58h] [bp-14h]@2
+  //Actor *v16; // [sp+58h] [bp-14h]@2
   int v17; // [sp+5Ch] [bp-10h]@6
-  stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1
+  //stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1
   int v19; // [sp+64h] [bp-8h]@8
   unsigned int v20; // [sp+68h] [bp-4h]@1
 
-  v1 = this;
-  v2 = 0;
-  v18 = v1;
-  v20 = 0;
+  //v1 = this;
+  //v2 = 0;
+  //v18 = this;
+  
   if ( (signed int)uNumActors > 0 )
   {
     //v3 = pActors;//[0].pActorBuffs;
-    v16 = pActors.data();//[0].pActorBuffs;
-	v3 = v16->pActorBuffs;
-    do
+    //v16 = pActors.data();//[0].pActorBuffs;
+    //v3 = v16->pActorBuffs;
+
+    for ( v20 = 0; v20 < uNumActors; ++v20 )
     {
-      v4 = v16;
-	  if ( SHIDWORD(v3[3].uExpireTime) < v2 || SHIDWORD(v3[3].uExpireTime) <= v2 && LODWORD(v3[3].uExpireTime) <= v2 )
-        v17 = v2;
+      if ( pActors[v20].pActorBuffs[3].uExpireTime <= 0 )
+        v17 = 0;
       else
         v17 = 1;
-      v19 = v2;
-      do
+      
+      for ( v19 = 0; v19 < 22; ++v19 )
       {
         if ( v19 != 10 )
-        {
-          v3->_4585CA(pParty->uTimePlayed);
-          v2 = 0;
-        }
-        ++v19;
-        ++v3;
+          pActors[v20].pActorBuffs[v19]._4585CA(pParty->uTimePlayed);
       }
-      while ( v19 < 22 );
-      if ( v17 != v2
-        && SHIDWORD(v4->pActorBuffs[3].uExpireTime) <= v2
-        && (SHIDWORD(v4->pActorBuffs[3].uExpireTime) < v2 || LODWORD(v4->pActorBuffs[3].uExpireTime) <= v2) )
-        v4->uActorHeight = pMonsterList->pMonsters[v4->pMonsterInfo.uID - 1].uMonsterHeight;
-      if ( !(v4->uAttributes & 0x80) )
+      if ( v17 && pActors[v20].pActorBuffs[3].uExpireTime <= 0 )
+        pActors[v20].uActorHeight = pMonsterList->pMonsters[pActors[v20].pMonsterInfo.uID - 1].uMonsterHeight;
+      if ( !(pActors[v20].uAttributes & 0x80) )
       {
-        if ( !v4->pActorBuffs[5].uExpireTime )
+        if ( !pActors[v20].pActorBuffs[5].uExpireTime )
         {
-          if ( !v4->pActorBuffs[6].uExpireTime )
+          if ( !pActors[v20].pActorBuffs[6].uExpireTime )
           {
-            v5 = v4->uCurrentActionLength;
-            v4->uCurrentActionTime += pMiscTimer->uTimeElapsed;
-            if ( (signed int)v4->uCurrentActionTime >= v5 )
+            //v5 = v16->uCurrentActionLength;
+            pActors[v20].uCurrentActionTime += pMiscTimer->uTimeElapsed;
+            if ( (signed int)pActors[v20].uCurrentActionTime >= pActors[v20].uCurrentActionLength )
             {
               v17 = ai_near_actors_targets_pid[v20];
-              v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, v2);
-              v7 = v4->uAIState;
-              memcpy(&v15, v6, sizeof(v15));
-              v8 = v7 - 4;
-              memcpy(&v14, &v15, sizeof(v14));
-              if ( v8 )
+              v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, 0);
+              //v7 = v16->uAIState;
+              memcpy(&v15, v6, sizeof(AIDirection));
+              //v8 = pActors[v20].uAIState - 4;
+              memcpy(&v14, &v15, sizeof(AIDirection));
+              if ( pActors[v20].uAIState > Dying )
               {
-                v9 = v8 - 1;
-                if ( v9 )
-                {
-                  v10 = v9 - 6;
-                  if ( v10 )
-                  {
-                    if ( v10 != 8 )
+                //v9 = v8 - 1;
+                //if ( v9 )
+                //{
+                  //v10 = v9 - 6;
+                  //if ( v10 )
+                  //{
+                    if ( pActors[v20].uAIState != Disabled )
                       Actor::AI_StandOrBored(v20, v17, 32, &v14);
-                  }
-                }
+                  //}
+                //}
               }
               else
               {
-                v4->uCurrentActionTime = 0;
-                v4->uCurrentActionLength = 0;
-                v4->uAIState = Dead;
-                v4->UpdateAnimation();
+                pActors[v20].uCurrentActionTime = 0;
+                pActors[v20].uCurrentActionLength = 0;
+                pActors[v20].uAIState = Dead;
+                pActors[v20].UpdateAnimation();
               }
-              v1 = v18;
-              v2 = 0;
+              //this = v18;
+              //v2 = 0;
             }
           }
         }
       }
-      ++v20;
-	  v3 = v16[1].pActorBuffs;
-      ++v16;
+      //++v20;
+	  //v3 = v16[1].pActorBuffs;
+      //++v16;
     }
-    while ( (signed int)v20 < (signed int)uNumActors );
+    //while ( (signed int)v20 < (signed int)uNumActors );
   }
-  if ( v1->field_4 == 1 )
+  if ( this->field_4 == 1 )
   {
-    v12 = v1->field_8;
-    if ( v12 == 64 )
+    //v12 = this->field_8;
+    if ( this->field_8 == 64 )
     {
-      v1->_406A63();
+      this->_406A63();
     }
     else
     {
-      if ( v12 > v2 )
+      if ( this->field_8 > 0 )
       {
-        v1->_406B9F();
+        this->_406B9F();
       }
       else
       {
-        v1->_406AFE();
-        v1->field_10 = 100;
+        this->_406AFE();
+        this->field_10 = 100;
       }
     }
-    v1->field_8 -= pEventTimer->uTimeElapsed;
+    this->field_8 -= pEventTimer->uTimeElapsed;
     return;
   }
-  if ( v1->field_4 == 2 )
+  if ( this->field_4 == 2 )
   {
-    if ( !(v1->field_18 & 1) )
+    if ( !(this->field_18 & 1) )
     {
-      v11 = v1->field_10;
-      if ( v11 == 100 )
+      //v11 = this->field_10;
+      if ( this->field_10 == 100 )
       {
-        v1->StartTurn();
-LABEL_39:
-        v1->_40652A();
+        this->StartTurn();
+        this->_40652A();
         return;
       }
-      if ( v11 > v2 || v1->pQueue[0].field_4 <= v2 )
+      if ( this->field_10 > 0 || this->pQueue[0].field_4 <= 0 )
       {
-        v1->_4065B0();
-        goto LABEL_39;
+        this->_4065B0();
+        this->_40652A();
+        return;
       }
     }
-    v1->NextTurn();
+    this->NextTurn();
     return;
   }
-  if ( v1->field_4 == 3 )
+  if ( this->field_4 == 3 )
   {
-    if ( v1->uActionPointsLeft <= v2 || v1->field_18 & 8 )
+    if ( this->uActionPointsLeft <= 0 || this->field_18 & 8 )
     {
-      v1->field_18 &= 0xFFFFFFF7u;
-      v1->field_4 = 1;
-      v1->field_8 = 64;
+      this->field_18 &= 0xFFFFFFF7u;
+      this->field_4 = 1;
+      this->field_8 = 64;
     }
     else
     {
-      v1->_406FA8();
+      this->_406FA8();
     }
   }
 }
\ No newline at end of file
--- a/mm7_5.cpp	Wed Jul 03 09:37:49 2013 +0600
+++ b/mm7_5.cpp	Thu Jul 04 09:21:40 2013 +0600
@@ -5583,44 +5583,43 @@
 //----- (00406A63) --------------------------------------------------------
 void stru262_TurnBased::_406A63()
 {
-  stru262_TurnBased *v1; // ebx@1
-  int v2; // esi@1
-  unsigned __int8 v3; // zf@1
-  unsigned __int8 v4; // sf@1
-  signed int v5; // ecx@4
+  //stru262_TurnBased *v1; // ebx@1
+  //int v2; // esi@1
+  //unsigned __int8 v3; // zf@1
+  //unsigned __int8 v4; // sf@1
+  //signed int v5; // ecx@4
   AIDirection a3; // [sp+8h] [bp-44h]@5
   AIDirection v7; // [sp+24h] [bp-28h]@5
   unsigned int v8; // [sp+40h] [bp-Ch]@5
   signed int a2; // [sp+44h] [bp-8h]@1
-  TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
-
-  v1 = this;
-  v2 = 0;
+  //TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2
+
+  //v1 = this;
+  //v2 = 0;
   this->field_8 = 64;
   dword_50C994 = 0;
   uActiveCharacter = 0;
-  v3 = this->uActorQueueSize == 0;
-  v4 = this->uActorQueueSize < 0;
-  a2 = 0;
-  if ( !(v4 | v3) )
+  //v3 = this->uActorQueueSize == 0;
+  //v4 = this->uActorQueueSize < 0;
+
+  if ( this->uActorQueueSize )
   {
-    v10 = this->pQueue;
-    while ( 1 )
+    //v10 = this->pQueue;
+
+    for ( a2 = 0; a2 < this->uActorQueueSize; ++a2 )
     {
-      v5 = v10->uPackedID;
-      if (PID_TYPE(v10->uPackedID) == OBJECT_Actor)
+      //v5 = this->pQueue[a2].uPackedID;
+      if (PID_TYPE(this->pQueue[a2].uPackedID) == OBJECT_Actor)
       {
-        v8 = ai_near_actors_targets_pid[PID_ID(v5)];
-        memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
-        if ( !v1->_406D10(a2) )
-          Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 0x20u, &v7);
+        v8 = ai_near_actors_targets_pid[PID_ID(this->pQueue[a2].uPackedID)];
+        memcpy(&v7, Actor::GetDirectionInfo(this->pQueue[a2].uPackedID, v8, &a3, 0), sizeof(v7));
+        if ( !this->_406D10(a2) )
+          Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v8, 0x20u, &v7);//actors move
       }
-      ++a2;
-      ++v10;
-      if ( a2 >= v1->uActorQueueSize )
-        break;
-      v2 = 0;
+      //++v10;
+      //v2 = 0;
     }
+
   }
 }
 // 50C994: using guessed type int dword_50C994;
@@ -5675,79 +5674,58 @@
 int stru262_TurnBased::_406B9F()
 {
   signed int result; // eax@1
-  unsigned __int8 v2; // zf@1
-  unsigned __int8 v3; // sf@1
-  int v4; // esi@4
-  unsigned int v5; // esi@5
-  Actor *v6; // ebx@5
-  unsigned __int16 v7; // cx@15
+  Actor *pCurrentActor; // ebx@5
   AIDirection a3; // [sp+0h] [bp-50h]@15
   AIDirection v9; // [sp+1Ch] [bp-34h]@15
-  signed int a1; // [sp+38h] [bp-18h]@4
-  stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1
   unsigned int v12; // [sp+40h] [bp-10h]@5
   unsigned int v13; // [sp+44h] [bp-Ch]@8
-  TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2
   signed int a2; // [sp+4Ch] [bp-4h]@1
 
   result = 0;
-  thisa = this;
-  v2 = this->uActorQueueSize == 0;
-  v3 = this->uActorQueueSize < 0;
-  a2 = 0;
-  if ( !(v3 | v2) )
+  if ( this->uActorQueueSize )
   {
-    v14 = this->pQueue;
-    while ( 1 )
+
+    for ( a2 = 0; a2 < this->uActorQueueSize; ++a2 )
     {
-      v4 = v14->uPackedID;
-      a1 = v14->uPackedID;
-      if (PID_TYPE(a1) != OBJECT_Player)
+      if (PID_TYPE(this->pQueue[a2].uPackedID) != OBJECT_Player)
       {
-        v5 = PID_ID(v4);
-        v12 = v5;
-        v6 = &pActors[v5];
-        if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result
-          || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result )
-          v13 = result;
+        pCurrentActor = &pActors[PID_ID(this->pQueue[a2].uPackedID)];
+        if ( pCurrentActor->pActorBuffs[5].uExpireTime <= 0 )
+          v13 = 0;
         else
           v13 = 1;
-        if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
-          && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
-          result = 1;
-        if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) )
+        if ( pCurrentActor->pActorBuffs[6].uExpireTime >= 0 )
+          v12 = 1;
+        if ( !(v13 != 0 || v12 || pCurrentActor->uAIState == Dead || pCurrentActor->uAIState == Removed || pCurrentActor->uAIState == Disabled) )
         {
-          v13 = ai_near_actors_targets_pid[v5];
-          memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
-          v7 = v6->uAIState;
-          if ( v7 == 6 || v7 == 1 )
+          v13 = ai_near_actors_targets_pid[PID_ID(this->pQueue[a2].uPackedID)];
+          memcpy(&v9, Actor::GetDirectionInfo(this->pQueue[a2].uPackedID, v13, &a3, 0), sizeof(v9));
+          if ( pCurrentActor->uAIState == Pursuing || pCurrentActor->uAIState == Tethered )
           {
             if ( (double)(signed int)v9.uDistance < 307.2 )
-              goto LABEL_26;
-          }
-          v6->uCurrentActionTime += pEventTimer->uTimeElapsed;
-          if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength )
-          {
-            if ( v7 == 4 )
             {
-              v6->uCurrentActionTime = 0;
-              v6->uCurrentActionLength = 0;
-              v6->uAIState = Dead;
-              v6->UpdateAnimation();
+              Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v13, 0x20u, &v9);
+              continue;
             }
-            if ( !thisa->_406D10(a2) )
-LABEL_26:
-              Actor::AI_Stand(v12, v13, 0x20u, &v9);
+          }
+          pCurrentActor->uCurrentActionTime += pEventTimer->uTimeElapsed;
+          if ( (signed int)pCurrentActor->uCurrentActionTime > pCurrentActor->uCurrentActionLength )
+          {
+            if ( pCurrentActor->uAIState == Dying )
+            {
+              pCurrentActor->uCurrentActionTime = 0;
+              pCurrentActor->uCurrentActionLength = 0;
+              pCurrentActor->uAIState = Dead;
+              pCurrentActor->UpdateAnimation();
+            }
+            if ( !this->_406D10(a2) )
+              Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v13, 0x20u, &v9);
           }
         }
       }
-      ++a2;
-      result = (signed int)thisa;
-      ++v14;
-      if ( a2 >= thisa->uActorQueueSize )
-        break;
       result = 0;
     }
+
   }
   return result;
 }
@@ -5785,7 +5763,7 @@
   unsigned int uActorID; // [sp+50h] [bp-4h]@2
   unsigned int a2a; // [sp+5Ch] [bp+8h]@7
 
-  __debugbreak();//срабатывает при пошаговом режиме после пяти шагов
+  //__debugbreak();//срабатывает при пошаговом режиме после пяти шагов
   v2 = *(&this->field_0 + 4 * (a2 + 2));
   if (PID_TYPE(v2) == OBJECT_Player)
     return 0;