changeset 827:085eb19b7ffd

mr.Malvik
author Ritor1
date Wed, 27 Mar 2013 01:39:54 +0600
parents 1133e34a7560
children d5b1870df3ab 3233927402e5
files Events.cpp GUIWindow.cpp UIHouses.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 8 files changed, 926 insertions(+), 959 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/Events.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -197,11 +197,11 @@
 	LevelDecoration *v26; // eax@55
 	int v27; // eax@57
 	int v28; // ecx@57
-	int v29; // edx@58
-	int v30; // eax@58
-	int v31; // ecx@58
-	int v32; // esi@58
-	NPCData *v33; // ecx@58
+	//int v29; // edx@58
+	int pEventID; // eax@58
+	int pNPC_ID; // ecx@58
+	int pIndex; // esi@58
+	NPCData *pNPC; // ecx@58
 	int v34; // esi@59
 	int v35; // esi@60
 	int v36; // esi@61
@@ -571,82 +571,49 @@
 				//v6 = v123;
 				//v7 = "";
 				break;
-			case EVENT_SetNPCTopic:
-				{
-			
-				v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
-				v30 = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8);
-				v31 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
-				v32 = _evt->v9;
-				v33 = &pNPCStats->pNewNPCData[v31];
-				if ( v32 )
-					{
-					v34 = v32 - 1;
-					if ( v34 )
-						{
-						v35 = v34 - 1;
-						if ( v35 )
-							{
-							v36 = v35 - 1;
-							if ( v36 )
-								{
-								v37 = v36 - 1;
-								if ( v37 )
-									{
-									if ( v37 == 1 )
-										v33->evt_F = v30;
-									}
-								else
-									{
-									v33->evt_E = v30;
-									}
-								}
-							else
-								{
-								v33->evt_D = v30;
-								}
-							}
-						else
-							{
-							v33->evt_C = v30;
-							}
-						}
-					else
-						{
-						v33->evt_B = v30;
-						}
-					}
-				else
-					{
-					v33->evt_A = v30;
-					}
-				if ( v29 == 8 )
-					{
-					if ( v30 == 78 )
-						{
-						sub_4BD8B5();
-						window_SpeakInHouse->Release();
-						pParty->uFlags &= ~2;
-						if ( EnterHouse(HOUSE_DARK_GUILD_PIT) )
-							{
-							pAudioPlayer->StopChannels(-1, -1);
-							window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
-							window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-							window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-							window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-							window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
-							window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
-							ptr_F8B1E8 = pNPCTopics[90].pText;
-							}
-						}
-					}
-				++curr_seq_num;
-				}
-				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
-				break;
+            case EVENT_SetNPCTopic:
+            {
+              //v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+              pEventID = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8);
+              pNPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+              pIndex = _evt->v9;
+              pNPC = &pNPCStats->pNewNPCData[pNPC_ID];
+              if ( pIndex == 0 )
+                pNPC->evt_A = pEventID;
+              if ( pIndex == 1 )
+                pNPC->evt_B = pEventID;
+              if ( pIndex == 2 )
+                pNPC->evt_C = pEventID;
+              if ( pIndex == 3 )
+                pNPC->evt_D = pEventID;
+              if ( pIndex == 4 )
+                pNPC->evt_E = pEventID;
+              if ( pIndex == 5 )
+                pNPC->evt_F = pEventID;
+              if ( pNPC_ID == 8 )
+              {
+                if ( pEventID == 78 )
+                {
+                  sub_4BD8B5();
+                  window_SpeakInHouse->Release();
+                  pParty->uFlags &= ~2;
+                  if ( EnterHouse(HOUSE_DARK_GUILD_PIT) )
+                  {
+                    pAudioPlayer->StopChannels(-1, -1);
+                    window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
+                    window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+                    window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+                    window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+                    window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+                    window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+                    current_npc_text = pNPCTopics[90].pText;
+                  }
+                }
+              }
+              ++curr_seq_num;
+            }
+            v4 = v124;
+            break;
 			case EVENT_NPCSetItem:
 				sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
 				++curr_seq_num;
@@ -1180,7 +1147,7 @@
 					{
 					if ( activeLevelDecoration == (LevelDecoration*)1 )
 						{
-						ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
+						current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
 						}
 					if ( canShowMessages == 1 )
 						{
@@ -1209,7 +1176,7 @@
 					{
 					v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92];
 					byte_5B0938[0] = 0;
-					ptr_F8B1E8 = v93;
+					current_npc_text = v93;
 					}
 				else
 					{
--- a/GUIWindow.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/GUIWindow.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -1075,15 +1075,15 @@
       JailDialog();
       goto LABEL_58;
     }
-    if ( ptr_F8B1E8 )
+    if ( current_npc_text )
     {
       w.uFrameWidth = 458;
       w.uFrameZ = 457;
-      v5 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0);
+      v5 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0);
       v6 = v5 + 7;
       pRenderer->_4A6A68(8, 352 - (v5 + 7), &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (v5 + 7));
       pRenderer->DrawTextureIndexed(8u, 347 - v6, pTexture_591428);
-      v7 = FitTextInAWindow(ptr_F8B1E8, pFontArrus, &w, 0xDu, 0);
+      v7 = FitTextInAWindow(current_npc_text, pFontArrus, &w, 0xDu, 0);
       window_SpeakInHouse->DrawText(pFontArrus, 13, 354 - v6, 0, v7, 0, 0, 0);
     }
     v8 = 0;
@@ -1797,7 +1797,7 @@
             num_menu_buttons = 0;
             v11 = LOBYTE(pFontArrus->uFontHeight) - 3;
             speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
-            if ( sub_445C8B(sDialogue_SpeakingActorNPC_ID) == 1 )
+            if ( GetGreetType(sDialogue_SpeakingActorNPC_ID) == 1 )//QuestsNPC_greet
             {
               if ( speakingNPC->joins )
               {
--- a/UIHouses.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/UIHouses.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -484,7 +484,7 @@
 		}
 	uOpenTime = p2DEvents[uHouseID - 1].uOpenTime;
 	uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
-	ptr_F8B1E8 = 0;
+	current_npc_text = 0;
 	dword_F8B1E4 = 0;
 	dword_F8B1F4 = 0;
 	memset(byte_F8B1F0, 0, 4);
@@ -2147,7 +2147,7 @@
 		v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
 		sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
 		sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
-		ptr_F8B1E8 = pTmpBuf2;
+		current_npc_text = pTmpBuf2;
 		memcpy(&a1, pDialogueWindow, sizeof(a1));
 		w.uFrameWidth = 458;
 		w.uFrameZ = 457;
@@ -2156,13 +2156,13 @@
 		if ( 352 - v9 < 8 )
 		{
 			pOutString = pFontCreate;
-			v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
+			v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
 		}
 
 		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
 		pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9);
 		pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
-		v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
+		v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 0xDu, 0);
 		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
 		break;
 		}
--- a/mm7_2.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/mm7_2.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -827,7 +827,7 @@
   pKeyActionMap->_459ED1(3);
   pKeyActionMap->ResetKeys();
   activeLevelDecoration = NULL;
-  ptr_F8B1E8 = 0;
+  current_npc_text = 0;
   if ( pDialogueNPCCount )
   {
     v0 = dialog_menu_id;
--- a/mm7_3.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/mm7_3.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -12426,8 +12426,8 @@
 
   v0 = pFontArrus;
   pFont = pFontArrus;
-  if ( ptr_F8B1E8 && !byte_5B0938[0] )
-    strcpy(byte_5B0938, ptr_F8B1E8);
+  if ( current_npc_text && !byte_5B0938[0] )
+    strcpy(byte_5B0938, current_npc_text);
   v5.uFrameWidth = game_viewport_width;
   v5.uFrameZ = 452;
   v1 = pFontArrus->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7;
@@ -12540,7 +12540,7 @@
 void __cdecl DrawDialogueUI()
 {
   NPCData *pNPC; // ebx@2
-  int v1; // eax@2
+  int pGreetType; // eax@2
   unsigned __int16 v2; // di@2
   //unsigned int v3; // eax@2
   char *v4; // esi@3
@@ -12591,7 +12591,7 @@
     return;
   memcpy(&v51, pDialogueWindow, sizeof(v51));
   pNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
-  v1 = sub_445C8B(sDialogue_SpeakingActorNPC_ID);
+  pGreetType = GetGreetType(sDialogue_SpeakingActorNPC_ID);
   v51.uFrameWidth -= 10;
   v51.uFrameZ -= 10;
   //v54 = v1;
@@ -12655,9 +12655,9 @@
     default:
       if (uDialogueType > DIALOGUE_18 && uDialogueType < DIALOGUE_23 && !byte_5B0938[0])
       {
-        pInString = (char *)ptr_F8B1E8;
-      }
-      else if (v1 == 1)//QuestNPCDialogue
+        pInString = (char *)current_npc_text;
+      }
+      else if (pGreetType == 1)//QuestNPC_greet
       {
         if (pNPC->greet)
         {
@@ -12667,7 +12667,7 @@
             pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1;
         }
       }
-      else if (v1 == 2)//HiredNPCDialogue
+      else if (pGreetType == 2)//HiredNPC_greet
       {
         auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1;
 
@@ -12891,7 +12891,7 @@
 }
 
 //----- (00445C8B) --------------------------------------------------------
-int __fastcall sub_445C8B(signed int a1)
+int __fastcall GetGreetType(signed int SpeakingNPC_ID)
 {
   signed int v1; // ebx@1
   int v3; // edi@6
@@ -12902,13 +12902,13 @@
   NPCData *v8; // esi@11
 
   v1 = 0;
-  if ( a1 >= 0 )
-  {
-    if ( a1 < 5000 )
-      return 1;
-    return 2;
-  }
-  if ( a1 >= 5000 )
+  if ( SpeakingNPC_ID >= 0 )
+  {
+    if ( SpeakingNPC_ID < 5000 )
+      return 1;//QuestNPC_greet
+    return 2;//HiredNPC_greet
+  }
+  if ( SpeakingNPC_ID >= 5000 )
     return 2;
   v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
   v4 = 0;
@@ -12938,7 +12938,7 @@
     }
     while ( v1 < (signed int)pNPCStats->uNumNewNPCs );
   }
-  return ((unsigned __int8)pTmpBuf[v3] < 2u) + 1;
+  return ((unsigned __int8)pTmpBuf[v3] < 2) + 1;
 }
 
 //----- (0044603D) --------------------------------------------------------
@@ -14931,834 +14931,834 @@
 // 4F75D8: using guessed type int ai_arrays_size;
 
 //----- (00401A91) --------------------------------------------------------
-void __cdecl UpdateActorAI()
-{
-	//unsigned int v0; // esi@4
-	int v1; // eax@7
-	int v2; // ecx@7
-	int v3; // eax@7
-	signed int v4; // edi@10
-	Actor *v5; // esi@12
-	signed int v6; // eax@14
-	__int16 v7; // cx@14
-	Player **v8; // esi@20
-	Player *pPlayer; // ecx@21
-	//Actor *pActor; // esi@34
-	//__int16 v11; // ax@34
-	//unsigned int v12; // eax@47
-	//signed int v13; // edi@47
-	//SpellBuff *v14; // ebx@47
-	//unsigned int v15; // edi@67
-	//char *v16; // eax@67
-	//unsigned int v17; // edx@67
-	//unsigned int v18; // ecx@67
-	//unsigned __int16 v19; // ax@72
-	//int *v20; // esi@80
-	Actor *v21; // ebx@80
-	unsigned __int16 v22; // ax@86
-	//signed int v23; // eax@94
-	//unsigned int v24; // eax@102
-	signed int v25; // edi@102
-	SpellBuff *v26; // esi@102
-	unsigned int v27; // ecx@123
-	unsigned int v28; // eax@123
-	unsigned int v29; // eax@127
-	AIDirection *v30; // eax@129
-	unsigned __int16 v31; // ax@132
-	unsigned int v32; // esi@142
-	int v33; // eax@144
-	int v34; // eax@147
-	char v35; // al@150
-	unsigned int v36; // edi@152
-	signed int v37; // eax@154
-	unsigned __int8 v38; // sf@158
-	unsigned __int8 v39; // of@158
-	signed int v40; // edx@166
-	unsigned int v41; // ecx@166
-	double v42; // st7@176
-	double v43; // st6@176
-	bool v44; // eax@189
-	bool v45; // eax@192
-	unsigned __int8 v46; // cl@197
-	double v47; // st7@206
-	double v48; // st7@207
-	char v49; // zf@208
-	char v50; // zf@214
-	signed int v51; // edx@219
-	unsigned int v52; // ecx@219
-	__int16 v53; // fps@224
-	unsigned __int8 v54; // c0@224
-	unsigned __int8 v55; // c3@224
-	double v56; // st7@226
-	AIDirection *v57; // eax@246
-	double v58; // st7@246
-	signed int v59; // [sp-18h] [bp-C8h]@213
-	int v60; // [sp-14h] [bp-C4h]@144
-	int v61; // [sp-14h] [bp-C4h]@168
-	AIDirection *v62; // [sp-14h] [bp-C4h]@213
-	signed int v63; // [sp-14h] [bp-C4h]@216
-	unsigned int v64; // [sp-14h] [bp-C4h]@219
-	unsigned int v65; // [sp-10h] [bp-C0h]@144
-	char v66; // [sp-10h] [bp-C0h]@147
-	AIDirection *v67; // [sp-10h] [bp-C0h]@167
-	int v68; // [sp-10h] [bp-C0h]@168
-	AIDirection *v69; // [sp-10h] [bp-C0h]@206
-	int v70; // [sp-10h] [bp-C0h]@213
-	AIDirection *v71; // [sp-10h] [bp-C0h]@216
-	AIDirection v72; // [sp+0h] [bp-B0h]@246
-	AIDirection a3; // [sp+1Ch] [bp-94h]@129
-	AIDirection v74; // [sp+38h] [bp-78h]@246
-	AIDirection v75; // [sp+54h] [bp-5Ch]@129
-	int v76; // [sp+70h] [bp-40h]@83
-	signed int a1; // [sp+74h] [bp-3Ch]@129
-	int v78; // [sp+78h] [bp-38h]@79
-	AIDirection pDir; // [sp+7Ch] [bp-34h]@129
-	float v80; // [sp+98h] [bp-18h]@33
-	int v81; // [sp+9Ch] [bp-14h]@100
-	int v82; // [sp+A0h] [bp-10h]@45
-	//unsigned int uActorID; // [sp+A4h] [bp-Ch]@32
-	unsigned int v84; // [sp+A8h] [bp-8h]@11
-	signed int a2; // [sp+ACh] [bp-4h]@83
-	
-	if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-	MakeActorAIList_ODM();
-	else
-	MakeActorAIList_BLV();
-	
-	//v0 = 0;
-	if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 )
-	{
-		if ( pParty->armageddon_timer > 417 )
-		{
-			pParty->armageddon_timer = 0;
-		}
-		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->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 )
-				{
-					v5 = pActors;//[0].sCurrentHP;
-					do
-					{
-						if ( v5->CanAct() )
-						{
-							v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4);
-							v7 = v5->sCurrentHP - v6;
-							v5->sCurrentHP = v7;
-							if ( v6 )
-							{
-								if ( v7 >= 0 )
-								{
-									Actor::_4030AD(v84, 4, 0);
-								}
-								else
-								{
-									Actor::Die(v84);
-									if ( v5->pMonsterInfo.uExp )
-									GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp);
-								}
-							}
-						}
-						++v84;
-						++v5;
-					}
-					while ( (signed int)v84 < (signed int)uNumActors );
-				}
-				v8 = &pPlayers[1];
-				do
-				{
-					pPlayer = *v8;
-					if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
-					pPlayer->ReceiveDamage(v4, 5);
-					++v8;
-				}
-				while ( (signed int)v8 <= (signed int)&pPlayers[4] );
-				//v0 = 0;
-			}
-			if (pTurnEngine->field_1C)
-			--pTurnEngine->field_1C;
-		}
-	}
-	
-	if (pParty->bTurnBasedModeOn)
-	{
-		pTurnEngine->_405E14();
-		return;
-	}
-	
-	
-	//uActorID = v0;
-	for (uint i = 0; i < uNumActors; ++i)
-	{
-		auto actor = pActors + i;
-		//LODWORD(v80) = (int)(char *)pActors + 176; // uAIState
-		//do
-		//{
-			//pActor = (Actor *)(LODWORD(v80) - 176);
-			//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)
-			continue;
-			
-			if (!actor->sCurrentHP && actor->uAIState != Dying)
-			Actor::Die(i);
-			
-			//v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
-			//v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1;
-			//v12 = 0;
-			//v13 = 0;
-			//v14 = (SpellBuff *)(LODWORD(v80) + 36);
-			for (uint j = 0; j < 22; ++j)
-			{
-				if (j != 10)
-				actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
-			}
-			/*do
-			{
-				if ( v13 != 10 )
-				{
-					v14->_4585CA(pParty->uTimePlayed);
-					v12 = 0;
-				}
-				++v13;
-				++v14;
-			}
-			while ( v13 < 22 );*/
-			if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime)
-			//&& 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 (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime)
-			actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-			else
-			actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType;
-			
-			if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime ||
-			actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime)
-			continue;
-			
-			//v15 = pMiscTimer->uTimeElapsed;
-			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
-			//v17 = pActor->uCurrentActionTime;
-			//v18 = pActor->pMonsterInfo.uRecoveryTime;
-			if (actor->pMonsterInfo.uRecoveryTime)
-			{
-				if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
-				actor->pMonsterInfo.uRecoveryTime = 0;
-				else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
-			}
-			
-			actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
-			if (actor->uCurrentActionTime < actor->uCurrentActionLength)
-			continue;
-			
-			//v19 = actor->uAIState;
-			if (actor->uAIState == Dying)
-			actor->uAIState = Dead;
-			else
-			{
-				if (actor->uAIState != Summoned)
-				{
-					Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr);
-					continue;
-				}
-				actor->uAIState = Standing;
-			}
-			
-			actor->uCurrentActionTime = 0;
-			actor->uCurrentActionLength = 0;
-			actor->UpdateAnimation();
-			//LABEL_78:
-			//++uActorID;
-			//LODWORD(v80) += 836;
-		//}
-		//while ( (signed int)uActorID < (signed int)uNumActors );
-	}
-	
-	
-	v78 = 0;
-	int actor_id = -1;
-	if ( ai_arrays_size > 0 )
-	{
-		//while ( 1 )
-		for(v78 = 0; v78 < ai_arrays_size; ++v78)
-		{
-			actor_id = ai_near_actors_ids[v78];
-			assert(actor_id < uNumActors);
-			
-			//v20 = &ai_near_actors_targets_pid[actor_id];
-			v21 = &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;
-			a2 = ai_near_actors_targets_pid[actor_id];
-			v76 = a2 & 7;
-			if ( (a2 & 7) == OBJECT_Actor)
-			v80 = 0.5;
-			else
-			v80 = 1.0;
-			v22 = v21->uAIState;
-			if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned)
-			{
-				continue;
-			}
-			else
-			{
-				if ( !v21->sCurrentHP )
-				Actor::Die(actor_id);
-				v25 = 0;
-				v26 = v21->pActorBuffs;
-				do
-				{
-					if ( v25 != 10 )
-					{
-						v26->_4585CA(pParty->uTimePlayed);
-						//v24 = 0;
-					}
-					++v25;
-					++v26;
-				}
-				while ( v25 < 22 );
-				if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0
-				&& SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0
-				&& (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0
-				|| LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) )
-				v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
-				if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 )
-				{
-					v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-					if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 )
-					{
-						if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0
-						|| LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 )
-						v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
-					}
-				}
-				if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0
-				&& SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0
-				&& (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0
-				|| LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) )
-				{
-					v21->uAIState = Removed;
-					continue;
-				}
-				else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )
-				{
-					continue;
-				}
-				else
-				{
-					v27 = pMiscTimer->uTimeElapsed;
-					v28 = v21->pMonsterInfo.uRecoveryTime;
-					v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
-					if ( (signed int)v28 > 0 )
-					v21->pMonsterInfo.uRecoveryTime = v28 - v27;
-					if ( v21->pMonsterInfo.uRecoveryTime< 0 )
-					v21->pMonsterInfo.uRecoveryTime = 0;
-					v29 = v21->uAttributes;
-					if ( !(v29 & 0x8000) )
-					v21->uAttributes = v29 | 0x8000;
-					a1 = 8 * actor_id | OBJECT_Actor;
-					v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0);
-					v49 = v21->pMonsterInfo.uHostilityType == 0;
-					memcpy(&v75, v30, sizeof(v75));
-					memcpy(&pDir, &v75, sizeof(pDir));
-					if ( !v49
-					&& (signed int)v21->pMonsterInfo.uRecoveryTime <= 0
-					&& v80 * 307.2 >= (double)(signed int)v75.uDistance
-					&& ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9)
-					|| v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 )
-					{
-						v32 = actor_id;
-					}
-					else
-					{
-						if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
-						{
-							continue;
-						}
-						else if ( v21->uAIState == 2 )
-						{
-							v32 = actor_id;
-							v35 = stru_50C198.special_ability_use_check(v21, actor_id);
-							stru_50FE08.Add(
-							a1,
-							5120,
-							v21->vPosition.x,
-							v21->vPosition.y,
-							v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
-							v35,
-							1
-							);
-						}
-						else if ( v21->uAIState == 3 )
-						{
-							v34 = v21->pMonsterInfo.uMissleAttack1Type;
-							v66 = 0;
-							v32 = actor_id;
-							Actor::_404874(actor_id, &pDir, v34, v66);
-						}
-						else if ( v21->uAIState == 12 )
-						{
-							v34 = v21->pMonsterInfo.uMissleAttack2Type;
-							v66 = 1;
-							v32 = actor_id;
-							Actor::_404874(actor_id, &pDir, v34, v66);
-						}
-						else
-						{
-							v32 = actor_id;
-							if ( v21->uAIState == 13 )
-							{
-								v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
-								v60 = 2;
-								v33 = v21->pMonsterInfo.uSpell1ID;
-								Actor::_404AC7(actor_id, &pDir, v33, v60, v65);
-							}
-							else if ( v21->uAIState == 18 )
-							{
-								v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
-								v60 = 3;
-								v33 = v21->pMonsterInfo.uSpell2ID;
-								Actor::_404AC7(actor_id, &pDir, v33, v60, v65);
-							}
-						}
-					}
-				}
-			}
-			v36 = v75.uDistance;
-			if ( !v21->pMonsterInfo.uHostilityType )
-			{
-				if ( v76 == 3 )
-				{
-					v36 = v75.uDistance;
-					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
-					+ (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3);
-				}
-				else
-				{
-					v37 = 4;
-				}
-				if ( v37 == 2 )
-				{
-					v39 = __OFSUB__(v36, 1024);
-					v38 = ((v36 - 1024) & 0x80000000u) != 0;
-				}
-				else if ( v37 == 3 )
-				{
-					v39 = __OFSUB__(v36, 2560);
-					v38 = ((v36 - 2560) & 0x80000000u) != 0;
-				}
-				else if ( v37 == 4 )
-				{
-					v39 = __OFSUB__(v36, 5120);
-					v38 = ((v36 - 5120) & 0x80000000u) != 0;
-				}
-				if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 )
-				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
-			}
-			if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
-			{
-				v40 = a2;
-				v41 = v32;
-				if ( (signed int)v36 >= 10240 )
-				{
-					v68 = 0;
-					v61 = 1024;
-					Actor::_4032B2(v41, v40, v61, v68);
-					continue;
-				}
-				v67 = &pDir;
-				Actor::_402968(v41, v40, 0, v67);
-				continue;
-			}
-			if ( v21->pMonsterInfo.uHostilityType == 4 && a2 )
-			{
-				if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 )
-				{
-					if ( v21->pMonsterInfo.uAIType == 1 )
-					{
-						v67 = &pDir;
-						if ( v21->pMonsterInfo.uMovementType != 5 )
-						{
-							v40 = a2;
-							v41 = v32;
-							Actor::_402968(v41, v40, 0, v67);
-							continue;
-						}
-						Actor::AI_Stand(
-						v32,
-						a2,
-						(signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),
-						&pDir);
-					}
-					else
-					{
-						if ( v21->pMonsterInfo.uAIType == 2 )
-						{
-							v84 = v21->sCurrentHP;
-							v42 = (double)(signed int)v84;
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
-						}
-						else
-						{
-							v84 = v21->sCurrentHP;
-							v42 = (double)(signed int)v84;
-							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
-						}
-						if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 )
-						if ( v43 > v42 && (signed int)v36 < 10240 )
-						{
-							v67 = &pDir;
-							v40 = a2;
-							v41 = v32;
-							Actor::_402968(v41, v40, 0, v67);
-							continue;
-						}
-					}
-				}
-				v81 = v36 - v21->uActorRadius;
-				if ( v76 == 3 )
-				v81 -= pActors[a2 >> 3].uActorRadius;
-				if ( v81 < 0 )
-				v81 = 0;
-				rand();
-				v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0;
-				v21->uAttributes &= 0xFBFFFF;
-				v82 = 0;
-				v49 = v21->pMonsterInfo.uMovementType == 5;
-				v84 = v44;
-				if ( v49 )
-				v82 = 1;
-				if ( v81 < 5120 )
-				{
-					v45 = stru_50C198.special_ability_use_check(v21, v32);
-					if ( !v45 )
-					{
-						if ( v21->pMonsterInfo.uMissleAttack1Type )
-						{
-							if ( v84 )
-							{
-								Actor::_403476(v32, a2, &pDir);
-								continue;
-								
-							}
-							if ( v82 )
-							{
-								v69 = &pDir;
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v51 = a2;
-								v64 = (signed __int64)v47;
-								v52 = v32;
-								Actor::AI_Stand(v52, v51, v64, v69);
-								continue;
-							}
-							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							//UNDEF(v53);
-							v69 = &pDir;
-							if ( !(v54 | v55) )
-							{
-								v51 = a2;
-								v64 = (signed __int64)v47;
-								v52 = v32;
-								Actor::AI_Stand(v52, v51, v64, v69);
-								continue;
-							}
-							Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
-							continue;
-						}
-						v56 = v80 * 307.2;
-						if ( (double)v81 >= v56 )
-						{
-							if ( v81 >= 1024 )
-							{
-								if ( v82 )
-								{
-									v69 = &pDir;
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v51 = a2;
-									v64 = (signed __int64)v47;
-									v52 = v32;
-									Actor::AI_Stand(v52, v51, v64, v69);
-									continue;
-								}
-								v71 = &pDir;
-								v63 = 0;
-								
-								Actor::_402686(v32, a2, v63, v71);
-								continue;
-							}
-							if ( v82 )
-							{
-								v69 = &pDir;
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v51 = a2;
-								v64 = (signed __int64)v47;
-								v52 = v32;
-								Actor::AI_Stand(v52, v51, v64, v69);
-								continue;
-							}
-							v70 = (signed __int64)v56;
-							v62 = &pDir;
-							v59 = 0;
-							Actor::_40281C(v32, a2, v59, v62, v70);
-							continue;
-						}
-						v49 = v84 == 0;
-						v69 = &pDir;
-						if ( v49 )
-						{
-							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							v51 = a2;
-							v64 = (signed __int64)v47;
-							v52 = v32;
-							Actor::AI_Stand(v52, v51, v64, v69);
-							continue;
-						}
-						Actor::_403C6C(v32, a2, &pDir);
-						continue;
-					}
-					if ( v45 != 1 )
-					{
-						if ( v45 > 1 && v45 <= 3 )
-						{
-							if ( v45 == 2 )
-							v46 = v21->pMonsterInfo.uSpell1ID;
-							else
-							v46 = v21->pMonsterInfo.uSpell2ID;
-							if ( v46 )
-							{
-								if ( v84 )
-								{
-									if ( v45 == 2 )
-									Actor::_403854(v32, a2, &pDir);
-									else
-									Actor::_403A60(v32, a2, &pDir);
-									continue;
-								}
-								if ( v80 * 307.2 > (double)v81 || v82 )
-								{
-									v69 = &pDir;
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v51 = a2;
-									v64 = (signed __int64)v47;
-									v52 = v32;
-									Actor::AI_Stand(v52, v51, v64, v69);
-									continue;
-									
-								}
-								v69 = &pDir;
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
-								continue;
-							}
-							v48 = v80 * 307.2;
-							if ( (double)v81 >= v48 )
-							{
-								if ( v81 >= 1024 )
-								{
-									v50 = v82 == 0;
-									if ( !v50 )
-									{
-										v69 = &pDir;
-										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										v51 = a2;
-										v64 = (signed __int64)v47;
-										v52 = v32;
-										Actor::AI_Stand(v52, v51, v64, v69);
-										continue;
-									}
-									v71 = &pDir;
-									v63 = 256;
-									Actor::_402686(v32, a2, v63, v71);
-									continue;
-									
-								}
-								if ( v82 )
-								{
-									v69 = &pDir;
-									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v51 = a2;
-									v64 = (signed __int64)v47;
-									v52 = v32;
-									Actor::AI_Stand(v52, v51, v64, v69);
-									continue;
-								}
-								v70 = (signed __int64)v48;
-								v62 = &pDir;
-								v59 = 0;
-								Actor::_40281C(v32, a2, v59, v62, v70);
-								continue;
-							}
-							v49 = v84 == 0;
-							v69 = &pDir;
-							if ( v49 )
-							{
-								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v51 = a2;
-								v64 = (signed __int64)v47;
-								v52 = v32;
-								Actor::AI_Stand(v52, v51, v64, v69);
-								continue;
-							}
-							Actor::_403C6C(v32, a2, &pDir);
-							continue;
-						}
-					}
-				}
-			}
-			if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 )
-			{
-				if ( !v21->pMonsterInfo.uMovementType )
-				{
-					v68 = 0;
-					v61 = 1024;
-					v41 = v32;
-					v40 = 4;
-					Actor::_4032B2(v41, v40, v61, v68);
-					continue;
-					
-				}
-				if ( v21->pMonsterInfo.uMovementType == 1 )
-				{
-					v68 = 0;
-					v61 = 2560;
-					v41 = v32;
-					v40 = 4;
-					Actor::_4032B2(v41, v40, v61, v68);
-					continue;
-				}
-				if ( v21->pMonsterInfo.uMovementType == 2 )
-				{
-					v68 = 0;
-					v61 = 5120;
-					v41 = v32;
-					v40 = 4;
-					Actor::_4032B2(v41, v40, v61, v68);
-					continue;
-				}
-				if ( v21->pMonsterInfo.uMovementType == 4 )
-				{
-					v68 = 0;
-					v61 = 10240;
-					v41 = v32;
-					v40 = 4;
-					Actor::_4032B2(v41, v40, v61, v68);
-					continue;
-				}
-				if ( v21->pMonsterInfo.uMovementType == 5 )
-				{
-					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
-					v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					memcpy(&v74, v57, sizeof(v74));
-					memcpy(&pDir, &v74, sizeof(pDir));
-					v69 = &pDir;
-					v52 = actor_id;
-					v64 = (signed __int64)v58;
-					v51 = 4;
-					Actor::AI_Stand(v52, v51, v64, v69);
-					continue;
-				}
-				continue;
-				
-			}
-			if ( !v21->pMonsterInfo.uMissleAttack2Type )
-			{
-				v56 = v80 * 307.2;
-				if ( (double)v81 >= v56 )
-				{
-					if ( v81 >= 1024 )
-					{
-						v50 = v82 == 0;
-						if ( !v50 )
-						{
-							v69 = &pDir;
-							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							v51 = a2;
-							v64 = (signed __int64)v47;
-							v52 = v32;
-							Actor::AI_Stand(v52, v51, v64, v69);
-							continue;
-						}
-						v71 = &pDir;
-						v63 = 256;
-						Actor::_402686(v32, a2, v63, v71);
-						continue;
-					}
-					if ( v82 )
-					{
-						v69 = &pDir;
-						v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-						v51 = a2;
-						v64 = (signed __int64)v47;
-						v52 = v32;
-						Actor::AI_Stand(v52, v51, v64, v69);
-						continue;
-					}
-					v70 = (signed __int64)v56;
-					v62 = &pDir;
-					v59 = 0;
-					Actor::_40281C(v32, a2, v59, v62, v70);
-					continue;
-					
-				}
-				v49 = v84 == 0;
-				v69 = &pDir;
-				if ( v49 )
-				{
-					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					v51 = a2;
-					v64 = (signed __int64)v47;
-					v52 = v32;
-					Actor::AI_Stand(v52, v51, v64, v69);
-					continue;
-				}
-				Actor::_403C6C(v32, a2, &pDir);
-				continue;
-			}
-			if ( !v84 )
-			{
-				if ( v82 )
-				{
-					v69 = &pDir;
-					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					v51 = a2;
-					v64 = (signed __int64)v47;
-					v52 = v32;
-					Actor::AI_Stand(v52, v51, v64, v69);
-					continue;
-				}
-				v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-				//UNDEF(v53);
-				v69 = &pDir;
-				if ( !(v54 | v55) )
-				{
-					v51 = a2;
-					v64 = (signed __int64)v47;
-					v52 = v32;
-					Actor::AI_Stand(v52, v51, v64, v69);
-					continue;
-				}
-				Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
-				continue;
-			}
-			Actor::_40368B(v32, a2, &pDir);
-		}
-	}
+void __cdecl UpdateActorAI()
+{
+	//unsigned int v0; // esi@4
+	int v1; // eax@7
+	int v2; // ecx@7
+	int v3; // eax@7
+	signed int v4; // edi@10
+	Actor *v5; // esi@12
+	signed int v6; // eax@14
+	__int16 v7; // cx@14
+	Player **v8; // esi@20
+	Player *pPlayer; // ecx@21
+	//Actor *pActor; // esi@34
+	//__int16 v11; // ax@34
+	//unsigned int v12; // eax@47
+	//signed int v13; // edi@47
+	//SpellBuff *v14; // ebx@47
+	//unsigned int v15; // edi@67
+	//char *v16; // eax@67
+	//unsigned int v17; // edx@67
+	//unsigned int v18; // ecx@67
+	//unsigned __int16 v19; // ax@72
+	//int *v20; // esi@80
+	Actor *v21; // ebx@80
+	unsigned __int16 v22; // ax@86
+	//signed int v23; // eax@94
+	//unsigned int v24; // eax@102
+	signed int v25; // edi@102
+	SpellBuff *v26; // esi@102
+	unsigned int v27; // ecx@123
+	unsigned int v28; // eax@123
+	unsigned int v29; // eax@127
+	AIDirection *v30; // eax@129
+	unsigned __int16 v31; // ax@132
+	unsigned int v32; // esi@142
+	int v33; // eax@144
+	int v34; // eax@147
+	char v35; // al@150
+	unsigned int v36; // edi@152
+	signed int v37; // eax@154
+	unsigned __int8 v38; // sf@158
+	unsigned __int8 v39; // of@158
+	signed int v40; // edx@166
+	unsigned int v41; // ecx@166
+	double v42; // st7@176
+	double v43; // st6@176
+	bool v44; // eax@189
+	bool v45; // eax@192
+	unsigned __int8 v46; // cl@197
+	double v47; // st7@206
+	double v48; // st7@207
+	char v49; // zf@208
+	char v50; // zf@214
+	signed int v51; // edx@219
+	unsigned int v52; // ecx@219
+	__int16 v53; // fps@224
+	unsigned __int8 v54; // c0@224
+	unsigned __int8 v55; // c3@224
+	double v56; // st7@226
+	AIDirection *v57; // eax@246
+	double v58; // st7@246
+	signed int v59; // [sp-18h] [bp-C8h]@213
+	int v60; // [sp-14h] [bp-C4h]@144
+	int v61; // [sp-14h] [bp-C4h]@168
+	AIDirection *v62; // [sp-14h] [bp-C4h]@213
+	signed int v63; // [sp-14h] [bp-C4h]@216
+	unsigned int v64; // [sp-14h] [bp-C4h]@219
+	unsigned int v65; // [sp-10h] [bp-C0h]@144
+	char v66; // [sp-10h] [bp-C0h]@147
+	AIDirection *v67; // [sp-10h] [bp-C0h]@167
+	int v68; // [sp-10h] [bp-C0h]@168
+	AIDirection *v69; // [sp-10h] [bp-C0h]@206
+	int v70; // [sp-10h] [bp-C0h]@213
+	AIDirection *v71; // [sp-10h] [bp-C0h]@216
+	AIDirection v72; // [sp+0h] [bp-B0h]@246
+	AIDirection a3; // [sp+1Ch] [bp-94h]@129
+	AIDirection v74; // [sp+38h] [bp-78h]@246
+	AIDirection v75; // [sp+54h] [bp-5Ch]@129
+	int v76; // [sp+70h] [bp-40h]@83
+	signed int a1; // [sp+74h] [bp-3Ch]@129
+	int v78; // [sp+78h] [bp-38h]@79
+	AIDirection pDir; // [sp+7Ch] [bp-34h]@129
+	float v80; // [sp+98h] [bp-18h]@33
+	int v81; // [sp+9Ch] [bp-14h]@100
+	int v82; // [sp+A0h] [bp-10h]@45
+	//unsigned int uActorID; // [sp+A4h] [bp-Ch]@32
+	unsigned int v84; // [sp+A8h] [bp-8h]@11
+	signed int a2; // [sp+ACh] [bp-4h]@83
+	
+	if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+	MakeActorAIList_ODM();
+	else
+	MakeActorAIList_BLV();
+	
+	//v0 = 0;
+	if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 )
+	{
+		if ( pParty->armageddon_timer > 417 )
+		{
+			pParty->armageddon_timer = 0;
+		}
+		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->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 )
+				{
+					v5 = pActors;//[0].sCurrentHP;
+					do
+					{
+						if ( v5->CanAct() )
+						{
+							v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4);
+							v7 = v5->sCurrentHP - v6;
+							v5->sCurrentHP = v7;
+							if ( v6 )
+							{
+								if ( v7 >= 0 )
+								{
+									Actor::_4030AD(v84, 4, 0);
+								}
+								else
+								{
+									Actor::Die(v84);
+									if ( v5->pMonsterInfo.uExp )
+									GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp);
+								}
+							}
+						}
+						++v84;
+						++v5;
+					}
+					while ( (signed int)v84 < (signed int)uNumActors );
+				}
+				v8 = &pPlayers[1];
+				do
+				{
+					pPlayer = *v8;
+					if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] )
+					pPlayer->ReceiveDamage(v4, 5);
+					++v8;
+				}
+				while ( (signed int)v8 <= (signed int)&pPlayers[4] );
+				//v0 = 0;
+			}
+			if (pTurnEngine->field_1C)
+			--pTurnEngine->field_1C;
+		}
+	}
+	
+	if (pParty->bTurnBasedModeOn)
+	{
+		pTurnEngine->_405E14();
+		return;
+	}
+	
+	
+	//uActorID = v0;
+	for (uint i = 0; i < uNumActors; ++i)
+	{
+		auto actor = pActors + i;
+		//LODWORD(v80) = (int)(char *)pActors + 176; // uAIState
+		//do
+		//{
+			//pActor = (Actor *)(LODWORD(v80) - 176);
+			//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)
+			continue;
+			
+			if (!actor->sCurrentHP && actor->uAIState != Dying)
+			Actor::Die(i);
+			
+			//v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1;
+			//v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1;
+			//v12 = 0;
+			//v13 = 0;
+			//v14 = (SpellBuff *)(LODWORD(v80) + 36);
+			for (uint j = 0; j < 22; ++j)
+			{
+				if (j != 10)
+				actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed);
+			}
+			/*do
+			{
+				if ( v13 != 10 )
+				{
+					v14->_4585CA(pParty->uTimePlayed);
+					v12 = 0;
+				}
+				++v13;
+				++v14;
+			}
+			while ( v13 < 22 );*/
+			if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime)
+			//&& 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 (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime)
+			actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+			else
+			actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType;
+			
+			if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime ||
+			actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime)
+			continue;
+			
+			//v15 = pMiscTimer->uTimeElapsed;
+			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
+			//v17 = pActor->uCurrentActionTime;
+			//v18 = pActor->pMonsterInfo.uRecoveryTime;
+			if (actor->pMonsterInfo.uRecoveryTime)
+			{
+				if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed)
+				actor->pMonsterInfo.uRecoveryTime = 0;
+				else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed;
+			}
+			
+			actor->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+			if (actor->uCurrentActionTime < actor->uCurrentActionLength)
+			continue;
+			
+			//v19 = actor->uAIState;
+			if (actor->uAIState == Dying)
+			actor->uAIState = Dead;
+			else
+			{
+				if (actor->uAIState != Summoned)
+				{
+					Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr);
+					continue;
+				}
+				actor->uAIState = Standing;
+			}
+			
+			actor->uCurrentActionTime = 0;
+			actor->uCurrentActionLength = 0;
+			actor->UpdateAnimation();
+			//LABEL_78:
+			//++uActorID;
+			//LODWORD(v80) += 836;
+		//}
+		//while ( (signed int)uActorID < (signed int)uNumActors );
+	}
+	
+	
+	v78 = 0;
+	int actor_id = -1;
+	if ( ai_arrays_size > 0 )
+	{
+		//while ( 1 )
+		for(v78 = 0; v78 < ai_arrays_size; ++v78)
+		{
+			actor_id = ai_near_actors_ids[v78];
+			assert(actor_id < uNumActors);
+			
+			//v20 = &ai_near_actors_targets_pid[actor_id];
+			v21 = &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;
+			a2 = ai_near_actors_targets_pid[actor_id];
+			v76 = a2 & 7;
+			if ( (a2 & 7) == OBJECT_Actor)
+			v80 = 0.5;
+			else
+			v80 = 1.0;
+			v22 = v21->uAIState;
+			if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned)
+			{
+				continue;
+			}
+			else
+			{
+				if ( !v21->sCurrentHP )
+				Actor::Die(actor_id);
+				v25 = 0;
+				v26 = v21->pActorBuffs;
+				do
+				{
+					if ( v25 != 10 )
+					{
+						v26->_4585CA(pParty->uTimePlayed);
+						//v24 = 0;
+					}
+					++v25;
+					++v26;
+				}
+				while ( v25 < 22 );
+				if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0
+				&& SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0
+				&& (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0
+				|| LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) )
+				v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
+				if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 )
+				{
+					v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+					if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 )
+					{
+						if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0
+						|| LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 )
+						v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType;
+					}
+				}
+				if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0
+				&& SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0
+				&& (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0
+				|| LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) )
+				{
+					v21->uAIState = Removed;
+					continue;
+				}
+				else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )
+				{
+					continue;
+				}
+				else
+				{
+					v27 = pMiscTimer->uTimeElapsed;
+					v28 = v21->pMonsterInfo.uRecoveryTime;
+					v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
+					if ( (signed int)v28 > 0 )
+					v21->pMonsterInfo.uRecoveryTime = v28 - v27;
+					if ( v21->pMonsterInfo.uRecoveryTime< 0 )
+					v21->pMonsterInfo.uRecoveryTime = 0;
+					v29 = v21->uAttributes;
+					if ( !(v29 & 0x8000) )
+					v21->uAttributes = v29 | 0x8000;
+					a1 = 8 * actor_id | OBJECT_Actor;
+					v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0);
+					v49 = v21->pMonsterInfo.uHostilityType == 0;
+					memcpy(&v75, v30, sizeof(v75));
+					memcpy(&pDir, &v75, sizeof(pDir));
+					if ( !v49
+					&& (signed int)v21->pMonsterInfo.uRecoveryTime <= 0
+					&& v80 * 307.2 >= (double)(signed int)v75.uDistance
+					&& ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9)
+					|| v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 )
+					{
+						v32 = actor_id;
+					}
+					else
+					{
+						if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength )
+						{
+							continue;
+						}
+						else if ( v21->uAIState == 2 )
+						{
+							v32 = actor_id;
+							v35 = stru_50C198.special_ability_use_check(v21, actor_id);
+							stru_50FE08.Add(
+							a1,
+							5120,
+							v21->vPosition.x,
+							v21->vPosition.y,
+							v21->vPosition.z + ((signed int)v21->uActorHeight >> 1),
+							v35,
+							1
+							);
+						}
+						else if ( v21->uAIState == 3 )
+						{
+							v34 = v21->pMonsterInfo.uMissleAttack1Type;
+							v66 = 0;
+							v32 = actor_id;
+							Actor::_404874(actor_id, &pDir, v34, v66);
+						}
+						else if ( v21->uAIState == 12 )
+						{
+							v34 = v21->pMonsterInfo.uMissleAttack2Type;
+							v66 = 1;
+							v32 = actor_id;
+							Actor::_404874(actor_id, &pDir, v34, v66);
+						}
+						else
+						{
+							v32 = actor_id;
+							if ( v21->uAIState == 13 )
+							{
+								v65 = v21->pMonsterInfo.uSpellSkillAndMastery1;
+								v60 = 2;
+								v33 = v21->pMonsterInfo.uSpell1ID;
+								Actor::_404AC7(actor_id, &pDir, v33, v60, v65);
+							}
+							else if ( v21->uAIState == 18 )
+							{
+								v65 = v21->pMonsterInfo.uSpellSkillAndMastery2;
+								v60 = 3;
+								v33 = v21->pMonsterInfo.uSpell2ID;
+								Actor::_404AC7(actor_id, &pDir, v33, v60, v65);
+							}
+						}
+					}
+				}
+			}
+			v36 = v75.uDistance;
+			if ( !v21->pMonsterInfo.uHostilityType )
+			{
+				if ( v76 == 3 )
+				{
+					v36 = v75.uDistance;
+					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3]
+					+ (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3);
+				}
+				else
+				{
+					v37 = 4;
+				}
+				if ( v37 == 2 )
+				{
+					v39 = __OFSUB__(v36, 1024);
+					v38 = ((v36 - 1024) & 0x80000000u) != 0;
+				}
+				else if ( v37 == 3 )
+				{
+					v39 = __OFSUB__(v36, 2560);
+					v38 = ((v36 - 2560) & 0x80000000u) != 0;
+				}
+				else if ( v37 == 4 )
+				{
+					v39 = __OFSUB__(v36, 5120);
+					v38 = ((v36 - 5120) & 0x80000000u) != 0;
+				}
+				if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 )
+				v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+			}
+			if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
+			{
+				v40 = a2;
+				v41 = v32;
+				if ( (signed int)v36 >= 10240 )
+				{
+					v68 = 0;
+					v61 = 1024;
+					Actor::_4032B2(v41, v40, v61, v68);
+					continue;
+				}
+				v67 = &pDir;
+				Actor::_402968(v41, v40, 0, v67);
+				continue;
+			}
+			if ( v21->pMonsterInfo.uHostilityType == 4 && a2 )
+			{
+				if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 )
+				{
+					if ( v21->pMonsterInfo.uAIType == 1 )
+					{
+						v67 = &pDir;
+						if ( v21->pMonsterInfo.uMovementType != 5 )
+						{
+							v40 = a2;
+							v41 = v32;
+							Actor::_402968(v41, v40, 0, v67);
+							continue;
+						}
+						Actor::AI_Stand(
+						v32,
+						a2,
+						(signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333),
+						&pDir);
+					}
+					else
+					{
+						if ( v21->pMonsterInfo.uAIType == 2 )
+						{
+							v84 = v21->sCurrentHP;
+							v42 = (double)(signed int)v84;
+							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2;
+						}
+						else
+						{
+							v84 = v21->sCurrentHP;
+							v42 = (double)(signed int)v84;
+							v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1;
+						}
+						if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 )
+						if ( v43 > v42 && (signed int)v36 < 10240 )
+						{
+							v67 = &pDir;
+							v40 = a2;
+							v41 = v32;
+							Actor::_402968(v41, v40, 0, v67);
+							continue;
+						}
+					}
+				}
+				v81 = v36 - v21->uActorRadius;
+				if ( v76 == 3 )
+				v81 -= pActors[a2 >> 3].uActorRadius;
+				if ( v81 < 0 )
+				v81 = 0;
+				rand();
+				v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0;
+				v21->uAttributes &= 0xFBFFFF;
+				v82 = 0;
+				v49 = v21->pMonsterInfo.uMovementType == 5;
+				v84 = v44;
+				if ( v49 )
+				v82 = 1;
+				if ( v81 < 5120 )
+				{
+					v45 = stru_50C198.special_ability_use_check(v21, v32);
+					if ( !v45 )
+					{
+						if ( v21->pMonsterInfo.uMissleAttack1Type )
+						{
+							if ( v84 )
+							{
+								Actor::_403476(v32, a2, &pDir);
+								continue;
+								
+							}
+							if ( v82 )
+							{
+								v69 = &pDir;
+								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v51 = a2;
+								v64 = (signed __int64)v47;
+								v52 = v32;
+								Actor::AI_Stand(v52, v51, v64, v69);
+								continue;
+							}
+							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							//UNDEF(v53);
+							v69 = &pDir;
+							if ( !(v54 | v55) )
+							{
+								v51 = a2;
+								v64 = (signed __int64)v47;
+								v52 = v32;
+								Actor::AI_Stand(v52, v51, v64, v69);
+								continue;
+							}
+							Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
+							continue;
+						}
+						v56 = v80 * 307.2;
+						if ( (double)v81 >= v56 )
+						{
+							if ( v81 >= 1024 )
+							{
+								if ( v82 )
+								{
+									v69 = &pDir;
+									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v51 = a2;
+									v64 = (signed __int64)v47;
+									v52 = v32;
+									Actor::AI_Stand(v52, v51, v64, v69);
+									continue;
+								}
+								v71 = &pDir;
+								v63 = 0;
+								
+								Actor::_402686(v32, a2, v63, v71);
+								continue;
+							}
+							if ( v82 )
+							{
+								v69 = &pDir;
+								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v51 = a2;
+								v64 = (signed __int64)v47;
+								v52 = v32;
+								Actor::AI_Stand(v52, v51, v64, v69);
+								continue;
+							}
+							v70 = (signed __int64)v56;
+							v62 = &pDir;
+							v59 = 0;
+							Actor::_40281C(v32, a2, v59, v62, v70);
+							continue;
+						}
+						v49 = v84 == 0;
+						v69 = &pDir;
+						if ( v49 )
+						{
+							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							v51 = a2;
+							v64 = (signed __int64)v47;
+							v52 = v32;
+							Actor::AI_Stand(v52, v51, v64, v69);
+							continue;
+						}
+						Actor::_403C6C(v32, a2, &pDir);
+						continue;
+					}
+					if ( v45 != 1 )
+					{
+						if ( v45 > 1 && v45 <= 3 )
+						{
+							if ( v45 == 2 )
+							v46 = v21->pMonsterInfo.uSpell1ID;
+							else
+							v46 = v21->pMonsterInfo.uSpell2ID;
+							if ( v46 )
+							{
+								if ( v84 )
+								{
+									if ( v45 == 2 )
+									Actor::_403854(v32, a2, &pDir);
+									else
+									Actor::_403A60(v32, a2, &pDir);
+									continue;
+								}
+								if ( v80 * 307.2 > (double)v81 || v82 )
+								{
+									v69 = &pDir;
+									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v51 = a2;
+									v64 = (signed __int64)v47;
+									v52 = v32;
+									Actor::AI_Stand(v52, v51, v64, v69);
+									continue;
+									
+								}
+								v69 = &pDir;
+								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
+								continue;
+							}
+							v48 = v80 * 307.2;
+							if ( (double)v81 >= v48 )
+							{
+								if ( v81 >= 1024 )
+								{
+									v50 = v82 == 0;
+									if ( !v50 )
+									{
+										v69 = &pDir;
+										v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										v51 = a2;
+										v64 = (signed __int64)v47;
+										v52 = v32;
+										Actor::AI_Stand(v52, v51, v64, v69);
+										continue;
+									}
+									v71 = &pDir;
+									v63 = 256;
+									Actor::_402686(v32, a2, v63, v71);
+									continue;
+									
+								}
+								if ( v82 )
+								{
+									v69 = &pDir;
+									v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									v51 = a2;
+									v64 = (signed __int64)v47;
+									v52 = v32;
+									Actor::AI_Stand(v52, v51, v64, v69);
+									continue;
+								}
+								v70 = (signed __int64)v48;
+								v62 = &pDir;
+								v59 = 0;
+								Actor::_40281C(v32, a2, v59, v62, v70);
+								continue;
+							}
+							v49 = v84 == 0;
+							v69 = &pDir;
+							if ( v49 )
+							{
+								v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v51 = a2;
+								v64 = (signed __int64)v47;
+								v52 = v32;
+								Actor::AI_Stand(v52, v51, v64, v69);
+								continue;
+							}
+							Actor::_403C6C(v32, a2, &pDir);
+							continue;
+						}
+					}
+				}
+			}
+			if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 )
+			{
+				if ( !v21->pMonsterInfo.uMovementType )
+				{
+					v68 = 0;
+					v61 = 1024;
+					v41 = v32;
+					v40 = 4;
+					Actor::_4032B2(v41, v40, v61, v68);
+					continue;
+					
+				}
+				if ( v21->pMonsterInfo.uMovementType == 1 )
+				{
+					v68 = 0;
+					v61 = 2560;
+					v41 = v32;
+					v40 = 4;
+					Actor::_4032B2(v41, v40, v61, v68);
+					continue;
+				}
+				if ( v21->pMonsterInfo.uMovementType == 2 )
+				{
+					v68 = 0;
+					v61 = 5120;
+					v41 = v32;
+					v40 = 4;
+					Actor::_4032B2(v41, v40, v61, v68);
+					continue;
+				}
+				if ( v21->pMonsterInfo.uMovementType == 4 )
+				{
+					v68 = 0;
+					v61 = 10240;
+					v41 = v32;
+					v40 = 4;
+					Actor::_4032B2(v41, v40, v61, v68);
+					continue;
+				}
+				if ( v21->pMonsterInfo.uMovementType == 5 )
+				{
+					v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
+					v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					memcpy(&v74, v57, sizeof(v74));
+					memcpy(&pDir, &v74, sizeof(pDir));
+					v69 = &pDir;
+					v52 = actor_id;
+					v64 = (signed __int64)v58;
+					v51 = 4;
+					Actor::AI_Stand(v52, v51, v64, v69);
+					continue;
+				}
+				continue;
+				
+			}
+			if ( !v21->pMonsterInfo.uMissleAttack2Type )
+			{
+				v56 = v80 * 307.2;
+				if ( (double)v81 >= v56 )
+				{
+					if ( v81 >= 1024 )
+					{
+						v50 = v82 == 0;
+						if ( !v50 )
+						{
+							v69 = &pDir;
+							v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							v51 = a2;
+							v64 = (signed __int64)v47;
+							v52 = v32;
+							Actor::AI_Stand(v52, v51, v64, v69);
+							continue;
+						}
+						v71 = &pDir;
+						v63 = 256;
+						Actor::_402686(v32, a2, v63, v71);
+						continue;
+					}
+					if ( v82 )
+					{
+						v69 = &pDir;
+						v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+						v51 = a2;
+						v64 = (signed __int64)v47;
+						v52 = v32;
+						Actor::AI_Stand(v52, v51, v64, v69);
+						continue;
+					}
+					v70 = (signed __int64)v56;
+					v62 = &pDir;
+					v59 = 0;
+					Actor::_40281C(v32, a2, v59, v62, v70);
+					continue;
+					
+				}
+				v49 = v84 == 0;
+				v69 = &pDir;
+				if ( v49 )
+				{
+					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v51 = a2;
+					v64 = (signed __int64)v47;
+					v52 = v32;
+					Actor::AI_Stand(v52, v51, v64, v69);
+					continue;
+				}
+				Actor::_403C6C(v32, a2, &pDir);
+				continue;
+			}
+			if ( !v84 )
+			{
+				if ( v82 )
+				{
+					v69 = &pDir;
+					v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					v51 = a2;
+					v64 = (signed __int64)v47;
+					v52 = v32;
+					Actor::AI_Stand(v52, v51, v64, v69);
+					continue;
+				}
+				v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+				//UNDEF(v53);
+				v69 = &pDir;
+				if ( !(v54 | v55) )
+				{
+					v51 = a2;
+					v64 = (signed __int64)v47;
+					v52 = v32;
+					Actor::AI_Stand(v52, v51, v64, v69);
+					continue;
+				}
+				Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69);
+				continue;
+			}
+			Actor::_40368B(v32, a2, &pDir);
+		}
+	}
 }
 
 //----- (0040261D) --------------------------------------------------------
--- a/mm7_4.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/mm7_4.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -6472,7 +6472,7 @@
   contract_approved = 0;
   v11 = 0;
   uDialogueType = 84;
-  ptr_F8B1E8 = (char *)pNPCTopics[667].pText;
+  current_npc_text = (char *)pNPCTopics[667].pText;
   v0 = _4F0882_evt_VAR_PlayerItemInHands_vals;
   while ( 1 )
   {
@@ -6499,7 +6499,7 @@
   }
   if ( v0 <= &_4F0882_evt_VAR_PlayerItemInHands_vals[53] )
   {
-	  ptr_F8B1E8 = (char *)pNPCTopics[666].pText; // Here's %s that you lost. Be careful
+	  current_npc_text = (char *)pNPCTopics[666].pText; // Here's %s that you lost. Be careful
 	  v4 = _4F0882_evt_VAR_PlayerItemInHands_vals[2 * v11];
 	  contract_approved = _4F0882_evt_VAR_PlayerItemInHands_vals[2 * v11];
 	  pParty->pPlayers[0].AddVariable(VAR_PlayerItemInHands, v4);
@@ -6587,8 +6587,8 @@
   switch ( uMessageParam )
   {
     case 13:
-      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
-      ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
+      current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
+      current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0);
       NPCHireableDialogPrepare();
       dialogue_show_profession_details = false;
       goto _return;
@@ -6638,7 +6638,7 @@
           }
           else
           {
-            ptr_F8B1E8 = 0;
+            current_npc_text = 0;
             activeLevelDecoration = (LevelDecoration*)1;
             EventProcessor(pEventNumber, 0, 1);
             activeLevelDecoration = NULL;
@@ -6666,10 +6666,10 @@
         v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
       else
         v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits;
-      ptr_F8B1E8 = v17;
+      current_npc_text = v17;
       v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0);
       dialogue_show_profession_details = ~dialogue_show_profession_details;
-      ptr_F8B1E8 = v18;
+      current_npc_text = v18;
     }
     else
     {
@@ -6786,8 +6786,8 @@
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
       dialogue_show_profession_details = false;
       uDialogueType = 13;
-      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
-      ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
+      current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
+      current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0);
       if ( uActiveCharacter )
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
@@ -7365,7 +7365,7 @@
           v32 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
           sprintf(pTmpBuf, &byte_4F0F98, v32, v31, v30);
           sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
-          ptr_F8B1E8 = pTmpBuf2;
+          current_npc_text = pTmpBuf2;
           v15 = "";
           goto LABEL_45;
         }
@@ -7407,8 +7407,8 @@
             if ( uDialogueType != 84 )
               goto LABEL_49;
             sprintf(pTmpBuf, format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName);
-            sprintf(pTmpBuf2, ptr_F8B1E8, pTmpBuf);
-            ptr_F8B1E8 = pTmpBuf2;
+            sprintf(pTmpBuf2, current_npc_text, pTmpBuf);
+            current_npc_text = pTmpBuf2;
             goto LABEL_45;
           }
           v21 = v20 - 1;
@@ -7495,16 +7495,16 @@
       }
     }
   }
-  if ( ptr_F8B1E8 )
+  if ( current_npc_text )
   {
     w.uFrameWidth = 458;
     w.uFrameZ = 457;
     v47 = pFontArrus;
-    v48 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
+    v48 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
     if ( 352 - v48 < 8 )
     {
       v47 = pFontCreate;
-      v48 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
+      v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
     }
     pRenderer->_4A6A68(
       8u,
@@ -7512,7 +7512,7 @@
       (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
       (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v48);
     pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428);
-    v49 = FitTextInAWindow(ptr_F8B1E8, v47, &w, 0xDu, 0);
+    v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0);
     a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0);
   }
 }
@@ -7792,7 +7792,7 @@
 void DrawJoinGuildWindow( int pEventCode )
 {
   uDialogueType = 81;//enum JoinGuildDialog
-  ptr_F8B1E8 = (char *)pNPCTopics[pEventCode + 99].pText;
+  current_npc_text = (char *)pNPCTopics[pEventCode + 99].pText;
   ContractSelectText(pEventCode);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0);
@@ -7813,7 +7813,7 @@
 
   v1 = a4;
   uDialogueType = 78;
-  ptr_F8B1E8 = (char *)pNPCTopics[a4 + 168].pText;
+  current_npc_text = (char *)pNPCTopics[a4 + 168].pText;
   _4B254D_SkillMasteryTeacher(a4);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
@@ -8214,7 +8214,7 @@
 					break;
 				default:
 					activeLevelDecoration = (LevelDecoration*)1;
-					ptr_F8B1E8 = 0;
+					current_npc_text = 0;
 					EventProcessor(npc_event_id, 0, 1);
 					activeLevelDecoration = NULL;
 					break;
--- a/mm7_data.cpp	Tue Mar 26 23:19:12 2013 +0600
+++ b/mm7_data.cpp	Wed Mar 27 01:39:54 2013 +0600
@@ -1990,7 +1990,7 @@
 int dword_F8B1DC; // weak
 int dword_F8B1E0; // weak
 int dword_F8B1E4; // weak
-const char *ptr_F8B1E8; // idb
+const char *current_npc_text; // idb
 char dialogue_show_profession_details = false; // F8B1EC
 char byte_F8B1EF[777]; // weak
 char byte_F8B1F0[4];
--- a/mm7_data.h	Tue Mar 26 23:19:12 2013 +0600
+++ b/mm7_data.h	Wed Mar 27 01:39:54 2013 +0600
@@ -1503,7 +1503,7 @@
 extern int dword_F8B1DC; // weak
 extern int dword_F8B1E0; // weak
 extern int dword_F8B1E4; // weak
-extern const char *ptr_F8B1E8; // idb
+extern const char *current_npc_text; // 0xF8B1E8
 extern char dialogue_show_profession_details; // weak
 extern char byte_F8B1EF[]; // weak
 extern char byte_F8B1F0[4];
@@ -1818,7 +1818,7 @@
 void __cdecl DrawDialogueUI();
 struct NPCData *__fastcall GetNPCData(signed int npcid);
 struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);
-int __fastcall sub_445C8B(signed int a1);
+int __fastcall GetGreetType(signed int SpeakingNPC_ID);
 void __cdecl sub_44603D();
 void PrepareHouse(enum HOUSE_ID house); // idb
 bool  EnterHouse(enum HOUSE_ID uHouseID);