changeset 1900:948c43b11599

Merge
author Nomad
date Mon, 21 Oct 2013 10:42:35 +0200
parents b3009adc0e2f (current diff) dd9d4b7c1199 (diff)
children 4cae2d58cfb4
files
diffstat 15 files changed, 745 insertions(+), 1188 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/Actor.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -44,6 +44,7 @@
 stru319 stru_50C198; // idb
 
 
+std::array<uint, 5> dword_4DF380_hostilityRanges = {0,1024,2560,5120,10240};
 
 
 //----- (0041AF52) --------------------------------------------------------
@@ -342,9 +343,9 @@
       else if (masteryLevel == 4)
         v23 = 14;
       spellnumb = 0;
+      v28 = 0;
       for ( int i = 0; i < v23; i++)
       {
-        v28 = spellnumb;
         v30 = rand() % 1000;
         spellnumc = v30 - 2500;
         v120 = v28 * v28;
@@ -396,6 +397,7 @@
           pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], PID(OBJECT_Item, v36), 0, -1, 0, 0, 0, 0);
         }
         spellnumb = rand() % 1024 - 512;
+        v28 = rand() % 1024 - 512;
       }
       return;
       break;
@@ -1219,34 +1221,18 @@
 void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
 {
   Actor *v3; // ebx@1
-  char v4; // zf@1
-  //unsigned int result; // eax@3
-  AIDirection *v6; // esi@6
-  AIDirection *v7; // edi@6
+  int16_t v6; // esi@6
+  int16_t 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 == MONSTER_MOVEMENT_TYPE_STAIONARY;
-  v24 = uActorID;
-  if ( v4 && v3->pMonsterInfo.uAIType == 1 )
+  if ( v3->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY && v3->pMonsterInfo.uAIType == 1 )
   {
     Actor::AI_Stand(uActorID, sTargetPid, 0, arg0);
     return;
@@ -1254,237 +1240,153 @@
 
   if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-	v8 = PID_ID(sTargetPid);
-    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);
+	  v8 = PID_ID(sTargetPid);
+    v6 = pActors[v8].vPosition.x;
+    v7 = pActors[v8].vPosition.y;
+    v23 = (int)(pActors[v8].uActorHeight * 0.75 + pActors[v8].vPosition.z);
   }
   else if ( PID_TYPE(sTargetPid) == OBJECT_Player)
   {
-	v6 = (AIDirection *)pParty->vPosition.x;
-    v7 = (AIDirection *)pParty->vPosition.y;
+	  v6 = pParty->vPosition.x;
+    v7 = pParty->vPosition.y;
     v23 = pParty->vPosition.z + pParty->sEyelevel;
   }
   else
   {
-    v6 = arg0;
-	v7 = arg0;
+    Error("Should not get here");
+    return;
   }
-  v21 = v3->uActorHeight;
-  v9 = (double)(signed int)v21 * 0.75;
-  v21 = v3->vPosition.z;
-  v10.z = (signed __int64)(v9 + (double)(signed int)v21);
+  v10.z = (int32_t)(v3->uActorHeight * 0.75 + v3->vPosition.z);
   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 )
+    if (arg0 != nullptr)
     {
-		v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0);
-        v12 = &v20;
-        memcpy(&v20, v14, sizeof(v20));
-        v13 = 0;
+      v12 = arg0;
     }
-    v15 = pSpriteFrameTable->pSpriteSFrames;
+    else
+    {
+		  v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0);
+    }
     v3->uYawAngle = LOWORD(v12->uYawAngle);
-    v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength;
-    v17 = v24;
-    v3->uCurrentActionLength = 8 * v16;
-    v3->uCurrentActionTime = v13;
+    v3->uCurrentActionLength = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength * 8;
+    v3->uCurrentActionTime = 0;
     v3->uAIState = AttackingMelee;
-    Actor::PlaySound(v17, 0);
-    LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    Actor::PlaySound(uActorID, 0);
     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) )
+    if ( v3->pActorBuffs[7].uExpireTime > 0 )
     {
-		LODWORD(v18) = 2 * v18;
-        v25 = v18;
+      v25 *= 2;
     }
     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;
+    {
+      v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * v25 * 2.133333333333333);
+    }
+    else
+    {
+      v3->pMonsterInfo.uRecoveryTime = v25;
+    }
+    v3->vVelocity.z = 0;
+    v3->vVelocity.y = 0;
+    v3->vVelocity.x = 0;
     v3->UpdateAnimation();
   }
   else
-	Actor::AI_Pursue1(v24, sTargetPid, rand() % 2, 64, arg0);
+	Actor::AI_Pursue1(uActorID, sTargetPid, rand() % 2, 64, arg0);
 }
 
 //----- (00438CF3) --------------------------------------------------------
 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
-  Player **ppPlayers; // esi@20
+  if ( uLevelMapStatsID == 0 || !pActors[uActorID].IsPeasant())
+    return;
 
-  v1 = uLevelMapStatsID;
-  if ( !uLevelMapStatsID || !pActors[uActorID].IsPeasant())
+  if ( (uLevelMapStatsID == 6 || uLevelMapStatsID == 7) && pParty->IsPartyEvil())   //celeste and bracada
+    return;
+
+  if ( (uLevelMapStatsID == 5 || uLevelMapStatsID == 8) && pParty->IsPartyGood())   // the pit and deyja
     return;
 
-  v2 = uActorID;
-  v3 = 1;
-  if ( v1 != 5 )
+  pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[uActorID].pMonsterInfo.uLevel + pParty->GetPartyReputation());
+  if ( pParty->uFine < 0 )
+    pParty->uFine = 0;
+  if ( pParty->uFine > 4000000 )
+    pParty->uFine = 4000000;
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
-    if ( v1 == 6 || v1 == 7 )
-    {
-      pParty->IsPartyGood(); //the binary file contains this call. if someone finds out whether it's supposed to be here or not, feel free to apply the appropriate change
-      if ( pParty->IsPartyEvil() )
-        return;
-      goto LABEL_12;
-    }
-    if ( v1 != 8 )
-      goto LABEL_12;
+    if (pOutdoor->ddm.uReputation < 10000)
+      pOutdoor->ddm.uReputation++;
   }
-  if ( pParty->IsPartyGood() )
-    v3 = 0;
-  if ( pParty->IsPartyEvil() )
-    v3 = 1;
-  if ( v3 )
+  else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-LABEL_12:
-    pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + pParty->GetPartyReputation());
-    if ( pParty->uFine < 0 )
-      pParty->uFine = 0;
-    if ( pParty->uFine > 4000000 )
-      pParty->uFine = 4000000;
+    if (pIndoor->dlv.uReputation < 10000)
+      pIndoor->dlv.uReputation++;
+  }
+  else assert(false);
 
-    if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-    {
-      if (pOutdoor->ddm.uReputation < 10000)
-        pOutdoor->ddm.uReputation++;
-    }
-    else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+  if ( pParty->uFine )
+  {
+    for ( int i = 1; i <= 4; i++)
     {
-      if (pIndoor->dlv.uReputation < 10000)
-        pIndoor->dlv.uReputation++;
+      if ( !_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1) )
+        _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1u);
     }
-    else assert(false);
-
-    ppPlayers = &pPlayers[1];
-    do
-    {
-      if ( pParty->uFine )
-      {
-        if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->_achieved_awards_bits, 1) )
-          _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->_achieved_awards_bits, 1, 1u);
-      }
-      ++ppPlayers;
-    }
-    while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
   }
 }
 
 //----- (0043AE80) --------------------------------------------------------
 void 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 = PID(OBJECT_Actor,uActorID);
   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;
+        pOtherOverlayList->_4418B6(904, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 2:
       if ( a3 )
       {
-        v9 = 0;
-        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
-        v7 = 0;
-        LOWORD(v6) = v4;
-        v5 = 905;
-        goto LABEL_16;
+        pOtherOverlayList->_4418B6(905, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 3:
       if ( a3 )
       {
-        v9 = 0;
-        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
-        v7 = 0;
-        LOWORD(v6) = v4;
-        v5 = 906;
-        goto LABEL_16;
+        pOtherOverlayList->_4418B6(906, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 4:
       if ( a3 )
       {
-        v9 = 0;
-        v8 = (signed __int64)(sub_43AE12(a3) * 65536.0);
-        v7 = 0;
-        LOWORD(v6) = v4;
-        v5 = 907;
-        goto LABEL_16;
+        pOtherOverlayList->_4418B6(907, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 5:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 901;
-      goto LABEL_16;
+      pOtherOverlayList->_4418B6(901, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     case 6:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 902;
-      goto LABEL_16;
+      pOtherOverlayList->_4418B6(902, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     case 7:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 903;
-      goto LABEL_16;
+      pOtherOverlayList->_4418B6(903, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     case 8:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 900;
-      goto LABEL_16;
+      pOtherOverlayList->_4418B6(900, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     case 9:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 909;
-      goto LABEL_16;
+      pOtherOverlayList->_4418B6(909, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     case 10:
-      v9 = 4;
-      v8 = 65536;
-      v7 = 0;
-      v6 = PID(OBJECT_Actor,uActorID);
-      v5 = 908;
-LABEL_16:
-      result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9);
-      break;
+      pOtherOverlayList->_4418B6(908, v4, 0, PID(OBJECT_Actor,uActorID), 0);
+      return;
     default:
       return;
   }
@@ -1492,13 +1394,12 @@
 }
 
 //----- (0043B3E0) --------------------------------------------------------
-int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2)
+int Actor::_43B3E0_CalcDamage( signed int dmgSource )
 {
   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
@@ -1506,61 +1407,47 @@
 
   v2 = 0;
   v11 = 0;
-  if ( a2 )
+
+  switch( dmgSource )
   {
-    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;
-    }
+    case 0: 
+      if ( this->pActorBuffs[14].uExpireTime > 0 )
+        v2 = this->pActorBuffs[14].uPower;
+      if ( this->pActorBuffs[18].uExpireTime > 0 && this->pActorBuffs[18].uPower > v2 )
+        v2 = this->pActorBuffs[18].uPower;
+      if ( this->pActorBuffs[21].uExpireTime > 0 )
+        v2 += this->pActorBuffs[21].uPower;
+      v3 = this->pMonsterInfo.uAttack1DamageDiceRolls;
+      v4 = this->pMonsterInfo.uAttack1DamageDiceSides;
+      v5 = this->pMonsterInfo.uAttack1DamageBonus;
+      break;
+    case 1: 
+      v3 = this->pMonsterInfo.uAttack2DamageDiceRolls;
+      v4 = this->pMonsterInfo.uAttack2DamageDiceSides;
+      v5 = this->pMonsterInfo.uAttack2DamageBonus;
+      break;
+    case 2: 
+      v8 = this->pMonsterInfo.uSpellSkillAndMastery1;
+      v9 = this->pMonsterInfo.uSpell1ID;
+      v10 = SkillToMastery(v8);
+      return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0);
+      break;
+    case 3: 
+      v8 = this->pMonsterInfo.uSpellSkillAndMastery2;
+      v9 = this->pMonsterInfo.uSpell2ID;
+      v10 = SkillToMastery(v8);
+      return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0);
+      break;
+    case 4:
+      v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
+      v4 = this->pMonsterInfo.uSpecialAbilityDamageDiceSides;
+      v5 = this->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+    default:
+      return 0;
   }
-  else
+  for ( int i = 0; i < v3; i++)
   {
-    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 );
+    v11 += rand() % v4 + 1;
   }
   return v11 + v5 + v2;
 }
@@ -1580,22 +1467,16 @@
 }
 
 //----- (0042EBEE) --------------------------------------------------------
-bool Actor::StealFrom(unsigned int uActorID)
+void 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 = &pParty->pPlayers[uActiveCharacter-1];
-  result = pPlayer->CanAct();
-  if ( result )
+  if ( pPlayer->CanAct() )
   {
     CastSpellInfoHelpers::_427D48();
     v4 = 0;
@@ -1605,113 +1486,90 @@
     v6 = &pOutdoor->ddm;
     if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
       v6 = &pIndoor->dlv;
-    pPlayer->StealFromActor(v7, v4, v6->uReputation++);
+    pPlayer->StealFromActor(uActorID, 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));
+      pPlayer->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * v8 * 2.133333333333333));
     pTurnEngine->ApplyPlayerAction();
-    result = 1;
   }
-  return result;
+  return;
 }
 
 //----- (00403A60) --------------------------------------------------------
 void Actor::AI_SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
-  AIDirection *v4; // esi@3
-  AIDirection *v5; // edi@3
+  int16_t v4; // esi@3
+  int16_t 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 ( PID_TYPE(edx0) == OBJECT_Actor)
   {
     v6 = PID_ID(edx0);
-    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);
+    v4 = pActors[v6].vPosition.x;
+    v5 = pActors[v6].vPosition.y;
+    v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z);
+  }
+  else if ( PID_TYPE(edx0) == OBJECT_Player)
+  {
+    v4 = pParty->vPosition.x;
+    v5 = pParty->vPosition.y;
+    v21 = pParty->vPosition.z + pParty->sEyelevel;
   }
   else
   {
-    if ( PID_TYPE(edx0) == OBJECT_Player)
+    Error("Should not get here");
+    return;
+  }
+  v19 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (int)(v19 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C(v4, v5, v21, v7) )
+  {
+    if ( pDir == nullptr)
     {
-      v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.y;
-      v21 = pParty->vPosition.z + pParty->sEyelevel;
+      v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), a2, &a3, 0);
     }
     else
     {
-      v4 = pDir;
-      v5 = pDir;
+      v9 = 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 )
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = 0;
+    v3->uAIState = AttackingRanged4;
+    Actor::PlaySound(uActorID, 0);
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if (v3->pActorBuffs[7].uExpireTime > 0)
     {
-      v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), a2, &a3, 0);
-      v9 = &v18;
-      memcpy(&v18, v11, sizeof(v18));
-      v10 = 0;
-    }
-    v12 = pSpriteFrameTable->pSpriteSFrames;
-    v3->uYawAngle = LOWORD(v9->uYawAngle);
-    v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].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;
+      pDira *= 2;
     }
     if ( pParty->bTurnBasedModeOn == 1 )
-      v3->pMonsterInfo.uRecoveryTime = v15;
+      v3->pMonsterInfo.uRecoveryTime = pDira;
     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 ( _42FB5C_check_spell(v16) )
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
+    v3->vVelocity.z = 0;
+    v3->vVelocity.y = 0;
+    v3->vVelocity.x = 0;
+    if ( _42FB5C_check_spell(v3->pMonsterInfo.uSpell2ID) )
     {
       v3->uCurrentActionLength = 64;
-      v3->uCurrentActionTime = v10;
+      v3->uCurrentActionTime = 0;
       v3->uAIState = Fidgeting;
       v3->UpdateAnimation();
       v3->uAIState = AttackingRanged4;
@@ -1720,104 +1578,82 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::AI_Pursue1(v22, a2, v22, 64, pDir);
+    Actor::AI_Pursue1(uActorID, a2, uActorID, 64, pDir);
 }
 
 //----- (00403854) --------------------------------------------------------
 void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
-  AIDirection *v4; // esi@3
-  AIDirection *v5; // edi@3
+  int16_t v4; // esi@3
+  int16_t 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 ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
     v6 = PID_ID(sTargetPid);
-    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);
+    v4 = pActors[v6].vPosition.x;
+    v5 = pActors[v6].vPosition.y;
+    v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z);
+  }
+  else if ( PID_TYPE(sTargetPid) == OBJECT_Player)
+  {
+    v4 = pParty->vPosition.x;
+    v5 = pParty->vPosition.y;
+    v21 = pParty->vPosition.z + pParty->sEyelevel;
   }
   else
   {
-    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
+    Error("Should not get here");
+    return;
+  }
+  v19 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (int)(v19 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C(v4, v5, v21, v7) )
+  {
+    if ( pDir == nullptr )
     {
-      v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.y;
-      v21 = pParty->vPosition.z + pParty->sEyelevel;
+      v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0);
     }
     else
     {
-      v4 = pDir;
-      v5 = pDir;
+      v9 = 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 )
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = 0;
+    v3->uAIState = AttackingRanged3;
+    Actor::PlaySound(uActorID, 0);
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if (v3->pActorBuffs[7].uExpireTime > 0)
     {
-      v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), sTargetPid, &a3, 0);
-      v9 = &v18;
-      memcpy(&v18, v11, sizeof(v18));
-      v10 = 0;
-    }
-    v12 = pSpriteFrameTable->pSpriteSFrames;
-    v3->uYawAngle = LOWORD(v9->uYawAngle);
-    v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].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;
+      pDira *= 2;
     }
     if ( pParty->bTurnBasedModeOn == 1 )
-      v3->pMonsterInfo.uRecoveryTime = v15;
+      v3->pMonsterInfo.uRecoveryTime = pDira;
     else
-      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength
-                                     - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2
-                                                                    * (double)(signed int)pDira
-                                                                    * -2.133333333333333);
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
     v16 = v3->pMonsterInfo.uSpell1ID;
-    v3->vVelocity.z = v10;
-    v3->vVelocity.y = v10;
-    v3->vVelocity.x = v10;
+    v3->vVelocity.z = 0;
+    v3->vVelocity.y = 0;
+    v3->vVelocity.x = 0;
     if ( _42FB5C_check_spell(v16) )
     {
       v3->uCurrentActionLength = 64;
-      v3->uCurrentActionTime = v10;
+      v3->uCurrentActionTime = 0;
       v3->uAIState = Fidgeting;
       v3->UpdateAnimation();
       v3->uAIState = AttackingRanged3;
@@ -1826,98 +1662,82 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::AI_Pursue1(v22, sTargetPid, v22, 64, pDir);
+    Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir);
 }
 
 //----- (0040368B) --------------------------------------------------------
 void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
-  AIDirection *v4; // esi@3
-  AIDirection *v5; // edi@3
+  int16_t v4; // esi@3
+  int16_t 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 ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
     v6 = PID_ID(sTargetPid);
-    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);
+    v4 = pActors[v6].vPosition.x;
+    v5 = pActors[v6].vPosition.y;
+    v20 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z);
+  }
+  else if ( PID_TYPE(sTargetPid) == OBJECT_Player)
+  {
+    v4 = pParty->vPosition.x;
+    v5 = pParty->vPosition.y;
+    v20 = pParty->vPosition.z + pParty->sEyelevel;
   }
   else
   {
-    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
+    Error("Should not get here");
+    return;
+  }
+  v18 = v3->uActorHeight;
+  v7.z = v3->vPosition.z - (int)(v18 * -0.75);
+  v7.y = v3->vPosition.y;
+  v7.x = v3->vPosition.x;
+  if ( sub_407A1C(v4, v5, v20, v7) )
+  {
+    if ( pDir == nullptr )
     {
-      v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.y;
-      v20 = pParty->vPosition.z + pParty->sEyelevel;
+      v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0);
     }
     else
     {
-      v4 = pDir;
-      v5 = pDir;
+      v9 = 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 )
+    v3->uYawAngle = LOWORD(v9->uYawAngle);
+    v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
+    v3->uCurrentActionLength = 8 * v13;
+    v3->uCurrentActionTime = 0;
+    v3->uAIState = AttackingRanged2;
+    Actor::PlaySound(uActorID, 0);
+    pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( v3->pActorBuffs[7].uExpireTime > 0 )
     {
-      v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0);
-      v9 = &v17;
-      memcpy(&v17, v11, sizeof(v17));
-      v10 = 0;
-    }
-    v12 = pSpriteFrameTable->pSpriteSFrames;
-    v3->uYawAngle = LOWORD(v9->uYawAngle);
-    v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].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;
+      pDira *= 2;
     }
     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;
+      v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
+    else
+    {
+      v3->pMonsterInfo.uRecoveryTime = pDira;
+    }
+    v3->vVelocity.z = 0;
+    v3->vVelocity.y = 0;
+    v3->vVelocity.x = 0;
     v3->UpdateAnimation();
   }
   else
-    Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir);
+    Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir);
 }
 
 //----- (00403476) --------------------------------------------------------
@@ -1928,24 +1748,15 @@
   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 ( PID_TYPE(sTargetPid) == OBJECT_Actor)
@@ -1953,7 +1764,7 @@
     v6 = PID_ID(sTargetPid);
     v4 = pActors[v6].vPosition.x;
     v5 = pActors[v6].vPosition.y;
-    v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
+    v22 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z);
   }
   else
   {
@@ -1973,134 +1784,105 @@
   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)) )
+  if ( sub_407A1C(v4, v5, v22, v7) || sub_407A1C(v7.x, v7.y, v7.z, Vec3_int_(v4, v5, v22)))
   {
-    v10 = pDir;
-    v11 = 0;
-    if ( !pDir )
+    if ( pDir == nullptr )
+    {
+      v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0);
+    }
+    else
     {
-      v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0);
-      v10 = &v18;
-      memcpy(&v18, v12, sizeof(v18));
-      v11 = 0;
+      v10 = pDir;
     }
-    v13 = pSpriteFrameTable->pSpriteSFrames;
     v3->uYawAngle = LOWORD(v10->uYawAngle);
-    v14 = v13[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
-    v15 = v21;
+    v14 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
     v3->uCurrentActionLength = 8 * v14;
-    v3->uCurrentActionTime = v11;
+    v3->uCurrentActionTime = 0;
     v3->uAIState = AttackingRanged1;
-    Actor::PlaySound(v15, 0);
-    v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    Actor::PlaySound(uActorID, 0);
     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) )
+    if ( v3->pActorBuffs[7].uExpireTime > 0 )
     {
-      v16 *= 2;
-      pDira = v16;
+      pDira *= 2;
     }
     if ( pParty->bTurnBasedModeOn == 1 )
-      v3->pMonsterInfo.uRecoveryTime = v16;
+      v3->pMonsterInfo.uRecoveryTime = pDira;
     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;
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - (int)(flt_6BE3A8_debug_recmod2 * pDira * -2.133333333333333);
+    v3->vVelocity.z = 0;
+    v3->vVelocity.y = 0;
+    v3->vVelocity.x = 0;
     v3->UpdateAnimation();
   }
   else
-    Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir);
+    Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir);
 }
 
 //----- (004032B2) --------------------------------------------------------
 void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength )
-    {
-  unsigned int v4; // edi@1
+{
   Actor *v5; // esi@1
-  int v6; // ebx@1
-  int v7; // ST08_4@1
-  int v8; // eax@1
+  int x; // ebx@1
+  int absy; // 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
+  AIDirection doNotInitializeBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7
   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
-
-  //v14 never filled, maybe it is passed to function but optimized away as local variable
-
-  uActorID = uActor_id;
-  v4 = uActor_id;
+  int absx; // [sp+38h] [bp-4h]@1
+  
   v5 = &pActors[uActor_id];
   v16 = uTarget_id;
-  v6 = v5->vInitialPosition.x - v5->vPosition.x;
-  v7 = v5->vInitialPosition.x - v5->vPosition.x;
+  x = 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);
+  absx = abs(x);
+  absy = abs(y);
+  if ( absx <= absy )
+    absx = absy + (absx / 2 );
   else
-    v19 += v8 >> 1;
+    absx = absx + absy / 2;
   if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14);
+    Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
-  if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 )
+  if ( pActors[uActor_id].pMonsterInfo.uMovementType == 3 && absx < 128 )
   {
-    Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
+    Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
-  v15 = (rand() & 0xF) << 12;
-  v19 += (unsigned __int64)(v15 * (signed __int64)radius) >> 16;
-  v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y);
+  absx += ((rand() & 0xF) * radius) / 16;
+  v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(x, y);
   if ( rand() % 100 < 25 )
   {
-    Actor::StandAwhile(uActorID);
+    Actor::StandAwhile(uActor_id);
     return;
   }
   v10 = v9 + rand() % 256 - 128;
   if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) )
   {
-    Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
+    Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom);
     return;
   }
   v5->uYawAngle = v10;
   if ( v5->uMovementSpeed)
-    v5->uCurrentActionLength = 32 * v19 / v5->uMovementSpeed;
+    v5->uCurrentActionLength = 32 * absx / v5->uMovementSpeed;
   else
     v5->uCurrentActionLength = 0;
   v5->uCurrentActionTime = 0;
   v5->uAIState = Tethered;
   if ( rand() % 100 < 2 )
-    Actor::PlaySound(uActorID, 3u);
+    Actor::PlaySound(uActor_id, 3u);
   v5->UpdateAnimation();
 }
 
 //----- (004031C1) --------------------------------------------------------
-char __fastcall Actor::_4031C1_update_job(unsigned int uActorID, signed int a2, int a3)
+char __fastcall Actor::_4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3)   //attempted to implement something like jobs for actors, but apparently was never finished
 {
-  unsigned int v3; // edi@1
+  return 0;
+  /*unsigned int v3; // edi@1
   Actor *v4; // esi@1
   ActorJob *v5; // eax@1
   signed int v6; // edx@2
@@ -2152,55 +1934,44 @@
       }
     }
   }
-  return (char)v5;
+  return (char)v5;*/
 }
 
 //----- (004030AD) --------------------------------------------------------
-void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int arg0)
+void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState)
 {
-  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
+  AIDirection* v10; // [sp+28h] [bp-24h]@16
 
-  v3 = uActorID;
-  a2 = edx0;
   v4 = &pActors[uActorID];
-  v11 = uActorID;
-  if ( v4->uAIState == 7 )
+  if ( v4->uAIState == Fleeing )
     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 )
+  if ( v4->pActorBuffs[1].uExpireTime > 0 )
     v4->pActorBuffs[1].Reset();
-  if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 )
+  if ( v4->pActorBuffs[4].uExpireTime > 0 )
     v4->pActorBuffs[4].Reset();
-  if ( arg0
-    || (v4->uAIState != 8
-    && v4->uAIState != 3
-    && v4->uAIState != 12
-    && v4->uAIState != 13
-    && v4->uAIState != 18
-    && v4->uAIState != 2))
+  if ( stunRegardlessOfState
+    || (v4->uAIState != Stunned
+    && v4->uAIState != AttackingRanged1
+    && v4->uAIState != AttackingRanged2
+    && v4->uAIState != AttackingRanged3
+    && v4->uAIState != AttackingRanged4
+    && v4->uAIState != AttackingMelee))
   {
-    memcpy(&v10, Actor::GetDirectionInfo(PID(OBJECT_Actor,v3), a2, &a3, 0), sizeof(v10));
-    v6 = pSpriteFrameTable->pSpriteSFrames;
-    v4->uYawAngle = LOWORD(v10.uYawAngle);
-    v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
-    v8 = v11;
+    v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0), sizeof(v10);
+    v4->uYawAngle = LOWORD(v10->uYawAngle);
+    v7 = pSpriteFrameTable->pSpriteSFrames[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
     v4->uCurrentActionTime = 0;
     v4->uAIState = Stunned;
     v4->uCurrentActionLength = 8 * v7;
-    Actor::PlaySound(v8, 2u);
+    Actor::PlaySound(uActorID, 2u);
     v4->UpdateAnimation();
   }
 }
@@ -2211,8 +1982,7 @@
   unsigned int v7; // eax@3
   unsigned int v9; // eax@3
   
-  assert(uActorID < uNumActors);
-  auto actor = &pActors[uActorID];
+  Actor* actor = &pActors[uActorID];
   
   AIDirection a3; // [sp+Ch] [bp-5Ch]@2
   if (!a4)
@@ -2243,16 +2013,12 @@
 void 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[ANIM_Dying];
   pActor->uCurrentActionTime = 0;
   pActor->uAIState = Resurrected;
   pActor->uCurrentActionAnimation = ANIM_Dying;
-  pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength;
+  pActor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[pActor->pSpriteIDs[ANIM_Dying]].uAnimLength;
   pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP);
   Actor::PlaySound(uActorID, 1u);
   pActor->UpdateAnimation();
@@ -2325,81 +2091,51 @@
 //----- (00402CED) --------------------------------------------------------
 void 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 = pActors[uActorID].pSoundSampleIDs[uSoundID];
   if ( v3 )
   {
-    if ( (signed __int64)pActors[uActorID].pActorBuffs[3].uExpireTime <= 0 )
+    if ( pActors[uActorID].pActorBuffs[3].uExpireTime <= 0 )
     {
-      v12 = 0;
-      v8 = -1;
+      pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
     }
     else
     {
-      v4 = pActors[uActorID].pActorBuffs[3].uPower - 2;
-      if ( v4 )
+      switch(pActors[uActorID].pActorBuffs[3].uPower)
       {
-        v5 = v4 - 1;
-        if ( v5 )
-        {
-          if ( v5 == 1 )
-            v6 = 55125;
-          else
-            v6 = uActorID;
-        }
-        else
-        {
-          v6 = 44100;
-        }
+        case 1: 
+          pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075);
+          break;
+        case 2: 
+          pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075);
+          break;
+        case 3: 
+        case 4: 
+          pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075);
+          break;
+        default:
+          pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0);
+          break;
       }
-      else
-      {
-        v6 = 33075;
-      }
-      v12 = v6;
-      v8 = 0;
     }
-    pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, 0, 0, 0, v12);
   }
 }
 
 //----- (00402AD7) --------------------------------------------------------
 void Actor::AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
 {
-  unsigned int v5; // edi@1
   int v6; // eax@1
   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 = PID(OBJECT_Actor,uActorID);
-  v9 = v7->pMonsterInfo.uFlying == 0;
-  if ( !v9 && !pParty->bFlying )
+  if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying )                //TODO: Does v6 have a point?
   {
     if ( v7->pMonsterInfo.uMissleAttack1Type )
       v6 = v7->uActorRadius + 512;
@@ -2407,38 +2143,41 @@
       v6 = pParty->uPartyHeight;
   }
 
-  v10 = pDir;
-  if ( !pDir )
+  if ( pDir == nullptr )
   {
-    memcpy(&v16, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v16));
-    v10 = &v16;
+    v10 = Actor::GetDirectionInfo(v8, a2, &a3, v6);
+  }
+  else
+  {
+    v10 = pDir;
   }
   if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    Actor::AI_StandOrBored(v5, 4, uActionLength, v10);
+    Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10);
     return;
   }
-  if ( (double)(signed int)v10->uDistance < 307.2 )
+  if ( v10->uDistance < 307.2 )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    Actor::AI_Stand(v5, v18, uActionLength, v10);
+    Actor::AI_Stand(uActorID, a2, uActionLength, v10);
     return;
   }
-  if ( !v7->uMovementSpeed )
+  if ( v7->uMovementSpeed == 0 )
   {
-    Actor::AI_Stand(v5, v18, uActionLength, v10);
+    Actor::AI_Stand(uActorID, a2, uActionLength, v10);
     return;
   }
-  v18 = 16;
   if ( arg0 % 2 )
     v18 = -16;
+  else
+    v18 = 16;
 
   v7->uYawAngle = stru_5C6E00->Atan2(
-                    pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x,
-                    pParty->vPosition.y + fixpoint_mul(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y);
+                    pParty->vPosition.x + (int)fixpoint_mul(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x,
+                    pParty->vPosition.y + (int)fixpoint_mul(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y);
   if ( uActionLength )
     v7->uCurrentActionLength = uActionLength;
   else
@@ -2451,49 +2190,33 @@
 //----- (00402968) --------------------------------------------------------
 void Actor::AI_Flee(unsigned int uActorID, signed int sTargetPid, 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
+  AIDirection* v10 = nullptr; // [sp+8h] [bp-7Ch]@4
+  AIDirection* a3 = nullptr; // [sp+24h] [bp-60h]@3
+  AIDirection* v13; // [sp+5Ch] [bp-28h]@4
 
-  v4 = uActorID;
-  //a2 = edx0;
-  v15 = uActorID;
   v5 = &pActors[uActorID];
-  //result = pActors[uActorID].CanAct();
-  if ( pActors[uActorID].CanAct() )
+  if ( v5->CanAct() )
   {
-    v7 = PID(OBJECT_Actor,v4);
-    a1 = PID(OBJECT_Actor,v4);
+    v7 = PID(OBJECT_Actor,uActorID);
     if ( !a4 )
     {
-      a4 = &v12;
-      memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
-      v7 = a1;
+      a4 = Actor::GetDirectionInfo(v7, sTargetPid, a3, v5->pMonsterInfo.uFlying);
     }
-    memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3));
-    memcpy(&v13, &a3, sizeof(v13));
+    v13 = Actor::GetDirectionInfo(v7, 4u, v10, 0);
     if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)
-      || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
+      || PID_TYPE(sTargetPid) == OBJECT_Actor && v13->uDistance < 307.2 )
     {
       if ( !uActionLength )
         uActionLength = 256;
-      Actor::AI_StandOrBored(v15, 4, uActionLength, &v13);
+      Actor::AI_StandOrBored(uActorID, 4, uActionLength, v13);
     }
     else
     {
-      v8 = v5->uMovementSpeed;
-      if ( v8 )
-        v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v8;
+      if ( v5->uMovementSpeed )
+        v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v5->uMovementSpeed;
       else
         v5->uCurrentActionLength = 0;
       if ( v5->uCurrentActionLength > 256 )
@@ -2512,30 +2235,19 @@
 //----- (0040281C) --------------------------------------------------------
 void Actor::AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5)
 {
-  unsigned int v5; // edi@1
   int v6; // eax@1
   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 = PID(OBJECT_Actor,uActorID);
-  v9 = v7->pMonsterInfo.uFlying == 0;
-  v20 = v5;
-  if ( !v9 && !pParty->bFlying )
+  if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying )
   {
     if ( v7->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor )
       v6 = v7->uActorRadius + 512;
@@ -2545,29 +2257,20 @@
   v10 = pDir;
   if ( !pDir )
   {
-    memcpy(&v18, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v18));
-    memcpy(0, &v18, 0x1Cu);
-    v10 = 0;
-    v5 = v20;
+    v10 = Actor::GetDirectionInfo(v8, a2, &a3, v6);
   }
   if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    v16 = v10;
-    v15 = uActionLength;
-    v11 = 4;
-    Actor::AI_StandOrBored(v5, v11, v15, v16);
+    Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10);
     return;
   }
   if ( (signed int)v10->uDistance < a5 )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    v11 = v19;
-    v16 = v10;
-    v15 = uActionLength;
-    Actor::AI_StandOrBored(v5, v11, v15, v16);
+    Actor::AI_StandOrBored(uActorID, a2, uActionLength, v10);
     return;
   }
   if ( uActionLength )
@@ -2595,31 +2298,19 @@
 //----- (00402686) --------------------------------------------------------
 void Actor::AI_Pursue3(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
+  AIDirection* v20; // [sp+28h] [bp-24h]@8
 
   v5 = 0;
   v6 = &pActors[uActorID];
-  v21 = a2;
   v7 = PID(OBJECT_Actor,uActorID);
-  v8 = v6->pMonsterInfo.uFlying == 0;
-  if ( !v8 && !pParty->bFlying )
+  if ( v6->pMonsterInfo.uFlying != 0 && !pParty->bFlying )
   {
     if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor )
       v5 = v6->uActorRadius + 512;
@@ -2628,7 +2319,7 @@
   }
   if ( !a4 )
   {
-    memcpy(&v20, Actor::GetDirectionInfo(v7, a2, &a3, v5), sizeof(v20));
+    v20 = Actor::GetDirectionInfo(v7, a2, &a3, v5);
   }
   if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
   {
@@ -2636,11 +2327,11 @@
       uActionLength = 256;
     return Actor::AI_StandOrBored(uActorID, 4, uActionLength, a4);
   }
-  if ( (double)(signed int)a4->uDistance < 307.2 )
+  if ( a4->uDistance < 307.2 )
   {
     if ( !uActionLength )
       uActionLength = 256;
-    return Actor::AI_StandOrBored(uActorID, v21, uActionLength, a4);
+    return Actor::AI_StandOrBored(uActorID, a2, uActionLength, a4);
   }
   if ( uActionLength )
   {
@@ -2656,13 +2347,12 @@
     if ( v6->uCurrentActionLength > 128 )
       v6->uCurrentActionLength = 128;
   }
-  v13 = rand() % 2;
   v14 = LOWORD(a4->uYawAngle);
-  if ( v13 )
-    v15 = v14 + 256;
+  if ( rand() % 2 )
+    v14 += 256;
   else
-    v15 = v14 - 256;
-  v6->uYawAngle = v15;
+    v14 -= 256;
+  v6->uYawAngle = v14;
   v16 = LOWORD(a4->uPitchAngle);
   v6->uCurrentActionTime = 0;
   v6->uPitchAngle = v16;
@@ -2672,137 +2362,99 @@
   v6->UpdateAnimation();
 }
 
-//----- (00SelectTarget) --------------------------------------------------------
+//----- (00401221) --------------------------------------------------------
 void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party)
 {
-  //Actor *v3; // esi@1
-  //unsigned int v4; // ebx@1
   int v5; // ecx@1
-  //unsigned int v6; // eax@1
-  //Actor *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
+  uint v11; // ebx@16
+  uint v12; // eax@16
   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
+  uint v15; // edi@43
+  uint v16; // ebx@45
+  uint v17; // eax@45
+  signed int closestId; // [sp+14h] [bp-1Ch]@1
+  uint v23; // [sp+1Ch] [bp-14h]@16
+  unsigned int lowestRadius; // [sp+24h] [bp-Ch]@1
+  uint v27; // [sp+2Ch] [bp-4h]@16
+  uint v28; // [sp+2Ch] [bp-4h]@45
 
-  v25 = -1;
-  //v22 = uActorID;
-  //v3 = &pActors[uActorID];
-  //v4 = 0;
+  lowestRadius = UINT_MAX;
   v5 = 0;
-  //v6 = v3->uLastCharacterIDToHit;
   *a2 = 0;
-  //v20 = a2;
-  v21 = 0;
-  //v24 = v3->uLastCharacterIDToHit;
-  //v26 = 0;
+  closestId = 0;
   assert(uActorID < uNumActors);
-  auto _this = &pActors[uActorID];
+  Actor* thisActor = &pActors[uActorID];
 
   for (uint i = 0; i < uNumActors; ++i)
   {
-    auto actor = &pActors[i];
-	  //v7 = pActors;
-	  //do
-	  //{
-		//v8 = v7->uAIState;
+    Actor* actor = &pActors[i];
     if (actor->uAIState == Dead || actor->uAIState == Dying ||
         actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i )
       continue;
 
-		if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = PID(OBJECT_Actor,v5), _this->uLastCharacterIDToHit != v9) )
+		if (thisActor->uLastCharacterIDToHit == 0 || PID(OBJECT_Actor,v5) != thisActor->uLastCharacterIDToHit )
 		{
-		  v10 = _this->GetActorsRelation(actor);
+		  v10 = thisActor->GetActorsRelation(actor);
 		  if ( v10 == 0 )
 			continue;
 		}
-		else if (_this->IsNotAlive())
+		else if (thisActor->IsNotAlive())
 		{
-		  _this->uLastCharacterIDToHit = 0;
-		  v10 = _this->GetActorsRelation(actor);
+		  thisActor->uLastCharacterIDToHit = 0;
+		  v10 = thisActor->GetActorsRelation(actor);
 		  if ( v10 == 0 )
 			continue;
 		}
 		else
 		{
-			//v18 = actor->uGroup;
-			if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup )
+			if ( (actor->uGroup != 0 || thisActor->uGroup != 0) && actor->uGroup == thisActor->uGroup )
 				continue;
 			v10 = 4;
 		}
-		if ( _this->pMonsterInfo.uHostilityType )
-		  v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType;
-		v11 = dword_4DF380[v10];
-		v23 = abs(_this->vPosition.x - actor->vPosition.x);
-		v27 = abs(_this->vPosition.y - actor->vPosition.y);
-		v12 = abs(_this->vPosition.z - actor->vPosition.z);
-		v19 = v12;
+		if ( thisActor->pMonsterInfo.uHostilityType )
+		  v10 = pMonsterStats->pInfos[thisActor->pMonsterInfo.uID].uHostilityType;
+		v11 = dword_4DF380_hostilityRanges[v10];
+		v23 = abs(thisActor->vPosition.x - actor->vPosition.x);
+		v27 = abs(thisActor->vPosition.y - actor->vPosition.y);
+		v12 = abs(thisActor->vPosition.z - actor->vPosition.z);
 		if ( v23 <= v11
 		  && v27 <= v11
 		  && v12 <= v11
 		  && sub_4070EF_prolly_detect_player(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID))
-		  && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
+		  && v23 * v23 + v27 * v27 + v12 * v12 < lowestRadius )
 		{
-		  v25 = v23 * v23 + v27 * v27 + v19 * v19;
-		  v21 = i;
+		  lowestRadius = v23 * v23 + v27 * v27 + v12 * v12;
+		  closestId = i;
 		}
-		//v4 = 0;
-		//++v7;
-		//v5 = v26++ + 1;
-	  //}
-	  //while ( v26 < (signed int)uNumActors );
+  }
 
+  if ( lowestRadius != UINT_MAX )
+  {
+    *a2 = PID(OBJECT_Actor, closestId);
   }
-  	  if ( v25 != -1 )
-	  {
-		//v13 = 8 * v21;
-		//LOBYTE(v13) = PID(OBJECT_Actor,v21);
-		*a2 = PID(OBJECT_Actor, v21);
-	  }
-
-  if (pParty->Invisible())
-    can_target_party = false;
-
-  if (can_target_party)
+  
+  if (can_target_party && !pParty->Invisible())
   {
-    v14 = _this->GetActorsRelation(0);
-    if ( BYTE2(_this->uAttributes) & 8
-      && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0
-      && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0)
-      && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0
-      && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0)
-      && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0
-      && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) )
+    if ( thisActor->uAttributes & 0x80000
+      && thisActor->pActorBuffs[12].uExpireTime <= 0
+      && thisActor->pActorBuffs[1].uExpireTime <= 0
+      && thisActor->pActorBuffs[2].uExpireTime <= 0 )
       v14 = 4;
+    else
+      v14 = thisActor->GetActorsRelation(0);
     if ( v14 != 0 )
     {
-      v15 = dword_4DF380[4];
-      if ( !_this->pMonsterInfo.uHostilityType )
-        v15 = dword_4DF380[v14];
-      v16 = abs(_this->vPosition.x - pParty->vPosition.x);
-      v28 = abs(_this->vPosition.y - pParty->vPosition.y);
-      v17 = abs(_this->vPosition.z - pParty->vPosition.z);
-      if ( v16 <= v15 && v28 <= v15 && v17 <= v15 )
+      if ( !thisActor->pMonsterInfo.uHostilityType )
+        v15 = dword_4DF380_hostilityRanges[v14];
+      else
+        v15 = dword_4DF380_hostilityRanges[4];
+      v16 = abs(thisActor->vPosition.x - pParty->vPosition.x);
+      v28 = abs(thisActor->vPosition.y - pParty->vPosition.y);
+      v17 = abs(thisActor->vPosition.z - pParty->vPosition.z);
+      if ( v16 <= v15 && v28 <= v15 && v17 <= v15 && (v16 * v16 + v28 * v28 + v17 * v17 < lowestRadius))
       {
-        if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 )
-          *a2 = OBJECT_Player;
+        *a2 = OBJECT_Player;
       }
     }
   }
@@ -2811,133 +2463,77 @@
 // 4DF390: using guessed type int dword_4DF390;
 
 //----- (0040104C) --------------------------------------------------------
-signed int Actor::GetActorsRelation(Actor *a2)
+signed int Actor::GetActorsRelation(Actor *otherActPtr)
 {
-  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
+  unsigned int thisGroup; // ebp@19
+  int otherGroup; // eax@22
+  unsigned int thisAlly; // edx@25
+  unsigned int otherAlly; // edx@33
 
-  auto a1 = this;
-  v2 = a2;
-  if ( a1 )
+  if ( otherActPtr)
   {
-    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;
+    v5 = otherActPtr->uGroup;
+    v6 = this->uGroup;
+    if ( v5 != 0 && v6 != 0 && v5 == v6 )
+      return 0;
   }
-  else
+
+  if (this->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0)
+    return 4;
+  thisAlly = this->uAlly;
+  if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || thisAlly == 9999)
+    thisGroup = 0;
+  else if ( thisAlly > 0 )
   {
-    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;
+    thisGroup = thisAlly;
   }
   else
   {
-    v4 = 0;
+    thisGroup = (this->pMonsterInfo.uID - 1) / 3 + 1;
   }
-  if ( a2 )
+
+  if ( otherActPtr )
   {
-    if ( a1 )
+    if (otherActPtr->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0)
+      return 4;
+    otherAlly = otherActPtr->uAlly;
+    if ( otherActPtr->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || otherAlly == 9999)
+      otherGroup = 0;
+    else  if ( otherAlly > 0 )
     {
-      v5 = a2->uGroup;
-      if ( v5 )
-      {
-        v6 = a1->uGroup;
-        if ( v6 )
-        {
-          if ( v5 == v6 )
-            return 0;
-        }
-      }
+      otherGroup = otherAlly;
+    }
+    else
+    {
+      otherGroup = (otherActPtr->pMonsterInfo.uID - 1) / 3 + 1;
     }
   }
-  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 )
-      {
-        v7 = a1->uAlly;
-      }
-    }
-	if(v9==9999)
-      v7 = 0;
-    if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 )
-      v7 = 0;
-  }
-  if ( v2 )
-  {
-	  v10 = v2->uAlly;
-	  if ( (signed int)v10 > 0 )
-	  {
-		if ( v10 != 9999 )
-		{
-		  v8 = v2->uAlly;
-		}
-	  }
-	  if(v10==9999)
-	    v8 = 0;
-	  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
-		v8 = 0;
+    otherGroup = 0;
   }
-  if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8
-    || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 )
+
+  if ( this->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !otherGroup
+    || otherActPtr && otherActPtr->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !thisGroup )
     return 0;
-  if ( a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && a1->uAttributes & 0x80000 && !v8 )
+  if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime <= 0 && this->uAttributes & 0x80000 && !otherGroup )
     return 4;
-  if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 )
+  if (thisGroup >= 89 || otherGroup >= 89)
+    return 0;
+
+  if ( thisGroup == 0  )
   {
-    if ( v7 )
-	{
-		if ( (signed int)v7 < 89 )
-		{
-		  if ( v8 < 89 )
-			return pFactionTable->relations[v7][v8];
-		  return 0;
-		}
-		return 0;
-	}
-    return 4;
+    if ( (!otherActPtr || this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 && !(otherActPtr->uAttributes & 0x80000)) && !pFactionTable->relations[otherGroup][0])
+      return pFactionTable->relations[0][otherGroup];
+    else
+      return 4;
   }
-  if ( !v7 )
+  else
   {
-    if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000))
-      && !pFactionTable->relations[v8][0]) 
-    {
-      if ( v8 < 89 )
-        return pFactionTable->relations[v7][v8];
-      return 0;
-    }
-    return 4;
+    return pFactionTable->relations[thisGroup][otherGroup];
   }
-  if ( (signed int)v7 < 89 )
-  {
-    if ( v8 < 89 )
-      return pFactionTable->relations[v7][v8];
-    return 0;
-  }
-  return 0;
 }
 
 //----- (0045976D) --------------------------------------------------------
@@ -3087,203 +2683,162 @@
 }
 
 //----- (0044FD29) --------------------------------------------------------
-int Actor::_44FD29(int a2)
+void Actor::SummonMinion( int summonerId )
 {
-  Actor *v2; // edi@1
-  unsigned __int8 v3; // al@1
-  int v4; // esi@1
+  unsigned __int8 extraSummonLevel; // al@1
+  int summonMonsterBaseType; // 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
+  unsigned int v19; // qax@10
   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
+  unsigned int monsterId; // [sp+10h] [bp-18h]@8
   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
+  int actorSector; // [sp+1Ch] [bp-Ch]@8
+
+
+  actorSector = 0;
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z);
 
-  v2 = this;
-  v24 = a2;
-  v30 = this;
-  v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
-  v4 = this->pMonsterInfo.field_3C_some_special_attack;
-  if ( v3 )
+  v19 = this->uAlly;
+  if ( !v19 )
+  {
+    monsterId = this->pMonsterInfo.uID - 1;
+    v19 = (uint)(monsterId * 0.33333334);
+  }
+  v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64;
+  v13 = rand() % 2048;
+  v15 = ((stru_5C6E00->Cos(v13) * (signed __int64)v27) >> 16) + this->vPosition.x;
+  v17 = ((stru_5C6E00->Sin(v13) * (signed __int64)v27) >> 16) + this->vPosition.y;
+
+  if (uCurrentlyLoadedLevelType != LEVEL_Outdoor)
   {
-    if ( v3 >= 1u && v3 <= 3u )
-      v4 = v4 + v3 - 1;
+    result = pIndoor->GetSector(v15, v17, this->vPosition.z);
+    if (result != actorSector)
+      return;
+    result = BLV_GetFloorLevel(v15, v17, v27, result, &monsterId);
+    if (result != -30000)
+      return;
+    if (abs(result - v27) > 1024)
+      return;
+  }
+
+  extraSummonLevel = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
+  summonMonsterBaseType = this->pMonsterInfo.field_3C_some_special_attack;
+  if ( extraSummonLevel )
+  {
+    if ( extraSummonLevel >= 1u && extraSummonLevel <= 3u )
+      summonMonsterBaseType = summonMonsterBaseType + extraSummonLevel - 1;
   }
   else
   {
     v5 = rand() % 100;
-    if ( v5 >= 60 )
+    if ( v5 >= 90 )
+      summonMonsterBaseType += 2;
+    else if ( v5 >= 60 )
     {
-      ++v4;
-      if ( v5 >= 90 )
-        ++v4;
+      summonMonsterBaseType += 1;
     }
   }
-  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;
+  v7 = summonMonsterBaseType - 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;
+  memcpy(&v8->pMonsterInfo, v9, sizeof(v8->pMonsterInfo));
+  v8->word_000086_some_monster_id = summonMonsterBaseType;
   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->Cos(v12 % 2048);
-  v26 = v14;
-  v15 = ((unsigned __int64)(v14 * (signed __int64)v27) >> 16) + v30->vPosition.x;
-  v16 = stru_5C6E00->Sin(v13);
-  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->uMovementSpeed = v10->uMovementSpeed;
+  v8->vInitialPosition.z = this->vPosition.z;
+  v8->vPosition.z = this->vPosition.z;
   v8->vInitialPosition.x = v15;
   v8->vPosition.x = v15;
   v8->vInitialPosition.y = v17;
   v8->vPosition.y = v17;
   v8->uTetherDistance = 256;
-  v8->uSectorID = v16;
+  v8->uSectorID = actorSector;
   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->uGroup = this->uGroup;
   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 = BLV_GetFloorLevel(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) = PID(OBJECT_Actor,v24);
-    v8->uSummonerID = result;
-  }
-  return result;
+
+  ++uNumActors;
+  ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+  if ( this->uAttributes & 0x80000 )
+    v8->uAttributes |= 0x80000u;
+  v8->uSummonerID = PID(OBJECT_Actor,summonerId);
+
 }
 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
 //----- (0046DF1A) --------------------------------------------------------
-signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2)
+bool Actor::_46DF1A_collide_against_actor( int a1, int a2 )
 {
   Actor *v2; // edi@1
   unsigned __int16 v3; // ax@1
   int v4; // esi@6
-  int v5; // ecx@8
-  int v6; // eax@10
-  int v7; // edx@12
   int v8; // ecx@14
   int v9; // eax@14
   int v10; // ebx@14
   int v11; // esi@14
   int v12; // ebx@15
   int v13; // ebx@17
-  unsigned int v14; // eax@20
-  signed int result; // eax@21
-  int v16; // [sp+Ch] [bp-10h]@1
-  int v17; // [sp+10h] [bp-Ch]@14
-  int v18; // [sp+14h] [bp-8h]@14
-  int v19; // [sp+18h] [bp-4h]@14
 
-  v16 = a1;
   v2 = &pActors[a1];
   v3 = v2->uAIState;
-  if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 )
-    goto LABEL_25;
+  if ( v3 == Removed || v3 == Dying || v3 == Disabled || v3 == Dead || v3 == Summoned )
+    return 0;
   v4 = v2->uActorRadius;
   if ( a2 )
     v4 = a2;
-  v5 = v2->vPosition.x;
-  if ( stru_721530.sMaxX > v5 + v4
-    || stru_721530.sMinX < v5 - v4
-    || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4)
-    || stru_721530.sMinY < v6 - v4
-    || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight)
-    || stru_721530.sMinZ < v7
-    || (v8 = v5 - stru_721530.normal.x,
-        v9 = v6 - stru_721530.normal.y,
-        v10 = stru_721530.prolly_normal_d + v4,
-        v17 = stru_721530.prolly_normal_d + v4,
-        v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16,
-        v18 = v8,
-        v19 = v9,
-        abs((v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16) > v10)
-    || (v12 = (v18 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16, v12 <= 0)
-    || (signed int)(((unsigned __int64)(stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z )
+
+  if (stru_721530.sMaxX > v2->vPosition.x + v4 || 
+      stru_721530.sMinX < v2->vPosition.x - v4 || 
+      stru_721530.sMaxY > v2->vPosition.y + v4 || 
+      stru_721530.sMinY < v2->vPosition.y - v4 ||
+      stru_721530.sMaxZ > v2->vPosition.z + v2->uActorHeight ||
+      stru_721530.sMinZ < v2->vPosition.z)
+  {
+    return false;
+  }
+  v8 = v2->vPosition.x - stru_721530.normal.x;
+  v9 = v2->vPosition.y - stru_721530.normal.y;
+  v10 = stru_721530.prolly_normal_d + v4;
+  v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16;
+  v12 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16;
+  if ( abs(v11) > v10 || v12 <= 0)
   {
-LABEL_25:
-    result = 0;
+    return false;
   }
-  else
+  if (((stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z < v2->vPosition.z)
   {
-    v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11);
-    if ( v13 < 0 )
-      v13 = 0;
-    if ( v13 < stru_721530.field_7C )
-    {
-      stru_721530.field_7C = v13;
-      v14 = 8 * v16;
-      LOBYTE(v14) = PID(OBJECT_Actor,v16);
-      stru_721530.uFaceID = v14;
-    }
-    result = 1;
+    return false;
   }
-  return result;
+
+  v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11);
+  if ( v13 < 0 )
+    v13 = 0;
+  if ( v13 < stru_721530.field_7C )
+  {
+    stru_721530.field_7C = v13;
+    stru_721530.uFaceID = PID(OBJECT_Actor,a1);
+  }
+  return true;
 }
 //----- (00401A91) --------------------------------------------------------
 void  UpdateActorAI()
@@ -4199,7 +3754,7 @@
 
     BYTE2(actor->uAttributes) &= 0x7Fu;
     if (BYTE2(actor->uAttributes) & 0x40)
-        Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1);
+        Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1);
   }
 }
 //----- (00439474) --------------------------------------------------------
--- a/Actor.h	Mon Oct 21 10:42:27 2013 +0200
+++ b/Actor.h	Mon Oct 21 10:42:35 2013 +0200
@@ -45,20 +45,21 @@
   ACTOR_BUFF_AFRAID = 4,
   ACTOR_BUFF_STONED = 5,
   ACTOR_BUFF_PARALYZED = 6,
-
-  ACTOR_BUFF_BERSERK = 8,
-
-  ACTOR_BUFF_FATE = 10,
-  ACTOR_BUFF_ENSLAVED = 11,
-  ACTOR_BUFF_DAY_OF_PROTECTION = 12,
-  ACTOR_BUFF_HOUR_OF_POWER = 13,
-  ACTOR_BUFF_SHIELD = 14,
-  ACTOR_BUFF_STONESKIN = 15,
-  ACTOR_BUFF_BLESS = 16,
-  ACTOR_BUFF_HEROISM = 17,
-  ACTOR_BUFF_HASTE = 18,
-  ACTOR_BUFF_PAIN_REFLECTION = 19,
-  ACTOR_BUFF_PAIN_HAMMERHANDS = 20,
+  ACTOR_BUFF_SLOWED = 7,
+  ACTOR_BUFF_SOMETHING_THAT_HALVES_AC = 8,
+  ACTOR_BUFF_BERSERK = 9,
+  ACTOR_BUFF_MASS_DISTORTION = 10,
+  ACTOR_BUFF_FATE = 11,
+  ACTOR_BUFF_ENSLAVED = 12,
+  ACTOR_BUFF_DAY_OF_PROTECTION = 13,
+  ACTOR_BUFF_HOUR_OF_POWER = 14,
+  ACTOR_BUFF_SHIELD = 15,
+  ACTOR_BUFF_STONESKIN = 16,
+  ACTOR_BUFF_BLESS = 17,
+  ACTOR_BUFF_HEROISM = 18,
+  ACTOR_BUFF_HASTE = 19,
+  ACTOR_BUFF_PAIN_REFLECTION = 20,
+  ACTOR_BUFF_PAIN_HAMMERHANDS = 21,
 };
 
 
@@ -194,7 +195,7 @@
   Reset();
 }
 
-  int _44FD29(int a2);
+  void SummonMinion(int summonerId);
   void Reset();
   void Remove();
   void PrepareSprites(char load_sounds_if_bit1_set);
@@ -216,7 +217,7 @@
   static void Resurrect(unsigned int uActorID);
   static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4);
   static void AI_Stun(unsigned int uActorID, signed int edx0, int arg0);
-  static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3);
+  static char __fastcall _4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3);
   static void AI_RandomMove(unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength);
   static void AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
   static void AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir);
@@ -236,14 +237,15 @@
 
   static void AggroSurroundingPeasants(unsigned int uActorID, int a2);
   static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2);
-  static bool StealFrom(unsigned int uActorID);
+  static void StealFrom(unsigned int uActorID);
   static void GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive);
   static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle);
   static void ApplyFineForKillingPeasant(unsigned int uActorID);
   static void DrawHealthBar(Actor *actor, struct GUIWindow *window);
-  static int _43B3E0_CalcDamage(Actor *a1, signed int a2);
+  int _43B3E0_CalcDamage(signed int dmgSource);
   static void AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3);
 
+  static bool _46DF1A_collide_against_actor(int a1, int a2);
 
   char pActorName[32];
   signed __int16 sNPC_ID;
--- a/Indoor.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/Indoor.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -3424,7 +3424,7 @@
                 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y);
                 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x);
                 if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius
-                  && _46DF1A_collide_against_actor(v54, 40) )
+                  && Actor::_46DF1A_collide_against_actor(v54, 40) )
                   ++v58;
                 v22 = 0;
               }
--- a/Items.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/Items.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -2395,7 +2395,6 @@
   }
   std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second;
   return (currList->find(attrToGet) != currList->end());
-  return false;
 }
 
 ITEM_EQUIP_TYPE ItemGen::GetItemEquipType()
--- a/Party.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/Party.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -99,10 +99,10 @@
     uNumDeaths = 0;
     uNumPrisonTerms = 0;
     uNumBountiesCollected = 0;
-    memset(monster_for_hunting_killed.data(), 5, sizeof(__int16));
-    memset(monster_id_for_hunting.data(), 5, sizeof(__int16));
-    memset(_quest_bits, 64, sizeof(__int8));
-    memset(pArcomageWins.data(), 16, sizeof(__int8));
+    monster_for_hunting_killed.fill(0);
+    monster_id_for_hunting.fill(0);
+    memset(_quest_bits, 0, sizeof(_quest_bits));
+    pArcomageWins.fill(0);
     uNumArenaPageWins = 0;
     uNumArenaSquireWins = 0;
     uNumArenaKnightWins = 0;
@@ -174,7 +174,7 @@
   }
 
   if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] )
-    memset(playerAlreadyPicked.data(), 0, 4u);
+    playerAlreadyPicked.fill(false);
   for (int i = 0; i < 4; i++)
   {
     v6 = &this->pPlayers[i];
@@ -293,7 +293,7 @@
   pHireling1Name[0] = 0;
   pHireling2Name[0] = 0;
   this->hirelingScrollPosition = 0;
-  memset(pHirelings.data(), 0, 2 * sizeof(NPCData));
+  memset(&pHirelings, 0, sizeof(pHirelings));
 
   strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan
   this->pPlayers[0].uPrevFace = 17;
@@ -552,9 +552,9 @@
 
   pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;  // default character ui - stats
   uFlags = 0;
-  memset(_autonote_bits, 0, 26);
-  memset(_quest_bits, 0, 64);
-  memset(pIsArtifactFound.data(), 0, 29);
+  memset(_autonote_bits, 0, sizeof(_autonote_bits));
+  memset(_quest_bits, 0, sizeof(_autonote_bits));
+  pIsArtifactFound.fill(0);
   _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1);
   _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE, 1);
   _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LONGBOW_ACTIVE, 1);
@@ -562,7 +562,7 @@
   _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LUTE_ACTIVE, 1);
   _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_HAT_ACTIVE, 1);
 
-  memset(PartyTimes._shop_ban_times.data(),0,53*sizeof(__int64));
+  PartyTimes._shop_ban_times.fill(0);
 
   memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu);
   memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u);
@@ -1120,10 +1120,9 @@
     v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
     v21 = areWeLoadingTexture;
     v8 = 0;
-    int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0;
     for (int i = 0; i < 4; i++)
     {
-      v9 = &pPlayers[(startId + i) % 4];  //start with current active player, then cycle right if item won't fit
+      v9 = &pPlayers[(uActiveCharacter + i) % 4];  //start with current active player, then cycle right if item won't fit
       v10 = v9->AddItem(-1, pItem->uItemID);
       if ( v10 )
       {
--- a/Player.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/Player.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -750,7 +750,7 @@
     case Condition_Zombie:
       if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead())
         return;
-      memset(&pConditions[0], 0, sizeof(pConditions));
+      pConditions.fill(0);
       sHealth = GetMaxHealth();
       sMana = 0;
       player_sex = 0;
@@ -1240,7 +1240,7 @@
 Player::Player()
 {  
   memset(&pEquipment, 0, sizeof(PlayerEquipment));
-  memset(pInventoryMatrix.data(), 0, 126 * sizeof(int));
+  pInventoryMatrix.fill(0);
   for (uint i = 0; i < 126; ++i)
     pInventoryItemList[i].Reset();
   for (uint i = 0; i < 12; ++i)
@@ -1260,7 +1260,7 @@
   pName[0] = 0;
   uCurrentFace = 0;
   uVoiceID = 0;
-  memset(pConditions.data(), 0, 20 * sizeof(__int64));
+  pConditions.fill(0);
 
   field_BB = 0;
 
@@ -1327,8 +1327,8 @@
   uNumArmageddonCasts = 0;
   uNumFireSpikeCasts = 0;
 
-  memset(field_1988, 0, 49 * sizeof(int));
-  memset(playerEventBits, 0, 64 * sizeof(char));
+  memset(field_1988, 0, sizeof(field_1988));
+  memset(playerEventBits, 0, sizeof(playerEventBits));
 
   field_E0 = 0;
   field_E4 = 0;
@@ -3910,9 +3910,9 @@
   uLevel = 1;
   uExperience = 251 + rand() % 100;
   uBirthYear = 1147 - rand() % 6;
-  memset(pActiveSkills.data(), 0, sizeof(pActiveSkills));
-  memset(_achieved_awards_bits, 0, 64);
-  memset(&spellbook, 0, sizeof(PlayerSpells));
+  pActiveSkills.fill(0);
+  memset(_achieved_awards_bits, 0, sizeof(_achieved_awards_bits));
+  memset(&spellbook, 0, sizeof(spellbook));
 
   for (uint i = 0; i < 37; ++i)
   {
@@ -4491,7 +4491,7 @@
               v30 = playerAffected->pConditions[Condition_Dead];
               v32 = playerAffected->pConditions[Condition_Pertified];
               v34 = playerAffected->pConditions[Condition_Eradicated];    
-              memset(&playerAffected->pConditions,0,sizeof(pConditions));
+              pConditions.fill(0);
               playerAffected->pConditions[Condition_Dead] = v30;
               playerAffected->pConditions[Condition_Pertified] = v32;
               playerAffected->pConditions[Condition_Eradicated] = v34;
@@ -5737,7 +5737,7 @@
       PlayAwardSound_Anim();
       return;
     case VAR_MajorCondition:
-      memset(this, 0, 0xA0u);
+      pConditions.fill(0);
       PlayAwardSound_Anim();
       return;
     case VAR_AutoNotes:
@@ -6333,7 +6333,7 @@
       PlayAwardSound_Anim97();
       return;
     case VAR_MajorCondition :
-      memset(this, 0, 0xA0u);
+      pConditions.fill(0);
       PlayAwardSound_Anim97();
       return;
     case VAR_AutoNotes:
@@ -7026,7 +7026,7 @@
         }
       }
       if ( pParty->pHirelings[0].uProfession == pValue )
-        memset(pParty->pHirelings.data(), 0, sizeof(NPCData));
+        memset(&pParty->pHirelings[0], 0, sizeof(NPCData));
       if ( pParty->pHirelings[1].uProfession == pValue )
         memset(&pParty->pHirelings[1], 0, sizeof(NPCData));
       pParty->hirelingScrollPosition = 0;
@@ -7246,7 +7246,7 @@
 
 
 //----- (00439FCB) --------------------------------------------------------
-void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4)
+void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int dmgSource, Vec3_int_ *pPos, unsigned int a4)
 {
   Player *playerPtr; // ebx@3
   Actor *actorPtr; // esi@3
@@ -7297,7 +7297,7 @@
       }
     }
     pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0);
-    int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element);
+    int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource);
     if ( actorPtr->pActorBuffs[3].uExpireTime > 0 )
     {
       __int16 spellPower = actorPtr->pActorBuffs[3].uPower;
@@ -7305,7 +7305,7 @@
         dmgToReceive /= (signed int)spellPower;
     }
     int damageType;
-    switch (element)
+    switch (dmgSource)
     {
       case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; 
         break;
@@ -7437,7 +7437,7 @@
       if ( a4 == -1 )
         a4 = stru_50C198.which_player_would_attack(actorPtr);
       Player *playerPtr = &pParty->pPlayers[a4];
-      int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element);
+      int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource);
       unsigned __int16 spriteType = v37->uType;
       if ( v37->uType == 545 )
       {
@@ -7492,7 +7492,7 @@
           dmgToReceive /= (signed int)spellPower;
       }
       int damageType;
-      switch(element)
+      switch(dmgSource)
       {
         case 0:
           damageType = actorPtr->pMonsterInfo.uAttack1Type;
@@ -7553,7 +7553,7 @@
           }
         }
       }
-      if ( !element
+      if ( !dmgSource
         && !(dword_6BE368_debug_settings_2 & 0x10)
         && actorPtr->pMonsterInfo.uSpecialAttackType
         && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel )
--- a/Player.h	Mon Oct 21 10:42:27 2013 +0200
+++ b/Player.h	Mon Oct 21 10:42:35 2013 +0200
@@ -220,6 +220,8 @@
   CHARACTER_ATTRIBUTE_SKILL_LEARNING    = 46
 };
 
+#pragma warning( push )
+#pragma warning( disable: 4341 )
 /*  328 */
 enum PLAYER_SKILL_TYPE: signed __int8
 {
@@ -264,6 +266,7 @@
   PLAYER_SKILL_MISC = 38,
   PLAYER_SKILL_INVALID = -1
 };
+#pragma warning( pop )
 
 /*  329 */
 enum PLAYER_CLASS_TYPE: unsigned __int8
--- a/SpriteObject.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/SpriteObject.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -430,7 +430,7 @@
            for (v56 =0; v56 < uNumActors; ++v56)            
               {
                 if ( v20->GetActorsRelation(&pActors[v56]) )
-                  _46DF1A_collide_against_actor(v56, 0);
+                  Actor::_46DF1A_collide_against_actor(v56, 0);
 
               }
         }
@@ -438,7 +438,7 @@
       else
       {
         for ( i = 0; i < (signed int)uNumActors; ++i )
-          _46DF1A_collide_against_actor(i, 0);
+          Actor::_46DF1A_collide_against_actor(i, 0);
       }
       v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
       v27 = ODM_GetFloorLevel(
@@ -712,7 +712,7 @@
               //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
 				if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID )
 					//not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
-					_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
+					Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
               ++v42;
               ++v39b;// += 836;
             }
@@ -727,7 +727,7 @@
             v39b = pActors.data();//[0].word_000086_some_monster_id;
             do
             {
-				_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
+				Actor::_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
               ++v39b;
             }
             while ( v42 < (signed int)uNumActors );
--- a/TileFrameTable.h	Mon Oct 21 10:42:27 2013 +0200
+++ b/TileFrameTable.h	Mon Oct 21 10:42:35 2013 +0200
@@ -20,7 +20,8 @@
   TILE_DESC_SCROLL_RIGHT = 0x2000,
 };
 
-
+#pragma warning( push )
+#pragma warning( disable: 4341 )
 enum Tileset: signed __int16
 {
   Tileset_Grass = 0,
@@ -36,6 +37,7 @@
   Tileset_RoadGrassCobble = 10,
   Tileset_NULL =-1
 };
+#pragma warning( pop )
 
 /*   48 */
 #pragma pack(push, 1)
--- a/mm7_2.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_2.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -4128,136 +4128,136 @@
 
 void IntegrityTest()
 {
-  assert(sizeof(MovieHeader) == 44);
-  assert(sizeof(SoundDesc_mm6) == 112);
-  assert(sizeof(SoundDesc) == 120);
-  assert(sizeof(OverlayDesc) == 8);
-  assert(sizeof(ChestDesc) == 36);
-  assert(sizeof(ObjectDesc_mm6) == 52);
-  assert(sizeof(ObjectDesc) == 56);
-  assert(sizeof(DecorationDesc) == 84);
-  assert(sizeof(IconFrame) == 32);
-  assert(sizeof(PlayerFrame) == 10);
-  assert(sizeof(TextureFrame) == 20);
-  assert(sizeof(SpriteFrame) == 60);
-  assert(sizeof(RenderVertexSoft) == 0x30);
-  assert(sizeof(RenderBillboard) == 0x34);
-  assert(sizeof(Texture) == 0x48);
-  assert(sizeof(RGBTexture) == 0x28);
-  assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4); // + virtual dtor ptr
-  assert(sizeof(AudioPlayer) == 0xC84);
-  assert(sizeof(SoundDesc) == 0x78);
-  assert(sizeof(stru339_spell_sound) == 0xAFD8);
-  assert(sizeof(VideoPlayer) == 0x108 + 4);
-  assert(sizeof(MovieHeader) == 0x2C);
-  assert(sizeof(DecorationDesc) == 0x54);
-  assert(sizeof(ObjectDesc) == 0x38);
-  assert(sizeof(OverlayDesc) == 0x8);
-  assert(sizeof(ChestDesc) == 0x24);
-  assert(sizeof(TileDesc) == 0x1A);
-  assert(sizeof(MonsterDesc_mm6) == 148);
-  assert(sizeof(MonsterDesc) == 152);
-  assert(sizeof(Timer) == 0x28);
-  assert(sizeof(OtherOverlay) == 0x14);
-  assert(sizeof(ItemGen) == 0x24);
-  assert(sizeof(SpriteObject) == 0x70);
-  assert(sizeof(ItemDesc) == 0x30);
-  assert(sizeof(ItemsTable) == 0x117A0);
-  assert(sizeof(Chest) == 0x14CC);
-  assert(sizeof(MapInfo) == 0x44);
-  assert(sizeof(SpellInfo) == 0x24);
-  assert(sizeof(SpellData) == 0x14);
-  assert(sizeof(SpellBuff) == 0x10);
-  assert(sizeof(AIDirection) == 0x1C);
-  assert(sizeof(ActorJob) == 0xC);
-  assert(sizeof(Actor) == 0x344);
-  assert(sizeof(LevelDecoration) == 0x20);
-  assert(sizeof(KeyboardActionMapping) == 0x20C);
-  assert(sizeof(UIAnimation) == 0xD);
-  assert(sizeof(SpawnPointMM7) == 0x18);
-  assert(sizeof(ODMFace) == 0x134);
-  assert(sizeof(BSPNode) == 0x8);
-  assert(sizeof(BSPModel) == 0xBC);
-  assert(sizeof(OutdoorLocation) == 0x1C28C);
-  assert(sizeof(BLVFace) == 0x60);
-  assert(sizeof(BLVFaceExtra) == 0x24);
-  assert(sizeof(BLVSector) == 0x74);
-  assert(sizeof(BLVLightMM7) == 0x10);
-  assert(sizeof(BLVDoor) == 0x50);
-  assert(sizeof(IndoorLocation) == 0x690);
-  //assert(sizeof(ODMRenderParams) == 0x74);
-  assert(sizeof(Mouse) == 0x114);
-  assert(sizeof(Particle_sw) == 0x68);
-  assert(sizeof(Particle) == 0x68);
-  assert(sizeof(ParticleEngine) == 0xE430);
-  assert(sizeof(Lightmap) == 0xC1C);
-  assert(sizeof(LightmapBuilder) == 0x3CBC38);
-  assert(sizeof(Vis_SelectionList) == 0x2008);
-  assert(sizeof(Vis) == 0x20D0);
-  assert(sizeof(PlayerBuffAnim) == 0x10);
-  assert(sizeof(ProjectileAnim) == 0x1C);
-  assert(sizeof(stru6) == 0x5F8);
-  assert(sizeof(IndoorCameraD3D_Vec3) == 0x10);
-  assert(sizeof(IndoorCameraD3D_Vec4) == 0x18); //should be 14 (10 vec3 + 4 vdtor)  but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3
-  //assert(sizeof(IndoorCameraD3D) == 0x1A1384);
-  assert(sizeof(StationaryLight) == 0xC);
-  assert(sizeof(LightsStack_StationaryLight_) == 0x12C8);
-  assert(sizeof(MobileLight) == 0x12);
-  assert(sizeof(LightsStack_MobileLight_) == 0x1C28);
-  assert(sizeof(Game) == 0xE78);
-  assert(sizeof(stru141_actor_collision_object) == 0xA8);
-  assert(sizeof(ActionQueue) == 0x7C);
-  assert(sizeof(NPCData) == 0x4C);
-  assert(sizeof(NPCStats) == 0x17FFC);
-  assert(sizeof(BspRenderer) == 0x53740);
-  assert(sizeof(PaletteManager) == 0x267AF0);
-  assert(sizeof(ViewingParams) == 0x26C);
-  //assert(sizeof(IndoorCamera) == 0x50);
-  assert(sizeof(Bloodsplat) == 0x28);
-  assert(sizeof(BloodsplatContainer) == 0xA0C);
-  assert(sizeof(TrailParticle) == 0x18);
-  assert(sizeof(EventIndex) == 0xC);
-  assert(sizeof(_2devent) == 0x34);
-  assert(sizeof(stru176) == 0x20);
-  assert(sizeof(SavegameHeader) == 0x64);
-  assert(sizeof(SavegameList) == 0x3138);
-  assert(sizeof(StorylineText) == 0x160);
-  assert(sizeof(FactionTable) == 0x1EF1);
-  assert(sizeof(Decal) == 0xC20);
-  assert(sizeof(DecalBuilder) == 0x30C038);
-  assert(sizeof(MonsterInfo) == 0x58);
-  assert(sizeof(MonsterStats) == 0x5BA0);
-  assert(sizeof(RenderD3D) == 0x148);
-//  assert(sizeof(Render) == 0x129844);
-  assert(sizeof(Player) == 0x1B3C);
-  assert(sizeof(PartyTimeStruct) == 0x678);
-  assert(sizeof(Party) == 0x16238);
-  assert(sizeof(GUIButton) == 0xBC);
-  assert(sizeof(GUIWindow) == 0x54);
-  assert(sizeof(GUIProgressBar) == 0x1B8);
-  assert(sizeof(GUIFont) == 0x1020);
- // assert(sizeof(stru262_TurnBased) == 0x40);
-  assert(sizeof(ArcomageGame) == 0xFB);
-  assert(sizeof(CastSpellInfo) == 0x14);
-  assert(sizeof(ArcomageCard) == 0x6C);
-  assert(sizeof(stru320) == 0x3FC);
-  assert(sizeof(TravelInfo) == 0x20);
-  assert(sizeof(stru336) == 0x798);
-  assert(sizeof(Vec3_short_) == 6);
-  assert(sizeof(BLVFace) == 96);
-  assert(sizeof(BLVFaceExtra) == 36);
-  assert(sizeof(BLVSector) == 116);
-  assert(sizeof(LevelDecoration) == 32);
-  assert(sizeof(BLVLightMM7) == 16);
-  assert(sizeof(BSPNode) == 8);
-  assert(sizeof(SpawnPointMM7) == 24);
-  assert(sizeof(DDM_DLV_Header) == 40);
-  assert(sizeof(Actor) == 836);
-  assert(sizeof(SpriteObject) == 112);
-  assert(sizeof(Chest) == 5324);
-  assert(sizeof(stru123) == 0xC8);
-  assert(sizeof(BLVMapOutline) == 12);
-  assert(sizeof(LODSprite) == 0x28);
+  static_assert(sizeof(MovieHeader) == 44, "Wrong type size");
+  static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size");
+  static_assert(sizeof(SoundDesc) == 120, "Wrong type size");
+  static_assert(sizeof(OverlayDesc) == 8, "Wrong type size");
+  static_assert(sizeof(ChestDesc) == 36, "Wrong type size");
+  static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size");
+  static_assert(sizeof(ObjectDesc) == 56, "Wrong type size");
+  static_assert(sizeof(DecorationDesc) == 84, "Wrong type size");
+  static_assert(sizeof(IconFrame) == 32, "Wrong type size");
+  static_assert(sizeof(PlayerFrame) == 10, "Wrong type size");
+  static_assert(sizeof(TextureFrame) == 20, "Wrong type size");
+  static_assert(sizeof(SpriteFrame) == 60, "Wrong type size");
+  static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size");
+  static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size");
+  static_assert(sizeof(Texture) == 0x48, "Wrong type size");
+  static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size");
+  static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr
+  static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size");
+  static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size");
+  static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size");
+  static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size");
+  static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size");
+  static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size");
+  static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size");
+  static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size");
+  static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size");
+  static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size");
+  static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size");
+  static_assert(sizeof(MonsterDesc) == 152, "Wrong type size");
+  static_assert(sizeof(Timer) == 0x28, "Wrong type size");
+  static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size");
+  static_assert(sizeof(ItemGen) == 0x24, "Wrong type size");
+  static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size");
+  static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size");
+  static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size");
+  static_assert(sizeof(Chest) == 0x14CC, "Wrong type size");
+  static_assert(sizeof(MapInfo) == 0x44, "Wrong type size");
+  static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size");
+  static_assert(sizeof(SpellData) == 0x14, "Wrong type size");
+  static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size");
+  static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size");
+  static_assert(sizeof(ActorJob) == 0xC, "Wrong type size");
+  static_assert(sizeof(Actor) == 0x344, "Wrong type size");
+  static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size");
+  static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size");
+  static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size");
+  static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size");
+  static_assert(sizeof(ODMFace) == 0x134, "Wrong type size");
+  static_assert(sizeof(BSPNode) == 0x8, "Wrong type size");
+  static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size");
+  static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size");
+  static_assert(sizeof(BLVFace) == 0x60, "Wrong type size");
+  static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size");
+  static_assert(sizeof(BLVSector) == 0x74, "Wrong type size");
+  static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size");
+  static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size");
+  static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size");
+  //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size");
+  static_assert(sizeof(Mouse) == 0x114, "Wrong type size");
+  static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size");
+  static_assert(sizeof(Particle) == 0x68, "Wrong type size");
+  static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size");
+  static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size");
+  static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size");
+  static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size");
+  static_assert(sizeof(Vis) == 0x20D0, "Wrong type size");
+  static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size");
+  static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size");
+  static_assert(sizeof(stru6) == 0x5F8, "Wrong type size");
+  static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size");
+  static_assert(sizeof(IndoorCameraD3D_Vec4) == 0x18, "Wrong type size"); //should be 14 (10 vec3 + 4 vdtor)  but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3
+  //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size");
+  static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size");
+  static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size");
+  static_assert(sizeof(MobileLight) == 0x12, "Wrong type size");
+  static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size");
+  static_assert(sizeof(Game) == 0xE78, "Wrong type size");
+  static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size");
+  static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size");
+  static_assert(sizeof(NPCData) == 0x4C, "Wrong type size");
+  static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size");
+  static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size");
+  static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size");
+  static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size");
+  //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size");
+  static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size");
+  static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size");
+  static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size");
+  static_assert(sizeof(EventIndex) == 0xC, "Wrong type size");
+  static_assert(sizeof(_2devent) == 0x34, "Wrong type size");
+  static_assert(sizeof(stru176) == 0x20, "Wrong type size");
+  static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size");
+  static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size");
+  static_assert(sizeof(StorylineText) == 0x160, "Wrong type size");
+  static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size");
+  static_assert(sizeof(Decal) == 0xC20, "Wrong type size");
+  static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size");
+  static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size");
+  static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size");
+  static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size");
+  //  static_assert(sizeof(Render) == 0x129844, "Wrong type size");
+  static_assert(sizeof(Player) == 0x1B3C, "Wrong type size");
+  static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size");
+  static_assert(sizeof(Party) == 0x16238, "Wrong type size");
+  static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size");
+  static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size");
+  static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size");
+  static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size");
+  // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size");
+  static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size");
+  static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size");
+  static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size");
+  static_assert(sizeof(stru320) == 0x3FC, "Wrong type size");
+  static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size");
+  static_assert(sizeof(stru336) == 0x798, "Wrong type size");
+  static_assert(sizeof(Vec3_short_) == 6, "Wrong type size");
+  static_assert(sizeof(BLVFace) == 96, "Wrong type size");
+  static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size");
+  static_assert(sizeof(BLVSector) == 116, "Wrong type size");
+  static_assert(sizeof(LevelDecoration) == 32, "Wrong type size");
+  static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size");
+  static_assert(sizeof(BSPNode) == 8, "Wrong type size");
+  static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size");
+  static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size");
+  static_assert(sizeof(Actor) == 836, "Wrong type size");
+  static_assert(sizeof(SpriteObject) == 112, "Wrong type size");
+  static_assert(sizeof(Chest) == 5324, "Wrong type size");
+  static_assert(sizeof(stru123) == 0xC8, "Wrong type size");
+  static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size");
+  static_assert(sizeof(LODSprite) == 0x28, "Wrong type size");
 }
 
 bool new_sky = false;
--- a/mm7_3.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_3.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -1093,7 +1093,7 @@
       for ( i = 0; v31 < ai_arrays_size; ++v31 )
       {
         v33 = ai_near_actors_ids[v31];
-        if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) )
+        if ( v33 != v75 && Actor::_46DF1A_collide_against_actor(v33, 40) )
           ++i;
       }
       v71 = i > 1;
@@ -1833,7 +1833,7 @@
       _46E44E_collide_against_faces_and_portals(1u);
       _46E0B2_collide_against_decorations();
       for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
-        _46DF1A_collide_against_actor(v80, 0);
+        Actor::_46DF1A_collide_against_actor(v80, 0);
       if ( _46F04E_collide_against_portals() )
         break;
       ++v73;
@@ -2685,7 +2685,7 @@
     _46E26D_collide_against_sprites(v38, v37);
     _46ED8A_collide_against_sprite_objects(4u);
     for ( i = 0; i < (signed int)uNumActors; ++i )
-      _46DF1A_collide_against_actor(i, 0);
+      Actor::_46DF1A_collide_against_actor(i, 0);
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       _angle_x = stru_721530.normal2.x;
--- a/mm7_5.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_5.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -3983,7 +3983,7 @@
       v6 = stru_50C198._4273BB(v8, v7, v4, 0);
       if ( v6 )
       {
-        v10 = (unsigned int)Actor::_43B3E0_CalcDamage(v8, a4);
+        v10 = (unsigned int)v8->_43B3E0_CalcDamage(a4);
         if ( (signed __int64)v8->pActorBuffs[3].uExpireTime > 0 )
         {
           v11 = v8->pActorBuffs[3].uPower;
--- a/mm7_6.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_6.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -399,7 +399,7 @@
   if ( pActor->pMonsterInfo.uSpecialAbilityType == 2
     && pActor->pMonsterInfo.uSpecialAbilityDamageDiceBonus < 3u
     && rand() % 100 < 5 )
-    pActor->_44FD29(a2);
+    pActor->SummonMinion(a2);
   v4 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell1ID);
   v5 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell2ID);
   if ( v4 && pActor->pMonsterInfo.uSpell1UseChance && rand() % 100 < pActor->pMonsterInfo.uSpell1UseChance )
--- a/mm7_data.cpp	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_data.cpp	Mon Oct 21 10:42:35 2013 +0200
@@ -348,7 +348,6 @@
 int (__stdcall *off_4DAFDC)(char); // weak
 char asc_4DB724[777]; // idb
 int dword_4DBD94; // weak
-std::array<int, 5> dword_4DF380 = {{0,1024,2560,5120,10240}}; // weak
 //int dword_4DF390; // weak
 char Str2[777]; // idb
 
--- a/mm7_data.h	Mon Oct 21 10:42:27 2013 +0200
+++ b/mm7_data.h	Mon Oct 21 10:42:35 2013 +0200
@@ -307,7 +307,6 @@
 extern int (__stdcall *off_4DAFDC)(char); // weak
 extern char asc_4DB724[]; // idb
 extern int dword_4DBD94; // weak
-extern std::array<int, 5> dword_4DF380; // weak
 extern int dword_4DF390; // weak
 extern char Str2[]; // idb
 
@@ -1283,7 +1282,6 @@
 int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4);
 void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out);
 unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID);
-int __fastcall _46DF1A_collide_against_actor(int, int); // weak
 void _46E0B2_collide_against_decorations();
 void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2);
 int _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb