changeset 1538:d6778b04c12a

Player:GetSkillBonus cleanup, minor edits
author Grumpy7
date Sat, 07 Sep 2013 05:06:15 +0200
parents fed56133bf8a
children 5cf28ec7322d
files Player.cpp
diffstat 1 files changed, 172 insertions(+), 183 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Sat Sep 07 05:01:12 2013 +0200
+++ b/Player.cpp	Sat Sep 07 05:06:15 2013 +0200
@@ -4805,7 +4805,7 @@
 
 
 //----- (0048FC00) --------------------------------------------------------
-int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill)
+int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill)    //TODO: move the individual implementations to attribute classes once possible
 {
   int armsMasterBonus;
 
@@ -4828,205 +4828,194 @@
   switch(inSkill)
   {
   case CHARACTER_ATTRIBUTE_HEALTH:
-    {
-      int base_value = pBaseHealthPerLevelByClass[classType];
-      int attrib_modif = GetBodybuilding();
-      return base_value * attrib_modif;
-    }
+    int base_value = pBaseHealthPerLevelByClass[classType];
+    int attrib_modif = GetBodybuilding();
+    return base_value * attrib_modif;
     break;
   case CHARACTER_ATTRIBUTE_MANA:
-    {
-      int base_value = pBaseManaPerLevelByClass[classType];
-      int attrib_modif = GetMeditation();
-      return base_value * attrib_modif;
-    }
+    int base_value = pBaseManaPerLevelByClass[classType];
+    int attrib_modif = GetMeditation();
+    return base_value * attrib_modif;
     break;
   case CHARACTER_ATTRIBUTE_AC_BONUS:
-    {
-      bool wearingArmor = false;
-      bool wearingLeather = false;
-      unsigned int ACSum = 0;
-
-      for (int j = 0; j < 16; ++j) 
-      {
-        if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken()))
+    bool wearingArmor = false;
+    bool wearingLeather = false;
+    unsigned int ACSum = 0;
+
+    for (int j = 0; j < 16; ++j) 
+    {
+      if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken()))
+      {
+        int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID;
+        PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType;
+        int currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
+        int multiplier = 0;
+        switch (itemSkillType)
+        {
+        case PLAYER_SKILL_STAFF:
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1);
+          break;
+        case PLAYER_SKILL_SWORD:
+        case PLAYER_SKILL_SPEAR:
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1);
+          break;
+        case PLAYER_SKILL_SHIELD:
+          wearingArmor = true;
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2);
+          break;
+        case PLAYER_SKILL_LEATHER:
+          wearingLeather = true;
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2);
+          break;
+        case PLAYER_SKILL_CHAIN:
+          wearingArmor = true;
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1);
+          break;
+        case PLAYER_SKILL_PLATE:
+          wearingArmor = true; 
+          multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1);
+          break;
+        }
+        ACSum += multiplier * (currArmorSkillLevel & 0x3F);
+      }
+    }
+
+    int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
+    int dodgeMastery = SkillToMastery(dodgeSkillLevel);
+    int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3);
+    if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) )
+    {
+      ACSum += multiplier * (dodgeSkillLevel & 0x3F);
+    }
+    return ACSum;
+    break;
+  case CHARACTER_ATTRIBUTE_ATTACK:
+    if ( this->IsUnarmed() )
+    {
+      int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+      if (!unarmedSkill)
+      {
+        return 0;
+      }
+      int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2);
+      return armsMasterBonus + multiplier * (unarmedSkill & 0x3F);
+    }
+    for (int i = 0; i < 16; ++i)
+    {
+      if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
+      {
+        int currItemIndex = this->pEquipment.pIndices[i] - 1;
+        if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND)
         {
-          int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID;
-          PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType;
-          int currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
-          int multiplier = 0;
-          switch (itemSkillType)
+          PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType;
+          int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
+          if (currItemSkillType == PLAYER_SKILL_BLASTER)
+          {
+            int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5);
+            return multiplier * (currentItemSkillLevel & 0x3F);
+          }
+          else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
+          {
+            int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+            int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2);
+            return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F);
+          }
+          else
+          {
+            return armsMasterBonus + (currentItemSkillLevel & 0x3F);
+          }
+        }
+      }
+    }
+    return 0;
+    break;
+
+  case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
+    for (int i = 0; i < 16; i++)
+    {
+      if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
+      {
+        PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType;
+        int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType);
+        if ( currentItemSkillType == PLAYER_SKILL_BOW )
+        {
+          int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0);
+          return multiplier * (currentItemSkillLevel & 0x3F);
+        }
+        else if ( currentItemSkillType == PLAYER_SKILL_BLASTER )
+        {      
+          int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5);
+          return multiplier * (currentItemSkillLevel & 0x3F);
+        }
+      }
+    }
+    return 0;
+    break;
+
+  case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
+    if ( this->IsUnarmed() )
+    {
+      int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+      if ( !unarmedSkillLevel )
+      {
+        return 0;
+      }
+      int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2);
+      return multiplier * (unarmedSkillLevel & 0x3F);
+    }
+    for (int i = 0; i < 16; i++)
+    {
+      if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
+      {
+        int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID;
+        if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND )
+        {
+          PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType;
+          int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
+          int baseSkillBonus;
+          int multiplier;
+          switch (currItemSkillType)
           {
           case PLAYER_SKILL_STAFF:
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1);
-            break;
-          case PLAYER_SKILL_SWORD:
-          case PLAYER_SKILL_SPEAR:
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1);
-            break;
-          case PLAYER_SKILL_SHIELD:
-            wearingArmor = true;
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2);
-            break;
-          case PLAYER_SKILL_LEATHER:
-            wearingLeather = true;
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2);
-            break;
-          case PLAYER_SKILL_CHAIN:
-            wearingArmor = true;
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1);
-            break;
-          case PLAYER_SKILL_PLATE:
-            wearingArmor = true; 
-            multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1);
-            break;
-          }
-          ACSum += multiplier * (currArmorSkillLevel & 0x3F);
-        }
-      }
-
-      int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
-      int dodgeMastery = SkillToMastery(dodgeSkillLevel);
-      int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3);
-      if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) )
-      {
-        ACSum += multiplier * (dodgeSkillLevel & 0x3F);
-      }
-      return ACSum;
-    }
-    break;
-  case CHARACTER_ATTRIBUTE_ATTACK:
-    {
-      if ( this->IsUnarmed() )
-      {
-        int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-        if (!unarmedSkill)
-        {
-          return 0;
-        }
-        int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2);
-        return armsMasterBonus + multiplier * (unarmedSkill & 0x3F);
-      }
-      for (int i = 0; i < 16; ++i)
-      {
-        if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
-        {
-          int currItemIndex = this->pEquipment.pIndices[i] - 1;
-          if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND)
-          {
-            PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType;
-            int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
-            if (currItemSkillType == PLAYER_SKILL_BLASTER)
-            {
-              int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5);
-              return multiplier * (currentItemSkillLevel & 0x3F);
-            }
-            else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
+            if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
             {
               int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-              int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2);
-              return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F);
+              int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2);
+              return multiplier * (unarmedSkillLevel & 0x3F);
             }
             else
             {
-              return armsMasterBonus + (currentItemSkillLevel & 0x3F);
+              return armsMasterBonus;
             }
-          }
-        }
-      }
-      return 0;
-    }
-    break;
-
-  case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
-    {
-      for (int i = 0; i < 16; i++)
-      {
-        if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
-        {
-          PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType;
-          int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType);
-          if ( currentItemSkillType == PLAYER_SKILL_BOW )
-          {
-            int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0);
-            return multiplier * (currentItemSkillLevel & 0x3F);
-          }
-          else if ( currentItemSkillType == PLAYER_SKILL_BLASTER )
-          {      
-            int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5);
-            return multiplier * (currentItemSkillLevel & 0x3F);
+            break;
+
+          case PLAYER_SKILL_DAGGER:
+            multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1);
+            baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
+            return armsMasterBonus + baseSkillBonus;
+            break;
+          case PLAYER_SKILL_SWORD:
+            multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0);
+            baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
+            return armsMasterBonus + baseSkillBonus;
+            break;
+          case PLAYER_SKILL_MACE:
+          case PLAYER_SKILL_SPEAR:
+            multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1);
+            baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
+            return armsMasterBonus + baseSkillBonus;
+            break;
+          case PLAYER_SKILL_AXE:
+            multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1);
+            baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
+            return armsMasterBonus + baseSkillBonus;
+            break;
           }
         }
       }
-      return 0;
-    }
+    }
+    return 0;
     break;
-
-  case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
-    {
-      if ( this->IsUnarmed() )
-      {
-        int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-        if ( !unarmedSkillLevel )
-          return 0;
-        {
-          int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2);
-          return multiplier * (unarmedSkillLevel & 0x3F);
-        }
-      }
-      for (int i = 0; i < 16; i++)
-      {
-        if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
-        {
-          int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID;
-          if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND )
-          {
-            PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType;
-            int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
-            int baseSkillBonus;
-            int multiplier;
-            switch (currItemSkillType)
-            {
-            case PLAYER_SKILL_STAFF:
-              if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
-              {
-                int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-                int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2);
-                return multiplier * (unarmedSkillLevel & 0x3F);
-              }
-              else
-              {
-                return armsMasterBonus;
-              }
-              break;
-
-            case PLAYER_SKILL_DAGGER:
-              multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1);
-              baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
-              return armsMasterBonus + baseSkillBonus;
-              break;
-            case PLAYER_SKILL_SWORD:
-              multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0);
-              baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
-              return armsMasterBonus + baseSkillBonus;
-              break;
-            case PLAYER_SKILL_MACE:
-            case PLAYER_SKILL_SPEAR:
-              multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1);
-              baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
-              return armsMasterBonus + baseSkillBonus;
-              break;
-            case PLAYER_SKILL_AXE:
-              multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1);
-              baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
-              return armsMasterBonus + baseSkillBonus;
-              break;
-            }
-          }
-        }
-      }
-      return 0;
-    }
   default:
     return 0;
   }