diff Actor.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children a9e9c6989d04
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Actor.cpp	Sat Jan 12 09:45:18 2013 +0600
@@ -0,0 +1,4236 @@
+#include "Actor.h"
+#include "LayingItem.h"
+#include "Math.h"
+#include "Party.h"
+#include "Outdoor.h"
+#include "AudioPlayer.h"
+#include "Game.h"
+#include "ObjectList.h"
+#include "Overlays.h"
+#include "Events.h"
+#include "IndoorCamera.h"
+#include "FactionTable.h"
+#include "TurnEngine.h"
+#include "MapInfo.h"
+#include "stru277.h"
+#include "Time.h"
+#include "LOD.h"
+#include "Party.h"
+#include "GUIWindow.h"
+#include "GUIFont.h"
+
+
+
+
+Actor pActors[500];
+size_t uNumActors;
+
+stru319 stru_50C198; // idb
+
+
+
+
+
+//----- (00448518) --------------------------------------------------------
+void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3)
+{
+  signed int v3; // eax@1
+  int *v4; // edi@2
+  signed int v5; // eax@6
+  char *v6; // ecx@6
+  char *v7; // eax@11
+  ItemGen *v8; // ecx@15
+
+  v3 = 0;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v4 = (int *)&pActors[0].uNPC_ID;
+    while ( *(short *)v4 != npc )
+    {
+      ++v3;
+      v4 += 209;
+      if ( v3 >= (signed int)uNumActors )
+        return;
+    }
+    v5 = v3;
+    v6 = (char *)&pActors[v5].uCarriedItemID;
+    if ( a3 )
+    {
+      if ( *(short *)v6 )
+      {
+        if ( pActors[v5].array_000234[0].uItemID )
+        {
+          v7 = (char *)&pActors[v5].array_000234[1];
+          if ( !*(int *)v7 )
+            *(int *)v7 = item;
+        }
+        else
+        {
+          pActors[v5].array_000234[0].uItemID = item;
+        }
+      }
+      else
+      {
+        *(short *)v6 = item;
+      }
+    }
+    else
+    {
+      if ( *(short *)v6 == item )
+      {
+        *(short *)v6 = 0;
+      }
+      else
+      {
+        v8 = pActors[v5].array_000234;
+        if ( pActors[v5].array_000234[0].uItemID == item
+          || (v8 = &pActors[v5].array_000234[1], pActors[v5].array_000234[1].uItemID == item) )
+          v8->Reset();
+      }
+    }
+  }
+}
+
+//----- (004485A7) --------------------------------------------------------
+void Actor::GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive)
+{
+  unsigned int v3; // eax@3
+  char *v4; // ecx@3
+  unsigned int *v5; // eax@8
+  ItemGen *v6; // ecx@12
+
+  if ( (uActorID & 0x80000000u) == 0 && (signed int)uActorID <= (signed int)(uNumActors - 1) )
+  {
+    v3 = uActorID;
+    v4 = (char *)&pActors[uActorID].uCarriedItemID;
+    if ( bGive )
+    {
+      if ( *(short *)v4 )
+      {
+        if ( pActors[v3].array_000234[0].uItemID )
+        {
+          v5 = &pActors[v3].array_000234[1].uItemID;
+          if ( !*v5 )
+            *v5 = uItemID;
+        }
+        else
+        {
+          pActors[v3].array_000234[0].uItemID = uItemID;
+        }
+      }
+      else
+      {
+        *(short *)v4 = uItemID;
+      }
+    }
+    else
+    {
+      if ( *(short *)v4 == uItemID )
+      {
+        *(short *)v4 = 0;
+      }
+      else
+      {
+        v6 = pActors[v3].array_000234;
+        if ( pActors[v3].array_000234[0].uItemID == uItemID
+          || (v6 = &pActors[v3].array_000234[1], pActors[v3].array_000234[1].uItemID == uItemID) )
+          v6->Reset();
+      }
+    }
+  }
+}
+
+
+//----- (00445D4A) --------------------------------------------------------
+void Actor::InitializeDialogue(int bPlayerSaysHello)
+{
+  Actor *v2; // esi@1
+  unsigned int v3; // ecx@1
+  NPCData *v4; // eax@1
+  NPCData *v5; // ebp@1
+  unsigned int v6; // eax@1
+  signed int v7; // eax@3
+  unsigned int v8; // eax@8
+  int v9; // esi@8
+  int v10; // eax@11
+  GUIWindow *v11; // ecx@19
+  signed int v12; // eax@21
+  int v13; // [sp-8h] [bp-44h]@34
+  const char *v14; // [sp-4h] [bp-40h]@4
+  int v15; // [sp-4h] [bp-40h]@34
+  signed int v16; // [sp-4h] [bp-40h]@35
+  int v17; // [sp+10h] [bp-2Ch]@1
+  char pContainer[32]; // [sp+14h] [bp-28h]@3
+
+  auto a1 = this;
+  v2 = a1;
+  v17 = bPlayerSaysHello;
+  dword_A74CDC = -1;
+  dword_AE336C = -1;
+  pEventTimer->Pause();
+  pMiscTimer->Pause();
+  pAudioPlayer->StopChannels(-1, -1);
+  uDialogueType = 0;
+  v3 = v2->uNPC_ID;
+  uDialogue_SpeakingActorNPC_ID = v2->uNPC_ID;
+  pDialogue_SpeakingActor = v2;
+  v4 = GetNPCData(v3);
+  v5 = v4;
+  v6 = v4->uFlags;
+  if ( (v6 & 3) != 2 )
+    v5->uFlags = v6 + 1;
+  v7 = const_2();
+  sprintf(pContainer, "evt%02d", v7);
+  if ( !pParty->uAlignment )
+  {
+    v14 = "-b";
+LABEL_7:
+    strcat(pContainer, v14);
+    goto LABEL_8;
+  }
+  if ( pParty->uAlignment == 2 )
+  {
+    v14 = "-c";
+    goto LABEL_7;
+  }
+LABEL_8:
+  v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+  array_5913D8[6] = 0;
+  uNumDialogueNPCPortraits = 1;
+  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8];
+  sprintf(pContainer, "npc%03u", v5->uPortraitID);
+  v9 = 0;
+  pDialogueNPCPortraits[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
+  dword_591084 = areWeLoadingTexture;
+  uTextureID_507B04 = uTextureID_right_panel;
+  if ( !(v5->uFlags & 0x80) && v5->house >= 0 )
+  {
+    if ( (signed int)pParty->GetPartyFame() <= v5->fame
+      || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) )
+    {
+LABEL_16:
+      v9 = 1;
+      goto LABEL_17;
+    }
+    if ( v10 > 1 )
+    {
+      if ( v10 == 2 )
+      {
+        v16 = 3;
+        goto LABEL_36;
+      }
+      if ( v10 != 3 )
+      {
+        if ( v10 == 4 )
+          goto LABEL_17;
+        goto LABEL_16;
+      }
+LABEL_35:
+      v16 = 2;
+LABEL_36:
+      v9 = v16;
+      goto LABEL_17;
+    }
+    if ( v5->rep )
+      goto LABEL_35;
+  }
+LABEL_17:
+  if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
+    v9 = 4;
+  v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
+  pDialogueWindow = v11;
+  if ( v5->uFlags & 0x80 )
+  {
+    if ( !v5->bHasUsedTheAbility )
+    {
+      v12 = v5->uProfession;
+      if ( v12 >= 10 )
+      {
+        if ( v12 <= 12 || v12 > 32 && (v12 <= 34 || v12 > 38 && (v12 <= 43 || v12 == 52)) )
+        {
+          v11->CreateButton(
+            0x1E0u,
+            0xFAu,
+            0x8Cu,
+            LOBYTE(pFontArrus->uFontHeight) - 3,
+            1,
+            0,
+            0x88u,
+            9u,
+            0,
+            "",
+            0);
+          pDialogueWindow->_41D08F(4, 1, 0, 1);
+        }
+      }
+    }
+  }
+  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  if ( v17 && uActiveCharacter && !(v5->uFlags & 0x80) )
+  {
+    if ( pParty->uCurrentHour < 5 || pParty->uCurrentHour > 0x15 )
+    {
+      v15 = 0;
+      v13 = 23;
+    }
+    else
+    {
+      v15 = 0;
+      v13 = 22;
+    }
+    pPlayers[uActiveCharacter]->PlaySound(v13, v15);
+  }
+}
+
+
+//----- (0040894B) --------------------------------------------------------
+bool Actor::CanAct()
+{
+  signed int v1; // esi@1
+  bool v2; // edi@2
+  unsigned __int16 v3; // ax@6
+
+  v1 = 0;
+  v2 = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned
+  if ( (signed __int64)this->pActorBuffs[6].uExpireTime > 0 )// paralyzed
+    v1 = 1;
+  v3 = this->uAIState;
+  return (v2 | v1 | v3 == Dying | v3 == Dead | v3 == Removed | v3 == Summoned | v3 == Disabled) == 0;
+}
+
+//----- (004089C7) --------------------------------------------------------
+bool Actor::IsAlive()
+{
+  signed int v1; // esi@1
+  unsigned __int16 v2; // ax@3
+
+  v1 = 0;
+  if ( (signed __int64)this->pActorBuffs[5].uExpireTime > 0 )
+    v1 = 1;
+  v2 = this->uAIState;
+  return (v1 | (v2 == Dying) | (v2 == Dead) | (v2 == Removed) | (v2 == Summoned) | (v2 == Disabled)) != 0;
+}
+
+//----- (004086E9) --------------------------------------------------------
+void Actor::SetRandomGoldIfTheresNoItem()
+{
+  Actor *v1; // esi@1
+  int v2; // edi@1
+  signed int v3; // ebx@2
+  unsigned __int8 v4; // al@7
+
+  v1 = this;
+  v2 = 0;
+  if ( !this->array_000234[3].uItemID )
+  {
+    v3 = 0;
+    if ( this->pMonsterInfo.uTreasureDiceRolls )
+    {
+      do
+      {
+        ++v3;
+        v2 += rand() % v1->pMonsterInfo.uTreasureDiceSides + 1;
+      }
+      while ( v3 < v1->pMonsterInfo.uTreasureDiceRolls );
+      if ( v2 )
+      {
+        v1->array_000234[3].uItemID = 197;
+        v1->array_000234[3].uAdditionalValue = v2;
+      }
+    }
+  }
+  if ( rand() % 100 < v1->pMonsterInfo.uTreasureDropChance )
+  {
+    v4 = v1->pMonsterInfo.uTreasureLevel;
+    if ( v4 )
+      pItemsTable->GenerateItem(v4, v1->pMonsterInfo.uTreasureType, &v1->array_000234[2]);
+  }
+  v1->uAttributes |= 0x800000;
+}
+
+//----- (00404AC7) --------------------------------------------------------
+void __fastcall Actor::_404AC7(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel)
+{
+  Actor *v5; // esi@1
+  unsigned int v6; // edi@1
+  unsigned int v7; // eax@1
+  int v8; // edi@16
+  int v9; // edi@17
+  signed int v10; // ecx@22
+  signed int v11; // eax@29
+  __int16 *v12; // edi@30
+  int v13; // ecx@34
+  int v14; // edx@34
+  int v15; // eax@34
+  AIDirection *v16; // esi@34
+  unsigned __int16 v17; // di@34
+  int v18; // eax@34
+  int v19; // edi@34
+  int v20; // eax@35
+  int v21; // eax@39
+  SoundID v22; // eax@39
+  signed int v23; // eax@41
+  double v24; // st7@49
+  float v25; // ST5C_4@50
+  int v26; // eax@50
+  double v27; // st7@50
+  double v28; // st6@50
+  float v29; // ST4C_4@51
+  int v30; // esi@50
+  int v31; // ST3C_4@51
+  unsigned int v32; // edi@51
+  char *v33; // eax@54
+  unsigned __int16 v34; // ax@57
+  signed int v35; // ecx@58
+  signed int v36; // eax@67
+  signed int v37; // eax@68
+  signed __int64 v38; // qtt@69
+  int v39; // ecx@75
+  int v40; // eax@79
+  int v41; // ecx@90
+  int v42; // ecx@91
+  int v43; // eax@95
+  int v44; // ecx@100
+  int v45; // ecx@101
+  int v46; // eax@105
+  unsigned int v47; // ebx@106
+  int v48; // ecx@110
+  char v49; // zf@123
+  int v50; // eax@127
+  int v51; // ecx@130
+  int v52; // eax@132
+  int v53; // ecx@137
+  int v54; // ecx@138
+  int v55; // eax@142
+  SpellBuff *v56; // esi@143
+  Player **v57; // esi@145
+  int v58; // eax@146
+  int v59; // edi@146
+  int v60; // eax@146
+  int v61; // edi@146
+  int v62; // eax@146
+  signed int v63; // edi@146
+  signed int v64; // edi@147
+  int v65; // eax@151
+  char *v66; // eax@160
+  int v67; // edi@167
+  int v68; // edi@168
+  int v69; // eax@171
+  signed int v70; // ecx@172
+  signed int v71; // eax@179
+  __int16 *v72; // edi@180
+  int v73; // ecx@184
+  int v74; // edx@184
+  int v75; // eax@184
+  AIDirection *v76; // esi@184
+  unsigned __int16 v77; // di@184
+  int v78; // eax@184
+  int v79; // edx@185
+  int v80; // eax@185
+  int v81; // eax@189
+  unsigned __int16 v82; // ax@190
+  int v83; // ecx@192
+  int v84; // edx@192
+  int v85; // eax@192
+  AIDirection *v86; // esi@192
+  unsigned __int16 v87; // di@192
+  __int16 v88; // ax@192
+  signed int v89; // ecx@192
+  int v90; // eax@192
+  signed int v91; // eax@200
+  int v92; // eax@201
+  int v93; // ecx@207
+  int v94; // ecx@208
+  int v95; // eax@212
+  int v96; // ecx@217
+  int v97; // eax@221
+  SoundID v98; // [sp-18h] [bp-E8h]@79
+  signed int v99; // [sp-14h] [bp-E4h]@39
+  unsigned int v100; // [sp-10h] [bp-E0h]@39
+  signed int v101; // [sp-Ch] [bp-DCh]@39
+  signed int v102; // [sp-8h] [bp-D8h]@39
+  int v103; // [sp-4h] [bp-D4h]@39
+  unsigned int v104; // [sp+0h] [bp-D0h]@39
+  signed int v105; // [sp+4h] [bp-CCh]@23
+  int v106; // [sp+4h] [bp-CCh]@39
+  signed int v107; // [sp+4h] [bp-CCh]@42
+  signed int v108; // [sp+4h] [bp-CCh]@173
+  int pitch; // [sp+2Ch] [bp-A4h]@51
+  float v110; // [sp+30h] [bp-A0h]@50
+  int v111; // [sp+38h] [bp-98h]@41
+  float v112; // [sp+3Ch] [bp-94h]@49
+  int v113; // [sp+40h] [bp-90h]@41
+  int v114; // [sp+48h] [bp-88h]@41
+  LayingItem a1; // [sp+4Ch] [bp-84h]@1
+  int v116; // [sp+BCh] [bp-14h]@49
+  AIDirection *v117; // [sp+C0h] [bp-10h]@1
+  int v118; // [sp+C4h] [bp-Ch]@29
+  float v119; // [sp+C8h] [bp-8h]@48
+  float v120; // [sp+CCh] [bp-4h]@1
+  int spellnuma; // [sp+D8h] [bp+8h]@29
+  int spellnumb; // [sp+D8h] [bp+8h]@48
+  float spellnumc; // [sp+D8h] [bp+8h]@50
+  signed int spellnumd; // [sp+D8h] [bp+8h]@53
+  int spellnume; // [sp+D8h] [bp+8h]@179
+  int a1a; // [sp+E0h] [bp+10h]@34
+  signed int a1b; // [sp+E0h] [bp+10h]@145
+  int a1c; // [sp+E0h] [bp+10h]@184
+
+  LODWORD(v120) = uActorID;
+  v5 = &pActors[uActorID];
+  v117 = pDir;
+  v6 = uSkillLevel & 0x3F;
+  v7 = SkillToMastery(uSkillLevel);
+  if ( spellnum <= 47 )
+  {
+    if ( spellnum != 47 )
+    {
+      if ( spellnum <= 18 )
+      {
+        if ( spellnum == 18 || spellnum == 2 )
+          goto LABEL_159;
+        if ( spellnum != 5 )
+        {
+          if ( spellnum == 6 )
+            goto LABEL_159;
+          if ( spellnum != 9 )
+          {
+            if ( spellnum != 11 )
+            {
+              if ( spellnum != 15 )
+              {
+                if ( spellnum != 17 )
+                  return;
+                if ( (signed int)v7 <= 0 )
+                  goto LABEL_20;
+                if ( (signed int)v7 <= 2 )
+                {
+                  v9 = 300 * v6;
+                }
+                else
+                {
+                  if ( v7 != 3 )
+                  {
+                    if ( v7 == 4 )
+                    {
+                      v8 = 3600 * (v6 + 64);
+LABEL_21:
+                      v5->pActorBuffs[15].Apply(
+                        pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335),
+                        v7,
+                        0,
+                        0,
+                        0);
+                      return;
+                    }
+LABEL_20:
+                    v8 = 0;
+                    goto LABEL_21;
+                  }
+                  v9 = 900 * v6;
+                }
+                v8 = v9 + 3840;
+                goto LABEL_21;
+              }
+              v10 = 3;
+              if ( uSkillLevel & 0x0100 )
+              {
+                v105 = 9;
+              }
+              else
+              {
+                if ( (uSkillLevel & 0x80u) == 0 )
+                {
+                  if ( !(uSkillLevel & 0x40) )
+                    goto LABEL_29;
+                  v105 = 5;
+                }
+                else
+                {
+                  v105 = 7;
+                }
+              }
+              v10 = v105;
+LABEL_29:
+              spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
+              a1.uItemType = stru_4E3ACC[15].uItemType;
+              v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1);
+              v11 = 0;
+              if ( (signed int)pObjectList->uNumObjects <= 0 )
+              {
+LABEL_33:
+                LOWORD(v11) = 0;
+              }
+              else
+              {
+                v12 = &pObjectList->pObjects->uObjectID;
+                while ( stru_4E3ACC[15].uItemType != *v12 )
+                {
+                  ++v11;
+                  v12 += 28;
+                  if ( v11 >= (signed int)pObjectList->uNumObjects )
+                    goto LABEL_33;
+                }
+              }
+              a1.uObjectDescID = v11;
+              a1.stru_24.Reset();
+              a1.field_48 = 15;
+              v13 = v5->vPosition.x;
+              v14 = v5->vPosition.y;
+              a1.field_4C = uSkillLevel;
+              a1.vPosition.x = v13;
+              v15 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+              v16 = v117;
+              v17 = LOWORD(v117->uYawAngle);
+              a1.field_50 = 0;
+              a1.vPosition.y = v14;
+              a1.vPosition.z = v15;
+              a1.uFacing = v17;
+              a1.uSoundID = 0;
+              a1.uAttributes = 0;
+              a1.uSectorID = pIndoor->GetSector(v13, v14, v15);
+              v18 = 8 * LODWORD(v120);
+              LOBYTE(v18) = 8 * LOBYTE(v120) | AI_OBJECT_ACTOR;
+              a1.field_58 = v18;
+              a1.uSpriteFrameID = 0;
+              a1.field_5C = 0;
+              a1.field_60_distance_related_prolly_lod = 3;
+              v19 = spellnuma / -2;
+              a1a = spellnuma / 2;
+              if ( spellnuma / -2 > spellnuma / 2 )
+              {
+                v20 = spellnuma / 2;
+              }
+              else
+              {
+                do
+                {
+                  a1.uFacing = v19 + LOWORD(v16->uYawAngle);
+                  v20 = a1.Create(
+                          (signed __int16)a1.uFacing,
+                          v16->uPitchAngle,
+                          pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+                          0);
+                  v19 += v118;
+                }
+                while ( v19 <= a1a );
+              }
+              if ( v20 != -1 )
+              {
+                v106 = 0;
+                v104 = 0;
+                v103 = 0;
+                v102 = 0;
+                v21 = 8 * v20;
+                v101 = -1;
+                LOBYTE(v21) = v21 | 2;
+                v100 = 0;
+                v99 = v21;
+                v22 = (SoundID)word_4EE088_sound_ids[15];
+LABEL_202:
+                v98 = v22;
+                goto LABEL_222;
+              }
+              return;
+            }
+LABEL_159:
+            a1.uItemType = stru_4E3ACC[spellnum].uItemType;
+            v119 = 0.0;
+            if ( (signed int)pObjectList->uNumObjects <= 0 )
+            {
+LABEL_191:
+              v82 = 0;
+            }
+            else
+            {
+              v66 = (char *)&pObjectList->pObjects->uObjectID;
+              while ( (short)a1.uItemType != *(short *)v66 )
+              {
+                ++LODWORD(v119);
+                v66 += 56;
+                if ( SLODWORD(v119) >= (signed int)pObjectList->uNumObjects )
+                  goto LABEL_191;
+              }
+              v82 = LOWORD(v119);
+            }
+            a1.uObjectDescID = v82;
+            a1.stru_24.Reset();
+            a1.field_48 = spellnum;
+            v83 = v5->vPosition.x;
+            v84 = v5->vPosition.y;
+            a1.field_4C = uSkillLevel;
+            a1.vPosition.x = v83;
+            v85 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+            v86 = v117;
+            v87 = LOWORD(v117->uYawAngle);
+            a1.field_50 = 0;
+            a1.vPosition.y = v84;
+            a1.vPosition.z = v85;
+            a1.uFacing = v87;
+            a1.uSoundID = 0;
+            a1.uAttributes = 0;
+            v88 = pIndoor->GetSector(v83, v84, v85);
+            v89 = v86->uDistance;
+            a1.uSectorID = v88;
+            LODWORD(v119) = v89;
+            v90 = 8 * LODWORD(v120);
+            LOBYTE(v90) = 8 * LOBYTE(v120) | 3;
+            a1.uSpriteFrameID = 0;
+            a1.field_58 = v90;
+            a1.field_5C = 0;
+            a1.field_60_distance_related_prolly_lod = 3;
+            if ( (double)v89 >= 307.2 )
+            {
+              if ( v89 >= 1024 )
+              {
+                if ( v89 >= 2560 )
+                {
+                  if ( v89 < 5120 )
+                    a1.field_60_distance_related_prolly_lod = 3;
+                }
+                else
+                {
+                  a1.field_60_distance_related_prolly_lod = 2;
+                }
+              }
+              else
+              {
+                a1.field_60_distance_related_prolly_lod = 1;
+              }
+            }
+            else
+            {
+              a1.field_60_distance_related_prolly_lod = 0;
+            }
+            a1.field_61 = 2;
+            v91 = a1.Create(
+                    v86->uYawAngle,
+                    v86->uPitchAngle,
+                    pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+                    0);
+            if ( v91 != -1 )
+            {
+              v106 = 0;
+              v104 = 0;
+              v103 = 0;
+              v102 = 0;
+              v92 = 8 * v91;
+              v101 = -1;
+              LOBYTE(v92) = v92 | 2;
+              v100 = 0;
+              v99 = v92;
+              v22 = (SoundID)word_4EE088_sound_ids[spellnum];
+              goto LABEL_202;
+            }
+            return;
+          }
+          if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+            return;
+          v118 = pParty->vPosition.z;
+          v111 = pParty->vPosition.x;
+          v114 = pParty->vPosition.z + 2500;
+          v113 = pParty->vPosition.y;
+          v23 = 8;
+          if ( uSkillLevel & 0x0100 )
+          {
+            v107 = 14;
+          }
+          else
+          {
+            if ( (uSkillLevel & 0x80u) == 0 )
+            {
+              if ( !(uSkillLevel & 0x40) )
+                goto LABEL_48;
+              v107 = 10;
+            }
+            else
+            {
+              v107 = 12;
+            }
+          }
+          v23 = v107;
+LABEL_48:
+          v119 = 0.0;
+          spellnumb = 0;
+          if ( v23 > 0 )
+          {
+            v24 = (double)v118;
+            v118 = v23;
+            v112 = v24;
+            v116 = 8 * LODWORD(v120) | 3;
+            do
+            {
+              v26 = rand();
+              v27 = (double)spellnumb;
+              v110 = v27;
+              v28 = (double)SLODWORD(v119);
+              v30 = v26 % 1000;
+              v25 = (double)v114;
+              spellnumc = (double)(v26 % 1000) + v112 - v25;
+              v120 = v28 * v28;
+              v119 = v27 * v27;
+              if ( sqrt(spellnumc * spellnumc + v119 + v120) <= 1.0 )
+              {
+                v32 = 0;
+                pitch = 0;
+              }
+              else
+              {
+                v31 = (signed __int64)sqrt(v119 + v120);
+                v29 = v28;
+                v32 = stru_5C6E00->Atan2((signed __int64)v110, (signed __int64)v29);
+                pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc);
+              }
+              a1.stru_24.Reset();
+              a1.uItemType = stru_4E3ACC[9].uItemType;
+              spellnumd = 0;
+              if ( (signed int)pObjectList->uNumObjects <= 0 )
+              {
+LABEL_57:
+                v34 = 0;
+              }
+              else
+              {
+                v33 = (char *)&pObjectList->pObjects->uObjectID;
+                while ( (short)a1.uItemType != *(short *)v33 )
+                {
+                  ++spellnumd;
+                  v33 += 56;
+                  if ( spellnumd >= (signed int)pObjectList->uNumObjects )
+                    goto LABEL_57;
+                }
+                v34 = spellnumd;
+              }
+              a1.uObjectDescID = v34;
+              a1.field_4C = uSkillLevel;
+              a1.vPosition.x = v111;
+              a1.vPosition.y = v113;
+              a1.vPosition.z = v30 + v114;
+              a1.field_48 = 9;
+              a1.field_50 = 0;
+              a1.uAttributes = 0;
+              a1.uSectorID = 0;
+              a1.uSpriteFrameID = 0;
+              a1.field_58 = v116;
+              a1.field_5C = 0;
+              a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500);
+              a1.uFacing = v32;
+              a1.uSoundID = 0;
+              v35 = v117->uDistance;
+              LODWORD(v119) = v117->uDistance;
+              if ( (double)SLODWORD(v119) >= 307.2 )
+              {
+                if ( v35 >= 1024 )
+                {
+                  if ( v35 >= 2560 )
+                  {
+                    if ( v35 < 5120 )
+                      a1.field_60_distance_related_prolly_lod = 3;
+                  }
+                  else
+                  {
+                    a1.field_60_distance_related_prolly_lod = 2;
+                  }
+                }
+                else
+                {
+                  a1.field_60_distance_related_prolly_lod = 1;
+                }
+              }
+              else
+              {
+                a1.field_60_distance_related_prolly_lod = 0;
+              }
+              a1.field_61 = 2;
+              v36 = a1.Create(
+                      v32,
+                      pitch,
+                      pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+                      0);
+              if ( v36 != -1 )
+              {
+                v37 = 8 * v36;
+                LOBYTE(v37) = v37 | 2;
+                pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], v37, 0, -1, 0, 0, 0, 0);
+              }
+              spellnumb = rand() % 1024 - 512;
+              v38 = rand();
+              v49 = v118-- == 1;
+              LODWORD(v119) = (unsigned __int64)(v38 % 1024) - 512;
+            }
+            while ( !v49 );
+          }
+          return;
+        }
+        if ( (signed int)v7 > 0 )
+        {
+          if ( (signed int)v7 <= 2 )
+          {
+            v39 = 60 * (v6 + 60);
+            goto LABEL_79;
+          }
+          if ( v7 == 3 )
+          {
+            v39 = 180 * (v6 + 20);
+            goto LABEL_79;
+          }
+          if ( v7 == 4 )
+          {
+            v39 = 240 * (v6 + 15);
+LABEL_79:
+            v5->pActorBuffs[19].Apply(
+              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335),
+              v7,
+              0,
+              0,
+              0);
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu);
+            v106 = 0;
+            v104 = 0;
+            v103 = 0;
+            v102 = 0;
+            v40 = 8 * LODWORD(v120);
+            v101 = -1;
+            LOBYTE(v40) = 8 * LOBYTE(v120) | 3;
+            v100 = 0;
+            v99 = v40;
+            v98 = (SoundID)10040;
+LABEL_222:
+            pAudioPlayer->PlaySound(v98, v99, v100, v101, v102, v103, v104, v106);
+            return;
+          }
+        }
+        v39 = 0;
+        goto LABEL_79;
+      }
+      if ( spellnum == 26 || spellnum == 29 )
+        goto LABEL_159;
+      if ( spellnum != 38 )
+      {
+        if ( spellnum == 39 || spellnum == 41 )
+          goto LABEL_159;
+        if ( spellnum != 46 )
+          return;
+        if ( (signed int)v7 > 0 )
+        {
+          if ( (signed int)v7 <= 2 )
+          {
+            v41 = 300 * v6;
+            goto LABEL_91;
+          }
+          if ( v7 == 3 )
+          {
+            v41 = 900 * v6;
+            goto LABEL_91;
+          }
+          if ( v7 == 4 )
+          {
+            v41 = 1200 * v6;
+LABEL_91:
+            v42 = v41 + 3840;
+LABEL_95:
+            v5->pActorBuffs[17].Apply(
+              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335),
+              v7,
+              v6 + 5,
+              0,
+              0);
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
+              v5,
+              (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+            v106 = 0;
+            v104 = 0;
+            v103 = 0;
+            v102 = 0;
+            v43 = 8 * LODWORD(v120);
+            v101 = -1;
+            LOBYTE(v43) = 8 * LOBYTE(v120) | 3;
+            v100 = 0;
+            v99 = v43;
+            v98 = (SoundID)14010;
+            goto LABEL_222;
+          }
+        }
+        v42 = 0;
+        goto LABEL_95;
+      }
+      if ( (signed int)v7 <= 0 )
+        goto LABEL_104;
+      if ( (signed int)v7 <= 2 )
+      {
+        v45 = 300 * v6;
+      }
+      else
+      {
+        if ( v7 != 3 )
+        {
+          if ( v7 == 4 )
+          {
+            v44 = 3600 * (v6 + 64);
+LABEL_105:
+            v5->pActorBuffs[16].Apply(
+              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335),
+              v7,
+              v6 + 5,
+              0,
+              0);
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
+              v5,
+              (unsigned int)((char *)&pLevelEVT_Events[4335].uEventID + 2));
+            v106 = 0;
+            v104 = 0;
+            v103 = 0;
+            v102 = 0;
+            v46 = 8 * LODWORD(v120);
+            v101 = -1;
+            LOBYTE(v46) = 8 * LOBYTE(v120) | 3;
+            v100 = 0;
+            v99 = v46;
+            v98 = (SoundID)13040;
+            goto LABEL_222;
+          }
+LABEL_104:
+          v44 = 0;
+          goto LABEL_105;
+        }
+        v45 = 900 * v6;
+      }
+      v44 = v45 + 3840;
+      goto LABEL_105;
+    }
+    v47 = 0;
+    if ( (signed int)v7 > 0 )
+    {
+      if ( (signed int)v7 <= 2 )
+      {
+        v48 = 2 * v6 + 40;
+        goto LABEL_114;
+      }
+      if ( v7 == 3 )
+      {
+        v48 = 3 * v6 + 60;
+        goto LABEL_114;
+      }
+      if ( v7 == 4 )
+      {
+        LOWORD(v48) = 2 * (3 * v6 + 60);
+LABEL_114:
+        v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
+          v5,
+          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+LABEL_127:
+        v106 = v47;
+        v104 = v47;
+        v103 = v47;
+        v50 = 8 * LODWORD(v120);
+        v102 = v47;
+        v101 = -1;
+        LOBYTE(v50) = 8 * LOBYTE(v120) | 3;
+        v100 = v47;
+        v99 = v50;
+        v98 = (SoundID)14020;
+        goto LABEL_222;
+      }
+    }
+    LOWORD(v48) = 0;
+    goto LABEL_114;
+  }
+  if ( spellnum <= 80 )
+  {
+    if ( spellnum == 80 )
+    {
+      v56 = pParty->pPartyBuffs;
+      do
+      {
+        v56->Reset();
+        ++v56;
+      }
+      while ( (signed int)v56 < (signed int)pParty->pPlayers );
+      a1b = 1;
+      v57 = &pPlayers[1];
+      do
+      {
+        v58 = (*v57)->GetActualWillpower();
+        v59 = (*v57)->_48EA1B_get_static_effect(v58);
+        v60 = (*v57)->GetActualIntelligence();
+        v61 = ((*v57)->_48EA1B_get_static_effect(v60) + v59) >> 1;
+        v62 = (*v57)->GetActualLuck();
+        v63 = v61 + (*v57)->_48EA1B_get_static_effect(v62) + 30;
+        if ( rand() % v63 < 30 )
+        {
+          v64 = 6048;
+          do
+          {
+            ((SpellBuff *)((char *)*v57 + v64))->Reset();
+            v64 += 16;
+          }
+          while ( v64 < 6432 );
+          pOtherOverlayList->_4418B1(11210, a1b + 99, 0, 65536);
+        }
+        ++a1b;
+        ++v57;
+      }
+      while ( (signed int)v57 <= (signed int)&pPlayers[4] );
+      v106 = 0;
+      v104 = 0;
+      v103 = 0;
+      v65 = 8 * LODWORD(v120);
+      v102 = 0;
+      v101 = -1;
+      LOBYTE(v65) = 8 * LOBYTE(v120) | 3;
+      v100 = 0;
+      v99 = v65;
+      v22 = (SoundID)word_4EE088_sound_ids[80];
+      goto LABEL_202;
+    }
+    if ( spellnum != 51 )
+    {
+      if ( spellnum == 57 || spellnum == 65 || spellnum == 70 )
+        goto LABEL_159;
+      if ( spellnum == 73 )
+      {
+        if ( (signed int)v7 <= 0 || (signed int)v7 > 4 )
+          v51 = 0;
+        else
+          v51 = 3600 * v6;
+        v5->pActorBuffs[21].Apply(
+          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335),
+          v7,
+          v6,
+          0,
+          0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u);
+        v106 = 0;
+        v104 = 0;
+        v103 = 0;
+        v102 = 0;
+        v52 = 8 * LODWORD(v120);
+        v101 = -1;
+        LOBYTE(v52) = 8 * LOBYTE(v120) | 3;
+        v100 = 0;
+        v99 = v52;
+        v98 = (SoundID)16060;
+        goto LABEL_222;
+      }
+      if ( spellnum == 77 )
+      {
+        v5->sCurrentHP += 5 * v6 + 10;
+        if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP )
+          v5->sCurrentHP = LOWORD(v5->pMonsterInfo.uHP);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u);
+        v47 = 0;
+        goto LABEL_127;
+      }
+      v49 = spellnum == 78;
+LABEL_158:
+      if ( !v49 )
+        return;
+      goto LABEL_159;
+    }
+    if ( (signed int)v7 > 0 )
+    {
+      if ( (signed int)v7 <= 2 )
+      {
+        v53 = 300 * v6;
+        goto LABEL_138;
+      }
+      if ( v7 == 3 )
+      {
+        v53 = 900 * v6;
+        goto LABEL_138;
+      }
+      if ( v7 == 4 )
+      {
+        v53 = 1200 * v6;
+LABEL_138:
+        v54 = v53 + 3840;
+LABEL_142:
+        v5->pActorBuffs[18].Apply(
+          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335),
+          v7,
+          v6 + 5,
+          0,
+          0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
+          v5,
+          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+        v106 = 0;
+        v104 = 0;
+        v103 = 0;
+        v102 = 0;
+        v55 = 8 * LODWORD(v120);
+        v101 = -1;
+        LOBYTE(v55) = 8 * LOBYTE(v120) | 3;
+        v100 = 0;
+        v99 = v55;
+        v98 = (SoundID)14060;
+        goto LABEL_222;
+      }
+    }
+    v54 = 0;
+    goto LABEL_142;
+  }
+  if ( spellnum == 85 )
+  {
+    if ( (signed int)v7 > 0 )
+    {
+      if ( (signed int)v7 <= 2 )
+      {
+        v96 = 300 * v6 + 3840;
+        goto LABEL_221;
+      }
+      if ( v7 == 3 )
+      {
+        LOWORD(v6) = 3 * v6;
+        v96 = 900 * (uSkillLevel & 0x3F) + 3840;
+        goto LABEL_221;
+      }
+      if ( v7 == 4 )
+      {
+        v96 = 1200 * v6 + 3840;
+        LOWORD(v6) = 4 * v6;
+LABEL_221:
+        v5->pActorBuffs[13].Apply(
+          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335),
+          v7,
+          v6,
+          0,
+          0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
+        v106 = 0;
+        v104 = 0;
+        v103 = 0;
+        v102 = 0;
+        v97 = 8 * LODWORD(v120);
+        v101 = -1;
+        LOBYTE(v97) = 8 * LOBYTE(v120) | 3;
+        v100 = 0;
+        v99 = v97;
+        v98 = (SoundID)17070;
+        goto LABEL_222;
+      }
+    }
+    LOWORD(v6) = uSkillLevel;
+    v96 = 0;
+    goto LABEL_221;
+  }
+  if ( spellnum == 86 )
+  {
+    if ( (signed int)v7 > 0 )
+    {
+      if ( (signed int)v7 <= 2 )
+      {
+        v93 = 300 * v6;
+        goto LABEL_208;
+      }
+      if ( v7 == 3 )
+      {
+        v93 = 900 * v6;
+        goto LABEL_208;
+      }
+      if ( v7 == 4 )
+      {
+        v93 = 1200 * v6;
+LABEL_208:
+        v94 = v93 + 3840;
+LABEL_212:
+        v5->pActorBuffs[14].Apply(
+          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335),
+          v7,
+          v6 + 5,
+          0,
+          0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu);
+        v106 = 0;
+        v104 = 0;
+        v103 = 0;
+        v102 = 0;
+        v95 = 8 * LODWORD(v120);
+        v101 = -1;
+        LOBYTE(v95) = 8 * LOBYTE(v120) | 3;
+        v100 = 0;
+        v99 = v95;
+        v98 = (SoundID)17080;
+        goto LABEL_222;
+      }
+    }
+    v94 = 0;
+    goto LABEL_212;
+  }
+  if ( spellnum == 90 )
+    goto LABEL_159;
+  if ( spellnum != 93 )
+  {
+    if ( spellnum != 95 )
+    {
+      v49 = spellnum == 97;
+      goto LABEL_158;
+    }
+    if ( (signed int)v7 > 0 )
+    {
+      if ( (signed int)v7 <= 3 )
+      {
+        v67 = 300 * v6;
+        goto LABEL_168;
+      }
+      if ( v7 == 4 )
+      {
+        v67 = 900 * v6;
+LABEL_168:
+        v68 = v67 + 3840;
+LABEL_171:
+        v5->pActorBuffs[20].Apply(
+          pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335),
+          v7,
+          0,
+          0,
+          0);
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
+          v5,
+          (unsigned int)((char *)&array_77EC08[1607].v_18.z + 2));
+        v106 = 0;
+        v104 = 0;
+        v103 = 0;
+        v102 = 0;
+        v69 = 8 * LODWORD(v120);
+        v101 = -1;
+        LOBYTE(v69) = 8 * LOBYTE(v120) | 3;
+        v100 = 0;
+        v99 = v69;
+        v98 = (SoundID)18060;
+        goto LABEL_222;
+      }
+    }
+    v68 = 0;
+    goto LABEL_171;
+  }
+  v70 = 3;
+  if ( uSkillLevel & 0x100 )
+  {
+    v108 = 9;
+  }
+  else
+  {
+    if ( (uSkillLevel & 0x80u) == 0 )
+    {
+      if ( !(uSkillLevel & 0x40) )
+        goto LABEL_179;
+      v108 = 5;
+    }
+    else
+    {
+      v108 = 7;
+    }
+  }
+  v70 = v108;
+LABEL_179:
+  spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
+  a1.uItemType = stru_4E3ACC[93].uItemType;
+  v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1);
+  v71 = 0;
+  if ( (signed int)pObjectList->uNumObjects <= 0 )
+  {
+LABEL_183:
+    LOWORD(v71) = 0;
+  }
+  else
+  {
+    v72 = &pObjectList->pObjects->uObjectID;
+    while ( stru_4E3ACC[93].uItemType != *v72 )
+    {
+      ++v71;
+      v72 += 28;
+      if ( v71 >= (signed int)pObjectList->uNumObjects )
+        goto LABEL_183;
+    }
+  }
+  a1.uObjectDescID = v71;
+  a1.stru_24.Reset();
+  a1.field_48 = 93;
+  v73 = v5->vPosition.x;
+  v74 = v5->vPosition.y;
+  a1.field_4C = uSkillLevel;
+  a1.vPosition.x = v73;
+  v75 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1);
+  v76 = v117;
+  v77 = LOWORD(v117->uYawAngle);
+  a1.field_50 = 0;
+  a1.vPosition.y = v74;
+  a1.vPosition.z = v75;
+  a1.uFacing = v77;
+  a1.uSoundID = 0;
+  a1.uAttributes = 0;
+  a1.uSectorID = pIndoor->GetSector(v73, v74, v75);
+  v78 = 8 * LODWORD(v120);
+  LOBYTE(v78) = 8 * LOBYTE(v120) | 3;
+  a1.field_58 = v78;
+  a1.uSpriteFrameID = 0;
+  a1.field_5C = 0;
+  a1.field_60_distance_related_prolly_lod = 3;
+  a1c = spellnume / -2;
+  if ( spellnume / -2 > spellnume / 2 )
+  {
+    v80 = spellnume / -2;
+  }
+  else
+  {
+    do
+    {
+      v79 = v76->uYawAngle;
+      a1.uFacing = a1c + LOWORD(v76->uYawAngle);
+      v80 = a1.Create(
+              v79,
+              v76->uPitchAngle,
+              pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+              0);
+      a1c += v116;
+    }
+    while ( a1c <= spellnume / 2 );
+  }
+  if ( v80 != -1 )
+  {
+    v106 = 0;
+    v104 = 0;
+    v103 = 0;
+    v102 = 0;
+    v81 = 8 * v80;
+    v101 = -1;
+    LOBYTE(v81) = v81 | 2;
+    v100 = 0;
+    v99 = v81;
+    v22 = (SoundID)word_4EE088_sound_ids[93];
+    goto LABEL_202;
+  }
+}
+
+
+//----- (0043ABB0) --------------------------------------------------------
+bool Actor::_43ABB0(Actor *a1, Actor *a2)
+{
+  unsigned int v2; // esi@1
+  unsigned int v3; // edi@1
+  bool result; // eax@9
+
+  v2 = a1->uAlly;
+  v3 = a2->uAlly;
+  if ( !v2 )
+    v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1;
+  if ( !v3 )
+    v3 = (a2->pMonsterInfo.uID - 1) / 3 + 1;
+  if ( (signed int)v2 >= 39 && (signed int)v2 <= 44 && (signed int)v3 >= 39 && (signed int)v3 <= 44
+    || (signed int)v2 >= 45 && (signed int)v2 <= 50 && (signed int)v3 >= 45 && (signed int)v3 <= 50
+    || (signed int)v2 >= 51 && (signed int)v2 <= 62 && (signed int)v3 >= 51 && (signed int)v3 <= 62
+    || (signed int)v2 >= 78 && (signed int)v2 <= 83 && (signed int)v3 >= 78 && (signed int)v3 <= 83 )
+    result = 1;
+  else
+    result = v2 == v3;
+  return result;
+}
+
+//----- (0043AC45) --------------------------------------------------------
+void Actor::_43AC45(unsigned int uActorID, int a2)
+{
+  Actor *v2; // esi@1
+  char *v3; // edi@4
+  int v4; // ebx@8
+  int v5; // ST1C_4@8
+  int v6; // eax@8
+  int v7; // [sp+4h] [bp-10h]@1
+  unsigned int uActorID_; // [sp+Ch] [bp-8h]@1
+  signed int v9; // [sp+10h] [bp-4h]@3
+
+  uActorID_ = uActorID;
+  v2 = &pActors[uActorID];
+  v7 = a2;
+  if ( a2 == 1 )
+    BYTE2(v2->uAttributes) |= 8u;
+  v9 = 0;
+  if ( (signed int)uNumActors > 0 )
+  {
+    v3 = (char *)&pActors[0].vPosition.y;
+    do
+    {
+      if ( ((Actor *)(v3 - 144))->CanAct() )
+      {
+        if ( v9 != uActorID_ )
+        {
+          if ( Actor::_43ABB0(v2, (Actor *)(v3 - 144)) )
+          {
+            v4 = abs(*((short *)v3 - 1) - v2->vPosition.x);
+            v5 = abs(*(short *)v3 - v2->vPosition.y);
+            v6 = abs(*((short *)v3 + 1) - v2->vPosition.z);
+            if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 )
+            {
+              *(v3 - 83) = 4;
+              if ( v7 == 1 )
+                *(v3 - 106) |= 8u;
+            }
+          }
+        }
+      }
+      ++v9;
+      v3 += 836;
+    }
+    while ( v9 < (signed int)uNumActors );
+  }
+}
+
+
+//----- (00404874) --------------------------------------------------------
+char __fastcall Actor::_404874(unsigned int uActorID, AIDirection *a2, int a3, char a4)
+{
+  AIDirection *v4; // edi@1
+  Actor *v5; // esi@1
+  char result; // al@1
+  char *v7; // eax@15
+  unsigned __int16 v8; // ax@18
+  unsigned __int16 v9; // ax@19
+  __int16 v10; // ax@19
+  signed int v11; // ecx@19
+  int v12; // eax@19
+  int v13; // edx@28
+  //LayingItem a1; // [sp+Ch] [bp-74h]@1
+  unsigned int v15; // [sp+7Ch] [bp-4h]@1
+  signed int v16; // [sp+88h] [bp+8h]@14
+  signed int v17; // [sp+88h] [bp+8h]@19
+
+  v15 = uActorID;
+  v4 = a2;
+  v5 = &pActors[uActorID];
+
+  LayingItem a1; // [sp+Ch] [bp-74h]@1
+  //LayingItem::LayingItem(&a1);
+
+  result = a3 - 1;
+  switch ( a3 )
+  {
+    case 1:
+      a1.uItemType = 545;
+      goto LABEL_14;
+    case 2:
+      a1.uItemType = 550;
+      goto LABEL_14;
+    case 3:
+      a1.uItemType = 510;
+      goto LABEL_14;
+    case 4:
+      a1.uItemType = 500;
+      goto LABEL_14;
+    case 5:
+      a1.uItemType = 515;
+      goto LABEL_14;
+    case 6:
+      a1.uItemType = 505;
+      goto LABEL_14;
+    case 7:
+      a1.uItemType = 530;
+      goto LABEL_14;
+    case 8:
+      a1.uItemType = 525;
+      goto LABEL_14;
+    case 9:
+      a1.uItemType = 520;
+      goto LABEL_14;
+    case 10:
+      a1.uItemType = 535;
+      goto LABEL_14;
+    case 11:
+      a1.uItemType = 540;
+      goto LABEL_14;
+    case 13:
+      a1.uItemType = 555;
+LABEL_14:
+      v16 = 0;
+      if ( (signed int)pObjectList->uNumObjects <= 0 )
+        goto LABEL_18;
+      v7 = (char *)&pObjectList->pObjects->uObjectID;
+      break;
+    default:
+      return result;
+  }
+  while ( (short)a1.uItemType != *(short *)v7 )
+  {
+    ++v16;
+    v7 += 56;
+    if ( v16 >= (signed int)pObjectList->uNumObjects )
+    {
+LABEL_18:
+      v8 = 0;
+      goto LABEL_19;
+    }
+  }
+  v8 = v16;
+LABEL_19:
+  a1.uObjectDescID = v8;
+  a1.stru_24.Reset();
+  a1.vPosition.x = v5->vPosition.x;
+  a1.field_48 = 0;
+  a1.vPosition.y = v5->vPosition.y;
+  a1.field_4C = 0;
+  v17 = v5->uActorHeight;
+  a1.field_50 = 0;
+  v9 = LOWORD(v4->uYawAngle);
+  a1.vPosition.z = v5->vPosition.z - (unsigned int)(signed __int64)((double)v17 * -0.75);
+  a1.uFacing = v9;
+  a1.uSoundID = 0;
+  a1.uAttributes = 0;
+  v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
+  v11 = v4->uDistance;
+  a1.uSectorID = v10;
+  v12 = 8 * v15;
+  LOBYTE(v12) = 8 * v15 | AI_OBJECT_ACTOR;
+  a1.uSpriteFrameID = 0;
+  a1.field_58 = v12;
+  a1.field_5C = 0;
+  if ( (double)v11 >= 307.2 )
+  {
+    if ( v11 >= 1024 )
+    {
+      a1.field_60_distance_related_prolly_lod = 2;
+      if ( v11 >= 2560 )
+        a1.field_60_distance_related_prolly_lod = 3;
+    }
+    else
+    {
+      a1.field_60_distance_related_prolly_lod = 1;
+    }
+  }
+  else
+  {
+    a1.field_60_distance_related_prolly_lod = 0;
+  }
+  a1.field_61 = a4;
+  result = a1.Create(
+             v4->uYawAngle,
+             v4->uPitchAngle,
+             pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+             0);
+  if ( v5->pMonsterInfo.uSpecialAbilityType == 1 )
+  {
+    result = v5->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+    if ( result == 2 )
+    {
+      a1.vPosition.z += 40;
+      v13 = v4->uYawAngle;
+    }
+    else
+    {
+      if ( result != 3 )
+        return result;
+      a1.Create(
+        v4->uYawAngle + 30,
+        v4->uPitchAngle,
+        pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+        0);
+      v13 = v4->uYawAngle - 30;
+    }
+    result = a1.Create(
+               v13,
+               v4->uPitchAngle,
+               pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
+               0);
+  }
+  return result;
+}
+
+//----- (00404736) --------------------------------------------------------
+signed int __fastcall Actor::Explode(unsigned int uActorID)
+{
+  Actor *v1; // esi@1
+  signed int v2; // edx@1
+  char *v3; // ecx@2
+  unsigned __int16 v4; // ax@5
+  int v5; // ebx@6
+  int v6; // ecx@6
+  int v7; // eax@6
+  LayingItem a1; // [sp+Ch] [bp-78h]@1
+  unsigned int v10; // [sp+7Ch] [bp-8h]@1
+  int v11; // [sp+80h] [bp-4h]@6
+
+  v10 = uActorID;
+  v1 = &pActors[uActorID];
+  v2 = 0;
+  a1.uItemType = 600;
+  if ( (signed int)pObjectList->uNumObjects <= 0 )
+  {
+LABEL_5:
+    v4 = 0;
+  }
+  else
+  {
+    v3 = (char *)&pObjectList->pObjects->uObjectID;
+    while ( *(short *)v3 != 600 )
+    {
+      ++v2;
+      v3 += 56;
+      if ( v2 >= (signed int)pObjectList->uNumObjects )
+        goto LABEL_5;
+    }
+    v4 = v2;
+  }
+  a1.uObjectDescID = v4;
+  a1.stru_24.Reset();
+  a1.vPosition.y = v1->vPosition.y;
+  a1.field_48 = 0;
+  v5 = v1->vPosition.x;
+  v11 = v1->uActorHeight;
+  a1.field_4C = 0;
+  a1.field_50 = 0;
+  a1.vPosition.x = v5;
+  v6 = v1->vPosition.z - (unsigned int)(signed __int64)((double)v11 * -0.75);
+  a1.uFacing = 0;
+  a1.vPosition.z = v6;
+  a1.uSoundID = 0;
+  a1.uAttributes = 0;
+  a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6);
+  v7 = 8 * v10;
+  LOBYTE(v7) = 8 * v10 | 3;
+  a1.uSpriteFrameID = 0;
+  a1.field_58 = v7;
+  a1.field_5C = 0;
+  a1.field_60_distance_related_prolly_lod = 3;
+  a1.field_61 = 4;
+  return a1.Create(0, 0, 0, 0);
+}
+
+//----- (004040E9) --------------------------------------------------------
+// // Get direction vector from object1 to object2,
+// // distance from object1 to object2 and Euler angles of the direction vector
+// //
+// //
+// // object1 & object2 format :  objectType | (objectID << 3)
+// //    objectType == 2 - LayingItem
+// //    objectType == 3 - Actor
+// //    objectType == 4 - Party
+// //    objectType == 5 - Decoration
+// //
+// // originally this function had following prototype:
+// // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4)
+// // but compiler converts functions returning structures by value in the such way
+AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4)
+{
+  signed int v4; // eax@1
+  unsigned int v5; // ecx@1
+  unsigned int v6; // ebx@1
+  int v7; // ecx@2
+  int v8; // ecx@3
+  int v9; // ecx@4
+  BLVFace *v10; // eax@8
+  unsigned int v11; // ecx@8
+  signed int v12; // eax@9
+  int v13; // ecx@9
+  int v14; // eax@9
+  int v15; // eax@11
+  int v16; // eax@12
+  int v17; // eax@13
+  int v18; // edx@15
+  signed int v19; // eax@25
+  signed int v20; // eax@28
+  int v21; // ebx@28
+  signed int v22; // eax@28
+  BLVFace *v23; // eax@35
+  int v24; // edx@35
+  unsigned int v25; // ecx@35
+  signed int v26; // eax@36
+  int v27; // ecx@36
+  int v28; // eax@36
+  int v29; // eax@37
+  signed int v30; // eax@42
+  double v31; // st7@45
+  double v32; // st6@45
+  double v33; // st7@45
+  AIDirection *result; // eax@48
+  int v35; // [sp-18h] [bp-64h]@17
+  int v36; // [sp-14h] [bp-60h]@17
+  Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15
+  int *v38; // [sp-4h] [bp-50h]@15
+  int *v39; // [sp+0h] [bp-4Ch]@15
+  int *v40; // [sp+4h] [bp-48h]@15
+  AIDirection v41; // [sp+14h] [bp-38h]@46
+  float v42; // [sp+30h] [bp-1Ch]@23
+  float v43; // [sp+34h] [bp-18h]@45
+  float v44; // [sp+38h] [bp-14h]@33
+  float v45; // [sp+3Ch] [bp-10h]@33
+  int outz; // [sp+40h] [bp-Ch]@6
+  int outy; // [sp+44h] [bp-8h]@6
+  int outx; // [sp+48h] [bp-4h]@6
+  float a4a; // [sp+58h] [bp+Ch]@45
+
+  v4 = (signed int)uObj1ID >> 3;
+  v5 = (uObj1ID & 7) - 2;
+  v6 = uObj2ID;
+  if ( !v5 )
+  {
+    v19 = v4;
+    outx = pLayingItems[v19].vPosition.x;
+    v13 = pLayingItems[v19].vPosition.y;
+    v14 = pLayingItems[v19].vPosition.z;
+    goto LABEL_26;
+  }
+  v7 = v5 - 1;
+  if ( !v7 )
+  {
+    outx = pActors[v4].vPosition.x;
+    outy = pActors[v4].vPosition.y;
+    LODWORD(v42) = pActors[v4].uActorHeight;
+    v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75);
+    goto LABEL_24;
+  }
+  v8 = v7 - 1;
+  if ( !v8 )
+  {
+    if ( !v4 )
+    {
+      outx = pParty->vPosition.x;
+      outy = pParty->vPosition.y;
+      v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+LABEL_27:
+      outz = v14;
+      goto LABEL_28;
+    }
+    v15 = v4 - 1;
+    if ( v15 )
+    {
+      v16 = v15 - 1;
+      if ( v16 )
+      {
+        v17 = v16 - 1;
+        if ( v17 )
+        {
+          if ( v17 != 1 )
+            goto LABEL_28;
+          v40 = &outz;
+          v39 = &outy;
+          v38 = &outx;
+          v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
+          v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+          goto LABEL_20;
+        }
+        v40 = &outz;
+        v39 = &outy;
+        v38 = &outx;
+        v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+      }
+      else
+      {
+        v40 = &outz;
+        v39 = &outy;
+        v38 = &outx;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
+      }
+      *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
+      v36 = 0;
+      v35 = 8;
+LABEL_21:
+      Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40);
+      goto LABEL_28;
+    }
+    v40 = &outz;
+    v39 = &outy;
+    v38 = &outx;
+    v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+    v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
+LABEL_20:
+    *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
+    v36 = 0;
+    v35 = 24;
+    goto LABEL_21;
+  }
+  v9 = v8 - 1;
+  if ( !v9 )
+  {
+    v12 = v4;
+    outx = pLevelDecorations[v12].vPosition.x;
+    v13 = pLevelDecorations[v12].vPosition.y;
+    v14 = pLevelDecorations[v12].vPosition.z;
+LABEL_26:
+    outy = v13;
+    goto LABEL_27;
+  }
+  if ( v9 != 1 )
+  {
+    outz = 0;
+    outy = 0;
+    outx = 0;
+    goto LABEL_28;
+  }
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  {
+    v10 = &pIndoor->pFaces[v4];
+    outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1;
+    outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1;
+    v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1;
+LABEL_24:
+    outz = v11;
+  }
+LABEL_28:
+  v20 = v6;
+  v21 = v6 & 7;
+  v22 = v20 >> 3;
+  if ( v21 == 2 )
+  {
+    v30 = v22;
+    LODWORD(v45) = pLayingItems[v30].vPosition.x;
+    v27 = pLayingItems[v30].vPosition.y;
+    v28 = pLayingItems[v30].vPosition.z;
+    goto LABEL_43;
+  }
+  if ( v21 == 3 )
+  {
+    LODWORD(v45) = pActors[v22].vPosition.x;
+    LODWORD(v44) = pActors[v22].vPosition.y;
+    v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75);
+    goto LABEL_41;
+  }
+  if ( v21 == 4 )
+  {
+    LODWORD(v45) = pParty->vPosition.x;
+    LODWORD(v44) = pParty->vPosition.y;
+    v29 = a4;
+    if ( !a4 )
+      v29 = pParty->sEyelevel;
+    v28 = pParty->vPosition.z + v29;
+    goto LABEL_44;
+  }
+  if ( v21 == 5 )
+  {
+    v26 = v22;
+    LODWORD(v45) = pLevelDecorations[v26].vPosition.x;
+    v27 = pLevelDecorations[v26].vPosition.y;
+    v28 = pLevelDecorations[v26].vPosition.z;
+LABEL_43:
+    LODWORD(v44) = v27;
+LABEL_44:
+    a4 = v28;
+    goto LABEL_45;
+  }
+  if ( v21 != 6 )
+  {
+    a4 = 0;
+    v44 = 0.0;
+    v45 = 0.0;
+    goto LABEL_45;
+  }
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  {
+    v23 = &pIndoor->pFaces[v22];
+    v24 = v23->pBounding.y1;
+    LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1;
+    LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1;
+    v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1;
+LABEL_41:
+    a4 = v25;
+  }
+LABEL_45:
+  v31 = (double)SLODWORD(v45) - (double)outx;
+  v42 = v31;
+  v32 = (double)SLODWORD(v44) - (double)outy;
+  v43 = v32;
+  a4a = (double)a4 - (double)outz;
+  v45 = v32 * v32;
+  v44 = v31 * v31;
+  v33 = sqrt(a4a * a4a + v44 + v45);
+  if ( v33 <= 1.0 )
+  {
+    v41.vDirection.x = 65536;
+    v41.vDirection.y = 0;
+    v41.vDirection.z = 0;
+    v41.uDistance = 1;
+    v41.uDistanceXZ = 1;
+    v41.uYawAngle = 0;
+    v41.uPitchAngle = 0;
+  }
+  else
+  {
+    v41.vDirection.x = (signed __int64)(1.0 / v33 * v42 * 65536.0);
+    v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0);
+    v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0);
+    v41.uDistance = (signed __int64)v33;
+    v41.uDistanceXZ = (signed __int64)sqrt(v44 + v45);
+    v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43);
+    v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
+  }
+  result = pOut;
+  memcpy(pOut, &v41, 0x1Cu);
+  return result;
+}
+
+
+//----- (00404030) --------------------------------------------------------
+unsigned int __fastcall Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4)
+{
+  unsigned int v4; // edi@1
+  unsigned int v5; // esi@1
+  unsigned int result; // eax@2
+  AIDirection *v7; // eax@3
+  unsigned int v8; // ecx@3
+  Actor *v9; // ebx@3
+  AIDirection *v10; // esi@4
+  unsigned __int16 v11; // ax@5
+  AIDirection a3; // [sp+8h] [bp-38h]@4
+  AIDirection v13; // [sp+24h] [bp-1Ch]@4
+
+  v4 = uObjID;
+  v5 = uActorID;
+  if ( rand() % 100 >= 5 )
+  {
+    v7 = a4;
+    v8 = 0;
+    v9 = &pActors[v5];
+    if ( !a4 )
+    {
+      v10 = Actor::GetDirectionInfo(8 * v5 | AI_OBJECT_ACTOR, v4, &a3, 0);
+      v7 = &v13;
+      memcpy(&v13, v10, sizeof(v13));
+      v8 = 0;
+    }
+    v9->uYawAngle = LOWORD(v7->uYawAngle);
+    v11 = LOWORD(v7->uPitchAngle);
+    v9->uCurrentActionTime = v8;
+    v9->vVelocity.z = v8;
+    v9->vVelocity.y = v8;
+    v9->vVelocity.x = v8;
+    v9->uPitchAngle = v11;
+    v9->uCurrentActionLength = 256;
+    v9->uAIState = Interacting;
+    result = v9->UpdateAnimation();
+  }
+  else
+  {
+    result = Actor::_402F87(v5, v4, a4);
+  }
+  return result;
+}
+
+//----- (00403F58) --------------------------------------------------------
+unsigned int __fastcall Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4)
+{
+  unsigned int v4; // esi@1
+  unsigned int result; // eax@2
+  AIDirection *v6; // eax@3
+  unsigned int v7; // edi@3
+  Actor *v8; // ebx@3
+  AIDirection *v9; // esi@4
+  AIDirection a3; // [sp+4h] [bp-3Ch]@4
+  AIDirection v11; // [sp+20h] [bp-20h]@4
+  signed int a2; // [sp+3Ch] [bp-4h]@1
+
+  a2 = uObjID;
+  v4 = uActorID;
+  if ( rand() % 2 )
+  {
+    result = Actor::_402F87(v4, a2, a4);
+  }
+  else
+  {
+    v6 = a4;
+    v7 = 0;
+    v8 = &pActors[v4];
+    if ( !a4 )
+    {
+      v9 = Actor::GetDirectionInfo(8 * v4 | 3, a2, &a3, 0);
+      v6 = &v11;
+      memcpy(&v11, v9, sizeof(v11));
+      v7 = 0;
+    }
+    v8->uYawAngle = LOWORD(v6->uYawAngle);
+    v8->uPitchAngle = LOWORD(v6->uPitchAngle);
+    if ( uActionLength == v7 )
+      v8->uCurrentActionLength = rand() % 256 + 256;
+    else
+      v8->uCurrentActionLength = uActionLength;
+    v8->uCurrentActionTime = v7;
+    v8->uAIState = Standing;
+    v8->vVelocity.z = v7;
+    v8->vVelocity.y = v7;
+    v8->vVelocity.x = v7;
+    result = v8->UpdateAnimation();
+  }
+  return result;
+}
+
+
+
+//----- (00403EB6) --------------------------------------------------------
+unsigned int __fastcall Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4)
+{
+  AIDirection *v4; // eax@1
+  unsigned int v5; // esi@1
+  Actor *v6; // ebx@1
+  AIDirection *v7; // esi@2
+  AIDirection a3; // [sp+Ch] [bp-38h]@2
+  AIDirection v10; // [sp+28h] [bp-1Ch]@2
+
+  v4 = a4;
+  v5 = 0;
+  v6 = &pActors[uActorID];
+  if ( !a4 )
+  {
+    v7 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0);
+    v4 = &v10;
+    memcpy(&v10, v7, sizeof(v10));
+    v5 = 0;
+  }
+  v6->uYawAngle = LOWORD(v4->uYawAngle);
+  if ( uActionLength == v5 )
+    v6->uCurrentActionLength = rand() % 256 + 256;
+  else
+    v6->uCurrentActionLength = uActionLength;
+  v6->uCurrentActionTime = v5;
+  v6->uAIState = Standing;
+  v6->vVelocity.z = v5;
+  v6->vVelocity.y = v5;
+  v6->vVelocity.x = v5;
+  return v6->UpdateAnimation();
+}
+
+
+//----- (00403E61) --------------------------------------------------------
+void __fastcall Actor::StandAwhile(unsigned int uActorID)
+{
+  Actor *v1; // esi@1
+
+  v1 = &pActors[uActorID];
+  v1->uCurrentActionLength = rand() % 128 + 128;
+  v1->uCurrentActionTime = 0;
+  v1->uAIState = Standing;
+  v1->vVelocity.z = 0;
+  v1->vVelocity.y = 0;
+  v1->vVelocity.x = 0;
+  v1->UpdateAnimation();
+}
+
+//----- (00403C6C) --------------------------------------------------------
+unsigned int __fastcall Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
+{
+  Actor *v3; // ebx@1
+  char v4; // zf@1
+  unsigned int result; // eax@3
+  AIDirection *v6; // esi@6
+  AIDirection *v7; // edi@6
+  signed int v8; // eax@7
+  double v9; // st7@9
+  Vec3_int_ v10; // ST04_12@9
+  int v11; // eax@10
+  AIDirection *v12; // eax@11
+  unsigned int v13; // esi@11
+  AIDirection *v14; // esi@12
+  SpriteFrame *v15; // ecx@13
+  __int16 v16; // ax@13
+  unsigned int v17; // ecx@13
+  signed __int64 v18; // qax@13
+  AIDirection a3; // [sp+Ch] [bp-48h]@12
+  AIDirection v20; // [sp+28h] [bp-2Ch]@12
+  unsigned int v21; // [sp+44h] [bp-10h]@9
+  signed int a2; // [sp+48h] [bp-Ch]@1
+  int v23; // [sp+4Ch] [bp-8h]@6
+  unsigned int v24; // [sp+50h] [bp-4h]@1
+  unsigned int v25; // [sp+5Ch] [bp+8h]@13
+
+  v3 = &pActors[uActorID];
+  a2 = edx0;
+  v4 = v3->pMonsterInfo.uMovementType == 5;
+  v24 = uActorID;
+  if ( v4 && v3->pMonsterInfo.uAIType == 1 )
+  {
+    result = Actor::_403EB6(uActorID, edx0, 0, arg0);
+  }
+  else
+  {
+    if ( (edx0 & 7) == 3 )
+    {
+      v8 = edx0 >> 3;
+      v6 = (AIDirection *)pActors[v8].vPosition.x;
+      v7 = (AIDirection *)pActors[v8].vPosition.y;
+      v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z);
+    }
+    else
+    {
+      if ( (edx0 & 7) == 4 )
+      {
+        v6 = (AIDirection *)pParty->vPosition.x;
+        v7 = (AIDirection *)pParty->vPosition.y;
+        v23 = pParty->vPosition.z + pParty->sEyelevel;
+      }
+      else
+      {
+        v6 = arg0;
+        v7 = arg0;
+      }
+    }
+    v21 = v3->uActorHeight;
+    v9 = (double)(signed int)v21 * 0.75;
+    v21 = v3->vPosition.z;
+    v10.z = (signed __int64)(v9 + (double)(signed int)v21);
+    v10.y = v3->vPosition.y;
+    v10.x = v3->vPosition.x;
+    if ( sub_407A1C((int)v6, (int)v7, v23, v10) )
+    {
+      v12 = arg0;
+      v13 = 0;
+      if ( !arg0 )
+      {
+        v14 = Actor::GetDirectionInfo(8 * v24 | 3, a2, &a3, 0);
+        v12 = &v20;
+        memcpy(&v20, v14, sizeof(v20));
+        v13 = 0;
+      }
+      v15 = pSpriteFrameTable->pSpriteSFrames;
+      v3->uYawAngle = LOWORD(v12->uYawAngle);
+      v16 = v15[v3->pSpriteIDs[2]].uAnimLength;
+      v17 = v24;
+      v3->uCurrentActionLength = 8 * v16;
+      v3->uCurrentActionTime = v13;
+      v3->uAIState = AttackingMelee;
+      Actor::PlaySound(v17, 0);
+      LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+      v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+      if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v13
+        && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v13 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v13) )
+      {
+        LODWORD(v18) = 2 * v18;
+        v25 = v18;
+      }
+      if ( pParty->bTurnBasedModeOn != 1 )
+        v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333);
+      v3->pMonsterInfo.uRecoveryTime = v18;
+      v3->vVelocity.z = v13;
+      v3->vVelocity.y = v13;
+      v3->vVelocity.x = v13;
+      result = v3->UpdateAnimation();
+    }
+    else
+    {
+      v11 = rand();
+      result = Actor::_402AD7(v24, a2, v11 % 2, 64, arg0);
+    }
+  }
+  return result;
+}
+
+
+//----- (00438CF3) --------------------------------------------------------
+void Actor::_438CF3(unsigned int uActorID)
+{
+  unsigned int v1; // esi@1
+  unsigned int v2; // edi@2
+  char v3; // bl@3
+  char *v4; // ecx@16
+  signed int v5; // eax@18
+  Player **ppPlayers; // esi@20
+
+  v1 = uLevelMapStatsID;
+  if ( !uLevelMapStatsID || (v2 = uActorID, !pActors[uActorID]._438B9B()) )
+    return;
+  v3 = 1;
+  if ( v1 != 5 )
+  {
+    if ( v1 == 6 || v1 == 7 )
+    {
+      _449B57_test_bit(pParty->_award_bits, 99);
+      if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 100) )
+        return;
+      goto LABEL_12;
+    }
+    if ( v1 != 8 )
+      goto LABEL_12;
+  }
+  if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 99) )
+    v3 = 0;
+  if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 100) )
+    v3 = 1;
+  if ( v3 )
+  {
+LABEL_12:
+    pParty->uFine += 100
+                  * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm
+                   + pActors[v2].pMonsterInfo.uLevel
+                   + GetPartyReputation());
+    if ( pParty->uFine < 0 )
+      pParty->uFine = 0;
+    if ( pParty->uFine > 4000000 )
+      pParty->uFine = 4000000;
+    v4 = (char *)&pOutdoor->ddm;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      v4 = (char *)&pIndoor->dlv;
+    v5 = *((int *)v4 + 2);
+    if ( v5 < 10000 )
+      *((int *)v4 + 2) = v5 + 1;
+    ppPlayers = &pPlayers[1];
+    do
+    {
+      if ( pParty->uFine )
+      {
+        if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->field_152, 1) )
+          _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->field_152, 1, 1u);
+      }
+      ++ppPlayers;
+    }
+    while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
+  }
+}
+
+
+//----- (0043AE80) --------------------------------------------------------
+int Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3)
+{
+  int result; // eax@1
+  unsigned int v4; // esi@1
+  int v5; // [sp-14h] [bp-18h]@3
+  unsigned int v6; // [sp-10h] [bp-14h]@3
+  int v7; // [sp-Ch] [bp-10h]@3
+  int v8; // [sp-8h] [bp-Ch]@3
+  __int16 v9; // [sp-4h] [bp-8h]@3
+
+  result = a2 - 1;
+  v4 = 8 * uActorID | 3;
+  switch ( a2 )
+  {
+    case 1:
+      if ( a3 )
+      {
+        v9 = 0;
+        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
+        v7 = 0;
+        LOWORD(v6) = v4;
+        v5 = 904;
+        goto LABEL_16;
+      }
+      return result;
+    case 2:
+      if ( a3 )
+      {
+        v9 = 0;
+        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
+        v7 = 0;
+        LOWORD(v6) = v4;
+        v5 = 905;
+        goto LABEL_16;
+      }
+      return result;
+    case 3:
+      if ( a3 )
+      {
+        v9 = 0;
+        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
+        v7 = 0;
+        LOWORD(v6) = v4;
+        v5 = 906;
+        goto LABEL_16;
+      }
+      return result;
+    case 4:
+      if ( a3 )
+      {
+        v9 = 0;
+        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
+        v7 = 0;
+        LOWORD(v6) = v4;
+        v5 = 907;
+        goto LABEL_16;
+      }
+      return result;
+    case 5:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 901;
+      goto LABEL_16;
+    case 6:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 902;
+      goto LABEL_16;
+    case 7:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 903;
+      goto LABEL_16;
+    case 8:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 900;
+      goto LABEL_16;
+    case 9:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 909;
+      goto LABEL_16;
+    case 10:
+      v9 = 4;
+      v8 = 65536;
+      v7 = 0;
+      v6 = 8 * uActorID | 3;
+      v5 = 908;
+LABEL_16:
+      result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9);
+      break;
+    default:
+      return result;
+  }
+  return result;
+}
+
+
+//----- (0043B3E0) --------------------------------------------------------
+int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2)
+{
+  signed int v2; // ebp@1
+  int v3; // eax@9
+  signed int v4; // edi@9
+  int v5; // esi@9
+  int v6; // ebx@11
+  unsigned __int16 v8; // si@21
+  int v9; // edi@21
+  signed int v10; // eax@23
+  int v11; // [sp+10h] [bp-4h]@1
+
+  v2 = 0;
+  v11 = 0;
+  if ( a2 )
+  {
+    if ( a2 == 1 )
+    {
+      v3 = a1->pMonsterInfo.uAttack2DamageDiceRolls;
+      v4 = a1->pMonsterInfo.uAttack2DamageDiceSides;
+      v5 = a1->pMonsterInfo.uAttack2DamageBonus;
+    }
+    else
+    {
+      if ( a2 <= 1 )
+        return 0;
+      if ( a2 <= 3 )
+      {
+        if ( a2 == 2 )
+        {
+          v8 = a1->pMonsterInfo.uSpellSkillAndMastery1;
+          v9 = a1->pMonsterInfo.uSpell1ID;
+        }
+        else
+        {
+          v8 = a1->pMonsterInfo.uSpellSkillAndMastery2;
+          v9 = a1->pMonsterInfo.uSpell2ID;
+        }
+        v10 = SkillToMastery(v8);
+        return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0);
+      }
+      if ( a2 != 4 )
+        return 0;
+      v3 = a1->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
+      v4 = a1->pMonsterInfo.uSpecialAbilityDamageDiceSides;
+      v5 = a1->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+    }
+  }
+  else
+  {
+    if ( (signed __int64)a1->pActorBuffs[14].uExpireTime > 0 )
+      v2 = a1->pActorBuffs[14].uPower;
+    if ( (signed __int64)a1->pActorBuffs[18].uExpireTime > 0 && a1->pActorBuffs[18].uPower > v2 )
+      v2 = a1->pActorBuffs[18].uPower;
+    if ( (signed __int64)a1->pActorBuffs[21].uExpireTime > 0 )
+      v2 += a1->pActorBuffs[21].uPower;
+    v3 = a1->pMonsterInfo.uAttack1DamageDiceRolls;
+    v4 = a1->pMonsterInfo.uAttack1DamageDiceSides;
+    v5 = a1->pMonsterInfo.uAttack1DamageBonus;
+  }
+  if ( v3 > 0 )
+  {
+    v6 = v3;
+    do
+    {
+      --v6;
+      v11 += rand() % v4 + 1;
+    }
+    while ( v6 );
+  }
+  return v11 + v5 + v2;
+}
+
+//----- (00438B9B) --------------------------------------------------------
+char Actor::_438B9B()
+{
+  unsigned int v1; // eax@1
+
+  v1 = this->uAlly;
+  if ( !v1 )
+    v1 = (this->pMonsterInfo.uID - 1) / 3 + 1;
+  return (signed int)v1 >= 39 && (signed int)v1 <= 44
+      || (signed int)v1 >= 45 && (signed int)v1 <= 50
+      || (signed int)v1 >= 51 && (signed int)v1 <= 62
+      || (signed int)v1 >= 78 && (signed int)v1 <= 83;
+}
+
+//----- (0042EBEE) --------------------------------------------------------
+bool Actor::StealFrom(unsigned int uActorID)
+{
+  unsigned int v1; // esi@1
+  Player *pPlayer; // edi@1
+  bool result; // eax@1
+  int v4; // ebx@2
+  unsigned int v5; // eax@2
+  DDM_DLV_Header *v6; // esi@4
+  unsigned int v7; // [sp+8h] [bp-4h]@1
+  int v8; // [sp+8h] [bp-4h]@6
+
+  v1 = uActiveCharacter;
+  v7 = uActorID;
+  pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552];
+  result = pPlayer->CanAct();
+  if ( result )
+  {
+    pStru277->_427D48(v1);
+    v4 = 0;
+    v5 = pMapStats->GetMapInfo(pCurrentMapName);
+    if ( v5 )
+      v4 = pMapStats->pInfos[v5]._steal_perm;
+    v6 = &pOutdoor->ddm;
+    if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
+      v6 = &pIndoor->dlv;
+    pPlayer->StealFromActor(v7, v4, v6->uReputation++);
+    v8 = pPlayer->GetAttackRecoveryTime(0);
+    if ( v8 < 30 )
+      v8 = 30;
+    if ( !pParty->bTurnBasedModeOn )
+      pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v8 * 2.133333333333333));
+    pTurnEngine->_40471C();
+    result = 1;
+  }
+  return result;
+}
+
+
+//----- (00403A60) --------------------------------------------------------
+unsigned int __fastcall Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+{
+  Actor *v3; // ebx@1
+  AIDirection *v4; // esi@3
+  AIDirection *v5; // edi@3
+  signed int v6; // eax@4
+  Vec3_int_ v7; // ST04_12@6
+  unsigned int result; // eax@7
+  AIDirection *v9; // eax@8
+  unsigned int v10; // esi@8
+  AIDirection *v11; // esi@9
+  SpriteFrame *v12; // ecx@10
+  __int16 v13; // ax@10
+  unsigned int v14; // ecx@10
+  unsigned int v15; // eax@10
+  signed int v16; // ecx@17
+  AIDirection a3; // [sp+Ch] [bp-48h]@9
+  AIDirection v18; // [sp+28h] [bp-2Ch]@9
+  int v19; // [sp+44h] [bp-10h]@6
+  signed int a2; // [sp+48h] [bp-Ch]@1
+  int v21; // [sp+4Ch] [bp-8h]@3
+  unsigned int v22; // [sp+50h] [bp-4h]@1
+  unsigned int pDira; // [sp+5Ch] [bp+8h]@10
+
+  v22 = uActorID;
+  v3 = &pActors[uActorID];
+  a2 = edx0;
+  if ( (edx0 & 7) == 3 )
+  {
+    v6 = edx0 >> 3;
+    v4 = (AIDirection *)pActors[v6].vPosition.x;
+    v5 = (AIDirection *)pActors[v6].vPosition.y;
+    v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
+  }
+  else
+  {
+    if ( (edx0 & 7) == 4 )
+    {
+      v4 = (AIDirection *)pParty->vPosition.x;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    else
+    {
+      v4 = pDir;
+      v5 = pDir;
+    }
+  }
+  v19 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C((int)v4, (int)v5, v21, v7) )
+  {
+    v9 = pDir;
+    v10 = 0;
+    if ( !pDir )
+    {
+      v11 = Actor::GetDirectionInfo(8 * v22 | 3, a2, &a3, 0);
+      v9 = &v18;
+      memcpy(&v18, v11, sizeof(v18));
+      v10 = 0;
+    }
+    v12 = pSpriteFrameTable->pSpriteSFrames;
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = v12[v3->pSpriteIDs[3]].uAnimLength;
+    v14 = v22;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = v10;
+    v3->uAIState = AttackingRanged4;
+    Actor::PlaySound(v14, 0);
+    v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10
+      && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) )
+    {
+      v15 *= 2;
+      pDira = v15;
+    }
+    if ( pParty->bTurnBasedModeOn == 1 )
+      v3->pMonsterInfo.uRecoveryTime = v15;
+    else
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength
+                                     - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2
+                                                                    * (double)(signed int)pDira
+                                                                    * -2.133333333333333);
+    v16 = v3->pMonsterInfo.uSpell2ID;
+    v3->vVelocity.z = v10;
+    v3->vVelocity.y = v10;
+    v3->vVelocity.x = v10;
+    if ( sub_42FB5C(v16) )
+    {
+      v3->uCurrentActionLength = 64;
+      v3->uCurrentActionTime = v10;
+      v3->uAIState = Fidgeting;
+      result = v3->UpdateAnimation();
+      v3->uAIState = AttackingRanged4;
+    }
+    else
+    {
+      result = v3->UpdateAnimation();
+    }
+  }
+  else
+  {
+    result = Actor::_402AD7(v22, a2, v22, 64, pDir);
+  }
+  return result;
+}
+
+
+//----- (00403854) --------------------------------------------------------
+unsigned int __fastcall Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+{
+  Actor *v3; // ebx@1
+  AIDirection *v4; // esi@3
+  AIDirection *v5; // edi@3
+  signed int v6; // eax@4
+  Vec3_int_ v7; // ST04_12@6
+  unsigned int result; // eax@7
+  AIDirection *v9; // eax@8
+  unsigned int v10; // esi@8
+  AIDirection *v11; // esi@9
+  SpriteFrame *v12; // ecx@10
+  __int16 v13; // ax@10
+  unsigned int v14; // ecx@10
+  unsigned int v15; // eax@10
+  signed int v16; // ecx@17
+  AIDirection a3; // [sp+Ch] [bp-48h]@9
+  AIDirection v18; // [sp+28h] [bp-2Ch]@9
+  int v19; // [sp+44h] [bp-10h]@6
+  signed int a2; // [sp+48h] [bp-Ch]@1
+  int v21; // [sp+4Ch] [bp-8h]@3
+  unsigned int v22; // [sp+50h] [bp-4h]@1
+  unsigned int pDira; // [sp+5Ch] [bp+8h]@10
+
+  v22 = uActorID;
+  v3 = &pActors[uActorID];
+  a2 = edx0;
+  if ( (edx0 & 7) == 3 )
+  {
+    v6 = edx0 >> 3;
+    v4 = (AIDirection *)pActors[v6].vPosition.x;
+    v5 = (AIDirection *)pActors[v6].vPosition.y;
+    v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
+  }
+  else
+  {
+    if ( (edx0 & 7) == 4 )
+    {
+      v4 = (AIDirection *)pParty->vPosition.x;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    else
+    {
+      v4 = pDir;
+      v5 = pDir;
+    }
+  }
+  v19 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C((int)v4, (int)v5, v21, v7) )
+  {
+    v9 = pDir;
+    v10 = 0;
+    if ( !pDir )
+    {
+      v11 = Actor::GetDirectionInfo(8 * v22 | 3, a2, &a3, 0);
+      v9 = &v18;
+      memcpy(&v18, v11, sizeof(v18));
+      v10 = 0;
+    }
+    v12 = pSpriteFrameTable->pSpriteSFrames;
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = v12[v3->pSpriteIDs[3]].uAnimLength;
+    v14 = v22;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = v10;
+    v3->uAIState = AttackingRanged3;
+    Actor::PlaySound(v14, 0);
+    v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10
+      && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) )
+    {
+      v15 *= 2;
+      pDira = v15;
+    }
+    if ( pParty->bTurnBasedModeOn == 1 )
+      v3->pMonsterInfo.uRecoveryTime = v15;
+    else
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength
+                                     - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2
+                                                                    * (double)(signed int)pDira
+                                                                    * -2.133333333333333);
+    v16 = v3->pMonsterInfo.uSpell1ID;
+    v3->vVelocity.z = v10;
+    v3->vVelocity.y = v10;
+    v3->vVelocity.x = v10;
+    if ( sub_42FB5C(v16) )
+    {
+      v3->uCurrentActionLength = 64;
+      v3->uCurrentActionTime = v10;
+      v3->uAIState = Fidgeting;
+      result = v3->UpdateAnimation();
+      v3->uAIState = AttackingRanged3;
+    }
+    else
+    {
+      result = v3->UpdateAnimation();
+    }
+  }
+  else
+  {
+    result = Actor::_402AD7(v22, a2, v22, 64, pDir);
+  }
+  return result;
+}
+
+
+//----- (0040368B) --------------------------------------------------------
+unsigned int __fastcall Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+{
+  Actor *v3; // ebx@1
+  AIDirection *v4; // esi@3
+  AIDirection *v5; // edi@3
+  signed int v6; // eax@4
+  Vec3_int_ v7; // ST04_12@6
+  unsigned int result; // eax@7
+  AIDirection *v9; // eax@8
+  unsigned int v10; // esi@8
+  AIDirection *v11; // esi@9
+  SpriteFrame *v12; // ecx@10
+  __int16 v13; // ax@10
+  unsigned int v14; // ecx@10
+  signed __int64 v15; // qax@10
+  AIDirection a3; // [sp+Ch] [bp-48h]@9
+  AIDirection v17; // [sp+28h] [bp-2Ch]@9
+  int v18; // [sp+44h] [bp-10h]@6
+  signed int a2; // [sp+48h] [bp-Ch]@1
+  int v20; // [sp+4Ch] [bp-8h]@3
+  unsigned int v21; // [sp+50h] [bp-4h]@1
+  unsigned int pDira; // [sp+5Ch] [bp+8h]@10
+
+  v21 = uActorID;
+  v3 = &pActors[uActorID];
+  a2 = edx0;
+  if ( (edx0 & 7) == 3 )
+  {
+    v6 = edx0 >> 3;
+    v4 = (AIDirection *)pActors[v6].vPosition.x;
+    v5 = (AIDirection *)pActors[v6].vPosition.y;
+    v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
+  }
+  else
+  {
+    if ( (edx0 & 7) == 4 )
+    {
+      v4 = (AIDirection *)pParty->vPosition.x;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v20 = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    else
+    {
+      v4 = pDir;
+      v5 = pDir;
+    }
+  }
+  v18 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v18 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C((int)v4, (int)v5, v20, v7) )
+  {
+    v9 = pDir;
+    v10 = 0;
+    if ( !pDir )
+    {
+      v11 = Actor::GetDirectionInfo(8 * v21 | 3, a2, &a3, 0);
+      v9 = &v17;
+      memcpy(&v17, v11, sizeof(v17));
+      v10 = 0;
+    }
+    v12 = pSpriteFrameTable->pSpriteSFrames;
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = v12[v3->pSpriteIDs[3]].uAnimLength;
+    v14 = v21;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = v10;
+    v3->uAIState = AttackingRanged2;
+    Actor::PlaySound(v14, 0);
+    LODWORD(v15) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10
+      && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) )
+    {
+      LODWORD(v15) = 2 * v15;
+      pDira = v15;
+    }
+    if ( pParty->bTurnBasedModeOn != 1 )
+      v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333);
+    v3->pMonsterInfo.uRecoveryTime = v15;
+    v3->vVelocity.z = v10;
+    v3->vVelocity.y = v10;
+    v3->vVelocity.x = v10;
+    result = v3->UpdateAnimation();
+  }
+  else
+  {
+    result = Actor::_402AD7(v21, a2, v21, 64, pDir);
+  }
+  return result;
+}
+
+
+//----- (00403476) --------------------------------------------------------
+unsigned int __fastcall Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+{
+  Actor *v3; // ebx@1
+  int v4; // esi@3
+  int v5; // edi@3
+  signed int v6; // eax@4
+  Vec3_int_ v7; // ST04_12@6
+  unsigned char v8[12]; // ST04_12@7
+  unsigned int result; // eax@8
+  AIDirection *v10; // eax@9
+  unsigned int v11; // esi@9
+  AIDirection *v12; // esi@10
+  SpriteFrame *v13; // ecx@11
+  __int16 v14; // ax@11
+  unsigned int v15; // ecx@11
+  unsigned int v16; // eax@11
+  AIDirection a3; // [sp+Ch] [bp-48h]@10
+  AIDirection v18; // [sp+28h] [bp-2Ch]@10
+  int v19; // [sp+44h] [bp-10h]@6
+  signed int a2; // [sp+48h] [bp-Ch]@1
+  unsigned int v21; // [sp+4Ch] [bp-8h]@1
+  int v22; // [sp+50h] [bp-4h]@3
+  unsigned int pDira; // [sp+5Ch] [bp+8h]@11
+
+  v21 = uActorID;
+  v3 = &pActors[uActorID];
+  a2 = edx0;
+  if ( (edx0 & 7) == 3 )
+  {
+    v6 = edx0 >> 3;
+    v4 = pActors[v6].vPosition.x;
+    v5 = pActors[v6].vPosition.y;
+    v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
+  }
+  else
+  {
+    if ( (edx0 & 7) == 4 )
+    {
+      v4 = pParty->vPosition.x;
+      v5 = pParty->vPosition.y;
+      v22 = pParty->vPosition.z + pParty->sEyelevel;
+    }
+    else
+    {
+      v4 = (int)pDir;
+      v5 = (int)pDir;
+    }
+  }
+  v19 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C(v4, v5, v22, v7)
+    || (*(unsigned int *)&v8[8] = v22,
+        v19 = v3->uActorHeight,
+        *(_QWORD *)v8 = __PAIR__(v5, v4),
+        sub_407A1C(
+          v3->vPosition.x,
+          v3->vPosition.y,
+          v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75),
+          *(Vec3_int_ *)v8)) )
+  {
+    v10 = pDir;
+    v11 = 0;
+    if ( !pDir )
+    {
+      v12 = Actor::GetDirectionInfo(8 * v21 | 3, a2, &a3, 0);
+      v10 = &v18;
+      memcpy(&v18, v12, sizeof(v18));
+      v11 = 0;
+    }
+    v13 = pSpriteFrameTable->pSpriteSFrames;
+    v3->uYawAngle = LOWORD(v10->uYawAngle);
+    v14 = v13[v3->pSpriteIDs[3]].uAnimLength;
+    v15 = v21;
+    v3->uCurrentActionLength = 8 * v14;
+    v3->uCurrentActionTime = v11;
+    v3->uAIState = AttackingRanged1;
+    Actor::PlaySound(v15, 0);
+    v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v11
+      && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v11 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v11) )
+    {
+      v16 *= 2;
+      pDira = v16;
+    }
+    if ( pParty->bTurnBasedModeOn == 1 )
+      v3->pMonsterInfo.uRecoveryTime = v16;
+    else
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength
+                                     - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2
+                                                                    * (double)(signed int)pDira
+                                                                    * -2.133333333333333);
+    v3->vVelocity.z = v11;
+    v3->vVelocity.y = v11;
+    v3->vVelocity.x = v11;
+    result = v3->UpdateAnimation();
+  }
+  else
+  {
+    result = Actor::_402AD7(v21, a2, v21, 64, pDir);
+  }
+  return result;
+}
+
+//----- (004032B2) --------------------------------------------------------
+void __fastcall Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
+{
+  unsigned int v4; // edi@1
+  Actor *v5; // esi@1
+  int v6; // ebx@1
+  int v7; // ST08_4@1
+  int v8; // eax@1
+  unsigned int v9; // ebx@11
+  int v10; // ebx@13
+  signed __int16 v11; // cx@17
+  unsigned int v12; // [sp-8h] [bp-44h]@10
+  AIDirection *v13; // [sp-4h] [bp-40h]@10
+  AIDirection v14; // [sp+Ch] [bp-30h]@7
+  int v15; // [sp+28h] [bp-14h]@11
+  unsigned int v16; // [sp+2Ch] [bp-10h]@1
+  int y; // [sp+30h] [bp-Ch]@1
+  unsigned int uActorID; // [sp+34h] [bp-8h]@1
+  int v19; // [sp+38h] [bp-4h]@1
+
+  uActorID = a1;
+  v4 = a1;
+  v5 = &pActors[a1];
+  v16 = a2;
+  v6 = v5->vInitialPosition.x - v5->vPosition.x;
+  v7 = v5->vInitialPosition.x - v5->vPosition.x;
+  y = v5->vInitialPosition.y - v5->vPosition.y;
+  v19 = abs(v7);
+  v8 = abs(y);
+  if ( v19 <= v8 )
+    v19 = v8 + (v19 >> 1);
+  else
+    v19 += v8 >> 1;
+  if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    Actor::_403F58(uActorID, 4, uActionLength, &v14);
+    return;
+  }
+  if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 )
+  {
+    v13 = &v14;
+    v12 = 256;
+LABEL_16:
+    Actor::_403EB6(uActorID, v16, v12, v13);
+    return;
+  }
+  v15 = (rand() & 0xF) << 12;
+  v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16;
+  v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y);
+  if ( rand() % 100 < 25 )
+  {
+    Actor::StandAwhile(uActorID);
+    return;
+  }
+  v10 = v9 + rand() % 256 - 128;
+  if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) )
+  {
+    v13 = &v14;
+    v12 = 256;
+    goto LABEL_16;
+  }
+  v11 = v5->uMovementSpeed;
+  v5->uYawAngle = v10;
+  if ( v11 )
+    v5->uCurrentActionLength = 32 * v19 / v11;
+  else
+    v5->uCurrentActionLength = 0;
+  v5->uCurrentActionTime = 0;
+  v5->uAIState = Tethered;
+  if ( rand() % 100 < 2 )
+    Actor::PlaySound(uActorID, 3u);
+  v5->UpdateAnimation();
+}
+
+
+//----- (004031C1) --------------------------------------------------------
+char __fastcall Actor::_4031C1_update_job(unsigned int uActorID, signed int a2, int a3)
+{
+  unsigned int v3; // edi@1
+  Actor *v4; // esi@1
+  ActorJob *v5; // eax@1
+  signed int v6; // edx@2
+  ActorJob *v7; // eax@2
+  signed int v8; // edi@2
+  char *v9; // ecx@2
+  __int16 v10; // cx@15
+  signed int v12; // [sp+8h] [bp-4h]@1
+
+  v3 = uActorID;
+  v12 = a2;
+  v4 = &pActors[uActorID];
+  v5 = (ActorJob *)pActors[uActorID].CanAct();
+  if ( v5 )
+  {
+    v6 = 65535;
+    v7 = &v4->pScheduledJobs[v3];
+    v8 = 7;
+    v9 = (char *)&v7[7].uHour;
+    while ( !(*(v9 - 3) & 1) || (unsigned __int8)*v9 > v12 )
+    {
+      --v8;
+      v9 -= 12;
+      if ( v8 < 0 )
+        goto LABEL_8;
+    }
+    v6 = v8;
+LABEL_8:
+    if ( !v8 && v6 == 65535 )
+      v6 = 7;
+    v5 = &v7[v6];
+    if ( v4->vInitialPosition.x != v5->vPos.x
+      || v4->vInitialPosition.y != v5->vPos.y
+      || v4->vInitialPosition.z != v5->vPos.z
+      || v4->pMonsterInfo.uMovementType != v5->uAction )
+    {
+      v4->vInitialPosition.x = v5->vPos.x;
+      v4->vInitialPosition.y = v5->vPos.y;
+      v10 = v5->vPos.z;
+      v4->vInitialPosition.z = v10;
+      LOBYTE(v5) = v5->uAction;
+      v4->pMonsterInfo.uMovementType = (unsigned __int8)v5;
+      if ( a3 == 1 )
+      {
+        v4->vPosition.x = v4->vInitialPosition.x;
+        v4->vPosition.y = v4->vInitialPosition.y;
+        LOBYTE(v5) = v10;
+        v4->vPosition.z = v10;
+      }
+    }
+  }
+  return (char)v5;
+}
+
+
+//----- (004030AD) --------------------------------------------------------
+__int16 __fastcall Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0)
+{
+  unsigned int v3; // edi@1
+  Actor *v4; // ebx@1
+  __int16 result; // ax@10
+  SpriteFrame *v6; // ecx@16
+  __int16 v7; // ax@16
+  unsigned int v8; // ecx@16
+  AIDirection a3; // [sp+Ch] [bp-40h]@16
+  AIDirection v10; // [sp+28h] [bp-24h]@16
+  unsigned int v11; // [sp+44h] [bp-8h]@1
+  signed int a2; // [sp+48h] [bp-4h]@1
+
+  v3 = uActorID;
+  a2 = edx0;
+  v4 = &pActors[uActorID];
+  v11 = uActorID;
+  if ( v4->uAIState == 7 )
+    BYTE2(v4->uAttributes) |= 2u;
+  if ( v4->pMonsterInfo.uHostilityType != 4 )
+  {
+    v4->uAttributes &= 0xFFFFFFFBu;
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+  }
+  if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 )
+    v4->pActorBuffs[1].Reset();
+  if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
+    v4->pActorBuffs[4].Reset();
+  if ( arg0
+    || (result = v4->uAIState, result != 8)
+    && result != 3
+    && result != 12
+    && result != 13
+    && result != 18
+    && result != 2 )
+  {
+    memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10));
+    v6 = pSpriteFrameTable->pSpriteSFrames;
+    v4->uYawAngle = LOWORD(v10.uYawAngle);
+    v7 = v6[v4->pSpriteIDs[4]].uAnimLength;
+    v8 = v11;
+    v4->uCurrentActionTime = 0;
+    v4->uAIState = Stunned;
+    v4->uCurrentActionLength = 8 * v7;
+    Actor::PlaySound(v8, 2u);
+    result = v4->UpdateAnimation();
+  }
+  return result;
+}
+
+//----- (00402F87) --------------------------------------------------------
+int __fastcall Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
+{
+  int v3; // edi@1
+  AIDirection *v4; // esi@1
+  Actor *v5; // ebx@1
+  SpriteFrame *v6; // ecx@3
+  unsigned int v7; // eax@3
+  int v8; // edx@3
+  unsigned int v9; // eax@3
+  int result; // eax@4
+  AIDirection a3; // [sp+Ch] [bp-5Ch]@2
+  AIDirection v12; // [sp+28h] [bp-40h]@2
+  AIDirection v13; // [sp+44h] [bp-24h]@2
+  unsigned int v14; // [sp+60h] [bp-8h]@1
+  unsigned int v15; // [sp+64h] [bp-4h]@1
+
+  v3 = uActorID;
+  v4 = a4;
+  v5 = &pActors[uActorID];
+  v14 = uObjID;
+  v15 = uActorID;
+  if ( !a4 )
+  {
+    memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | AI_OBJECT_ACTOR, uObjID, &a3, (int)a4), sizeof(v13));
+    memcpy(&v12, &v13, sizeof(v12));
+    v3 = v15;
+    v4 = &v12;
+  }
+  v6 = pSpriteFrameTable->pSpriteSFrames;
+  v5->uYawAngle = LOWORD(v4->uYawAngle);
+  v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[7]].uAnimLength;
+  v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y);
+  LOWORD(v8) = v5->uYawAngle;
+  v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
+  if ( BYTE1(v9) & 7 )
+  {
+    result = Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4);
+  }
+  else
+  {
+    v5->uAIState = Fidgeting;
+    v5->uCurrentActionTime = 0;
+    v5->vVelocity.z = 0;
+    v5->vVelocity.y = 0;
+    v5->vVelocity.x = 0;
+    if ( rand() % 100 < 5 )
+      Actor::PlaySound(v3, 3u);
+    result = v5->UpdateAnimation();
+  }
+  return result;
+}
+
+//----- (00402F27) --------------------------------------------------------
+unsigned int __fastcall Actor::Resurrect(unsigned int uActorID)
+{
+  Actor *pActor; // esi@1
+  SpriteFrame *v2; // edx@1
+  int v3; // eax@1
+
+  pActor = &pActors[uActorID];
+  v2 = pSpriteFrameTable->pSpriteSFrames;
+  v3 = pActor->pSpriteIDs[5];
+  pActor->uCurrentActionTime = 0;
+  pActor->uAIState = Resurrected;
+  pActor->uCurrentActionAnimation = ANIM_Dying;
+  pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength;
+  pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP);
+  Actor::PlaySound(uActorID, 1u);
+  return pActor->UpdateAnimation();
+}
+
+
+//----- (00402D6E) --------------------------------------------------------
+void __fastcall Actor::Die(unsigned int uActorID)
+{
+  Actor *v1; // esi@1
+  SpriteFrame *v2; // ecx@1
+  int v3; // eax@1
+  int v4; // ecx@1
+  char *v5; // eax@1
+  SpellBuff *v6; // edi@5
+  signed int v7; // ebx@5
+  MONSTER_TYPE v8; // eax@7
+  int v9; // eax@23
+  ItemGen _this; // [sp+8h] [bp-28h]@7
+  unsigned int v11; // [sp+2Ch] [bp-4h]@1
+
+  v1 = &pActors[uActorID];
+  v11 = uActorID;
+  v2 = pSpriteFrameTable->pSpriteSFrames;
+  v3 = 60 * v1->pSpriteIDs[5];
+  v1->uCurrentActionTime = 0;
+  v1->uAIState = Dying;
+  v1->uCurrentActionAnimation = 5;
+  LOWORD(v3) = *(__int16 *)((char *)&v2->uAnimLength + v3);
+  v1->sCurrentHP = 0;
+  v1->uCurrentActionLength = 8 * v3;
+  v1->pActorBuffs[6].Reset();
+  v1->pActorBuffs[5].Reset();
+  Actor::PlaySound(v11, 1u);
+  v1->UpdateAnimation();
+  v4 = v1->pMonsterInfo.uID;
+  v5 = (char *)pParty->field_75A;
+  do
+  {
+    if ( v4 == *((short *)v5 - 5) )
+      *(short *)v5 = 1;
+    v5 += 2;
+  }
+  while ( (signed int)v5 < (signed int)&pParty->field_764 );
+  v6 = v1->pActorBuffs;
+  v7 = 22;
+  do
+  {
+    v6->Reset();
+    ++v6;
+    --v7;
+  }
+  while ( v7 );
+  _this.Reset();
+  v8 = (MONSTER_TYPE)v1->pMonsterInfo.uID;
+  if ( v8 > MONSTER_HARPY_3 )
+  {
+    if ( v8 < MONSTER_OOZE_1 )
+      goto LABEL_21;
+    if ( v8 <= MONSTER_OOZE_3 )
+    {
+      _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
+      goto LABEL_21;
+    }
+    if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 )
+    {
+LABEL_21:
+      if ( !_this.uItemID )
+        goto LABEL_24;
+      goto LABEL_22;
+    }
+    _this.uItemID = ITEM_TROLL_BLOOD;
+  }
+  else
+  {
+    if ( v8 >= MONSTER_HARPY_1 )
+    {
+      _this.uItemID = ITEM_HARPY_FEATHER;
+    }
+    else
+    {
+      if ( v8 < MONSTER_DEVIL_1 )
+        goto LABEL_21;
+      if ( v8 > MONSTER_DEVIL_3 )
+      {
+        if ( v8 <= MONSTER_DRAGON_3 )
+        {
+          _this.uItemID = ITEM_DRAGON_EYE;
+          goto LABEL_22;
+        }
+        goto LABEL_21;
+      }
+      _this.uItemID = ITEM_DEVIL_ICHOR;
+    }
+  }
+LABEL_22:
+  if ( rand() % 100 < 20 )
+  {
+    v9 = rand();
+    sub_42F7EB_DropItemAt(
+      pItemsTable->pItems[_this.uItemID].uSpriteID,
+      v1->vPosition.x,
+      v1->vPosition.y,
+      v1->vPosition.z + 16,
+      v9 % 200 + 200,
+      1,
+      1,
+      0,
+      &_this);
+  }
+LABEL_24:
+  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+    Actor::Explode(v11);
+}
+
+//----- (00402CED) --------------------------------------------------------
+void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID)
+{
+  Actor *v2; // eax@1
+  unsigned __int16 v3; // dx@1
+  int v4; // eax@3
+  int v5; // eax@4
+  unsigned int v6; // eax@6
+  signed int v7; // eax@12
+  signed int v8; // [sp-18h] [bp-1Ch]@10
+  signed int v9; // [sp-14h] [bp-18h]@10
+  int v10; // [sp-10h] [bp-14h]@10
+  unsigned int v11; // [sp-Ch] [bp-10h]@10
+  int v12; // [sp-8h] [bp-Ch]@10
+
+  v2 = &pActors[uActorID];
+  v3 = v2->pSoundSampleIDs[uSoundID];
+  if ( v3 )
+  {
+    if ( (signed __int64)v2->pActorBuffs[3].uExpireTime <= 0 )
+    {
+      v12 = 0;
+      v11 = 0;
+      v10 = 0;
+      v9 = 0;
+      v8 = -1;
+    }
+    else
+    {
+      v4 = v2->pActorBuffs[3].uPower - 2;
+      if ( v4 )
+      {
+        v5 = v4 - 1;
+        if ( v5 )
+        {
+          if ( v5 == 1 )
+            v6 = 55125;
+          else
+            v6 = uActorID;
+        }
+        else
+        {
+          v6 = 44100;
+        }
+      }
+      else
+      {
+        v6 = 33075;
+      }
+      v12 = v6;
+      v11 = 0;
+      v10 = 0;
+      v9 = 0;
+      v8 = 0;
+    }
+    v7 = 8 * uActorID;
+    LOBYTE(v7) = 8 * uActorID | 3;
+    pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, v7, 0, v8, v9, v10, v11, v12);
+  }
+}
+
+
+//----- (00402AD7) --------------------------------------------------------
+unsigned int __fastcall Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
+{
+  unsigned int v5; // edi@1
+  int v6; // eax@1
+  Actor *v7; // ebx@1
+  unsigned int v8; // ecx@1
+  char v9; // zf@1
+  AIDirection *v10; // esi@6
+  int v12; // ecx@19
+  unsigned int v13; // eax@19
+  AIDirection a3; // [sp+Ch] [bp-5Ch]@7
+  AIDirection v15; // [sp+28h] [bp-40h]@7
+  AIDirection v16; // [sp+44h] [bp-24h]@7
+  unsigned int v17; // [sp+60h] [bp-8h]@1
+  unsigned int v18; // [sp+64h] [bp-4h]@1
+  int v19; // [sp+70h] [bp+8h]@19
+
+  v5 = uActorID;
+  v6 = 0;
+  v7 = &pActors[uActorID];
+  v18 = a2;
+  v8 = 8 * uActorID | 3;
+  v9 = v7->pMonsterInfo.uFlying == 0;
+  v17 = v5;
+  if ( !v9 && !pParty->bFlying )
+  {
+    if ( v7->pMonsterInfo.uMissleAttack1Type )
+      v6 = v7->uActorRadius + 512;
+    else
+      v6 = pParty->uPartyHeight;
+  }
+  v10 = pDir;
+  if ( !pDir )
+  {
+    memcpy(&v15, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v15));
+    memcpy(&v16, &v15, sizeof(v16));
+    v5 = v17;
+    v10 = &v16;
+  }
+  if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    return Actor::_403F58(v5, 4, uActionLength, v10);
+  }
+  if ( (double)(signed int)v10->uDistance < 307.2 )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    return Actor::_403EB6(v5, v18, uActionLength, v10);
+  }
+  if ( !v7->uMovementSpeed )
+    return Actor::_403EB6(v5, v18, uActionLength, v10);
+  v18 = 16;
+  if ( arg0 % 2 )
+    v18 = -16;
+  v12 = ((unsigned __int64)(stru_5C6E00->SinCos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle)
+                          * (signed __int64)v10->uDistanceXZ) >> 16)
+      + pParty->vPosition.x;
+  v13 = stru_5C6E00->uIntegerPi + v10->uYawAngle;
+  v17 = v12;
+  v19 = stru_5C6E00->SinCos(v18 + v13 - stru_5C6E00->uIntegerHalfPi);
+  v7->uYawAngle = stru_5C6E00->Atan2(
+                    v17 - v7->vPosition.x,
+                    pParty->vPosition.y
+                  + ((unsigned __int64)(v19 * (signed __int64)v10->uDistanceXZ) >> 16)
+                  - v7->vPosition.y);
+  if ( uActionLength )
+    v7->uCurrentActionLength = uActionLength;
+  else
+    v7->uCurrentActionLength = 128;
+  v7->uPitchAngle = LOWORD(v10->uPitchAngle);
+  v7->uAIState = Pursuing;
+  return v7->UpdateAnimation();
+}
+
+//----- (00402968) --------------------------------------------------------
+unsigned int __fastcall Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4)
+{
+  unsigned int v4; // esi@1
+  Actor *v5; // ebx@1
+  unsigned int result; // eax@1
+  int v7; // ecx@2
+  signed __int16 v8; // cx@10
+  unsigned __int16 v9; // ax@15
+  AIDirection v10; // [sp+8h] [bp-7Ch]@4
+  AIDirection a3; // [sp+24h] [bp-60h]@3
+  AIDirection v12; // [sp+40h] [bp-44h]@3
+  AIDirection v13; // [sp+5Ch] [bp-28h]@4
+  signed int a1; // [sp+78h] [bp-Ch]@2
+  unsigned int v15; // [sp+7Ch] [bp-8h]@1
+  signed int a2; // [sp+80h] [bp-4h]@1
+
+  v4 = uActorID;
+  a2 = edx0;
+  v15 = uActorID;
+  v5 = &pActors[uActorID];
+  result = pActors[uActorID].CanAct();
+  if ( result )
+  {
+    v7 = 8 * v4 | 3;
+    a1 = 8 * v4 | 3;
+    if ( !a4 )
+    {
+      a4 = &v12;
+      memcpy(&v12, Actor::GetDirectionInfo(v7, a2, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
+      v7 = a1;
+    }
+    memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3));
+    memcpy(&v13, &a3, sizeof(v13));
+    if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)
+      || (a2 & 7) == 3 && (double)(signed int)v13.uDistance < 307.2 )
+    {
+      if ( !uActionLength )
+        uActionLength = 256;
+      result = Actor::_403F58(v15, 4, uActionLength, &v13);
+    }
+    else
+    {
+      v8 = v5->uMovementSpeed;
+      if ( v8 )
+        v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v8;
+      else
+        v5->uCurrentActionLength = 0;
+      if ( v5->uCurrentActionLength > 256 )
+        v5->uCurrentActionLength = 256;
+      v5->uYawAngle = LOWORD(stru_5C6E00->uIntegerHalfPi) + LOWORD(a4->uYawAngle);
+      v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi);
+      v9 = LOWORD(a4->uPitchAngle);
+      v5->uCurrentActionTime = 0;
+      v5->uPitchAngle = v9;
+      v5->uAIState = Fleeing;
+      result = v5->UpdateAnimation();
+    }
+  }
+  return result;
+}
+
+
+//----- (0040281C) --------------------------------------------------------
+int __fastcall Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
+{
+  unsigned int v5; // edi@1
+  int v6; // eax@1
+  Actor *v7; // ebx@1
+  unsigned int v8; // ecx@1
+  char v9; // zf@1
+  AIDirection *v10; // esi@7
+  signed int v11; // edx@12
+  signed __int16 v13; // cx@19
+  unsigned __int16 v14; // ax@25
+  int v15; // [sp-8h] [bp-54h]@12
+  AIDirection *v16; // [sp-4h] [bp-50h]@12
+  AIDirection a3; // [sp+Ch] [bp-40h]@8
+  AIDirection v18; // [sp+28h] [bp-24h]@8
+  unsigned int v19; // [sp+44h] [bp-8h]@1
+  unsigned int v20; // [sp+48h] [bp-4h]@1
+
+  v5 = uActorID;
+  v6 = 0;
+  v7 = &pActors[uActorID];
+  v19 = a2;
+  v8 = 8 * uActorID | 3;
+  v9 = v7->pMonsterInfo.uFlying == 0;
+  v20 = v5;
+  if ( !v9 && !pParty->bFlying )
+  {
+    if ( v7->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+      v6 = v7->uActorRadius + 512;
+    else
+      v6 = pParty->uPartyHeight;
+  }
+  v10 = pDir;
+  if ( !pDir )
+  {
+    memcpy(&v18, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v18));
+    memcpy(0, &v18, 0x1Cu);
+    v10 = 0;
+    v5 = v20;
+  }
+  if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    v16 = v10;
+    v15 = uActionLength;
+    v11 = 4;
+    return Actor::_403F58(v5, v11, v15, v16);
+  }
+  if ( (signed int)v10->uDistance < a5 )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    v11 = v19;
+    v16 = v10;
+    v15 = uActionLength;
+    return Actor::_403F58(v5, v11, v15, v16);
+  }
+  if ( uActionLength )
+  {
+    v7->uCurrentActionLength = uActionLength;
+  }
+  else
+  {
+    v13 = v7->uMovementSpeed;
+    if ( v13 )
+      v7->uCurrentActionLength = (signed int)(v10->uDistanceXZ << 7) / v13;
+    else
+      v7->uCurrentActionLength = 0;
+    if ( v7->uCurrentActionLength > 32 )
+      v7->uCurrentActionLength = 32;
+  }
+  v7->uYawAngle = LOWORD(v10->uYawAngle);
+  v14 = LOWORD(v10->uPitchAngle);
+  v7->uCurrentActionTime = 0;
+  v7->uPitchAngle = v14;
+  v7->uAIState = Pursuing;
+  return v7->UpdateAnimation();
+}
+
+
+//----- (00402686) --------------------------------------------------------
+unsigned int __fastcall Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
+{
+  unsigned int v4; // edi@1
+  int v5; // eax@1
+  Actor *v6; // ebx@1
+  int v7; // ecx@1
+  char v8; // zf@1
+  AIDirection *v9; // esi@7
+  signed int v10; // edx@12
+  signed __int16 v12; // cx@19
+  int v13; // edx@25
+  __int16 v14; // ax@25
+  unsigned __int16 v15; // ax@26
+  unsigned __int16 v16; // ax@28
+  int v17; // [sp-8h] [bp-54h]@12
+  AIDirection *v18; // [sp-4h] [bp-50h]@12
+  AIDirection a3; // [sp+Ch] [bp-40h]@8
+  AIDirection v20; // [sp+28h] [bp-24h]@8
+  int v21; // [sp+44h] [bp-8h]@1
+  unsigned int v22; // [sp+48h] [bp-4h]@1
+
+  v4 = uActorID;
+  v5 = 0;
+  v6 = &pActors[uActorID];
+  v21 = a2;
+  v7 = 8 * uActorID | 3;
+  v8 = v6->pMonsterInfo.uFlying == 0;
+  v22 = v4;
+  if ( !v8 && !pParty->bFlying )
+  {
+    if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+      v5 = v6->uActorRadius + 512;
+    else
+      v5 = pParty->uPartyHeight;
+  }
+  v9 = a4;
+  if ( !a4 )
+  {
+    memcpy(&v20, Actor::GetDirectionInfo(v7, a2, &a3, v5), sizeof(v20));
+    memcpy(0, &v20, 0x1Cu);
+    v9 = 0;
+    v4 = v22;
+  }
+  if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    v18 = v9;
+    v17 = uActionLength;
+    v10 = 4;
+    return Actor::_403F58(v4, v10, v17, v18);
+  }
+  if ( (double)(signed int)v9->uDistance < 307.2 )
+  {
+    if ( !uActionLength )
+      uActionLength = 256;
+    v10 = v21;
+    v18 = v9;
+    v17 = uActionLength;
+    return Actor::_403F58(v4, v10, v17, v18);
+  }
+  if ( uActionLength )
+  {
+    v6->uCurrentActionLength = uActionLength + rand() % uActionLength;
+  }
+  else
+  {
+    v12 = v6->uMovementSpeed;
+    if ( v12 )
+      v6->uCurrentActionLength = (signed int)(v9->uDistanceXZ << 7) / v12;
+    else
+      v6->uCurrentActionLength = 0;
+    if ( v6->uCurrentActionLength > 128 )
+      v6->uCurrentActionLength = 128;
+  }
+  v13 = rand() % 2;
+  v14 = LOWORD(v9->uYawAngle);
+  if ( v13 )
+    v15 = v14 + 256;
+  else
+    v15 = v14 - 256;
+  v6->uYawAngle = v15;
+  v16 = LOWORD(v9->uPitchAngle);
+  v6->uCurrentActionTime = 0;
+  v6->uPitchAngle = v16;
+  v6->uAIState = Pursuing;
+  if ( rand() % 100 < 2 )
+    Actor::PlaySound(v4, 2u);
+  return v6->UpdateAnimation();
+}
+
+//----- (00401221) --------------------------------------------------------
+void __fastcall Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3)
+{
+  Actor *v3; // esi@1
+  unsigned int v4; // ebx@1
+  int v5; // ecx@1
+  unsigned int v6; // eax@1
+  char *v7; // edi@2
+  __int16 v8; // ax@3
+  int v9; // eax@10
+  signed int v10; // eax@13
+  int v11; // ebx@16
+  int v12; // eax@16
+  int v13; // eax@25
+  signed int v14; // eax@31
+  int v15; // edi@43
+  int v16; // ebx@45
+  int v17; // eax@45
+  int v18; // eax@51
+  int v19; // [sp+Ch] [bp-24h]@16
+  int *v20; // [sp+10h] [bp-20h]@1
+  signed int v21; // [sp+14h] [bp-1Ch]@1
+  unsigned int v22; // [sp+18h] [bp-18h]@1
+  int v23; // [sp+1Ch] [bp-14h]@16
+  unsigned int v24; // [sp+20h] [bp-10h]@1
+  int v25; // [sp+24h] [bp-Ch]@1
+  signed int v26; // [sp+28h] [bp-8h]@1
+  int v27; // [sp+2Ch] [bp-4h]@16
+  int v28; // [sp+2Ch] [bp-4h]@45
+
+  v25 = -1;
+  v22 = uActorID;
+  v3 = &pActors[uActorID];
+  v4 = 0;
+  v5 = 0;
+  v6 = v3->uLastCharacterIDToHit;
+  *a2 = 0;
+  v20 = a2;
+  v21 = 0;
+  v24 = v6;
+  v26 = 0;
+  if ( (signed int)uNumActors <= 0 )
+    goto LABEL_26;
+  v7 = (char *)&pActors[0].uAIState;
+  do
+  {
+    v8 = *(short *)v7;
+    if ( *(short *)v7 == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
+      goto LABEL_23;
+    if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
+      goto LABEL_13;
+    if ( ((Actor *)(v7 - 176))->IsAlive() == 1 )
+    {
+      v24 = v4;
+      v3->uLastCharacterIDToHit = v4;
+LABEL_13:
+      v10 = v3->GetActorsRelation((Actor *)(v7 - 176));
+      if ( v10 == v4 )
+        goto LABEL_23;
+      goto LABEL_14;
+    }
+    v18 = *((unsigned int *)v7 + 133);
+    if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
+      goto LABEL_23;
+    v10 = 4;
+LABEL_14:
+    if ( v3->pMonsterInfo.uHostilityType )
+      v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
+    v11 = dword_4DF380[v10];
+    v23 = abs(v3->vPosition.x - *((short *)v7 - 17));
+    v27 = abs(v3->vPosition.y - *((short *)v7 - 16));
+    v12 = abs(v3->vPosition.z - *((short *)v7 - 15));
+    v19 = v12;
+    if ( v23 <= v11
+      && v27 <= v11
+      && v12 <= v11
+      && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
+      && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
+    {
+      v25 = v23 * v23 + v27 * v27 + v19 * v19;
+      v21 = v26;
+    }
+    v4 = 0;
+LABEL_23:
+    v7 += 836;
+    v5 = v26++ + 1;
+  }
+  while ( v26 < (signed int)uNumActors );
+  if ( v25 != -1 )
+  {
+    v13 = 8 * v21;
+    LOBYTE(v13) = 8 * v21 | 3;
+    *v20 = v13;
+  }
+LABEL_26:
+  if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4
+    && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) )
+    a3 = v4;
+  if ( a3 != v4 )
+  {
+    v14 = v3->GetActorsRelation(0);
+    if ( BYTE2(v3->uAttributes) & 8
+      && SHIDWORD(v3->pActorBuffs[12].uExpireTime) <= (signed int)v4
+      && (SHIDWORD(v3->pActorBuffs[12].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[12].uExpireTime) <= v4)
+      && SHIDWORD(v3->pActorBuffs[1].uExpireTime) <= (signed int)v4
+      && (SHIDWORD(v3->pActorBuffs[1].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[1].uExpireTime) <= v4)
+      && SHIDWORD(v3->pActorBuffs[2].uExpireTime) <= (signed int)v4
+      && (SHIDWORD(v3->pActorBuffs[2].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[2].uExpireTime) <= v4) )
+      v14 = 4;
+    if ( v14 != v4 )
+    {
+      v15 = dword_4DF390;
+      if ( !v3->pMonsterInfo.uHostilityType )
+        v15 = dword_4DF380[v14];
+      v16 = abs(v3->vPosition.x - pParty->vPosition.x);
+      v28 = abs(v3->vPosition.y - pParty->vPosition.y);
+      v17 = abs(v3->vPosition.z - pParty->vPosition.z);
+      if ( v16 <= v15 && v28 <= v15 && v17 <= v15 )
+      {
+        if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 )
+          *v20 = 4;
+      }
+    }
+  }
+}
+// 4DF380: using guessed type int dword_4DF380[];
+// 4DF390: using guessed type int dword_4DF390;
+
+//----- (0040104C) --------------------------------------------------------
+signed int Actor::GetActorsRelation(Actor *a2)
+{
+  Actor *v2; // esi@1
+  int v3; // ebp@5
+  int v4; // edi@11
+  unsigned int v5; // edx@15
+  unsigned int v6; // eax@16
+  unsigned int v7; // ebp@19
+  int v8; // eax@22
+  unsigned int v9; // edx@25
+  unsigned int v10; // edx@33
+
+  auto a1 = this;
+  v2 = a2;
+  if ( a1 )
+  {
+    if ( SHIDWORD(a1->pActorBuffs[9].uExpireTime) >= 0
+      && (SHIDWORD(a1->pActorBuffs[9].uExpireTime) > 0 || LODWORD(a1->pActorBuffs[9].uExpireTime) > 0) )
+      return 4;
+    v3 = a1->pMonsterInfo.uID;
+  }
+  else
+  {
+    v3 = 0;
+  }
+  if ( a2 )
+  {
+    if ( SHIDWORD(a2->pActorBuffs[9].uExpireTime) >= 0
+      && (SHIDWORD(a2->pActorBuffs[9].uExpireTime) > 0 || LODWORD(a2->pActorBuffs[9].uExpireTime) > 0) )
+      return 4;
+    v4 = a2->pMonsterInfo.uID;
+  }
+  else
+  {
+    v4 = 0;
+  }
+  if ( a2 )
+  {
+    if ( a1 )
+    {
+      v5 = a2->uGroup;
+      if ( v5 )
+      {
+        v6 = a1->uGroup;
+        if ( v6 )
+        {
+          if ( v5 == v6 )
+            return 0;
+        }
+      }
+    }
+  }
+  if ( v3 )
+    v7 = (v3 - 1) / 3 + 1;
+  else
+    v7 = 0;
+  if ( v4 )
+    v8 = (v4 - 1) / 3 + 1;
+  else
+    v8 = 0;
+  if ( a1 )
+  {
+    v9 = a1->uAlly;
+    if ( (signed int)v9 <= 0 )
+    {
+      if ( v9 != 9999 )
+        goto LABEL_30;
+    }
+    else
+    {
+      if ( v9 != 9999 )
+      {
+        v7 = a1->uAlly;
+        goto LABEL_30;
+      }
+    }
+    v7 = 0;
+LABEL_30:
+    if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 )
+      v7 = 0;
+  }
+  if ( !v2 )
+    goto LABEL_40;
+  v10 = v2->uAlly;
+  if ( (signed int)v10 <= 0 )
+  {
+    if ( v10 != 9999 )
+      goto LABEL_38;
+  }
+  else
+  {
+    if ( v10 != 9999 )
+    {
+      v8 = v2->uAlly;
+      goto LABEL_38;
+    }
+  }
+  v8 = 0;
+LABEL_38:
+  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
+    v8 = 0;
+LABEL_40:
+  if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8
+    || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 )
+    return 0;
+  if ( a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && a1->uAttributes & 0x80000 && !v8 )
+    return 4;
+  if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 )
+  {
+    if ( v7 )
+      goto LABEL_55;
+    return 4;
+  }
+  if ( !v7 )
+  {
+    if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000))
+      && !*((unsigned char *)&pFactionTable->relations + 89 * v8) )
+    {
+LABEL_56:
+      if ( v8 < 89 )
+        return *((unsigned char *)&pFactionTable->relations + 89 * v7 + v8);
+      return 0;
+    }
+    return 4;
+  }
+LABEL_55:
+  if ( (signed int)v7 < 89 )
+    goto LABEL_56;
+  return 0;
+}
+
+
+//----- (0045976D) --------------------------------------------------------
+unsigned int Actor::UpdateAnimation()
+{
+  AIState state; // edx@1
+  unsigned int result; // eax@1
+
+  state = (AIState)this->uAIState;
+  BYTE2(this->uAttributes) &= 0xDFu;
+  result = this->uAttributes;
+  switch ( state )
+  {
+    case Tethered:
+      this->uCurrentActionAnimation = ANIM_Walking;
+      return result;
+    case AttackingMelee:
+      this->uCurrentActionAnimation = ANIM_AtkMelee;
+      goto LABEL_10;
+    case AttackingRanged1:
+    case AttackingRanged2:
+    case AttackingRanged3:
+    case AttackingRanged4:
+      this->uCurrentActionAnimation = ANIM_AtkRanged;
+      goto LABEL_10;
+    case Dying:
+    case Resurrected:
+      this->uCurrentActionAnimation = ANIM_Dying;
+      goto LABEL_10;
+    case Pursuing:
+    case Fleeing:
+      this->uCurrentActionAnimation = ANIM_Walking;
+      goto LABEL_10;
+    case Stunned:
+      this->uCurrentActionAnimation = ANIM_GotHit;
+      goto LABEL_10;
+    case Fidgeting:
+      this->uCurrentActionAnimation = ANIM_Bored;
+      goto LABEL_10;
+    case Standing:
+    case Interacting:
+    case Summoned:
+      this->uCurrentActionAnimation = ANIM_Standing;
+LABEL_10:
+      result |= 0x200000u;
+      this->uAttributes = result;
+      break;
+    case Dead:
+      result = 60 * this->pSpriteIDs[6];
+      if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 )
+        this->uAIState = Removed;
+      else
+        this->uCurrentActionAnimation = ANIM_Dead;
+      break;
+    default:
+      return result;
+  }
+  return result;
+}
+
+//----- (00459671) --------------------------------------------------------
+void Actor::Reset()
+{
+  this->pActorName[0] = 0;
+  this->word_000086_some_monster_id = 0;
+  this->uNPC_ID = 0;
+  this->vPosition.z = 0;
+  this->vPosition.y = 0;
+  this->vPosition.x = 0;
+  this->vVelocity.z = 0;
+  this->vVelocity.y = 0;
+  this->vVelocity.x = 0;
+  this->uYawAngle = 0;
+  this->uPitchAngle = 0;
+  this->uAttributes = 0;
+  this->uSectorID = 0;
+  this->uCurrentActionTime = 0;
+  this->vInitialPosition.z = 0;
+  this->vInitialPosition.y = 0;
+  this->vInitialPosition.x = 0;
+  this->vGuardingPosition.z = 0;
+  this->vGuardingPosition.y = 0;
+  this->vGuardingPosition.x = 0;
+  this->uTetherDistance = 256;
+  this->uActorRadius = 32;
+  this->uActorHeight = 128;
+  this->uAIState = Standing;
+  this->uCurrentActionAnimation = 0;
+  this->uMovementSpeed = 200;
+  this->uCarriedItemID = 0;
+  this->uGroup = 0;
+  this->uAlly = 0;
+  this->uSummonerID = 0;
+  this->uLastCharacterIDToHit = 0;
+  this->dword_000334_unique_name = 0;
+  memset(this->pSpriteIDs, 0, sizeof(pSpriteIDs));
+  memset(this->pActorBuffs, 0, 0x160u);
+}
+
+//----- (0045959A) --------------------------------------------------------
+void Actor::PrepareSprites(char load_sounds_if_bit1_set)
+{
+  //Actor *v2; // edi@1
+  MonsterDesc *v3; // esi@1
+  //__int16 v4; // ax@2
+  unsigned __int16 *v5; // ecx@4
+  unsigned __int16 *v6; // eax@4
+  signed int v7; // edx@4
+  //char pSpriteName[120]; // [sp+Ch] [bp-88h]@2
+  MonsterInfo *v9; // [sp+84h] [bp-10h]@1
+  //int v10; // [sp+88h] [bp-Ch]@1
+  //char *Source; // [sp+8Ch] [bp-8h]@1
+  //unsigned __int16 *v12; // [sp+90h] [bp-4h]@1
+
+  //v2 = this;
+  //v10 = 8;
+  v3 = &pMonsterList->pMonsters[pMonsterInfo.uID - 1];
+  v9 = &pMonsterStats->pInfos[pMonsterInfo.uID - 1 + 1];
+  //v12 = pSpriteIDs;
+  //Source = (char *)v3->pSpriteNames;
+  //do
+  for (uint i = 0; i < 8; ++i)
+  {
+    //strcpy(pSpriteName, v3->pSpriteNames[i]);
+    pSpriteIDs[i] = pSpriteFrameTable->FastFindSprite(v3->pSpriteNames[i]);
+    //*v12 = v4;
+    pSpriteFrameTable->InitializeSprite(pSpriteIDs[i]);
+    //++v12;
+    //Source += 10;
+    //--v10;
+  }
+  //while ( v10 );
+  uActorHeight = v3->uMonsterHeight;
+  uActorRadius = v3->uMonsterRadius;
+  uMovementSpeed = LOWORD(v9->uBaseSpeed);
+  if ( !(load_sounds_if_bit1_set & 1) )
+  {
+    v5 = pSoundSampleIDs;
+    v6 = v3->pSoundSampleIDs;
+    v7 = 4;
+    do
+    {
+      *v5 = *v6;
+      ++v6;
+      ++v5;
+      --v7;
+    }
+    while ( v7 );
+  }
+}
+
+
+//----- (00459667) --------------------------------------------------------
+void Actor::Remove()
+{
+  this->uAIState = Removed;
+}
+
+
+//----- (0044FD29) --------------------------------------------------------
+int Actor::_44FD29(int a2)
+{
+  Actor *v2; // edi@1
+  unsigned __int8 v3; // al@1
+  int v4; // esi@1
+  int v5; // edx@2
+  int v6; // eax@8
+  int v7; // edi@10
+  Actor *v8; // esi@10
+  MonsterInfo *v9; // ebx@10
+  MonsterDesc *v10; // edi@10
+  unsigned __int16 v11; // ax@10
+  int v12; // eax@10
+  int v13; // ebx@10
+  int v14; // eax@10
+  int v15; // edi@10
+  int v16; // eax@10
+  int v17; // ebx@10
+  Actor *v18; // ecx@10
+  signed __int64 v19; // qax@10
+  unsigned int v20; // eax@12
+  int v21; // eax@13
+  int result; // eax@13
+  Actor *v23; // eax@16
+  int v24; // [sp+Ch] [bp-1Ch]@1
+  unsigned int uFaceID; // [sp+10h] [bp-18h]@8
+  int v26; // [sp+14h] [bp-14h]@10
+  int v27; // [sp+18h] [bp-10h]@10
+  int v28; // [sp+1Ch] [bp-Ch]@8
+  int v29; // [sp+20h] [bp-8h]@10
+  Actor *v30; // [sp+24h] [bp-4h]@1
+
+  v2 = this;
+  v24 = a2;
+  v30 = this;
+  v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
+  v4 = this->pMonsterInfo.field_3C_some_special_attack;
+  if ( v3 )
+  {
+    if ( v3 >= 1u && v3 <= 3u )
+      v4 = v4 + v3 - 1;
+  }
+  else
+  {
+    v5 = rand() % 100;
+    if ( v5 >= 60 )
+    {
+      ++v4;
+      if ( v5 >= 90 )
+        ++v4;
+    }
+  }
+  v6 = v2->vPosition.z;
+  v28 = 0;
+  uFaceID = v6;
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    v28 = pIndoor->GetSector(v2->vPosition.x, v2->vPosition.y, v6);
+  v7 = v4 - 1;
+  v8 = &pActors[uNumActors];
+  v27 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
+  v29 = v7;
+  v9 = &pMonsterStats->pInfos[v7 + 1];
+  pActors[uNumActors].Reset();
+  v10 = &pMonsterList->pMonsters[v7];
+  strcpy(v8->pActorName, v9->pName);
+  v8->sCurrentHP = LOWORD(v9->uHP);
+  memcpy(&v8->pMonsterInfo, v9, 0x58u);
+  v8->word_000086_some_monster_id = v29 + 1;
+  v8->uActorRadius = v10->uMonsterRadius;
+  v8->uActorHeight = v10->uMonsterHeight;
+  v11 = v10->uMovementSpeed;
+  v8->pMonsterInfo.uTreasureDiceRolls = 0;
+  v8->pMonsterInfo.uTreasureType = 0;
+  v8->pMonsterInfo.uExp = 0;
+  v8->uMovementSpeed = v11;
+  v12 = rand();
+  v13 = v12 % 2048;
+  v14 = stru_5C6E00->SinCos(v12 % 2048);
+  v26 = v14;
+  v15 = ((unsigned __int64)(v14 * (signed __int64)v27) >> 16) + v30->vPosition.x;
+  v16 = stru_5C6E00->SinCos(v13 - stru_5C6E00->uIntegerHalfPi);
+  v26 = v16;
+  v29 = (unsigned __int64)(v16 * (signed __int64)v27) >> 16;
+  LOWORD(v16) = uFaceID;
+  v17 = v29 + v30->vPosition.y;
+  v8->vInitialPosition.z = uFaceID;
+  v8->vPosition.z = v16;
+  LOWORD(v16) = v28;
+  v8->vInitialPosition.x = v15;
+  v8->vPosition.x = v15;
+  v8->vInitialPosition.y = v17;
+  v8->vPosition.y = v17;
+  v8->uTetherDistance = 256;
+  v8->uSectorID = v16;
+  v8->PrepareSprites(0);
+  v18 = v30;
+  v8->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+  LODWORD(v19) = v18->uAlly;
+  if ( !(uint)v19 )
+  {
+    uFaceID = v18->pMonsterInfo.uID - 1;
+    v19 = (signed __int64)((double)uFaceID * 0.33333334);
+    v18 = v30;
+  }
+  v8->uAlly = v19;
+  v20 = v18->uGroup;
+  v8->uCurrentActionTime = 0;
+  v8->uGroup = v20;
+  v8->uAIState = Summoned;
+  v8->uCurrentActionLength = 256;
+  v8->UpdateAnimation();
+  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
+    || (v21 = v30->vPosition.z,
+        v27 = v30->vPosition.z,
+        result = pIndoor->GetSector(v15, v17, v21),
+        result == v28)
+    && (result = _46CEC3_get_floor_level(v15, v17, v27, result, &uFaceID), result != -30000)
+    && (result = abs(result - v27), result <= 1024) )
+  {
+    v23 = v30;
+    ++uNumActors;
+    ++v23->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+    if ( v23->uAttributes & 0x80000 )
+      v8->uAttributes |= 0x80000u;
+    result = 8 * v24;
+    LOBYTE(result) = 8 * v24 | 3;
+    v8->uSummonerID = result;
+  }
+  return result;
+}
\ No newline at end of file