diff Player.cpp @ 290:4776715a964b

StatTable
author Ritor1
date Mon, 18 Feb 2013 20:47:41 +0600
parents 92d443ed0cba
children 055cea8660e5 2503214e5258
line wrap: on
line diff
--- a/Player.cpp	Mon Feb 18 19:16:38 2013 +0600
+++ b/Player.cpp	Mon Feb 18 20:47:41 2013 +0600
@@ -31,7 +31,7 @@
 
 /*  381 */
 #pragma pack(push, 1)
-struct PlayerCreation_AttributeProp
+struct PlayerCreation_AttributeProps
 {
   unsigned __int8 uBaseValue;
   char uMaxValue;
@@ -42,26 +42,16 @@
 
 
 #pragma pack(push, 1)
-struct PlayerCreation_AttributePropsByRace
-{
-  PlayerCreation_AttributeProp attr[7];
-};
-
-struct PlayerCreation_AttributeProps
-{
-  union
-  {
-    unsigned __int8 _[4][7][4];
-    PlayerCreation_AttributePropsByRace race[4];
-  };
-};
+
+
+
 #pragma pack(pop)
-PlayerCreation_AttributeProps stru_4ED7B0 =
-{
-  11, 25, 1, 1,   11, 25, 1, 1,   11, 25, 1, 1,    9, 25, 1, 1,   11, 25, 1, 1,   11, 25, 1, 1,   9, 25, 1, 1,
-   7, 15, 2, 1,   14, 30, 1, 2,   11, 25, 1, 1,    7, 15, 2, 1,   14, 30, 1, 2,   11, 25, 1, 1,   9, 20, 1, 1,
-  14, 30, 1, 2,    7, 15, 2, 1,    7, 15, 2, 1,   11, 25, 1, 1,   11, 25, 1, 1,   14, 30, 1, 2,   9, 20, 1, 1,
-  14, 30, 1, 2,   11, 25, 1, 1,   11, 25, 1, 1,   14, 30, 1, 2,    7, 15, 2, 1,    7, 15, 2, 1,   9, 20, 1, 1
+PlayerCreation_AttributeProps StatTable[4][7] = //0x4ED7B0
+{
+  {{11, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, { 9, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {9, 25, 1, 1},},
+  {{ 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, { 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, {9, 20, 1, 1},},
+  {{14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, {9, 20, 1, 1},},
+  {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}}
 };
 
 
@@ -173,16 +163,16 @@
         v0 = pParty->pPlayers[v1].uMight;
       }
       v3 = v2 + v9;
-      v4 = stru_4ED7B0.race[0].attr[v3].uBaseValue;
+      v4 = StatTable[0][v3].uBaseValue;
       if ( v0 >= v4 )
       {
-        v5 = stru_4ED7B0.race[0].attr[v3].uDroppedStep;
-        v6 = stru_4ED7B0.race[0].attr[v3].uBaseStep;
+        v5 = StatTable[0][v3].uDroppedStep;
+        v6 = StatTable[0][v3].uBaseStep;
       }
       else
       {
-        v5 = stru_4ED7B0.race[0].attr[v3].uBaseStep;
-        v6 = stru_4ED7B0.race[0].attr[v3].uDroppedStep;
+        v5 = StatTable[0][v3].uBaseStep;
+        v6 = StatTable[0][v3].uDroppedStep;
       }
       v8 += v5 * (v4 - v0) / v6;
       ++v9;
@@ -6449,13 +6439,13 @@
 void Player::SetInitialStats()
 {
   auto v1 = GetRace();
-  uMight = stru_4ED7B0.race[v1].attr[0].uBaseValue;
-  uIntelligence = stru_4ED7B0.race[v1].attr[1].uBaseValue;
-  uWillpower = stru_4ED7B0.race[v1].attr[2].uBaseValue;
-  uEndurance = stru_4ED7B0.race[v1].attr[3].uBaseValue;
-  uAccuracy = stru_4ED7B0.race[v1].attr[4].uBaseValue;
-  uSpeed = stru_4ED7B0.race[v1].attr[5].uBaseValue;
-  uLuck = stru_4ED7B0.race[v1].attr[6].uBaseValue;
+  uMight = StatTable[v1][0].uBaseValue;
+  uIntelligence = StatTable[v1][1].uBaseValue;
+  uWillpower = StatTable[v1][2].uBaseValue;
+  uEndurance = StatTable[v1][3].uBaseValue;
+  uAccuracy = StatTable[v1][4].uBaseValue;
+  uSpeed = StatTable[v1][5].uBaseValue;
+  uLuck = StatTable[v1][6].uBaseValue;
 }
 
 //----- (004901FC) --------------------------------------------------------
@@ -6638,10 +6628,10 @@
   int uMinValue; // [sp+Ch] [bp-4h]@1
 
   v2 = eAttribute + 7 * GetRace();
-  pBaseValue = stru_4ED7B0.race[0].attr[v2].uBaseValue;
-  pDroppedStep = stru_4ED7B0.race[0].attr[v2].uDroppedStep;
+  pBaseValue = StatTable[0][v2].uBaseValue;
+  pDroppedStep = StatTable[0][v2].uDroppedStep;
   uMinValue = pBaseValue - 2;
-  pStep = stru_4ED7B0.race[0].attr[v2].uBaseStep;
+  pStep = StatTable[0][v2].uBaseStep;
     switch ( eAttribute )
     {
       case CHARACTER_MIGHT:
@@ -6705,10 +6695,10 @@
 
   v2 = this;
   v3 = eAttribute + 7 * GetRace();
-  v4 = stru_4ED7B0.race[0].attr[v3].uMaxValue;
-  v5 = stru_4ED7B0.race[0].attr[v3].uBaseStep;
-  v9 = stru_4ED7B0.race[0].attr[v3].uBaseValue;
-  v10 = stru_4ED7B0.race[0].attr[v3].uDroppedStep;
+  v4 = StatTable[0][v3].uMaxValue;
+  v5 = StatTable[0][v3].uBaseStep;
+  v9 = StatTable[0][v3].uBaseValue;
+  v10 = StatTable[0][v3].uDroppedStep;
   PlayerCreation_ComputeAttributeBonus();
   if ( eAttribute )
   {
@@ -6830,47 +6820,34 @@
 //----- (004907E7) --------------------------------------------------------
 __int16 Player::GetStatColor(unsigned int uStat)
 {
-  Player *v2; // edi@1
   __int16 uWhite; // si@1
-//  int uStartingHP; // eax@1
-  int v5; // edx@1
- // unsigned __int8 v6; // zf@1
- // char v7; // sf@1
+  int attribute_value; // edx@1
   unsigned __int8 v8; // of@1
-  __int16 result; // ax@2
   __int16 uGreen; // [sp+8h] [bp-8h]@1
   __int16 uRed; // [sp+Ch] [bp-4h]@1
 
-  v2 = this;
   uRed = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
   uGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
   uWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v8 = stru_4ED7B0.race[GetRace()].attr[uStat].uBaseValue;
-
-  int attribute_value = 0;
+  v8 = StatTable[GetRace()][uStat].uBaseValue;
+
   switch (uStat)
   {
     case 0:  attribute_value = uMight;        break;
     case 1:  attribute_value = uIntelligence; break;
     case 2:  attribute_value = uWillpower;    break;
     case 3:  attribute_value = uEndurance;    break;
-    case 4:  attribute_value = uSpeed;        break;
-    case 5:  attribute_value = uAccuracy;     break;
+    case 4:  attribute_value = uAccuracy;     break;
+    case 5:  attribute_value = uSpeed;        break;
     case 6:  attribute_value = uLuck;         break;
   };
 
-  v5 = attribute_value;
-  if ( v5 >= v8 )
-  {
-    result = uGreen;
-    if ( v5 == v8 )
-      result = uWhite;
-  }
+  if ( attribute_value == v8 )
+    return uWhite;
+  else if ( attribute_value > v8 )
+    return uGreen;
   else
-  {
-    result = uRed;
-  }
-  return result;
+    return uRed;
 }
 
 //----- (004908A8) --------------------------------------------------------