diff Actor.cpp @ 1878:6ffa3228eaf7

Actor::AI_SpellAttack2 cleaned up
author Grumpy7
date Thu, 17 Oct 2013 09:50:25 +0200
parents bed4532cfe59
children 7efa09ddb8b4
line wrap: on
line diff
--- a/Actor.cpp	Thu Oct 17 09:10:18 2013 +0200
+++ b/Actor.cpp	Thu Oct 17 09:50:25 2013 +0200
@@ -1275,14 +1275,14 @@
     v3->uAIState = AttackingMelee;
     Actor::PlaySound(uActorID, 0);
     v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
+    if ( v3->pActorBuffs[7].uExpireTime > 0 )
+    {
+      v25 *= 2;
+    }
     if ( pParty->bTurnBasedModeOn != 1 )
     {
       v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * v25 * 2.133333333333333);
     }
-    else if ( v3->pActorBuffs[7].uExpireTime > 0 )
-    {
-      v3->pMonsterInfo.uRecoveryTime = v25 * 2;
-    }
     else
     {
       v3->pMonsterInfo.uRecoveryTime = v25;
@@ -1500,97 +1500,78 @@
 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);
+      v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
     v16 = v3->pMonsterInfo.uSpell2ID;
-    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 = AttackingRanged4;
@@ -1599,7 +1580,7 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::AI_Pursue1(v22, a2, v22, 64, pDir);
+    Actor::AI_Pursue1(uActorID, a2, uActorID, 64, pDir);
 }
 
 //----- (00403854) --------------------------------------------------------