diff Actor.cpp @ 1875:1d9e4b50bc7c

Actor::_43B3E0_CalcDamage cleaned up, fixed actor buff enums and added 2 values
author Grumpy7
date Thu, 17 Oct 2013 08:55:28 +0200
parents a6276dda8804
children 2070d01ccfae
line wrap: on
line diff
--- a/Actor.cpp	Thu Oct 17 07:57:01 2013 +0200
+++ b/Actor.cpp	Thu Oct 17 08:55:28 2013 +0200
@@ -1347,25 +1347,25 @@
     case 1:
       if ( a3 )
       {
-        pOtherOverlayList->_4418B6(904, v4, 0, (sub_43AE12(a3) * 65536.0), 0);
+        pOtherOverlayList->_4418B6(904, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 2:
       if ( a3 )
       {
-        pOtherOverlayList->_4418B6(905, v4, 0, (sub_43AE12(a3) * 65536.0), 0);
+        pOtherOverlayList->_4418B6(905, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 3:
       if ( a3 )
       {
-        pOtherOverlayList->_4418B6(906, v4, 0, (sub_43AE12(a3) * 65536.0), 0);
+        pOtherOverlayList->_4418B6(906, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 4:
       if ( a3 )
       {
-        pOtherOverlayList->_4418B6(907, v4, 0, (sub_43AE12(a3) * 65536.0), 0);
+        pOtherOverlayList->_4418B6(907, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0);
       }
       return;
     case 5:
@@ -1393,13 +1393,12 @@
 }
 
 //----- (0043B3E0) --------------------------------------------------------
-int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2)
+int Actor::_43B3E0_CalcDamage(Actor *a1, 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
@@ -1407,61 +1406,47 @@
 
   v2 = 0;
   v11 = 0;
-  if ( a2 )
+
+  switch( dmgSource )
   {
-    if ( a2 == 1 )
-    {
+    case 0: 
+      if ( a1->pActorBuffs[14].uExpireTime > 0 )
+        v2 = a1->pActorBuffs[14].uPower;
+      if ( a1->pActorBuffs[18].uExpireTime > 0 && a1->pActorBuffs[18].uPower > v2 )
+        v2 = a1->pActorBuffs[18].uPower;
+      if ( a1->pActorBuffs[21].uExpireTime > 0 )
+        v2 += a1->pActorBuffs[21].uPower;
+      v3 = a1->pMonsterInfo.uAttack1DamageDiceRolls;
+      v4 = a1->pMonsterInfo.uAttack1DamageDiceSides;
+      v5 = a1->pMonsterInfo.uAttack1DamageBonus;
+      break;
+    case 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;
+      break;
+    case 2: 
+      v8 = a1->pMonsterInfo.uSpellSkillAndMastery1;
+      v9 = a1->pMonsterInfo.uSpell1ID;
+      v10 = SkillToMastery(v8);
+      return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0);
+      break;
+    case 3: 
+      v8 = a1->pMonsterInfo.uSpellSkillAndMastery2;
+      v9 = a1->pMonsterInfo.uSpell2ID;
+      v10 = SkillToMastery(v8);
+      return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0);
+      break;
+    case 4:
       v3 = a1->pMonsterInfo.uSpecialAbilityDamageDiceRolls;
       v4 = a1->pMonsterInfo.uSpecialAbilityDamageDiceSides;
       v5 = a1->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;
 }