changeset 1324:78f0f74eab1d

GetActual(stat) functions changed to similar code
author Grumpy7
date Tue, 02 Jul 2013 00:39:26 +0200
parents bfde0563ecdc
children d9e4c0bbb2d2
files Player.cpp
diffstat 1 files changed, 64 insertions(+), 135 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Mon Jul 01 22:42:09 2013 +0200
+++ b/Player.cpp	Tue Jul 02 00:39:26 2013 +0200
@@ -2402,69 +2402,40 @@
 //----- (0048C93C) --------------------------------------------------------
 int Player::GetActualMight()
 {
-  Player *v1; // esi@1
-  unsigned int v2; // eax@1
-  signed int v3; // ecx@1
-  signed int v4; // ebx@4
-  int v5; // edi@5
-  int v6; // ST14_4@5
-
-  v1 = this;
-  v2 = this->sAgeModifier + GetBaseAge();
-  v3 = 0;
-  while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
-  {
-    ++v3;
-    if ( v3 >= 4 )
-    {
-      v4 = 100;
-      goto LABEL_5;
-    }
-  }
-  v4 = pAgeingStrengthMultiplier[v3];
-LABEL_5:
-  v5 = pConditionStrengthMultiplier[GetMajorConditionIdx()];
-  v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH, 0);
-  return v5 * v4 * v1->uMight / 100 / 100 + GetMagicalBonus((CHARACTER_ATTRIBUTE_TYPE)0) + v6 + v1->uMightBonus;
+  uint uActualAge = GetBaseAge() + this->sAgeModifier;
+  uint uAgeingMultiplier = 100;
+  for (uint i = 0; i < 4; ++i)
+    if (uActualAge >= pAgeingTable[i])
+      uAgeingMultiplier = pAgeingStrengthMultiplier[i];
+    else break;
+
+  auto uConditionMult = pConditionStrengthMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uMight / 100 / 100 
+       + GetMagicalBonus(CHARACTER_ATTRIBUTE_STRENGTH) 
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH, 0) 
+       + uMightBonus;
 }
 
 //----- (0048C9C2) --------------------------------------------------------
 int Player::GetActualIntelligence()
 {
-  Player *v1; // esi@1
-  unsigned int sAge; // eax@1
-  signed int uAgeLevel; // ecx@1
-  signed int v4; // ebx@4
-  int v5; // edi@5
-  int v6; // ebp@5
-
-  v1 = this;
-  sAge = this->sAgeModifier + GetBaseAge();
-  uAgeLevel = 0;
-  while ( (signed int)sAge >= (signed int)pAgeingTable[uAgeLevel] )
-  {
-    ++uAgeLevel;
-    if ( uAgeLevel >= 4 )
-    {
-      v4 = 100;
-      goto LABEL_5;
-    }
-  }
-  v4 = pAgeingIntelligenceMultiplier[uAgeLevel];
-LABEL_5:
-  v5 = pConditionIntelligenceMultiplier[GetMajorConditionIdx()];
-  v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0);
-  return v5 * v4 * v1->uIntelligence / 100 / 100
+  uint uActualAge = GetBaseAge() + this->sAgeModifier;
+  uint uAgeingMultiplier = 100;
+  for (uint i = 0; i < 4; ++i)
+    if (uActualAge >= pAgeingTable[i])
+      uAgeingMultiplier = pAgeingIntelligenceMultiplier[i];
+    else break;
+
+  auto uConditionMult = pConditionIntelligenceMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uIntelligence / 100 / 100
        + GetMagicalBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE)
-       + v6
-       + v1->uIntelligenceBonus;
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0)
+       + uIntelligenceBonus;
 }
 
 //----- (0048CA3F) --------------------------------------------------------
 int Player::GetActualWillpower()
 {
-  int v5; // edi@5
-  
   uint uActualAge = GetBaseAge() + sAgeModifier;
   uint uAgeingMultiplier = 100;
   for (uint i = 0; i < 4; ++i)
@@ -2472,8 +2443,8 @@
       uAgeingMultiplier = pAgeingWillpowerMultiplier[i];
     else break;
 
-  v5 = pConditionWillpowerMultiplier[GetMajorConditionIdx()];
-  return v5 * uAgeingMultiplier * uWillpower / 100 / 100
+  auto uConditionMult = pConditionWillpowerMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uWillpower / 100 / 100
        + GetMagicalBonus(CHARACTER_ATTRIBUTE_WILLPOWER)
        + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER, 0)
        + uWillpowerBonus;
@@ -2490,88 +2461,51 @@
     else break;
 
   auto uConditionMult = pConditionEnduranceMultiplier[GetMajorConditionIdx()];
-  auto uItemBonus = GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0);
   return uConditionMult * uAgeingMultiplier * uEndurance / 100 / 100
        + GetMagicalBonus(CHARACTER_ATTRIBUTE_ENDURANCE)
-       + uItemBonus
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0)
        + uEnduranceBonus;
 }
 
 //----- (0048CB39) --------------------------------------------------------
 int Player::GetActualAccuracy()
 {
-  Player *v1; // esi@1
-  unsigned int v2; // eax@1
-  signed int v3; // ecx@1
-  signed int v4; // ebx@4
-  int v5; // edi@5
-  int v6; // ebp@5
-
-  v1 = this;
-  v2 = this->sAgeModifier + GetBaseAge();
-  v3 = 0;
-  while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
-  {
-    ++v3;
-    if ( v3 >= 4 )
-    {
-      v4 = 100;
-      goto LABEL_5;
-    }
-  }
-  v4 = pAgeingAccuracyMultiplier[v3];
-LABEL_5:
-  v5 = pConditionAccuracyMultiplier[GetMajorConditionIdx()];
-  v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0);
-  return v5 * v4 * v1->uAccuracy / 100 / 100
+
+  uint uActualAge = this->sAgeModifier + GetBaseAge();
+  uint uAgeingMultiplier = 100;
+  for (uint i = 0; i < 4; ++i)
+    if (uActualAge >= pAgeingTable[i])
+      uAgeingMultiplier = pAgeingAccuracyMultiplier[i];
+    else break;
+
+  auto uConditionMult = pConditionAccuracyMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uAccuracy / 100 / 100
        + GetMagicalBonus(CHARACTER_ATTRIBUTE_ACCURACY)
-       + v6
-       + v1->uAccuracyBonus;
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0)
+       + uAccuracyBonus;
 }
 
 //----- (0048CBB6) --------------------------------------------------------
 int Player::GetActualSpeed()
 {
-  Player *v1; // esi@1
-  unsigned int v2; // eax@1
-  signed int v3; // ecx@1
-  signed int v4; // ebx@4
-  int v5; // edi@5
-  int v6; // ebp@5
-
-  v1 = this;
-  v2 = this->sAgeModifier + GetBaseAge();
-  v3 = 0;
-  while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
-  {
-    ++v3;
-    if ( v3 >= 4 )
-    {
-      v4 = 100;
-      goto LABEL_5;
-    }
-  }
-  v4 = pAgeingSpeedMultiplier[v3];
-LABEL_5:
-  v5 = pConditionSpeedMultiplier[GetMajorConditionIdx()];
-  v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0);
-  return v5 * v4 * v1->uSpeed / 100 / 100
+  uint uActualAge = this->sAgeModifier + GetBaseAge();
+  uint uAgeingMultiplier = 100;
+  for (uint i = 0; i < 4; ++i)
+    if (uActualAge >= pAgeingTable[i])
+      uAgeingMultiplier = pAgeingSpeedMultiplier[i];
+    else break;
+
+  auto uConditionMult = pConditionSpeedMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uSpeed / 100 / 100
        + GetMagicalBonus(CHARACTER_ATTRIBUTE_SPEED)
-       + v6
-       + v1->uSpeedBonus;
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0)
+       + uSpeedBonus;
 }
 
 //----- (0048CC33) --------------------------------------------------------
 int Player::GetActualLuck()
 {
-  signed int curr_age; // eax@7
-  signed int i; // ecx@7
-  signed int age_luck_pc; // ebx@10
-  int condition_luck_pc; // edi@11
-  int items_luck_bonus; // ebp@11
   signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1
-  signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1
-  int full_luck;
 
   npc_luck_bonus = 0;
   if ( CheckHiredNPCSpeciality(Fool) )
@@ -2580,25 +2514,20 @@
     npc_luck_bonus += 20;
   if ( CheckHiredNPCSpeciality(Psychic) )
     npc_luck_bonus += 10;
-  curr_age = sAgeModifier + GetBaseAge();
-  i = 0;
-  while ( curr_age >= pAgeingTable[i] )
-  {
-    ++i;
-    if ( i >= 4 )
-      break;
-  }
-  if (i < 4)
-    age_luck_pc = pAgeingLuckMultiplier[i];
-  else
-    age_luck_pc = 100;
-
-  condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()];
-  items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0);
-  magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK);
-  full_luck = magic_luck_bonus  + items_luck_bonus   + npc_luck_bonus+  uLuckBonus
-                + condition_luck_pc * age_luck_pc * uLuck / 100 / 100;
-   return full_luck;
+
+  uint uActualAge = this->sAgeModifier + GetBaseAge();
+  uint uAgeingMultiplier = 100;
+  for (uint i = 0; i < 4; ++i)
+    if (uActualAge >= pAgeingTable[i])
+      uAgeingMultiplier = pAgeingLuckMultiplier[i];
+    else break;
+
+  auto uConditionMult = pConditionLuckMultiplier[GetMajorConditionIdx()];
+  return uConditionMult * uAgeingMultiplier * uLuck / 100 / 100
+       + GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK)  
+       + GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0)   
+       + uLuckBonus
+       + npc_luck_bonus;
 }
 
 //----- (0048CCF5) --------------------------------------------------------
@@ -7924,7 +7853,7 @@
             if (v9->uItemID == 615)
               break;
           }
-          if (v9 != NULL || v9->uItemID != 615)
+          if (v9 != NULL && v9->uItemID != 615)
           {
             v10 = (int)((char *)this + 36 * 138);   //originally 36 * v8. the code got to this condition only if v8 was equal to 138
             *(int *)(v10 + 532) = 601;