diff Actor.cpp @ 1894:fe7182c30aad

Actor::_44FD29 cleanup 1
author Grumpy7
date Sun, 20 Oct 2013 02:30:36 -0700
parents 7293e7e8810b
children 6b4e14436ee8
line wrap: on
line diff
--- a/Actor.cpp	Sun Oct 20 00:38:38 2013 -0700
+++ b/Actor.cpp	Sun Oct 20 02:30:36 2013 -0700
@@ -2366,17 +2366,17 @@
 {
   int v5; // ecx@1
   signed int v10; // eax@13
-  int v11; // ebx@16
-  int v12; // eax@16
+  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
+  uint v15; // edi@43
+  uint v16; // ebx@45
+  uint v17; // eax@45
   signed int closestId; // [sp+14h] [bp-1Ch]@1
-  int v23; // [sp+1Ch] [bp-14h]@16
+  uint v23; // [sp+1Ch] [bp-14h]@16
   unsigned int lowestRadius; // [sp+24h] [bp-Ch]@1
-  int v27; // [sp+2Ch] [bp-4h]@16
-  int v28; // [sp+2Ch] [bp-4h]@45
+  uint v27; // [sp+2Ch] [bp-4h]@16
+  uint v28; // [sp+2Ch] [bp-4h]@45
 
   lowestRadius = UINT_MAX;
   v5 = 0;
@@ -2432,11 +2432,8 @@
   {
     *a2 = PID(OBJECT_Actor, closestId);
   }
-
-  if (pParty->Invisible())
-    can_target_party = false;
-
-  if (can_target_party)
+  
+  if (can_target_party && !pParty->Invisible())
   {
     if ( thisActor->uAttributes & 0x80000
       && thisActor->pActorBuffs[12].uExpireTime <= 0
@@ -2685,41 +2682,25 @@
 }
 
 //----- (0044FD29) --------------------------------------------------------
-int Actor::_44FD29(int a2)
+void Actor::_44FD29( int a2 )
 {
-  Actor *v2; // edi@1
   unsigned __int8 v3; // al@1
   int v4; // esi@1
   int v5; // edx@2
-  int v6; // eax@8
   int v7; // edi@10
   Actor *v8; // esi@10
   MonsterInfo *v9; // ebx@10
   MonsterDesc *v10; // edi@10
   unsigned __int16 v11; // ax@10
-  int v12; // eax@10
   int v13; // ebx@10
-  int v14; // eax@10
   int v15; // edi@10
-  int v16; // eax@10
   int v17; // ebx@10
-  Actor *v18; // ecx@10
-  signed __int64 v19; // qax@10
-  unsigned int v20; // eax@12
-  int v21; // eax@13
+  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
 
-  v2 = this;
-  v24 = a2;
-  v30 = this;
   v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
   v4 = this->pMonsterInfo.field_3C_some_special_attack;
   if ( v3 )
@@ -2730,29 +2711,26 @@
   else
   {
     v5 = rand() % 100;
-    if ( v5 >= 60 )
+    if ( v5 >= 90 )
+      v4 += 2;
+    else if ( v5 >= 60 )
     {
-      ++v4;
-      if ( v5 >= 90 )
-        ++v4;
+      v4 += 1;
     }
   }
-  v6 = v2->vPosition.z;
-  v28 = 0;
-  uFaceID = v6;
+  actorSector = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    v28 = pIndoor->GetSector(v2->vPosition.x, v2->vPosition.y, v6);
+    actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z);
   v7 = v4 - 1;
   v8 = &pActors[uNumActors];
   v27 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
-  v29 = v7;
   v9 = &pMonsterStats->pInfos[v7 + 1];
   pActors[uNumActors].Reset();
   v10 = &pMonsterList->pMonsters[v7];
   strcpy(v8->pActorName, v9->pName);
   v8->sCurrentHP = LOWORD(v9->uHP);
-  memcpy(&v8->pMonsterInfo, v9, 0x58u);
-  v8->word_000086_some_monster_id = v29 + 1;
+  memcpy(&v8->pMonsterInfo, v9, sizeof(v8->pMonsterInfo));
+  v8->word_000086_some_monster_id = v4;
   v8->uActorRadius = v10->uMonsterRadius;
   v8->uActorHeight = v10->uMonsterHeight;
   v11 = v10->uMovementSpeed;
@@ -2760,60 +2738,50 @@
   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;
+  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;
+  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 )
+  v19 = this->uAlly;
+  if ( !v19 )
   {
-    uFaceID = v18->pMonsterInfo.uID - 1;
-    v19 = (signed __int64)((double)uFaceID * 0.33333334);
-    v18 = v30;
+    monsterId = this->pMonsterInfo.uID - 1;
+    v19 = (uint)(monsterId * 0.33333334);
   }
   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) )
+
+  if (uCurrentlyLoadedLevelType != LEVEL_Outdoor)
   {
-    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;
+    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;
   }
-  return result;
+
+  ++uNumActors;
+  ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
+  if ( this->uAttributes & 0x80000 )
+    v8->uAttributes |= 0x80000u;
+  v8->uSummonerID = PID(OBJECT_Actor,a2);
+
 }
 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
 //----- (0046DF1A) --------------------------------------------------------