diff mm7_6.cpp @ 2292:ab8797ea43b6

stru319::CalcMagicalDamageToActor small cleanups
author Grumpy7
date Sun, 16 Mar 2014 19:37:28 +0100
parents 69661f22ff03
children b0f10ef66e00
line wrap: on
line diff
--- a/mm7_6.cpp	Sun Mar 16 19:11:52 2014 +0100
+++ b/mm7_6.cpp	Sun Mar 16 19:37:28 2014 +0100
@@ -60,7 +60,7 @@
 }
 
 //----- (0042756B) --------------------------------------------------------
-int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3)
+int stru319::CalcMagicalDamageToActor(Actor *pActor, DAMAGE_TYPE dmgType, signed int incomingDmg)
 {
   int v4; // edx@1
   int v5; // ecx@1
@@ -70,44 +70,44 @@
 
   v4 = 0;
   v5 = 0;
-  if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 )
+  if ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 )
     v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower;
-  switch ( a2 )
+  switch ( dmgType )
   {
-    case 0:
+    case DMGT_FIRE:
       v6 = pActor->pMonsterInfo.uResFire;
       v4 = v5;
       break;
-    case 1:
+    case DMGT_ELECTR:
       v6 = pActor->pMonsterInfo.uResAir;
       v4 = v5;
       break;
-    case 2:
+    case DMGT_COLD:
       v6 = pActor->pMonsterInfo.uResWater;
       v4 = v5;
       break;
-    case 3:
+    case DMGT_EARTH:
       v6 = pActor->pMonsterInfo.uResEarth;
       v4 = v5;
       break;
-    case 4:
+    case DMGT_PHISYCAL:
       v6 = pActor->pMonsterInfo.uResPhysical;
       break;
-    case 6:
+    case DMGT_SPIRIT:
       v6 = pActor->pMonsterInfo.uResSpirit;
       break;
-    case 7:
+    case DMGT_MIND:
       v6 = pActor->pMonsterInfo.uResMind;
       v4 = v5;
       break;
-    case 8:
+    case DMGT_BODY:
       v6 = pActor->pMonsterInfo.uResBody;
       v4 = v5;
       break;
-    case 9:
+    case DMGT_LIGHT:
       v6 = pActor->pMonsterInfo.uResLight;
       break;
-    case 10:
+    case DMGT_DARK:
       v6 = pActor->pMonsterInfo.uResDark;
       break;
     default:
@@ -117,21 +117,13 @@
   if ( v6 < 200 )
   {
     v8 = v4 + v6 + 30;
-    if ( rand() % v8 >= 30 )
+    for (int i = 0; i < 4; i++)
     {
-      a3 >>= 1;
-      if ( rand() % v8 >= 30 )
-      {
-        a3 >>= 1;
-        if ( rand() % v8 >= 30 )
-        {
-          a3 >>= 1;
-          if ( rand() % v8 >= 30 )
-            a3 >>= 1;
-        }
-      }
+      if ( rand() % v8 < 30 )
+        break;
+      incomingDmg /= 2;
     }
-    result = a3;
+    result = incomingDmg;
   }
   else
     result = 0;