changeset 1134:22a42961d349

Слияние
author Ritor1
date Fri, 24 May 2013 23:34:00 +0600
parents 5c6db175877e (current diff) 6cbf4eb0f953 (diff)
children 6b34a45a3983
files
diffstat 16 files changed, 723 insertions(+), 703 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Actor.cpp	Fri May 24 23:34:00 2013 +0600
@@ -293,7 +293,7 @@
 }
 
 //----- (00404AC7) --------------------------------------------------------
-void __fastcall Actor::SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel)
+void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel)
 {
   Actor *v5; // esi@1
   unsigned int v6; // edi@1
@@ -1398,7 +1398,7 @@
 }
 
 //----- (00404874) --------------------------------------------------------
-char __fastcall Actor::RangedAttack(unsigned int uActorID, AIDirection *a2, int a3, char a4)
+char __fastcall Actor::AI_RangedAttack(unsigned int uActorID, AIDirection *a2, int a3, char a4)
 {
   AIDirection *v4; // edi@1
   Actor *v5; // esi@1
@@ -1890,7 +1890,7 @@
 }
 
 //----- (00404030) --------------------------------------------------------
-void Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4)
+void Actor::AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4)
 {
   unsigned int v4; // edi@1
   unsigned int v5; // esi@1
@@ -1981,7 +1981,7 @@
 }
 
 //----- (00403C6C) --------------------------------------------------------
-void Actor::MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
+void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
 {
   Actor *v3; // ebx@1
   char v4; // zf@1
@@ -2077,7 +2077,7 @@
     v3->UpdateAnimation();
   }
   else
-	Actor::Pursue1(v24, sTargetPid, rand() % 2, 64, arg0);
+	Actor::AI_Pursue1(v24, sTargetPid, rand() % 2, 64, arg0);
 }
 
 //----- (00438CF3) --------------------------------------------------------
@@ -2383,7 +2383,7 @@
 }
 
 //----- (00403A60) --------------------------------------------------------
-void Actor::SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::AI_SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2485,11 +2485,11 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::Pursue1(v22, a2, v22, 64, pDir);
+    Actor::AI_Pursue1(v22, a2, v22, 64, pDir);
 }
 
 //----- (00403854) --------------------------------------------------------
-void Actor::SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
+void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2591,11 +2591,11 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::Pursue1(v22, sTargetPid, v22, 64, pDir);
+    Actor::AI_Pursue1(v22, sTargetPid, v22, 64, pDir);
 }
 
 //----- (0040368B) --------------------------------------------------------
-void Actor::MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
+void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2682,11 +2682,11 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::Pursue1(v21, sTargetPid, v21, 64, pDir);
+    Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (00403476) --------------------------------------------------------
-void Actor::MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
+void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   int v4; // esi@3
@@ -2786,11 +2786,11 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::Pursue1(v21, sTargetPid, v21, 64, pDir);
+    Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (004032B2) --------------------------------------------------------
-void Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
+void Actor::AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
 {
   unsigned int v4; // edi@1
   Actor *v5; // esi@1
@@ -2926,7 +2926,7 @@
 }
 
 //----- (004030AD) --------------------------------------------------------
-void Actor::Stun(unsigned int uActorID, signed int edx0, int arg0)
+void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int arg0)
 {
   unsigned int v3; // edi@1
   Actor *v4; // ebx@1
@@ -2980,7 +2980,7 @@
 {
   unsigned int v7; // eax@3
   unsigned int v9; // eax@3
-
+  
   assert(uActorID < uNumActors);
   auto actor = pActors + uActorID;
   
@@ -3148,7 +3148,7 @@
 }
 
 //----- (00402AD7) --------------------------------------------------------
-void Actor::Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
+void Actor::AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
 {
   unsigned int v5; // edi@1
   int v6; // eax@1
@@ -3221,7 +3221,7 @@
 }
 
 //----- (00402968) --------------------------------------------------------
-void Actor::Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4)
+void Actor::AI_Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4)
 {
   unsigned int v4; // esi@1
   Actor *v5; // ebx@1
@@ -3282,7 +3282,7 @@
 }
 
 //----- (0040281C) --------------------------------------------------------
-void Actor::Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
+void Actor::AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
 {
   unsigned int v5; // edi@1
   int v6; // eax@1
@@ -3365,7 +3365,7 @@
 }
 
 //----- (00402686) --------------------------------------------------------
-void Actor::Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
+void Actor::AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
 {
   //unsigned int v4; // edi@1
   int v5; // eax@1
--- a/Actor.h	Fri May 24 23:33:50 2013 +0600
+++ b/Actor.h	Fri May 24 23:34:00 2013 +0600
@@ -191,30 +191,30 @@
 
   
   static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party);
-  static void Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4);
-  static void Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5);
-  static void Flee(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4);
-  static void Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir);
+  static void AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4);
+  static void AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5);
+  static void AI_Flee(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4);
+  static void AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir);
   static void PlaySound(unsigned int uActorID, unsigned int uSoundID);
   static void Die(unsigned int uActorID);
   static void Resurrect(unsigned int uActorID);
   static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4);
-  static void Stun(unsigned int uActorID, signed int edx0, int arg0);
+  static void AI_Stun(unsigned int uActorID, signed int edx0, int arg0);
   static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3);
-  static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength);
-  static void MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
-  static void MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
-  static void SpellAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
-  static void SpellAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
-  static void MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0);
+  static void AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength);
+  static void AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void AI_SpellAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
+  static void AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0);
   static void __fastcall StandAwhile(unsigned int uActorID);
   static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4);
   static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4);
-  static void FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4);
+  static void AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4);
   static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4);
   static signed int __fastcall Explode(unsigned int uActorID);
-  static char __fastcall RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4);
-  static void __fastcall SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel);
+  static char __fastcall AI_RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4);
+  static void __fastcall AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel);
   static void AggroSurroundingPeasants(unsigned int uActorID, int a2);
   static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2);
   static bool StealFrom(unsigned int uActorID);
--- a/Game.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Game.cpp	Fri May 24 23:34:00 2013 +0600
@@ -265,7 +265,7 @@
   //Render *v2; // edi@7
   //signed int v3; // esi@7
   signed int pNewNPCsCount; // ecx@58
-  char *pFlags; // eax@59
+  NPCData *pNPC; // eax@59
   Player *pPlayer; // esi@65
   //OtherOverlay *pOtherOverlay; // esi@67
   //signed int v8; // edi@67
@@ -442,13 +442,13 @@
       pNewNPCsCount = 0;
       if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
       {
-        pFlags = (char *)&pNPCStats->pNewNPCData[0].uFlags;
+        pNPC = pNPCStats->pNewNPCData;
         do
         {
-          if ( *((int *)pFlags + 6) )
-            *pFlags &= 0x7Fu;
+		  if ( pNPC->field_24 )
+			  pNPC->uFlags &= 0xFFFFFF7Fu;
           ++pNewNPCsCount;
-          pFlags += 76;
+          ++pNPC;
         }
         while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs );
       }
--- a/Indoor.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Indoor.cpp	Fri May 24 23:34:00 2013 +0600
@@ -1734,15 +1734,12 @@
 //----- (004488F7) --------------------------------------------------------
 void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle)
 {
-  char *v2; // eax@4
-
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) )
   {
-    v2 = (char *)&pIndoor->pLights[sLightID].uAtributes;
     if ( bToggle )
-      *v2 &= 0xF7u;
+      pIndoor->pLights[sLightID].uAtributes &= 0xFFFFFFF7u;
     else
-      *v2 |= 8u;
+      pIndoor->pLights[sLightID].uAtributes |= 8u;
     pParty->uFlags |= 2u;
   }
 }
@@ -4208,7 +4205,7 @@
               }
               v36 = stru_721530.uFaceID;
 LABEL_118:
-              Actor::FaceObject(v63, v36, v22, (AIDirection *)v22);
+              Actor::AI_FaceObject(v63, v36, v22, (AIDirection *)v22);
               goto LABEL_119;
             }
             if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 3) )
@@ -4225,7 +4222,7 @@
                 if ( !pActors[v37].pMonsterInfo.uHostilityType )
                   goto LABEL_118;
 LABEL_114:
-                Actor::Flee(v63, v36, v22, (AIDirection *)v22);
+                Actor::AI_Flee(v63, v36, v22, (AIDirection *)v22);
                 goto LABEL_119;
               }
             }
--- a/Mouse.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Mouse.cpp	Fri May 24 23:34:00 2013 +0600
@@ -94,46 +94,13 @@
   {
     v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow");
     SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3);
-    /*if (pAsyncMouse)
-    {
-      v10 = 0.0;
-      v5 = 0.0;
-//LABEL_12:
-      v6 = v5;
-
-		GetCursorPos(&Point);
-		SetCursorPos(Point.x, Point.y);
-
-	  return;
-    }*/
-    GetCursorPos(&Point);
-	ClientToScreen(hWnd,&Point);
-    SetCursorPos(Point.x, Point.y);
-    return;
   }
-  if ( !strcmp(pName, "MICON2") )
+  else if ( !strcmp(pName, "MICON2") )
   {
     v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target");
     SetClassLongA(hWnd, -12, v7);
-    /*if (pAsyncMouse)
-    {
-      v10 = 14.0;
-      v5 = 14.0;
-      v6 = v5;
-      pAsyncMouse->SetHotspot(v6, v10);
-	  if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) )
-	  {
-		GetCursorPos(&Point);
-		SetCursorPos(Point.x, Point.y);
-	  }
-	  return;
-    }*/
-//LABEL_20:
-    GetCursorPos(&Point);
-    SetCursorPos(Point.x, Point.y);
-    return;
   }
-  if ( !strcmp(pName, "MICON3") )
+  else if ( !strcmp(pName, "MICON3") )
   {
     v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT);
     SetClassLongA(hWnd, -12, v8);
@@ -141,6 +108,7 @@
 //LABEL_18:
 
     GetCursorPos(&Point);
+	ClientToScreen(hWnd,&Point);
     SetCursorPos(Point.x, Point.y);
 }
 // 506128: using guessed type int areWeLoadingTexture;
--- a/Outdoor.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Outdoor.cpp	Fri May 24 23:34:00 2013 +0600
@@ -2249,7 +2249,7 @@
         if (face.HasEventHint())
           face.uAttributes |= 0x1000u;
         else
-          face.uAttributes &= 0xEFFFu;
+          face.uAttributes &= 0xFFFFEFFFu;
       }
           //++thisa;
           //v89 = pBModels;
--- a/Party.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Party.cpp	Fri May 24 23:34:00 2013 +0600
@@ -854,7 +854,7 @@
 		  v2 = abs(v0->vPosition.y - pParty->vPosition.y);
 		  v3 = abs(v0->vPosition.z - pParty->vPosition.z);
           if (int_get_vector_length(v1, v2, v3) < 512)
-            Actor::Flee(v4, 4, 0, 0);
+            Actor::AI_Flee(v4, 4, 0, 0);
         }
         ++v4;
         ++v0;
--- a/Player.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/Player.cpp	Fri May 24 23:34:00 2013 +0600
@@ -5221,8 +5221,8 @@
           if ((v28 < 0) || v28 > 2 )
               return v5 + v62 + v61;
         }
-      v15 = pItemsTable->pItems[v29].uDamageMod;
-      v14 = pItemsTable->pItems[v29].uDamageDice * pItemsTable->pItems[v29].uDamageRoll;
+      v15 = pItemsTable->pItems[v23].uDamageMod;
+      v14 = pItemsTable->pItems[v23].uDamageDice * pItemsTable->pItems[v23].uDamageRoll;
       v5 += v15 + v14;
       return v5 + v62 + v61;
     }
@@ -5407,43 +5407,38 @@
 //----- (0048F882) --------------------------------------------------------
 int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType )
     {
-  signed int v2; // esi@1
-  unsigned __int16 v3; // ax@126
-  char result; // al@127
-  unsigned int v5; // [sp-4h] [bp-14h]@13
-  signed int v6; // [sp-4h] [bp-14h]@27
-  //unsigned int v7; // [sp-4h] [bp-14h]@35
-  CHARACTER_ATTRIBUTE_TYPE v8; // [sp-4h] [bp-14h]@68
-  //Player *v9; // [sp+Ch] [bp-4h]@1
+  signed int bonus_value; // esi@1
+  unsigned __int16 skill_value; // ax@126
+  int result; // al@127
   
-  v2 = 0;
+  bonus_value = 0;
   switch (uSkillType)
   {
     case PLAYER_SKILL_MONSTER_ID:
     {
       if ( CheckHiredNPCSpeciality(Hunter) )
-        v2 = 6;
+        bonus_value = 6;
       if ( CheckHiredNPCSpeciality(Sage) )
-        v2 += 6;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 0);
+        bonus_value += 6;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 0);
     }
     break;
 
     case PLAYER_SKILL_ARMSMASTER:
     {
         if ( CheckHiredNPCSpeciality(Armsmaster) )
-          v2 = 2;
+          bonus_value = 2;
         if ( CheckHiredNPCSpeciality(Weaponsmaster) )
-          v2 += 3;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 0);
+          bonus_value += 3;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 0);
     }
     break;
 
     case PLAYER_SKILL_STEALING:
     {
       if (CheckHiredNPCSpeciality(Burglar))
-          v2 = 8;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING, 0);
+          bonus_value = 8;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING, 0);
     }
     break;
 
@@ -5451,185 +5446,188 @@
     case PLAYER_SKILL_ALCHEMY:
     {
         if ( CheckHiredNPCSpeciality(Herbalist) )
-          v2 = 4;
+          bonus_value = 4;
         if ( CheckHiredNPCSpeciality(Apothecary) )
-          v2 += 8;
-        v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 0);
+          bonus_value += 8;
+        bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 0);
     }
     break;
 
     case PLAYER_SKILL_LEARNING:
     {
         if ( CheckHiredNPCSpeciality(Teacher) )
-          v2 = 10;
+          bonus_value = 10;
         if ( CheckHiredNPCSpeciality(Instructor) )
-          v2 += 15;
+          bonus_value += 15;
         if ( CheckHiredNPCSpeciality(Scholar) )
-          v2 += 5;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING, 0);
+          bonus_value += 5;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING, 0);
     }
     break;
 
     case PLAYER_SKILL_UNARMED:
     {
       if (CheckHiredNPCSpeciality(Monk) )
-        v2 = 2;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 0);
+        bonus_value = 2;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 0);
     }
     break;
 
     case PLAYER_SKILL_DODGE:
     {
       if ( CheckHiredNPCSpeciality(Monk) )
-        v2 = 2;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE, 0);
+        bonus_value = 2;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE, 0);
     }
     break;
     
     case PLAYER_SKILL_BOW:
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW, 0);
     break;
     case PLAYER_SKILL_SHIELD:
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 0);
     break;
 
     case PLAYER_SKILL_EARTH:
       if ( CheckHiredNPCSpeciality(Apprentice) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Mystic) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Spellmaster) )
-            v2 += 4;
+            bonus_value += 4;
           if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
-            v2 += 3;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH, 0);
+            bonus_value += 3;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH, 0);
     break;
     case PLAYER_SKILL_FIRE:
       if ( CheckHiredNPCSpeciality(Apprentice) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Mystic) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Spellmaster) )
-            v2 += 4;
+            bonus_value += 4;
           if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
-            v2 += 3;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0);
+            bonus_value += 3;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0);
     break;
     case PLAYER_SKILL_AIR:
       if ( CheckHiredNPCSpeciality(Apprentice) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Mystic) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Spellmaster) )
-            v2 += 4;
+            bonus_value += 4;
           if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
-            v2 += 3;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR, 0);
+            bonus_value += 3;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR, 0);
     break;
     case PLAYER_SKILL_WATER:
       if ( CheckHiredNPCSpeciality(Apprentice) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Mystic) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Spellmaster) )
-            v2 += 4;
+            bonus_value += 4;
           if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
-            v2 += 3;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER, 0);
+            bonus_value += 3;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER, 0);
     break;
     case PLAYER_SKILL_SPIRIT:
           if ( CheckHiredNPCSpeciality(Acolyte2) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Initiate) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Prelate) )
-            v2 += 4;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0);
+            bonus_value += 4;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0);
     break;
     case PLAYER_SKILL_MIND:
           if ( CheckHiredNPCSpeciality(Acolyte2) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Initiate) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Prelate) )
-            v2 += 4;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND, 0);
+            bonus_value += 4;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND, 0);
     break;
     case PLAYER_SKILL_BODY:
           if ( CheckHiredNPCSpeciality(Acolyte2) )
-            v2 = 2;
+            bonus_value = 2;
           if ( CheckHiredNPCSpeciality(Initiate) )
-            v2 += 3;
+            bonus_value += 3;
           if ( CheckHiredNPCSpeciality(Prelate) )
-            v2 += 4;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY, 0);
+            bonus_value += 4;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY, 0);
     break;
     case PLAYER_SKILL_LIGHT:
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0);
     break;
     case PLAYER_SKILL_DARK:
     {
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK, 0);
     }
     break;
 
     case PLAYER_SKILL_MERCHANT:
     {
         if ( CheckHiredNPCSpeciality(Trader) )
-          v2 = 4;
+          bonus_value = 4;
         if ( CheckHiredNPCSpeciality(Merchant) )
-          v2 += 6;
+          bonus_value += 6;
         if ( CheckHiredNPCSpeciality(Gypsy) )
-          v2 += 3;
+          bonus_value += 3;
         if ( CheckHiredNPCSpeciality(Duper) )
-          v2 += 8;
+          bonus_value += 8;
     }
     break;
 
     case PLAYER_SKILL_PERCEPTION:
     {
       if ( CheckHiredNPCSpeciality(Scout) )
-        v2 = 6;
+        bonus_value = 6;
       if ( CheckHiredNPCSpeciality(Psychic) )
-        v2 += 5;
+        bonus_value += 5;
     }
     break;
 
     case PLAYER_SKILL_ITEM_ID:
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 0);
       break;
     case PLAYER_SKILL_MEDITATION:
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 0);
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 0);
     break;
     case PLAYER_SKILL_TRAP_DISARM:
     {
       if ( CheckHiredNPCSpeciality(Tinker) )
-        v2 = 4;
+        bonus_value = 4;
       if ( CheckHiredNPCSpeciality(Locksmith) )
-        v2 += 6;
+        bonus_value += 6;
       if ( CheckHiredNPCSpeciality(Burglar) )
-        v2 += 8;
-      v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 0);
+        bonus_value += 8;
+      bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 0);
     }
     break;
   }
 
-  v3 = pActiveSkills[uSkillType];
-  if ( v2 + (v3 & 0x3F) < 60 )
-    result = v2 + v3;
+  skill_value = pActiveSkills[uSkillType];
+  if ( bonus_value + (skill_value & 0x3F) < 60 )
+    result = bonus_value + skill_value;
   else
-    result = v3 & 0xFFFC | 0x3C; //al
+    result = skill_value & 0xFFFC | 0x3C; //al
   return result;
 }
 
 //----- (0048FC00) --------------------------------------------------------
 int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE a2)
 {
+ 
+
+
   Player *v2; // esi@1
-  int v3; // eax@1
+  int armmaster_skill; // eax@1
   char v4; // di@1
   signed int v5; // ebx@1
-  unsigned int v6; // eax@2
+  unsigned int armaster_mastery; // eax@2
   unsigned __int8 v7; // sf@5
   unsigned __int8 v8; // of@5
   PlayerEquipment *v9; // ebx@19
@@ -5682,8 +5680,8 @@
   unsigned int v57; // eax@118
   int v58; // esi@121
   signed int j; // ecx@121
-  int v60; // edi@126
-  int v61; // eax@126
+  int base_value; // edi@126
+  int attrib_modif; // eax@126
   signed int v62; // [sp-4h] [bp-30h]@26
   signed int v63; // [sp-4h] [bp-30h]@80
   int v64; // [sp+Ch] [bp-20h]@104
@@ -5697,56 +5695,148 @@
   int a1; // [sp+34h] [bp+8h]@21
   int a1a; // [sp+34h] [bp+8h]@74
   signed int a1b; // [sp+34h] [bp+8h]@94
+  int multiplier;
+  int arm_bonus;
+  int lvl_avl[4];
 
   v2 = this;
   v70 = 0;
   v69 = 0;
+  multiplier =0;
+  arm_bonus =0;
   v71 = (ITEM_EQUIP_TYPE)0;
-  LOBYTE(v3) = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER);
-  v4 = v3;
+  armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER);
+  v4 = armmaster_skill;
   v5 = 1;
-  if ( v3 )
-  {
-    v6 = SkillToMastery(v3);
+  if ( armmaster_skill )
+  {
+    armaster_mastery = SkillToMastery(armmaster_skill);
     if ( a2 == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS )
     {
-      if ( (signed int)v6 >= 4 )
-        goto LABEL_4;
-      v8 = __OFSUB__(v6, 3);
-      v7 = ((v6 - 3) & 0x80000000u) != 0;
-    }
-    else
-    {
-      if ( a2 != CHARACTER_ATTRIBUTE_ATTACK )
-        goto LABEL_11;
-      if ( (signed int)v6 >= 4 )
-      {
-LABEL_4:
-        v71 = (ITEM_EQUIP_TYPE)2;
-LABEL_11:
-        v69 = (PlayerEquipment *)(v71 * (v4 & 0x3F));
-        goto LABEL_12;
-      }
-      v8 = __OFSUB__(v6, 2);
-      v7 = ((v6 - 2) & 0x80000000u) != 0;
-    }
-    if ( !(v7 ^ v8) )
-      v71 = (ITEM_EQUIP_TYPE)1;
-    goto LABEL_11;
-  }
-LABEL_12:
+      if ( armaster_mastery == 4 )
+          multiplier =2;
+      else if ( armaster_mastery == 3 )
+          multiplier =1;
+    }
+    else if ( a2 == CHARACTER_ATTRIBUTE_ATTACK )
+    {
+    if ( armaster_mastery == 4 )
+        multiplier =2;
+    else if ( armaster_mastery >= 2 )
+        multiplier =1;
+    } 
+    arm_bonus=(armmaster_skill&0x3F)*multiplier;
+  }
+ 
+  
   if ( a2 == CHARACTER_ATTRIBUTE_HEALTH )
   {
-    v60 = pBaseHealthPerLevelByClass[v2->classType];
-    v61 = v2->GetBodybuilding();
-    return v60 * v61;
+    base_value = pBaseHealthPerLevelByClass[classType];
+    attrib_modif = GetBodybuilding();
+    return base_value * attrib_modif;
   }
   if ( a2 == CHARACTER_ATTRIBUTE_MANA )
   {
-    v60 = pBaseManaPerLevelByClass[v2->classType];
-    v61 = v2->GetMeditation();
-    return v60 * v61;
-  }
+    base_value = pBaseManaPerLevelByClass[classType];
+    attrib_modif = GetMeditation();
+    return base_value * attrib_modif;
+  }
+  if ( a2 == CHARACTER_ATTRIBUTE_AC_BONUS )
+      {
+      a1b = 0;
+      v71 = (ITEM_EQUIP_TYPE)0;
+     
+      for (j=0; j<16; ++j) 
+          {
+           if (pEquipment.pIndices[j]&&(!pOwnItems[ pEquipment.pIndices[j]].Broken()))
+               {
+               int curr_item =pOwnItems[pEquipment.pIndices[j]].uItemID;
+               v44=pItemsTable->pItems[curr_item].uSkillType;
+               switch (v44)
+                   {
+
+               case PLAYER_SKILL_STAFF:
+                   
+                   lvl_avl[0]=0;
+                   lvl_avl[1]=1;
+                   lvl_avl[2]=0;
+                   lvl_avl[3]=0;
+                   break;
+               case PLAYER_SKILL_SWORD:
+               case PLAYER_SKILL_SPEAR:
+                   lvl_avl[0]=0;
+                   lvl_avl[1]=0;
+                   lvl_avl[2]=0;
+                   lvl_avl[3]=1;
+                   break;
+               case PLAYER_SKILL_SHIELD:
+                    a1b = 1;
+                   lvl_avl[0]=1;
+                   lvl_avl[1]=0;
+                   lvl_avl[2]=1;
+                   lvl_avl[3]=0;
+                   break;
+               case PLAYER_SKILL_LEATHER:
+                   v71 = (ITEM_EQUIP_TYPE)1;
+                   lvl_avl[0]=1;
+                   lvl_avl[1]=0;
+                   lvl_avl[2]=1;
+                   lvl_avl[3]=0;
+
+                   break;
+               case PLAYER_SKILL_CHAIN:
+                    a1b = 1;
+                   lvl_avl[0]=1;
+                   lvl_avl[1]=0;
+                   lvl_avl[2]=0;
+                   lvl_avl[3]=0;
+                   break;
+               case PLAYER_SKILL_PLATE:
+                     a1b = 1; 
+                   lvl_avl[0]=1;
+                   lvl_avl[1]=0;
+                   lvl_avl[2]=0;
+                   lvl_avl[3]=0;
+                   break;
+               default:
+                   continue;
+                   }
+
+               v50= GetActualSkillLevel((PLAYER_SKILL_TYPE)v44);
+               v51 = v50;
+               v52 = SkillToMastery(v50);
+               v53 = v51 & 0x3F;
+               for ( i = 0; i < (signed int)v52; ++i )
+                   {
+                   if ( lvl_avl[i] )
+                       v70 += v53;
+                   }
+
+               }
+          }
+
+      lvl_avl[0]=1;
+      lvl_avl[1]=1;
+      lvl_avl[2]=1;
+      lvl_avl[3]=0;
+
+      v55 = GetActualSkillLevel(PLAYER_SKILL_DODGE);
+      v56 = v55;
+      v57 = SkillToMastery(v55);
+      if ( !a1b && (!v71 || v57 == 4) )
+          {
+          v58 = v56 & 0x3F;
+          for ( j = 0; j < (signed int)v57; ++j )
+              {
+              if ( lvl_avl[i] )
+                  v70 += v58;
+              }
+          }
+      return v70;
+
+    
+      }
+
   if ( a2 != 9 )
   {
     if ( a2 != CHARACTER_ATTRIBUTE_ATTACK )
@@ -5906,7 +5996,7 @@
     {
       if ( v2->HasItemEquipped(v35) )
       {
-        v37 = *(int *)&v2->pInventoryItems[v35].uItemID;
+        v37 = v2->pInventoryItems[v35].uItemID;
         if ( pItemsTable->pItems[v37].uEquipType <= 1u )
           break;
       }
@@ -5972,99 +6062,7 @@
     v30 = v68 + v71 * (a1a & 0x3F);
     return (int)((char *)v69 + v30);
   }
-  a1b = 0;
-  v71 = (ITEM_EQUIP_TYPE)0;
-  v68 = 16;
-  v69 = &v2->pEquipment;
-  do
-  {
-    if ( !v69->uShield || (v42 = (int)((char *)v2 + 36 * v69->uShield), *(char *)(v42 + 516) & 2) )
-      goto LABEL_117;
-    v43 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[*(int *)(v42 + 496)].uSkillType;
-    v44 = pItemsTable->pItems[*(int *)(v42 + 496)].uSkillType;
-    if ( !v44 )
-    {
-      v64 = 0;
-      v65 = 1;
-LABEL_111:
-      v66 = 0;
-      goto LABEL_112;
-    }
-    v45 = v44 - 1;
-    if ( !v45 || (v46 = v45 - 3) == 0 )
-    {
-      v64 = 0;
-      v65 = 0;
-      v66 = 0;
-      v67 = 1;
-      goto LABEL_113;
-    }
-    v47 = v46 - 4;
-    if ( v47 )
-    {
-      v48 = v47 - 1;
-      if ( v48 )
-      {
-        v49 = v48 - 1;
-        if ( v49 )
-        {
-          if ( v49 != 1 )
-            goto LABEL_117;
-          a1b = 1;
-          v64 = 1;
-          v65 = 0;
-          v66 = 0;
-          v67 = 0;
-          goto LABEL_113;
-        }
-        a1b = 1;
-        v64 = 1;
-        v65 = 0;
-        goto LABEL_111;
-      }
-      v71 = (ITEM_EQUIP_TYPE)1;
-    }
-    else
-    {
-      a1b = 1;
-    }
-    v64 = 1;
-    v65 = 0;
-    v66 = 1;
-LABEL_112:
-    v67 = 0;
-LABEL_113:
-    LOBYTE(v50) = v2->GetActualSkillLevel(v43);
-    v51 = v50;
-    v52 = SkillToMastery(v50);
-    v53 = v51 & 0x3F;
-    for ( i = 0; i < (signed int)v52; ++i )
-    {
-      if ( *(&v64 + i) )
-        v70 += v53;
-    }
-LABEL_117:
-    v69 = (PlayerEquipment *)((char *)v69 + 4);
-    --v68;
-  }
-  while ( v68 );
-  v64 = 1;
-  v65 = 1;
-  v66 = 1;
-  v67 = 0;
-  LOBYTE(v55) = v2->GetActualSkillLevel(PLAYER_SKILL_DODGE);
-  v56 = v55;
-  v57 = SkillToMastery(v55);
-  if ( !a1b && (!v71 || v57 == 4) )
-  {
-    v58 = v56 & 0x3F;
-    for ( j = 0; j < (signed int)v57; ++j )
-    {
-      if ( *(&v64 + j) )
-        v70 += v58;
-    }
-  }
-  return v70;
+  
 }
 
 //----- (00490109) --------------------------------------------------------
--- a/SpriteObject.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/SpriteObject.cpp	Fri May 24 23:34:00 2013 +0600
@@ -1095,7 +1095,7 @@
   {
     if (pSpriteObjects[uLayingItemID].uAttributes & 4 )
     {
-      pSpriteObjects[uLayingItemID].uAttributes &= 0xFB;
+      pSpriteObjects[uLayingItemID].uAttributes &= 0xFFFB;
       --pTurnEngine->field_1C;
     }
   }
--- a/UICharacter.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/UICharacter.cpp	Fri May 24 23:34:00 2013 +0600
@@ -772,7 +772,7 @@
         if ( _50C9A8_item_enchantment_timer <= 0 )
         {
           _50C9A8_item_enchantment_timer = 0;
-          item_MainHand4->uAttributes &= 0xFu;
+          item_MainHand4->uAttributes &= 0xFFFFFF0Fu;
           ptr_50C9A4 = 0;
         }
         v17 = (double)GetTickCount() * 0.1;
@@ -819,7 +819,7 @@
         if ( _50C9A8_item_enchantment_timer <= 0 )
         {
           _50C9A8_item_enchantment_timer = 0;
-          itemBow->uAttributes &= 0xFu;
+          itemBow->uAttributes &= 0xFFFFFF0Fu;
           ptr_50C9A4 = 0;
         }
         v28 = (double)GetTickCount() * 0.1;
@@ -881,7 +881,7 @@
           if ( _50C9A8_item_enchantment_timer <= 0 )
           {
             _50C9A8_item_enchantment_timer = 0;
-            item_Cloak->uAttributes &= 0xFu;
+            item_Cloak->uAttributes &= 0xFFFFFF0Fu;
             ptr_50C9A4 = 0;
           }
           v40 = (double)GetTickCount() * 0.1;
@@ -949,7 +949,7 @@
           if ( _50C9A8_item_enchantment_timer <= 0 )
           {
             _50C9A8_item_enchantment_timer = 0;
-            item_Armor->uAttributes &= 0xFu;
+            item_Armor->uAttributes &= 0xFFFFFF0Fu;
             ptr_50C9A4 = 0;
           }
           v52 = (double)GetTickCount() * 0.1;
@@ -1005,7 +1005,7 @@
                 if ( _50C9A8_item_enchantment_timer <= 0 )
                 {
                   _50C9A8_item_enchantment_timer = 0;
-                  item_Armor->uAttributes &= 0xFu;
+                  item_Armor->uAttributes &= 0xFFFFFF0Fu;
                   ptr_50C9A4 = 0;
                 }
                 v97 = (double)GetTickCount();
@@ -1050,7 +1050,7 @@
               if ( _50C9A8_item_enchantment_timer <= 0 )
               {
                 _50C9A8_item_enchantment_timer = 0;
-                item_Armor->uAttributes &= 0xFu;
+                item_Armor->uAttributes &= 0xFFFFFF0Fu;
                 ptr_50C9A4 = 0;
               }
               v97 = (double)GetTickCount();
@@ -1114,7 +1114,7 @@
           if ( _50C9A8_item_enchantment_timer <= 0 )
           {
             _50C9A8_item_enchantment_timer = 0;
-            item_Boot->uAttributes &= 0xFu;
+            item_Boot->uAttributes &= 0xFFFFFF0Fu;
             ptr_50C9A4 = 0;
           }
           v64 = (double)GetTickCount() * 0.1;
@@ -1185,7 +1185,7 @@
             if ( _50C9A8_item_enchantment_timer <= 0 )
             {
               _50C9A8_item_enchantment_timer = 0;
-              item_Belt->uAttributes &= 0xFu;
+              item_Belt->uAttributes &= 0xFFFFFF0Fu;
               ptr_50C9A4 = 0;
             }
             v78 = (double)GetTickCount() * 0.1;
@@ -1260,7 +1260,7 @@
               if ( _50C9A8_item_enchantment_timer <= 0 )
               {
                 _50C9A8_item_enchantment_timer = 0;
-                item_CloakCollar->uAttributes &= 0xFu;
+                item_CloakCollar->uAttributes &= 0xFFFFFF0Fu;
                 ptr_50C9A4 = 0;
               }
               v118 = (double)GetTickCount() * 0.1;
@@ -1324,7 +1324,7 @@
           if ( _50C9A8_item_enchantment_timer <= 0 )
           {
             _50C9A8_item_enchantment_timer = 0;
-            item_Helm->uAttributes &= 0xFu;
+            item_Helm->uAttributes &= 0xFFFFFF0Fu;
             ptr_50C9A4 = 0;
           }
           v130 = (double)GetTickCount() * 0.1;
@@ -1388,7 +1388,7 @@
         if ( _50C9A8_item_enchantment_timer <= 0 )
         {
           _50C9A8_item_enchantment_timer = 0;
-          item_MainHand3->uAttributes &= 0xFu;
+          item_MainHand3->uAttributes &= 0xFFFFFF0Fu;
           ptr_50C9A4 = 0;
         }
         v141 = (double)GetTickCount() * 0.1;
@@ -1460,7 +1460,7 @@
         if ( _50C9A8_item_enchantment_timer <= 0 )
         {
           _50C9A8_item_enchantment_timer = 0;
-          item_Shield->uAttributes &= 0xFu;
+          item_Shield->uAttributes &= 0xFFFFFF0Fu;
           ptr_50C9A4 = 0;
         }
         v158 = (double)GetTickCount() * 0.1;
@@ -1602,7 +1602,7 @@
     if (_50C9A8_item_enchantment_timer <= 0)
     {
       _50C9A8_item_enchantment_timer = 0;
-      item->uAttributes &= 0xF;
+      item->uAttributes &= 0xFFFFFF0F;
       ptr_50C9A4 = 0;
     }
     pRenderer->_4A63E6(x, y, item_texture, enchantment_texture, GetTickCount() * 0.1, 0, 255);
--- a/UiGame.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/UiGame.cpp	Fri May 24 23:34:00 2013 +0600
@@ -2570,7 +2570,7 @@
 LABEL_15:
     //v12 = &pIndoor->pFaces[pOutline->uFace1ID];
     if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 &&
-        (pFace1->uAttributes & 0x2000000 || pFace2->uAttributes & 0x2000000) &&
+        (pFace1->uAttributes & 0x2000 || pFace2->uAttributes & 0x2000) &&
         (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID))
     {
       if (uNumBlueFacesInBLVMinimap < 49)
--- a/mm7_1.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/mm7_1.cpp	Fri May 24 23:34:00 2013 +0600
@@ -1069,7 +1069,7 @@
       if ( !v17->CanAct() )
         return;
       v18 = a2.y;
-      Actor::FaceObject(a2.y, 4u, 0, 0);
+      Actor::AI_FaceObject(a2.y, 4u, 0, 0);
       if ( !v17->sNPC_ID )
       {
         v19 = pNPCStats->pGroups_copy[v17->uGroup];
--- a/mm7_2.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/mm7_2.cpp	Fri May 24 23:34:00 2013 +0600
@@ -5445,9 +5445,9 @@
 }
 
 //----- (00458244) --------------------------------------------------------
-unsigned int SkillToMastery(unsigned int value)
-{
-  switch (value & 0x1C0)
+int SkillToMastery( unsigned int skill_value )
+{
+  switch (skill_value & 0x1C0)
   {
     case 0x100: return 4;     // Grandmaster
     case 0x80:  return 3;     // Master
@@ -10473,7 +10473,7 @@
       {
         if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() )
         {
-          Actor::FaceObject(v12, 4u, 0, 0);
+          Actor::AI_FaceObject(v12, 4u, 0, 0);
           if ( v13->sNPC_ID )
           {
             pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0);
--- a/mm7_3.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/mm7_3.cpp	Fri May 24 23:34:00 2013 +0600
@@ -1178,7 +1178,7 @@
             {
               if ( v71 == 0 )
 			  {
-				  Actor::Flee(v75, v38, 0, (AIDirection *)0);
+				  Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
 			  }
 			  else
 			  {
@@ -1191,11 +1191,11 @@
 			}
 			else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
             {
-              Actor::Flee(v75, v38, 0, (AIDirection *)0);
+              Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
             }
 			else
 			{
-				Actor::FaceObject(v75, v38, 0, (AIDirection *)0);
+				Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
 			}
           }
           break;
@@ -1203,7 +1203,7 @@
           if ( !v0->GetActorsRelation(0) )
           {
             v38 = stru_721530.uFaceID;
-            Actor::FaceObject(v75, v38, 0, (AIDirection *)0);
+            Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
             break;
           }
           //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0;
@@ -2230,7 +2230,9 @@
   v1 = 0;
   v103 = 0;
   v2 = 0;
-  *(float *)&v128 = 0.0;
+  //*(float *)&v128 = 0.0;
+  v128 = 0;
+  v129 = 0;
   pX = pParty->vPosition.x;
   pY = pParty->vPosition.y;
   v113 = pParty->field_6F0;
@@ -2648,14 +2650,14 @@
     }
   }
 
-LABEL_123:
+//LABEL_123:
   pParty->sRotationY = _angle_y;
   pParty->sRotationX = _angle_x;
-  if ( pZ < v111 )
+  if ( pZ < v111 || pParty->bFlying)
   {
     if ( pParty->bFlying )
     {
-LABEL_130:
+//LABEL_130:
       v31 = GetTickCount();
       v126 = stru_5C6E00->Cos(v31);
       v129 = (unsigned __int64)(4i64 * v126) >> 16;
@@ -2665,60 +2667,61 @@
       if (pParty->FlyActive())
         stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu;
       pParty->uFallStartY = pZ;
-      goto LABEL_141;
-    }
-    if ( v130 && v121 )
-      sub_42F960_create_object(pX, pY, v111);
-    v121 = 0;
-    pZ = v111;
-    pParty->uFallStartY = v111;
-  }
-  if ( pParty->bFlying )
-    goto LABEL_130;
-  v113 = pZ;
-  if (pParty->FlyActive())
-    stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
-
-LABEL_141:
+      //goto LABEL_141;
+    }
+	else
+	{
+		if ( v130 && v121 )
+		  sub_42F960_create_object(pX, pY, v111);
+		v121 = 0;
+		pZ = v111;
+		pParty->uFallStartY = v111;
+	    v113 = pZ;
+	    if (pParty->FlyActive())
+		  stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
+
+	}
+  }
+  else
+  {
+	  v113 = pZ;
+	  if (pParty->FlyActive())
+		stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
+  }
+//LABEL_141:
   if (bJumping && !pParty->bFlying)
   {
     v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
     v34 = v121 + 2 * v33;
     v121 += 2 * v33;
-    goto LABEL_164;
-  }
-  if (!partyAtHighSlope)
+  }
+  else if (!partyAtHighSlope)
   {
     v34 = v121;
-    if (!bJumping)
-      goto LABEL_150;
-    goto LABEL_164;
-  }
-  if (!bJumping)
-  {
-    if ( v108 )
-      goto LABEL_150;
-
-    // rolling down the hill
-    // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
-    // and falling to the gravity, gradually sliding downwards. nice trick
-    pZ = v111;
-    ODM_GetTerrainNormalAt(pX, pY, &v98);
-    v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
-    v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
-    v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
-    v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
-    v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
-    v128 = v1;
-    v121 = v34;
-    if (!bJumping)
-      goto LABEL_150;
-    goto LABEL_164;
-  }
-  v34 = v121;
-
-LABEL_164:
-  if ( !bUnderwater && v34 <= 0)
+  }
+  else if (!bJumping)
+  {
+    if ( !v108 )
+	{
+		// rolling down the hill
+		// how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
+		// and falling to the gravity, gradually sliding downwards. nice trick
+		pZ = v111;
+		ODM_GetTerrainNormalAt(pX, pY, &v98);
+		v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
+		v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
+		v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
+		v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
+		v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
+		v128 = v1;
+		v121 = v34;
+	}
+  }
+  else
+	  v34 = v121;
+
+//LABEL_164:
+  if ( !bUnderwater && v34 <= 0 && bJumping)
   {
     if ( v34 < -500
       && !pParty->bFlying
@@ -2735,7 +2738,7 @@
   }
   else
   {
-LABEL_150:
+//LABEL_150:
   pParty->uFallStartY = pZ;
   }
 
@@ -2801,27 +2804,37 @@
     v43 = 1;
     v44 = 1;
     if ( bUnderwater || !v107 )
-      goto LABEL_197;
-    if ( v127 && v129 > pZ )
-      v44 = 0;
-    if ( v118 && v119 > pZ )
-      v43 = 0;
-    if ( v44 )
-      goto LABEL_197;
-    if ( v43 )
-      goto LABEL_198;
-    v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
-    if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
-    {
-      v43 = 1;
-LABEL_197:
-      pX = _angle_x;
-      if ( !v43 )
-        goto LABEL_199;
-LABEL_198:
-      pY = _angle_y;
-    }
-LABEL_199:
+	{
+		  pX = _angle_x;
+		  if ( v43 )
+			  pY = _angle_y;
+	}
+	else
+	{
+		if ( v127 && v129 > pZ )
+		  v44 = 0;
+		if ( v118 && v119 > pZ )
+		  v43 = 0;
+		if ( v44 )
+		{
+			  pX = _angle_x;
+			  if ( v43 )
+				  pY = _angle_y;
+		}
+		else if ( v43 )
+		  pY = _angle_y;
+		else
+		{
+			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
+			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
+			{
+			  v43 = 1;
+			  pX = _angle_x;
+			  if ( v43 )
+				  pY = _angle_y;
+			}
+		}
+	}
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       if ( !v107 )
@@ -2843,8 +2856,14 @@
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
 
       viewparams->bRedrawGameUI = 1;
-      goto LABEL_234;
-    }
+		v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+		v127 = (BSPModel *)58500;
+		v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+		v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+		++v126;
+		v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+		continue;
+	}
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v56 = integer_sqrt(v2 * v2 + v128 * v128);
@@ -2884,15 +2903,26 @@
         v53 = v47->uPolygonType;
         if ( v53 == 3 )
         {
-          if ( v121 < 0 )
-            v121 = 0;
-          pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
-          if ( v2 * v2 + v128 * v128 < 400 )
-          {
-            v2 = 0;
-            *(float *)&v128 = 0.0;
-          }
-          goto LABEL_221;
+			if ( v121 < 0 )
+				v121 = 0;
+			pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
+			if ( v2 * v2 + v128 * v128 < 400 )
+			{
+				v2 = 0;
+				*(float *)&v128 = 0.0;
+			}
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
         }
         if ( !v129 && (v53 != 4 || v119) )
         {
@@ -2925,15 +2955,20 @@
             if ( !v119 )
               pZ = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
           }
-LABEL_220:
-          v45 = stru_721530.uFaceID;
-LABEL_221:
-          if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
-          {
-            pParty->floor_face_pid = v45;
-            v103 = v47->sCogTriggeredID;
-          }
-          goto LABEL_234;
+//LABEL_220:
+			v45 = stru_721530.uFaceID;
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
         }
         v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
         if ( stru_721530.field_64 >> 3 > v118 )
@@ -2948,13 +2983,27 @@
         v2 += v122;
         v128 += (int)v127;
         if ( v2 * v2 + v128 * v128 >= 400 )
-          goto LABEL_220;
+		{
+			v45 = stru_721530.uFaceID;
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
+		}
         v2 = 0;
         v121 = 0;
         *(float *)&v128 = 0.0;
       }
     }
-LABEL_234:
+//LABEL_234:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     v127 = (BSPModel *)58500;
     v128 = (unsigned __int64)(58500i64 * v128) >> 16;
@@ -2969,54 +3018,71 @@
     v126 = abs(pParty->vPosition.y - pY);
     v62 = abs(pParty->vPosition.z - pZ);
     if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
-      goto LABEL_344;
-    if ( v114 && (!bJumping || v101) )
-    {
-      if ( !v107
-        && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
-      {
+	{
+		  pAudioPlayer->_4AA258(804);
+		  pParty->walk_sound_timer = 64;
+	}
+	else
+	{
+		if ( v114 && (!bJumping || v101) )
+		{
+		  if ( !v107
+			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
+		  {
         
-        v90 = -1;
-        v89 = 1;
-        v88 = 804;
-        v87 = 64;
-        goto LABEL_257;
-      }
-     
-      v90 = -1;
-      v89 = 1;
-      v88 = 804;
-      v86 = 1;
-LABEL_255:
-      v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-      v64 = WorldPosToGridCellX(pParty->vPosition.x);
-      v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
-      goto LABEL_257;
-    }
-    if ( v124 && (!bJumping || v101) )
-    {
-      if ( v107
-        || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
-      {
+			v90 = -1;
+			v89 = 1;
+			v88 = 804;
+			v87 = 64;
+			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+		  }
+		  else
+		  {
+			v90 = -1;
+			v89 = 1;
+			v88 = 804;
+			v86 = 1;
+		//LABEL_255:
+			v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+			v64 = WorldPosToGridCellX(pParty->vPosition.x);
+			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
+			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+		  }
+		}
+		else
+		{
+			if ( v124 && (!bJumping || v101) )
+			{
+			  if ( v107
+				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
+			  {
         
-        v90 = -1;
-        v89 = 1;
-        v88 = 804;
-        v86 = 0;
-        goto LABEL_255;
-      }
-      v90 = -1;
-      v89 = 1;
-      v88 = 804;
-      v87 = 103;
-LABEL_257:
-      pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
-    }
-    else
-    {
-LABEL_344:
-      pAudioPlayer->_4AA258(804);
-      pParty->walk_sound_timer = 64;
+				v90 = -1;
+				v89 = 1;
+				v88 = 804;
+				v86 = 0;
+				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+				v64 = WorldPosToGridCellX(pParty->vPosition.x);
+				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
+				pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+			  }
+			  else
+			  {
+				  v90 = -1;
+				  v89 = 1;
+				  v88 = 804;
+				  v87 = 103;
+			//LABEL_257:
+				  pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+			  }
+			}
+			else
+			{
+		//LABEL_344:
+			  pAudioPlayer->_4AA258(804);
+			  pParty->walk_sound_timer = 64;
+			}
+		}
     }
   }
   if ( !bJumping || v101 )
@@ -3113,24 +3179,26 @@
     if ( v127 )
     {
       v78 = v69 != 0;
-      goto LABEL_306;
-    }
-    v114 = 1;
-  }
-  v78 = 1;
-LABEL_306:
+    }
+	else
+	{
+		v114 = 1;
+		v78 = 1;
+	}
+  }
+  else
+	v78 = 1;
+//LABEL_306:
   if ( v77 )
   {
     pParty->vPosition.x = pX;
-    if ( !v78 )
-      goto LABEL_313;
-    goto LABEL_312;
   }
   if ( v78 )
   {
-LABEL_312:
     pParty->vPosition.y = pY;
-LABEL_313:
+  }
+  if ( v78 || v77)
+  {
     if ( bWaterWalk )
     {
       pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER;
@@ -3148,14 +3216,13 @@
         }
       }
     }
-    goto LABEL_318;
-  }
-  if ( bWalkSound && pParty->walk_sound_timer <= 0 )
+  }
+  else if ( bWalkSound && pParty->walk_sound_timer <= 0 )
   {
     pAudioPlayer->_4AA258(804);
     pParty->walk_sound_timer = 64;
   }
-LABEL_318:
+//LABEL_318:
   v81 = pZ;
   v82 = pZ;
   pParty->vPosition.z = pZ;
@@ -14385,15 +14452,15 @@
 {
 	//unsigned int v0; // esi@4
 	int v1; // eax@7
-	int v2; // ecx@7
-	int v3; // eax@7
+	//int v2; // ecx@7
+	//int v3; // eax@7
 	signed int v4; // edi@10
 	Actor *v5; // esi@12
-	signed int v6; // eax@14
+	signed int sDmg; // eax@14
 	__int16 v7; // cx@14
-	Player **v8; // esi@20
+	//Player **v8; // esi@20
 	Player *pPlayer; // ecx@21
-	//Actor *pActor; // esi@34
+	Actor *pActor; // esi@34
 	//__int16 v11; // ax@34
 	//unsigned int v12; // eax@47
 	//signed int v13; // edi@47
@@ -14404,7 +14471,7 @@
 	//unsigned int v18; // ecx@67
 	//unsigned __int16 v19; // ax@72
 	//int *v20; // esi@80
-	Actor *v21; // ebx@80
+	//Actor *v21; // ebx@80
 	unsigned __int16 v22; // ax@86
 	//signed int v23; // eax@94
 	//unsigned int v24; // eax@102
@@ -14487,58 +14554,48 @@
 		else
 		{
 			pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8);
-			v1 = rand();
-			v2 = 128;
-			v3 = pParty->sRotationX + v1 % 16 - 8;
-			pParty->sRotationX = v3;
-			if ( v3 > 128 || (v2 = -128, v3 < -128) )
-				pParty->sRotationX = v2;
+			pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8;
+			if ( pParty->sRotationX > 128) 
+				pParty->sRotationX = 128;
+			else if ( pParty->sRotationX < -128 )
+				pParty->sRotationX = -128;
+				
 			pParty->uFlags |= 2u;
 			pParty->armageddon_timer -= pMiscTimer->uTimeElapsed;
 			v4 = pParty->field_16140 + 50;
 			if ( pParty->armageddon_timer <= 0 )
 			{
 				pParty->armageddon_timer = 0;
-				v84 = 0;
-				if ( (signed int)uNumActors > 0 )
+				for(int i = 0; i < uNumActors; i++)
 				{
-					v5 = pActors;//[0].sCurrentHP;
-					do
+					pActor=&pActors[i];
+					if ( pActor->CanAct() )
 					{
-						if ( v5->CanAct() )
+						sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4);
+						pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4);
+						if ( sDmg )
 						{
-							v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4);
-							v7 = v5->sCurrentHP - v6;
-							v5->sCurrentHP = v7;
-							if ( v6 )
+							if ( pActor->sCurrentHP >= 0 )
 							{
-								if ( v7 >= 0 )
-								{
-									Actor::Stun(v84, 4, 0);
-								}
-								else
-								{
-									Actor::Die(v84);
-									if ( v5->pMonsterInfo.uExp )
-										GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp);
-								}
+								Actor::AI_Stun(i, 4, 0);
+							}
+							else
+							{
+								Actor::Die(i);
+								if ( pActor->pMonsterInfo.uExp )
+									GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp);
 							}
 						}
-						++v84;
-						++v5;
 					}
-					while ( (signed int)v84 < (signed int)uNumActors );
+					++v84;
+					++v5;
 				}
-				v8 = &pPlayers[1];
-				do
+				for(int i = 1; i <= 4; i++)
 				{
-					pPlayer = *v8;
-					if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
+					pPlayer = pPlayers[i];
+					if ( !pPlayer->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
 						pPlayer->ReceiveDamage(v4, DMGT_5);
-					++v8;
 				}
-				while ( (signed int)v8 <= (signed int)&pPlayers[4] );
-				//v0 = 0;
 			}
 			if (pTurnEngine->field_1C)
 				--pTurnEngine->field_1C;
@@ -14555,7 +14612,7 @@
 	//uActorID = v0;
 	for (uint i = 0; i < uNumActors; ++i)
 	{
-		auto actor = pActors + i;
+		pActor = &pActors[i];
 		//LODWORD(v80) = (int)(char *)pActors + 176; // uAIState
 		//do
 		//{
@@ -14563,10 +14620,10 @@
 			//v11 = *(unsigned int *)LODWORD(v80);
 			//v49 = *(unsigned int *)LODWORD(v80) == 5;
 			ai_near_actors_targets_pid[i] = OBJECT_Player;
-			if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400)
+			if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & 0x0400)
 				continue;
 			
-			if (!actor->sCurrentHP && actor->uAIState != Dying)
+			if (!pActor->sCurrentHP && pActor->uAIState != Dying)
 				Actor::Die(i);
 			
 			//v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
@@ -14577,7 +14634,7 @@
 			for (uint j = 0; j < 22; ++j)
 			{
 				if (j != 10)
-				actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
+				pActor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
 			}
 			/*do
 			{
@@ -14590,52 +14647,52 @@
 				++v14;
 			}
 			while ( v13 < 22 );*/
-			if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
 			//&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12
 			// || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) )
-				actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
-				actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else  if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
-				actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType;
+			else  if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
 			
-			if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
-				|| (signed __int64)actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
+			if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
+				|| (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
 				continue;
 			
 			//v15 = pMiscTimer->uTimeElapsed;
 			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
 			//v17 = pActor->uCurrentActionTime;
 			//v18 = pActor->pMonsterInfo.uRecoveryTime;
-			if (actor->pMonsterInfo.uRecoveryTime)
+			if (pActor->pMonsterInfo.uRecoveryTime)
 			{
-				if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
-					actor->pMonsterInfo.uRecoveryTime = 0;
+				if (pActor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
+					pActor->pMonsterInfo.uRecoveryTime = 0;
 				else 
-					actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
+					pActor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
 			}
 			
-			actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
-			if (actor->uCurrentActionTime < actor->uCurrentActionLength)
+			pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+			if (pActor->uCurrentActionTime < pActor->uCurrentActionLength)
 				continue;
 			
 			//v19 = actor->uAIState;
-			if (actor->uAIState == Dying)
-				actor->uAIState = Dead;
+			if (pActor->uAIState == Dying)
+				pActor->uAIState = Dead;
 			else
 			{
-				if (actor->uAIState != Summoned)
+				if (pActor->uAIState != Summoned)
 				{
 					Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr);
 					continue;
 				}
-				actor->uAIState = Standing;
+				pActor->uAIState = Standing;
 			}
 			
-			actor->uCurrentActionTime = 0;
-			actor->uCurrentActionLength = 0;
-			actor->UpdateAnimation();
+			pActor->uCurrentActionTime = 0;
+			pActor->uCurrentActionLength = 0;
+			pActor->UpdateAnimation();
 			//LABEL_78:
 			//++uActorID;
 			//LODWORD(v80) += 836;
@@ -14655,61 +14712,61 @@
 			assert(actor_id < uNumActors);
 			
 			//v20 = &ai_near_actors_targets_pid[actor_id];
-			v21 = &pActors[actor_id];
+			pActor = &pActors[actor_id];
 			Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true);
-			if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
-				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+			if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			target_pid = ai_near_actors_targets_pid[actor_id];
 			target_pid_type = PID_TYPE(target_pid);
 			if ( target_pid_type == OBJECT_Actor)
 				v80 = 0.5;
 			else
 				v80 = 1.0;
-			v22 = v21->uAIState;
+			v22 = pActor->uAIState;
 			if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned)
 			{
 				continue;
 			}
-			if ( !v21->sCurrentHP )
+			if ( !pActor->sCurrentHP )
 				Actor::Die(actor_id);
 			for(int i=0;i<22;i++)
 			{
 				if ( i != 10 )
 				{
-					v21->pActorBuffs[i]._4585CA(pParty->uTimePlayed);
+					pActor->pActorBuffs[i]._4585CA(pParty->uTimePlayed);
 				}
 			}
-			if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
-				v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
-				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
+			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
-				v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
-			if ( (signed __int64)v21->pActorBuffs[2].uExpireTime < 0 )
+			else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
+			if ( (signed __int64)pActor->pActorBuffs[2].uExpireTime < 0 )
 			{
-				v21->uAIState = Removed;
+				pActor->uAIState = Removed;
 				continue;
 			}
-			if ( (signed __int64)v21->pActorBuffs[5].uExpireTime > 0
-				|| (signed __int64)v21->pActorBuffs[6].uExpireTime > 0)
+			if ( (signed __int64)pActor->pActorBuffs[5].uExpireTime > 0
+				|| (signed __int64)pActor->pActorBuffs[6].uExpireTime > 0)
 			{
 				continue;
 			}
 			v27 = pMiscTimer->uTimeElapsed;
-			v28 = v21->pMonsterInfo.uRecoveryTime;
-			v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+			v28 = pActor->pMonsterInfo.uRecoveryTime;
+			pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
 			if ( (signed int)v28 > 0 )
-				v21->pMonsterInfo.uRecoveryTime = v28 - v27;
-			if ( v21->pMonsterInfo.uRecoveryTime < 0 )
-				v21->pMonsterInfo.uRecoveryTime = 0;
-			if ( !(v21->uAttributes & 0x8000) )
-				v21->uAttributes |= 0x8000;
+				pActor->pMonsterInfo.uRecoveryTime = v28 - v27;
+			if ( pActor->pMonsterInfo.uRecoveryTime < 0 )
+				pActor->pMonsterInfo.uRecoveryTime = 0;
+			if ( !(pActor->uAttributes & 0x8000) )
+				pActor->uAttributes |= 0x8000;
 			a1 = PID(OBJECT_Actor,actor_id);
 			v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0);
 			memcpy(&v75, v30, sizeof(v75));
 			memcpy(&pDir, &v75, sizeof(pDir));
-			uAIState = v21->uAIState; 
+			uAIState = pActor->uAIState; 
 			/*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly
 				&& (signed int)v21->pMonsterInfo.uRecoveryTime <= 0
 				&& v80 * 307.2 >= (double)(signed int)v75.uDistance
@@ -14720,60 +14777,60 @@
 			}
 			else
 			*/
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
-				|| (signed int)v21->pMonsterInfo.uRecoveryTime > 0
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly
+				|| (signed int)pActor->pMonsterInfo.uRecoveryTime > 0
 				|| v80 * 307.2 < (double)(signed int)v75.uDistance
 				|| uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting
-				&&  !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
+				&&  !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned )
 			{
-				if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
+				if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength )
 				{
 					continue;
 				}
-				else if ( v21->uAIState == AttackingMelee )
+				else if ( pActor->uAIState == AttackingMelee )
 				{
-					v35 = stru_50C198.special_ability_use_check(v21, actor_id);
+					v35 = stru_50C198.special_ability_use_check(pActor, actor_id);
 					stru_50FE08.Add(
 						a1,
 						5120,
-						v21->vPosition.x,
-						v21->vPosition.y,
-						v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
+						pActor->vPosition.x,
+						pActor->vPosition.y,
+						pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1),
 						v35,
 						1
 					);
 				}
-				else if ( v21->uAIState == AttackingRanged1 )
+				else if ( pActor->uAIState == AttackingRanged1 )
 				{
-					v34 = v21->pMonsterInfo.uMissleAttack1Type;
-					Actor::RangedAttack(actor_id, &pDir, v34, 0);
+					v34 = pActor->pMonsterInfo.uMissleAttack1Type;
+					Actor::AI_RangedAttack(actor_id, &pDir, v34, 0);
 				}
-				else if ( v21->uAIState == AttackingRanged2 )
+				else if ( pActor->uAIState == AttackingRanged2 )
 				{
-					v34 = v21->pMonsterInfo.uMissleAttack2Type;
-					Actor::RangedAttack(actor_id, &pDir, v34, 1);
+					v34 = pActor->pMonsterInfo.uMissleAttack2Type;
+					Actor::AI_RangedAttack(actor_id, &pDir, v34, 1);
 				}
-				else if ( v21->uAIState == AttackingRanged3 )
+				else if ( pActor->uAIState == AttackingRanged3 )
 				{
-					v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
-					v33 = v21->pMonsterInfo.uSpell1ID;
-					Actor::SpellAttack(actor_id, &pDir, v33, 2, v65);
+					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1;
+					v33 = pActor->pMonsterInfo.uSpell1ID;
+					Actor::AI_SpellAttack(actor_id, &pDir, v33, 2, v65);
 				}
-				else if ( v21->uAIState == AttackingRanged4 )
+				else if ( pActor->uAIState == AttackingRanged4 )
 				{
-					v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
-					v33 = v21->pMonsterInfo.uSpell2ID;
-					Actor::SpellAttack(actor_id, &pDir, v33, 3, v65);
+					v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2;
+					v33 = pActor->pMonsterInfo.uSpell2ID;
+					Actor::AI_SpellAttack(actor_id, &pDir, v33, 3, v65);
 				}
 			}
 
 			v36 = v75.uDistance;
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
 			{
 				if ( target_pid_type == OBJECT_Actor )
 				{
 					v36 = v75.uDistance;
-					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
+					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3]
 						+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
 				}
 				else
@@ -14800,85 +14857,85 @@
 					v38 = 5120;
 				}
 				if ( v37 >= 1 && v37 <= 4 && v36 < v38  || v37 == 1 )
-					v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+					pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 			}
 
-			if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
+			if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 )
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
-					Actor::_4032B2(actor_id, target_pid, 1024, 0);
+					Actor::AI_4032B2(actor_id, target_pid, 1024, 0);
 				}
 				else
 				{
 					//peasents after attacked
 					//guard after attacked
-					Actor::Flee(actor_id, target_pid, 0, &pDir);
+					Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 				}
 				continue;
 			}
 
-			if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
+			if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
 			{
 
-				if ( v21->pMonsterInfo.uAIType == 1 )
+				if ( pActor->pMonsterInfo.uAIType == 1 )
 				{
-					if ( v21->pMonsterInfo.uMovementType == 5 )
+					if ( pActor->pMonsterInfo.uMovementType == 5 )
 					{
-						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
 					}
 					else
 					{
-						Actor::Flee(actor_id, target_pid, 0, &pDir);
+						Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 						continue;
 					}
 						
 				}
-				if ( !(v21->uAttributes & 0x020000) )
+				if ( !(pActor->uAttributes & 0x020000) )
 				{
-					if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3)
+					if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3)
 					{
-						if ( v21->pMonsterInfo.uAIType == 2 )
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
-						if ( v21->pMonsterInfo.uAIType == 3 )
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
-						v84 = v21->sCurrentHP;
+						if ( pActor->pMonsterInfo.uAIType == 2 )
+							v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2;
+						if ( pActor->pMonsterInfo.uAIType == 3 )
+							v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1;
+						v84 = pActor->sCurrentHP;
 						v42 = (double)(signed int)v84;
 						if ( v43 > v42 && (signed int)v36 < 10240 )
 						{
-							Actor::Flee(actor_id, target_pid, 0, &pDir);
+							Actor::AI_Flee(actor_id, target_pid, 0, &pDir);
 							continue;
 						}
 					}
 				}
 				
-				v81 = v36 - v21->uActorRadius;
+				v81 = v36 - pActor->uActorRadius;
 				if ( target_pid_type == OBJECT_Actor )
 					v81 -= pActors[PID_ID(target_pid)].uActorRadius;
 				if ( v81 < 0 )
 					v81 = 0;
 				rand();
-				v21->uAttributes &= 0xFBFFFF;
+				pActor->uAttributes &= 0xFFFBFFFF;
 				if ( v81 < 5120 )
 				{
-					v45 = stru_50C198.special_ability_use_check(v21, actor_id);
+					v45 = stru_50C198.special_ability_use_check(pActor, actor_id);
 					if ( v45 == 0 )
 					{
-						if ( v21->pMonsterInfo.uMissleAttack1Type )
+						if ( pActor->pMonsterInfo.uMissleAttack1Type )
 						{
-							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
+							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
-								Actor::MissileAttack1(actor_id, target_pid, &pDir);
+								Actor::AI_MissileAttack1(actor_id, target_pid, &pDir);
 							}
-							else if ( v21->pMonsterInfo.uMovementType == 5 )
+							else if ( pActor->pMonsterInfo.uMovementType == 5 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								if ( v80 * 307.2 > (double)v81 )
 								{
 									v64 = (signed __int64)v47;
@@ -14886,7 +14943,7 @@
 								}
 								else
 								{
-									Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+									Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 								}
 							}
 						}
@@ -14896,21 +14953,21 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( v21->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == 5 )
 									{
-										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
 										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
 										//monsters
-										Actor::Pursue3(actor_id, target_pid, 0, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir);
 									}
 								}
-								else if ( v21->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == 5 )
 								{
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
 									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
@@ -14920,19 +14977,19 @@
 									//monsters
 									//guard after player runs away
 									// follow player
-									Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
-							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
 								//monsters
-								Actor::MeleeAttack(actor_id, target_pid, &pDir);
+								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
@@ -14940,28 +14997,28 @@
 					else if ( v45 == 2 || v45 == 3 )
 					{
 						if ( v45 == 2 )
-							v46 = v21->pMonsterInfo.uSpell1ID;
+							v46 = pActor->pMonsterInfo.uSpell1ID;
 						else
-							v46 = v21->pMonsterInfo.uSpell2ID;
+							v46 = pActor->pMonsterInfo.uSpell2ID;
 						if ( v46 )
 						{
-							if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 )
+							if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
 							{
 								if ( v45 == 2 )
-									Actor::SpellAttack1(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack1(actor_id, target_pid, &pDir);
 								else
-									Actor::SpellAttack2(actor_id, target_pid, &pDir);
+									Actor::AI_SpellAttack2(actor_id, target_pid, &pDir);
 							}
-							else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 )
+							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 							}
 						}
 						else
@@ -14970,130 +15027,130 @@
 							{
 								if ( v81 >= 1024 )
 								{
-									if ( v21->pMonsterInfo.uMovementType == 5 )
+									if ( pActor->pMonsterInfo.uMovementType == 5 )
 									{
-										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 										v64 = (signed __int64)v47;
 										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 									}
 									else
 									{
-										Actor::Pursue3(actor_id, target_pid, 256, &pDir);
+										Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 									}
 								}
-								else if ( v21->pMonsterInfo.uMovementType == 5 )
+								else if ( pActor->pMonsterInfo.uMovementType == 5 )
 								{
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 									v64 = (signed __int64)v47;
 									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 								}
 								else
 								{
 									v70 = (signed __int64)v80 * 307.2;
-									Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+									Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 								}
 							}
-							else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								v64 = (signed __int64)v47;
 								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 							}
 							else
 							{
-								Actor::MeleeAttack(actor_id, target_pid, &pDir);
+								Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 							}
 						}
 						continue;
 					}
 				}
 			}
-
-			if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
+			
+			if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
 			{
-				if ( !v21->pMonsterInfo.uMovementType )
+				if ( !pActor->pMonsterInfo.uMovementType )
 				{
-					Actor::_4032B2(actor_id, 4, 1024, 0);
+					Actor::AI_4032B2(actor_id, 4, 1024, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 1 )
+				else if ( pActor->pMonsterInfo.uMovementType == 1 )
 				{
-					Actor::_4032B2(actor_id, 4, 2560, 0);
+					Actor::AI_4032B2(actor_id, 4, 2560, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 2 )
+				else if ( pActor->pMonsterInfo.uMovementType == 2 )
 				{
-					Actor::_4032B2(actor_id, 4, 5120, 0);
+					Actor::AI_4032B2(actor_id, 4, 5120, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 4 )
+				else if ( pActor->pMonsterInfo.uMovementType == 4 )
 				{
-					Actor::_4032B2(actor_id, 4, 10240, 0);
+					Actor::AI_4032B2(actor_id, 4, 10240, 0);
 				}
-				else if ( v21->pMonsterInfo.uMovementType == 5 )
+				else if ( pActor->pMonsterInfo.uMovementType == 5 )
 				{
 					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
-					v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					memcpy(&v74, v57, sizeof(v74));
 					memcpy(&pDir, &v74, sizeof(pDir));
 					v64 = (signed __int64)v58;
 					Actor::AI_Stand(actor_id, 4, v64, &pDir);
 				}				
 			}
-			else if ( !v21->pMonsterInfo.uMissleAttack2Type )
+			else if ( !pActor->pMonsterInfo.uMissleAttack2Type )
 			{
 				if ( (double)v81 >= v80 * 307.2 )
 				{
 					if ( v81 >= 1024 )
 					{
-						if ( v21->pMonsterInfo.uMovementType == 5 )
+						if ( pActor->pMonsterInfo.uMovementType == 5 )
 						{
-							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 							v64 = (signed __int64)v47;
 							Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 						}
 						else
 						{
-							Actor::Pursue3(actor_id, target_pid, 256, &pDir);
+							Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
 						}
 					}
-					else if ( v21->pMonsterInfo.uMovementType == 5 )
+					else if ( pActor->pMonsterInfo.uMovementType == 5 )
 					{
-						v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+						v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 						v64 = (signed __int64)v47;
 						Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 					}
 					else
 					{
 						v70 = (signed __int64)v80 * 307.2;
-						Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70);
+						Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70);
 					}
 				}
-				else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+				else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 				{
-					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					v64 = (signed __int64)v47;
 					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::MeleeAttack(actor_id, target_pid, &pDir);
+					Actor::AI_MeleeAttack(actor_id, target_pid, &pDir);
 				}
 			}
-			else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 )
+			else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 			{
-				v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-				if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 )
+				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 )
 				{
 					v64 = (signed __int64)v47;
 					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
 				}
 				else
 				{
-					Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+					Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
 				}
 			}
 			else
 			{
-				Actor::MissileAttack2(actor_id, target_pid, &pDir);
-			}
+				Actor::AI_MissileAttack2(actor_id, target_pid, &pDir);
+			}		
 		}
 	}
 }
--- a/mm7_5.cpp	Fri May 24 23:33:50 2013 +0600
+++ b/mm7_5.cpp	Fri May 24 23:34:00 2013 +0600
@@ -4672,7 +4672,7 @@
   }
   if ( pMonster->sCurrentHP > 0 )
   {
-    Actor::Stun(uActorID_Monster_, a1, 0);
+    Actor::AI_Stun(uActorID_Monster_, a1, 0);
     Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
     if ( bShowDamage )
     {
@@ -5007,7 +5007,7 @@
             {
               if ( v7->sCurrentHP >= 1 )
               {
-                Actor::Stun(uActorID, PID(OBJECT_Player,a4), 0);
+                Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
                 Actor::AggroSurroundingPeasants(uActorID, 1);
               }
               else
@@ -5193,7 +5193,7 @@
                   {
                     if ( v44->sCurrentHP >= 1 )
                     {
-                      Actor::Stun(uActorID, PID(OBJECT_Player,a4), 0);
+                      Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
                       Actor::AggroSurroundingPeasants(uActorID, 1);
                     }
                     else
@@ -5459,7 +5459,7 @@
         if ( v7 )
         {
           if ( pActor->sCurrentHP > 0 )
-            Actor::Stun(uActorIDa, a2, 0);
+            Actor::AI_Stun(uActorIDa, a2, 0);
           else
             Actor::Die(uActorIDa);
           a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP;
@@ -5478,7 +5478,7 @@
         }
         else
         {
-          Actor::Stun(uActorIDa, a2, 0);
+          Actor::AI_Stun(uActorIDa, a2, 0);
         }
       }
     }
@@ -5567,7 +5567,7 @@
               if ( v14 )
               {
                 if ( v7->sCurrentHP > 0 )
-                  Actor::Stun(uActorID, v17, 0);
+                  Actor::AI_Stun(uActorID, v17, 0);
                 else
                   Actor::Die(uActorID);
                 Actor::AggroSurroundingPeasants(uActorID, 0);
@@ -5587,7 +5587,7 @@
               }
               else
               {
-                Actor::Stun(uActorID, v17, 0);
+                Actor::AI_Stun(uActorID, v17, 0);
               }
               return;
             }
@@ -6884,7 +6884,7 @@
                   v22 = 2;
                   v17 = v5->pMonsterInfo.uSpell1ID;
                 }
-                Actor::SpellAttack(v4, &a4, v17, v22, v24);
+                Actor::AI_SpellAttack(v4, &a4, v17, v22, v24);
 LABEL_25:
                 v16 = a2a;
                 v23 = &a4;
@@ -6900,7 +6900,7 @@
               v18 = v5->pMonsterInfo.uMissleAttack1Type;
               v25 = 0;
             }
-            Actor::RangedAttack(v4, &a4, v18, v25);
+            Actor::AI_RangedAttack(v4, &a4, v18, v25);
             goto LABEL_25;
           }
         }
@@ -7015,7 +7015,7 @@
         {
           if ( v5->pMonsterInfo.uMissleAttack2Type )
           {
-            Actor::MissileAttack2(v13, v22, &v18);
+            Actor::AI_MissileAttack2(v13, v22, &v18);
             goto LABEL_43;
           }
         }
@@ -7030,16 +7030,16 @@
             if ( v15 )
             {
               if ( v14 == 2 )
-                Actor::SpellAttack1(v13, v22, &v18);
+                Actor::AI_SpellAttack1(v13, v22, &v18);
               else
-                Actor::SpellAttack2(v13, v22, &v18);
+                Actor::AI_SpellAttack2(v13, v22, &v18);
               goto LABEL_43;
             }
             goto LABEL_44;
           }
           if ( v5->pMonsterInfo.uMissleAttack1Type )
           {
-            Actor::MissileAttack1(v13, v22, &v18);
+            Actor::AI_MissileAttack1(v13, v22, &v18);
 LABEL_43:
             //v3 = v21;
             v21->field_C = 1;
@@ -7052,7 +7052,7 @@
 LABEL_44:
         if ( (double)(signed int)v20 < 307.2 )
         {
-          Actor::MeleeAttack(v13, v22, &v18);
+          Actor::AI_MeleeAttack(v13, v22, &v18);
           //v3 = v21;
           v21->field_C = 3;
           goto LABEL_48;
@@ -7331,12 +7331,12 @@
   {
     if ( (signed int)v11 < 10240 )
     {
-      Actor::Flee(uActorID, a2a, 0, &pDir);
+      Actor::AI_Flee(uActorID, a2a, 0, &pDir);
       v29->field_C = 4;
       v29->uActionLength = actor->uCurrentActionLength;
       return 1;
     }
-    Actor::_4032B2(uActorID, a2a, 1024, 0);
+    Actor::AI_4032B2(uActorID, a2a, 1024, 0);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
     return 1;
@@ -7354,7 +7354,7 @@
         v29->uActionLength = actor->uCurrentActionLength;
         return 1;
       }
-      Actor::Flee(uActorID, a2a, 32, 0);
+      Actor::AI_Flee(uActorID, a2a, 32, 0);
       v29->field_C = 4;
       v29->uActionLength = actor->uCurrentActionLength;
       return 1;
@@ -7373,7 +7373,7 @@
           v29->uActionLength = actor->uCurrentActionLength;
           return 1;
         }
-        Actor::Flee(uActorID, a2a, 32, 0);
+        Actor::AI_Flee(uActorID, a2a, 32, 0);
         v29->field_C = 4;
         v29->uActionLength = actor->uCurrentActionLength;
         return 1;
@@ -7394,7 +7394,7 @@
           v29->uActionLength = actor->uCurrentActionLength;
           return 1;
         }
-        Actor::Flee(uActorID, a2a, 32, 0);
+        Actor::AI_Flee(uActorID, a2a, 32, 0);
         v29->field_C = 4;
         v29->uActionLength = actor->uCurrentActionLength;
         return 1;
@@ -7408,9 +7408,9 @@
   if ( (signed int)v11 < 5120 )
   {
     if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 )
-      Actor::Pursue1(uActorID, a2a, uActorID, 32, &pDir);
+      Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir);
     else
-      Actor::Pursue2(uActorID, a2a, 32, &pDir, 307);
+      Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
      return 1;
@@ -7418,28 +7418,28 @@
 LABEL_46:
   if ( !actor->pMonsterInfo.uMovementType )
   {
-    Actor::_4032B2(uActorID, a2a, 1024, 32);
+    Actor::AI_4032B2(uActorID, a2a, 1024, 32);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
     return 1;
   }
   if ( actor->pMonsterInfo.uMovementType == 1 )
   {
-    Actor::_4032B2(uActorID, a2a, 2560, 32);
+    Actor::AI_4032B2(uActorID, a2a, 2560, 32);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
     return 1;
   }
   if ( actor->pMonsterInfo.uMovementType == 2 )
   {
-    Actor::_4032B2(uActorID, a2a, 5120, 32);
+    Actor::AI_4032B2(uActorID, a2a, 5120, 32);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
     return 1;
   }
   if ( actor->pMonsterInfo.uMovementType == 4 )
   {
-    Actor::_4032B2(uActorID, a2a, 10240, 32);
+    Actor::AI_4032B2(uActorID, a2a, 10240, 32);
     v29->field_C = 2;
     v29->uActionLength = actor->uCurrentActionLength;
     return 1;
--- a/mm7_data.h	Fri May 24 23:33:50 2013 +0600
+++ b/mm7_data.h	Fri May 24 23:34:00 2013 +0600
@@ -1425,7 +1425,7 @@
 int __cdecl j_SetSomeItemsNames();
 
 
-unsigned int SkillToMastery(unsigned int skill_value);
+int SkillToMastery(unsigned int skill_value);
 unsigned int __fastcall GetSpellColor(signed int a1);
 void *__thiscall unknown_vdtor_6(void *_this, bool a2);
 unsigned short * MakeScreenshot(signed int width, signed int height);