diff Actor.cpp @ 322:ce39b96acf5c

Killing friendly peasants subs
author Nomad
date Wed, 20 Feb 2013 04:36:14 +0200
parents 15decc249a94
children d720a13e2273
line wrap: on
line diff
--- a/Actor.cpp	Wed Feb 20 03:35:22 2013 +0200
+++ b/Actor.cpp	Wed Feb 20 04:36:14 2013 +0200
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "Actor.h"
 #include "LayingItem.h"
 #include "Math.h"
@@ -1404,7 +1406,7 @@
 
 
 //----- (0043ABB0) --------------------------------------------------------
-bool Actor::_43ABB0(Actor *a1, Actor *a2)
+bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2)
 {
   unsigned int v2; // esi@1
   unsigned int v3; // edi@1
@@ -1427,50 +1429,34 @@
 }
 
 //----- (0043AC45) --------------------------------------------------------
-void Actor::_43AC45(unsigned int uActorID, int a2)
+void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2)
 {
-  Actor *v2; // esi@1
-  Actor *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;
+  auto victim = pActors + uActorID;
   if ( a2 == 1 )
-    BYTE2(v2->uAttributes) |= 8u;
-  v9 = 0;
-  if ( (signed int)uNumActors > 0 )
+    BYTE2(victim->uAttributes) |= 8u;
+
+  for (uint i = 0; i < uNumActors; ++i)
   {
-    v3 = pActors;
-    do
+    auto actor = pActors + i;
+    if (!actor->CanAct() || i == uActorID)
+      continue;
+
+    if (Actor::ArePeasantsOfSameFaction(victim, actor))
     {
-      if ( v3->CanAct() )
+      v4 = abs(actor->vPosition.x - victim->vPosition.x);
+      v5 = abs(actor->vPosition.y - victim->vPosition.y);
+      v6 = abs(actor->vPosition.z - victim->vPosition.z);
+      if (int_get_vector_length(v4, v5, v6) < 4096)
       {
-        if ( v9 != uActorID_ )
-        {
-          if ( Actor::_43ABB0(v2, v3) )
-          {
-			v4 = abs(v3->vPosition.x - v2->vPosition.x);
-			v5 = abs(v3->vPosition.y - v2->vPosition.y);
-			v6 = abs(v3->vPosition.z - v2->vPosition.z);
-            if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 )
-            {
-				v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4;
-              if ( v7 == 1 )
-				  BYTE2(v3->uAttributes) |= 8u;
-            }
-          }
-        }
+        actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
+        if ( a2 == 1 )
+          BYTE2(actor->uAttributes) |= 8u;
       }
-      ++v9;
-      ++v3;
     }
-    while ( v9 < (signed int)uNumActors );
   }
 }
 
@@ -1958,11 +1944,11 @@
 
 
 //----- (00404030) --------------------------------------------------------
-unsigned int __fastcall Actor::FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4)
+void 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
+  //unsigned int result; // eax@2
   AIDirection *v7; // eax@3
   unsigned int v8; // ecx@3
   Actor *v9; // ebx@3
@@ -1994,20 +1980,17 @@
     v9->uPitchAngle = v11;
     v9->uCurrentActionLength = 256;
     v9->uAIState = Interacting;
-    result = v9->UpdateAnimation();
+    v9->UpdateAnimation();
   }
   else
-  {
-    result = Actor::_402F87(v5, v4, a4);
-  }
-  return result;
+    Actor::_402F87(v5, v4, a4);
 }
 
 //----- (00403F58) --------------------------------------------------------
-unsigned int __fastcall Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4)
+void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4)
 {
   unsigned int v4; // esi@1
-  unsigned int result; // eax@2
+  //unsigned int result; // eax@2
   AIDirection *v6; // eax@3
   unsigned int v7; // edi@3
   Actor *v8; // ebx@3
@@ -2020,10 +2003,10 @@
   v4 = uActorID;
   if ( rand() % 2 )
   {
-    result = Actor::_402F87(v4, a2, a4);
+    Actor::_402F87(v4, a2, a4);
+    return;
   }
-  else
-  {
+
     v6 = a4;
     v7 = 0;
     v8 = &pActors[v4];
@@ -2045,15 +2028,13 @@
     v8->vVelocity.z = v7;
     v8->vVelocity.y = v7;
     v8->vVelocity.x = v7;
-    result = v8->UpdateAnimation();
-  }
-  return result;
+    v8->UpdateAnimation();
 }
 
 
 
 //----- (00403EB6) --------------------------------------------------------
-unsigned int __fastcall Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4)
+void Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4)
 {
   AIDirection *v4; // eax@1
   unsigned int v5; // esi@1
@@ -2082,7 +2063,7 @@
   v6->vVelocity.z = v5;
   v6->vVelocity.y = v5;
   v6->vVelocity.x = v5;
-  return v6->UpdateAnimation();
+  v6->UpdateAnimation();
 }
 
 
@@ -2102,17 +2083,17 @@
 }
 
 //----- (00403C6C) --------------------------------------------------------
-unsigned int __fastcall Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
+void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
 {
   Actor *v3; // ebx@1
   char v4; // zf@1
-  unsigned int result; // eax@3
+  //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
+  //int v11; // eax@10
   AIDirection *v12; // eax@11
   unsigned int v13; // esi@11
   AIDirection *v14; // esi@12
@@ -2134,11 +2115,11 @@
   v24 = uActorID;
   if ( v4 && v3->pMonsterInfo.uAIType == 1 )
   {
-    result = Actor::_403EB6(uActorID, edx0, 0, arg0);
+    Actor::_403EB6(uActorID, edx0, 0, arg0);
+    return;
   }
-  else
-  {
-    if ( (edx0 & 7) == OBJECT_Actor)
+
+  if ( (edx0 & 7) == OBJECT_Actor)
     {
       v8 = edx0 >> 3;
       v6 = (AIDirection *)pActors[v8].vPosition.x;
@@ -2198,31 +2179,28 @@
       v3->vVelocity.z = v13;
       v3->vVelocity.y = v13;
       v3->vVelocity.x = v13;
-      result = v3->UpdateAnimation();
+      v3->UpdateAnimation();
     }
     else
-    {
-      v11 = rand();
-      result = Actor::_402AD7(v24, a2, v11 % 2, 64, arg0);
-    }
-  }
-  return result;
+      Actor::_402AD7(v24, a2, rand() % 2, 64, arg0);
 }
 
 
 //----- (00438CF3) --------------------------------------------------------
-void Actor::_438CF3(unsigned int uActorID)
+void Actor::ApplyFineForKillingPeasant(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
+  //char *v4; // ecx@16
+  //signed int v5; // eax@18
   Player **ppPlayers; // esi@20
 
   v1 = uLevelMapStatsID;
-  if ( !uLevelMapStatsID || (v2 = uActorID, !pActors[uActorID]._438B9B()) )
+  if ( !uLevelMapStatsID || !pActors[uActorID].IsPeasant())
     return;
+
+  v2 = uActorID;
   v3 = 1;
   if ( v1 != 5 )
   {
@@ -2243,20 +2221,24 @@
   if ( v3 )
   {
 LABEL_12:
-    pParty->uFine += 100
-                  * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm
-                   + pActors[v2].pMonsterInfo.uLevel
-                   + GetPartyReputation());
+    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;
+
+    if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    {
+      if (pOutdoor->ddm.uReputation < 10000)
+        pOutdoor->ddm.uReputation++;
+    }
+    else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    {
+      if (pIndoor->dlv.uReputation < 10000)
+        pIndoor->dlv.uReputation++;
+    }
+    else assert(false);
+
     ppPlayers = &pPlayers[1];
     do
     {
@@ -2273,7 +2255,7 @@
 
 
 //----- (0043AE80) --------------------------------------------------------
-int Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3)
+void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3)
 {
   int result; // eax@1
   unsigned int v4; // esi@1
@@ -2297,7 +2279,7 @@
         v5 = 904;
         goto LABEL_16;
       }
-      return result;
+      return;
     case 2:
       if ( a3 )
       {
@@ -2308,7 +2290,7 @@
         v5 = 905;
         goto LABEL_16;
       }
-      return result;
+      return;
     case 3:
       if ( a3 )
       {
@@ -2319,7 +2301,7 @@
         v5 = 906;
         goto LABEL_16;
       }
-      return result;
+      return;
     case 4:
       if ( a3 )
       {
@@ -2330,7 +2312,7 @@
         v5 = 907;
         goto LABEL_16;
       }
-      return result;
+      return;
     case 5:
       v9 = 4;
       v8 = 65536;
@@ -2376,9 +2358,9 @@
       result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9);
       break;
     default:
-      return result;
+      return;
   }
-  return result;
+  return;
 }
 
 
@@ -2457,7 +2439,7 @@
 }
 
 //----- (00438B9B) --------------------------------------------------------
-char Actor::_438B9B()
+bool Actor::IsPeasant()
 {
   unsigned int v1; // eax@1
 
@@ -2510,14 +2492,14 @@
 
 
 //----- (00403A60) --------------------------------------------------------
-unsigned int __fastcall Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void 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
+  //unsigned int result; // eax@7
   AIDirection *v9; // eax@8
   unsigned int v10; // esi@8
   AIDirection *v11; // esi@9
@@ -2605,31 +2587,26 @@
       v3->uCurrentActionLength = 64;
       v3->uCurrentActionTime = v10;
       v3->uAIState = Fidgeting;
-      result = v3->UpdateAnimation();
+      v3->UpdateAnimation();
       v3->uAIState = AttackingRanged4;
     }
     else
-    {
-      result = v3->UpdateAnimation();
-    }
+      v3->UpdateAnimation();
   }
   else
-  {
-    result = Actor::_402AD7(v22, a2, v22, 64, pDir);
-  }
-  return result;
+    Actor::_402AD7(v22, a2, v22, 64, pDir);
 }
 
 
 //----- (00403854) --------------------------------------------------------
-unsigned int __fastcall Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void 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
+  //unsigned int result; // eax@7
   AIDirection *v9; // eax@8
   unsigned int v10; // esi@8
   AIDirection *v11; // esi@9
@@ -2717,31 +2694,26 @@
       v3->uCurrentActionLength = 64;
       v3->uCurrentActionTime = v10;
       v3->uAIState = Fidgeting;
-      result = v3->UpdateAnimation();
+      v3->UpdateAnimation();
       v3->uAIState = AttackingRanged3;
     }
     else
-    {
-      result = v3->UpdateAnimation();
-    }
+      v3->UpdateAnimation();
   }
   else
-  {
-    result = Actor::_402AD7(v22, a2, v22, 64, pDir);
-  }
-  return result;
+    Actor::_402AD7(v22, a2, v22, 64, pDir);
 }
 
 
 //----- (0040368B) --------------------------------------------------------
-unsigned int __fastcall Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void 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
+  //unsigned int result; // eax@7
   AIDirection *v9; // eax@8
   unsigned int v10; // esi@8
   AIDirection *v11; // esi@9
@@ -2818,18 +2790,15 @@
     v3->vVelocity.z = v10;
     v3->vVelocity.y = v10;
     v3->vVelocity.x = v10;
-    result = v3->UpdateAnimation();
+    v3->UpdateAnimation();
   }
   else
-  {
-    result = Actor::_402AD7(v21, a2, v21, 64, pDir);
-  }
-  return result;
+    Actor::_402AD7(v21, a2, v21, 64, pDir);
 }
 
 
 //----- (00403476) --------------------------------------------------------
-unsigned int __fastcall Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   int v4; // esi@3
@@ -2837,7 +2806,7 @@
   signed int v6; // eax@4
   Vec3_int_ v7; // ST04_12@6
   unsigned char v8[12]; // ST04_12@7
-  unsigned int result; // eax@8
+  //unsigned int result; // eax@8
   AIDirection *v10; // eax@9
   unsigned int v11; // esi@9
   AIDirection *v12; // esi@10
@@ -2926,17 +2895,14 @@
     v3->vVelocity.z = v11;
     v3->vVelocity.y = v11;
     v3->vVelocity.x = v11;
-    result = v3->UpdateAnimation();
+    v3->UpdateAnimation();
   }
   else
-  {
-    result = Actor::_402AD7(v21, a2, v21, 64, pDir);
-  }
-  return result;
+    Actor::_402AD7(v21, a2, v21, 64, pDir);
 }
 
 //----- (004032B2) --------------------------------------------------------
-void __fastcall Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
+void Actor::_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength)
 {
   unsigned int v4; // edi@1
   Actor *v5; // esi@1
@@ -3072,11 +3038,11 @@
 
 
 //----- (004030AD) --------------------------------------------------------
-__int16 __fastcall Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0)
+void Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0)
 {
   unsigned int v3; // edi@1
   Actor *v4; // ebx@1
-  __int16 result; // ax@10
+  //__int16 result; // ax@10
   SpriteFrame *v6; // ecx@16
   __int16 v7; // ax@16
   unsigned int v8; // ecx@16
@@ -3101,12 +3067,12 @@
   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 )
+    || (v4->uAIState != 8
+    && v4->uAIState != 3
+    && v4->uAIState != 12
+    && v4->uAIState != 13
+    && v4->uAIState != 18
+    && v4->uAIState != 2))
   {
     memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10));
     v6 = pSpriteFrameTable->pSpriteSFrames;
@@ -3117,13 +3083,12 @@
     v4->uAIState = Stunned;
     v4->uCurrentActionLength = 8 * v7;
     Actor::PlaySound(v8, 2u);
-    result = v4->UpdateAnimation();
+    v4->UpdateAnimation();
   }
-  return result;
 }
 
 //----- (00402F87) --------------------------------------------------------
-int __fastcall Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
+void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
 {
   int v3; // edi@1
   AIDirection *v4; // esi@1
@@ -3132,7 +3097,7 @@
   unsigned int v7; // eax@3
   int v8; // edx@3
   unsigned int v9; // eax@3
-  int result; // eax@4
+  //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
@@ -3159,7 +3124,7 @@
   v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
   if ( BYTE1(v9) & 7 )
   {
-    result = Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4);
+    Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4);
   }
   else
   {
@@ -3170,13 +3135,12 @@
     v5->vVelocity.x = 0;
     if ( rand() % 100 < 5 )
       Actor::PlaySound(v3, 3u);
-    result = v5->UpdateAnimation();
+    v5->UpdateAnimation();
   }
-  return result;
 }
 
 //----- (00402F27) --------------------------------------------------------
-unsigned int __fastcall Actor::Resurrect(unsigned int uActorID)
+void Actor::Resurrect(unsigned int uActorID)
 {
   Actor *pActor; // esi@1
   SpriteFrame *v2; // edx@1
@@ -3191,7 +3155,7 @@
   pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength;
   pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP);
   Actor::PlaySound(uActorID, 1u);
-  return pActor->UpdateAnimation();
+  pActor->UpdateAnimation();
 }
 
 
@@ -3259,7 +3223,7 @@
 }
 
 //----- (00402CED) --------------------------------------------------------
-void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID)
+void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID)
 {
   Actor *v2; // eax@1
   unsigned __int16 v3; // dx@1
@@ -3321,7 +3285,7 @@
 
 
 //----- (00402AD7) --------------------------------------------------------
-unsigned int __fastcall Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
+void 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
@@ -3364,16 +3328,21 @@
   {
     if ( !uActionLength )
       uActionLength = 256;
-    return Actor::_403F58(v5, 4, uActionLength, v10);
+    Actor::_403F58(v5, 4, uActionLength, v10);
+    return;
   }
   if ( (double)(signed int)v10->uDistance < 307.2 )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    return Actor::_403EB6(v5, v18, uActionLength, v10);
+    Actor::_403EB6(v5, v18, uActionLength, v10);
+    return;
   }
   if ( !v7->uMovementSpeed )
-    return Actor::_403EB6(v5, v18, uActionLength, v10);
+  {
+    Actor::_403EB6(v5, v18, uActionLength, v10);
+    return;
+  }
   v18 = 16;
   if ( arg0 % 2 )
     v18 = -16;
@@ -3394,15 +3363,15 @@
     v7->uCurrentActionLength = 128;
   v7->uPitchAngle = LOWORD(v10->uPitchAngle);
   v7->uAIState = Pursuing;
-  return v7->UpdateAnimation();
+  v7->UpdateAnimation();
 }
 
 //----- (00402968) --------------------------------------------------------
-unsigned int __fastcall Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4)
+void 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
+  //unsigned int result; // eax@1
   int v7; // ecx@2
   signed __int16 v8; // cx@10
   unsigned __int16 v9; // ax@15
@@ -3418,8 +3387,8 @@
   a2 = edx0;
   v15 = uActorID;
   v5 = &pActors[uActorID];
-  result = pActors[uActorID].CanAct();
-  if ( result )
+  //result = pActors[uActorID].CanAct();
+  if ( pActors[uActorID].CanAct() )
   {
     v7 = 8 * v4 | 3;
     a1 = 8 * v4 | 3;
@@ -3436,7 +3405,7 @@
     {
       if ( !uActionLength )
         uActionLength = 256;
-      result = Actor::_403F58(v15, 4, uActionLength, &v13);
+      Actor::_403F58(v15, 4, uActionLength, &v13);
     }
     else
     {
@@ -3453,15 +3422,14 @@
       v5->uCurrentActionTime = 0;
       v5->uPitchAngle = v9;
       v5->uAIState = Fleeing;
-      result = v5->UpdateAnimation();
+      v5->UpdateAnimation();
     }
   }
-  return result;
 }
 
 
 //----- (0040281C) --------------------------------------------------------
-int __fastcall Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
+void Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
 {
   unsigned int v5; // edi@1
   int v6; // eax@1
@@ -3508,7 +3476,8 @@
     v16 = v10;
     v15 = uActionLength;
     v11 = 4;
-    return Actor::_403F58(v5, v11, v15, v16);
+    Actor::_403F58(v5, v11, v15, v16);
+    return;
   }
   if ( (signed int)v10->uDistance < a5 )
   {
@@ -3517,7 +3486,8 @@
     v11 = v19;
     v16 = v10;
     v15 = uActionLength;
-    return Actor::_403F58(v5, v11, v15, v16);
+    Actor::_403F58(v5, v11, v15, v16);
+    return;
   }
   if ( uActionLength )
   {
@@ -3538,12 +3508,12 @@
   v7->uCurrentActionTime = 0;
   v7->uPitchAngle = v14;
   v7->uAIState = Pursuing;
-  return v7->UpdateAnimation();
+  v7->UpdateAnimation();
 }
 
 
 //----- (00402686) --------------------------------------------------------
-unsigned int __fastcall Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
+void Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4)
 {
   unsigned int v4; // edi@1
   int v5; // eax@1
@@ -3631,11 +3601,11 @@
   v6->uAIState = Pursuing;
   if ( rand() % 100 < 2 )
     Actor::PlaySound(v4, 2u);
-  return v6->UpdateAnimation();
+  v6->UpdateAnimation();
 }
 
 //----- (00401221) --------------------------------------------------------
-void __fastcall Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3)
+void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3)
 {
   Actor *v3; // esi@1
   unsigned int v4; // ebx@1
@@ -3913,61 +3883,72 @@
 
 
 //----- (0045976D) --------------------------------------------------------
-unsigned int Actor::UpdateAnimation()
+void Actor::UpdateAnimation()
 {
-  AIState state; // edx@1
-  unsigned int result; // eax@1
+  //AIState state; // edx@1
+  //unsigned int result; // eax@1
 
-  state = (AIState)this->uAIState;
-  BYTE2(this->uAttributes) &= 0xDFu;
-  result = this->uAttributes;
-  switch ( state )
+  //state = (AIState)this->;
+  uAttributes &= 0xFFDFFFFF;
+  //result = this->uAttributes;
+  switch (uAIState)
   {
     case Tethered:
-      this->uCurrentActionAnimation = ANIM_Walking;
-      return result;
+      uCurrentActionAnimation = ANIM_Walking;
+    break;
+
     case AttackingMelee:
-      this->uCurrentActionAnimation = ANIM_AtkMelee;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_AtkMelee;
+      uAttributes |= 0x200000u;
+    break;
+
     case AttackingRanged1:
     case AttackingRanged2:
     case AttackingRanged3:
     case AttackingRanged4:
-      this->uCurrentActionAnimation = ANIM_AtkRanged;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_AtkRanged;
+      uAttributes |= 0x200000u;
+    break;
+
     case Dying:
     case Resurrected:
-      this->uCurrentActionAnimation = ANIM_Dying;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_Dying;
+      uAttributes |= 0x200000u;
+    break;
+
     case Pursuing:
     case Fleeing:
-      this->uCurrentActionAnimation = ANIM_Walking;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_Walking;
+      uAttributes |= 0x200000u;
+    break;
+
     case Stunned:
-      this->uCurrentActionAnimation = ANIM_GotHit;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_GotHit;
+      uAttributes |= 0x200000u;
+    break;
+
     case Fidgeting:
-      this->uCurrentActionAnimation = ANIM_Bored;
-      goto LABEL_10;
+      uCurrentActionAnimation = ANIM_Bored;
+      uAttributes |= 0x200000u;
+    break;
+
     case Standing:
     case Interacting:
     case Summoned:
-      this->uCurrentActionAnimation = ANIM_Standing;
-LABEL_10:
-      result |= 0x200000u;
-      this->uAttributes = result;
-      break;
+      uCurrentActionAnimation = ANIM_Standing;
+      uAttributes |= 0x200000u;
+    break;
+
     case Dead:
-      result = 60 * this->pSpriteIDs[ANIM_Dead];
-      if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 )
-        this->uAIState = Removed;
+      if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0)
+        uAIState = Removed;
       else
-        this->uCurrentActionAnimation = ANIM_Dead;
-      break;
+        uCurrentActionAnimation = ANIM_Dead;
+    break;
+
     default:
-      return result;
+      assert(false);
   }
-  return result;
 }
 
 //----- (00459671) --------------------------------------------------------