diff Player.cpp @ 353:95be2dcecadf

Partial refactor for Player::GetActualSkillLevel
author Nomad
date Thu, 21 Feb 2013 03:49:33 +0200
parents ec6cc5cefa4b
children 7f5538ed7875
line wrap: on
line diff
--- a/Player.cpp	Thu Feb 21 03:06:13 2013 +0200
+++ b/Player.cpp	Thu Feb 21 03:49:33 2013 +0200
@@ -5643,260 +5643,238 @@
 }
 
 //----- (0048F882) --------------------------------------------------------
-char Player::GetActualSkillLevel(enum PLAYER_SKILL_TYPE uSkillType)
+char Player::GetActualSkillLevel(PLAYER_SKILL_TYPE uSkillType)
 {
   signed int v2; // esi@1
   unsigned __int16 v3; // ax@126
   char result; // al@127
   unsigned int v5; // [sp-4h] [bp-14h]@13
   signed int v6; // [sp-4h] [bp-14h]@27
-  unsigned int v7; // [sp-4h] [bp-14h]@35
+  //unsigned int v7; // [sp-4h] [bp-14h]@35
   CHARACTER_ATTRIBUTE_TYPE v8; // [sp-4h] [bp-14h]@68
-  Player *v9; // [sp+Ch] [bp-4h]@1
-
+  //Player *v9; // [sp+Ch] [bp-4h]@1
+  
   v2 = 0;
-  v9 = this;
-  if ( uSkillType > PLAYER_SKILL_DODGE )
-  {
-    if ( uSkillType != PLAYER_SKILL_UNARMED )
-    {
-      if ( uSkillType == PLAYER_SKILL_MONSTER_ID )
-      {
-        if ( CheckHiredNPCSpeciality(0x3Au) )
-          v2 = 6;
-        if ( CheckHiredNPCSpeciality(0x39u) )
-          v2 += 6;
-        goto LABEL_83;
-      }
-      if ( uSkillType == PLAYER_SKILL_ARMSMASTER )
-      {
-        if ( CheckHiredNPCSpeciality(0xFu) )
+  switch (uSkillType)
+  {
+    case PLAYER_SKILL_MONSTER_ID:
+    {
+      if ( CheckHiredNPCSpeciality(58) )
+        v2 = 6;
+      if ( CheckHiredNPCSpeciality(57) )
+        v2 += 6;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)20;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_ARMSMASTER:
+    {
+        if ( CheckHiredNPCSpeciality(15) )
           v2 = 2;
-        if ( CheckHiredNPCSpeciality(0x10u) )
-          v2 += 3;
-        goto LABEL_64;
-      }
-      if ( uSkillType == PLAYER_SKILL_STEALING )
-      {
-        if ( CheckHiredNPCSpeciality(0x33u) )
-          v2 = 8;
-        goto LABEL_64;
-      }
-      if ( uSkillType == PLAYER_SKILL_ALCHEMY )
-      {
-        if ( CheckHiredNPCSpeciality(0x17u) )
-          v2 = 4;
-        if ( CheckHiredNPCSpeciality(0x18u) )
-          v2 += 8;
-        goto LABEL_64;
-      }
-      if ( uSkillType == 36 )                   // learning
-      {
-        if ( CheckHiredNPCSpeciality(0xDu) )
-          v2 = 10;
-        if ( CheckHiredNPCSpeciality(0xEu) )
-          v2 += 15;
-        if ( CheckHiredNPCSpeciality(4u) )
-          v2 += 5;
-        goto LABEL_64;
-      }
-      goto LABEL_86;
-    }
-    if ( !CheckHiredNPCSpeciality(0x38u) )
-      goto LABEL_112;
-LABEL_85:
-    v2 = 2;
-    goto LABEL_86;
-  }
-  if ( uSkillType == PLAYER_SKILL_DODGE )
-  {
-    if ( !CheckHiredNPCSpeciality(0x38u) )
-      goto LABEL_112;
-    v6 = 2;
-    goto LABEL_51;
-  }
-  if ( uSkillType <= PLAYER_SKILL_ITEM_ID )
-  {
-    if ( uSkillType != PLAYER_SKILL_ITEM_ID )
-    {
-      if ( (signed int)uSkillType < 0 )
-        goto LABEL_86;
-      if ( uSkillType > PLAYER_SKILL_PLATE )
-      {
-        if ( uSkillType <= PLAYER_SKILL_EARTH )
-        {
-          if ( CheckHiredNPCSpeciality(0x11u) )
-            v2 = 2;
-          if ( CheckHiredNPCSpeciality(0x12u) )
-            v2 += 3;
-          v5 = 19;
-        }
-        else
-        {
-          if ( uSkillType > PLAYER_SKILL_BODY )
-            goto LABEL_86;
-          if ( CheckHiredNPCSpeciality(0x35u) )
-            v2 = 2;
-          if ( CheckHiredNPCSpeciality(0x36u) )
-            v2 += 3;
-          v5 = 55;
-        }
-        if ( CheckHiredNPCSpeciality(v5) )
-          v2 += 4;
-        if ( v9->classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
+        if ( CheckHiredNPCSpeciality(16) )
           v2 += 3;
-LABEL_86:
-        if ( uSkillType <= PLAYER_SKILL_DARK )
-        {
-          if ( uSkillType == PLAYER_SKILL_DARK )
-          {
-            v8 = (CHARACTER_ATTRIBUTE_TYPE)42;
-          }
-          else
-          {
-            if ( uSkillType > PLAYER_SKILL_EARTH )
-            {
-              switch ( uSkillType )
-              {
-                case 16:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)38;
-                  break;
-                case 17:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)39;
-                  break;
-                case 18:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)40;
-                  break;
-                default:
-                  if ( uSkillType != 19 )
-                    goto LABEL_126;
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)41;
-                  break;
-              }
-            }
-            else
-            {
-              switch ( uSkillType )
-              {
-                case PLAYER_SKILL_EARTH:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)37;
-                  break;
-                case PLAYER_SKILL_BOW:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)44;
-                  break;
-                case PLAYER_SKILL_SHIELD:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)45;
-                  break;
-                case PLAYER_SKILL_FIRE:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)34;
-                  break;
-                case PLAYER_SKILL_AIR:
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)35;
-                  break;
-                default:
-                  if ( uSkillType != 14 )
-                    goto LABEL_126;
-                  v8 = (CHARACTER_ATTRIBUTE_TYPE)36;
-                  break;
-              }
-            }
-          }
-          goto LABEL_125;
-        }
-        if ( uSkillType <= PLAYER_SKILL_MONSTER_ID )
-        {
-          if ( uSkillType != PLAYER_SKILL_MONSTER_ID )
-            goto LABEL_112;
-LABEL_83:
-          v8 = (CHARACTER_ATTRIBUTE_TYPE)20;
-          goto LABEL_125;
-        }
-LABEL_64:
-        switch ( uSkillType )
-        {
-          case PLAYER_SKILL_ARMSMASTER:
-            v8 = (CHARACTER_ATTRIBUTE_TYPE)21;
-            break;
-          case PLAYER_SKILL_STEALING:
-            v8 = (CHARACTER_ATTRIBUTE_TYPE)17;
-            break;
-          case PLAYER_SKILL_ALCHEMY:
-            v8 = (CHARACTER_ATTRIBUTE_TYPE)16;
-            break;
-          default:
-            if ( uSkillType != 36 )
-              goto LABEL_126;
-            v8 = (CHARACTER_ATTRIBUTE_TYPE)46;
-            break;
-        }
-        goto LABEL_125;
-      }
-      if ( !CheckHiredNPCSpeciality(0x2Eu) )
-        goto LABEL_86;
-      goto LABEL_85;
-    }
-    if ( !CheckHiredNPCSpeciality(0x39u) )
-      goto LABEL_112;
-    v6 = 6;
-LABEL_51:
-    v2 = v6;
-    goto LABEL_112;
-  }
-  if ( uSkillType == PLAYER_SKILL_MERCHANT )
-  {
-    if ( CheckHiredNPCSpeciality(0x14u) )
-      v2 = 4;
-    if ( CheckHiredNPCSpeciality(0x15u) )
-      v2 += 6;
-    if ( CheckHiredNPCSpeciality(0x30u) )
-      v2 += 3;
-    v7 = 50;
-LABEL_47:
-    if ( CheckHiredNPCSpeciality(v7) )
-      v2 += 8;
-    goto LABEL_112;
-  }
-  if ( uSkillType != PLAYER_SKILL_PERCEPTION )
-  {
-    if ( uSkillType != PLAYER_SKILL_TRAP_DISARM )
-      goto LABEL_86;
-    if ( CheckHiredNPCSpeciality(0x19u) )
-      v2 = 4;
-    if ( CheckHiredNPCSpeciality(0x1Au) )
-      v2 += 6;
-    v7 = 51;
-    goto LABEL_47;
-  }
-  if ( CheckHiredNPCSpeciality(0x16u) )
-    v2 = 6;
-  if ( CheckHiredNPCSpeciality(0x2Fu) )
-    v2 += 5;
-LABEL_112:
-  switch ( uSkillType )
-  {
+        v8 = (CHARACTER_ATTRIBUTE_TYPE)21;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_STEALING:
+    {
+      if (CheckHiredNPCSpeciality(51))
+          v2 = 8;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)17;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+
+    case PLAYER_SKILL_ALCHEMY:
+    {
+        if ( CheckHiredNPCSpeciality(23) )
+          v2 = 4;
+        if ( CheckHiredNPCSpeciality(24) )
+          v2 += 8;
+        v8 = (CHARACTER_ATTRIBUTE_TYPE)16;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_LEARNING:
+    {
+        if ( CheckHiredNPCSpeciality(13) )
+          v2 = 10;
+        if ( CheckHiredNPCSpeciality(14) )
+          v2 += 15;
+        if ( CheckHiredNPCSpeciality(4) )
+          v2 += 5;
+        v8 = (CHARACTER_ATTRIBUTE_TYPE)46;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_UNARMED:
+    {
+      if (CheckHiredNPCSpeciality(56) )
+        v2 = 2;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)23;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_DODGE:
+    {
+      if ( CheckHiredNPCSpeciality(56) )
+        v2 = 2;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)22;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+    
+    case PLAYER_SKILL_BOW:
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)44;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_SHIELD:
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)45;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+
+    case PLAYER_SKILL_EARTH:
+      if ( CheckHiredNPCSpeciality(17) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(18) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(19) )
+            v2 += 4;
+          if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
+            v2 += 3;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)37;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_FIRE:
+      if ( CheckHiredNPCSpeciality(17) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(18) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(19) )
+            v2 += 4;
+          if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
+            v2 += 3;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)34;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_AIR:
+      if ( CheckHiredNPCSpeciality(17) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(18) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(19) )
+            v2 += 4;
+          if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
+            v2 += 3;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)35;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_WATER:
+      if ( CheckHiredNPCSpeciality(17) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(18) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(19) )
+            v2 += 4;
+          if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
+            v2 += 3;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)36;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_SPIRIT:
+          if ( CheckHiredNPCSpeciality(53) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(54) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(55) )
+            v2 += 4;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)38;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_MIND:
+          if ( CheckHiredNPCSpeciality(53) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(54) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(55) )
+            v2 += 4;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)39;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_BODY:
+          if ( CheckHiredNPCSpeciality(53) )
+            v2 = 2;
+          if ( CheckHiredNPCSpeciality(54) )
+            v2 += 3;
+          if ( CheckHiredNPCSpeciality(55) )
+            v2 += 4;
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)40;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_LIGHT:
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)41;
+      v2 += GetItemsBonus(v8, 0);
+    break;
+    case PLAYER_SKILL_DARK:
+    {
+      v8 = (CHARACTER_ATTRIBUTE_TYPE)42;
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+
+    case PLAYER_SKILL_MERCHANT:
+    {
+        if ( CheckHiredNPCSpeciality(20) )
+          v2 = 4;
+        if ( CheckHiredNPCSpeciality(21) )
+          v2 += 6;
+        if ( CheckHiredNPCSpeciality(48) )
+          v2 += 3;
+        if ( CheckHiredNPCSpeciality(50) )
+          v2 += 8;
+    }
+    break;
+
+    case PLAYER_SKILL_PERCEPTION:
+    {
+      if ( CheckHiredNPCSpeciality(22) )
+        v2 = 6;
+      if ( CheckHiredNPCSpeciality(47) )
+        v2 += 5;
+    }
+    break;
+
     case PLAYER_SKILL_ITEM_ID:
       v8 = (CHARACTER_ATTRIBUTE_TYPE)19;
+      v2 += GetItemsBonus(v8, 0);
       break;
     case PLAYER_SKILL_MEDITATION:
       v8 = (CHARACTER_ATTRIBUTE_TYPE)43;
-      break;
+      v2 += GetItemsBonus(v8, 0);
+    break;
     case PLAYER_SKILL_TRAP_DISARM:
+    {
+      if ( CheckHiredNPCSpeciality(25) )
+        v2 = 4;
+      if ( CheckHiredNPCSpeciality(26) )
+        v2 += 6;
+      if ( CheckHiredNPCSpeciality(51) )
+        v2 += 8;
       v8 = (CHARACTER_ATTRIBUTE_TYPE)18;
-      break;
-    case PLAYER_SKILL_DODGE:
-      v8 = (CHARACTER_ATTRIBUTE_TYPE)22;
-      break;
-    default:
-      if ( uSkillType != 31 )
-        goto LABEL_126;
-      v8 = (CHARACTER_ATTRIBUTE_TYPE)23;
-      break;
-  }
-LABEL_125:
-  v2 += v9->GetItemsBonus(v8, 0);
-LABEL_126:
-  v3 = v9->pActiveSkills[uSkillType];
-  if ( v2 + (v9->pActiveSkills[uSkillType] & 0x3F) < 60 )
+      v2 += GetItemsBonus(v8, 0);
+    }
+    break;
+  }
+
+  v3 = pActiveSkills[uSkillType];
+  if ( v2 + (pActiveSkills[uSkillType] & 0x3F) < 60 )
     result = v2 + v3;
   else
     result = v3 & 0xFC | 0x3C;