Mercurial > mm7
comparison Player.cpp @ 1538:d6778b04c12a
Player:GetSkillBonus cleanup, minor edits
author | Grumpy7 |
---|---|
date | Sat, 07 Sep 2013 05:06:15 +0200 |
parents | fed56133bf8a |
children | 5cf28ec7322d |
comparison
equal
deleted
inserted
replaced
1537:fed56133bf8a | 1538:d6778b04c12a |
---|---|
4803 return result; | 4803 return result; |
4804 } | 4804 } |
4805 | 4805 |
4806 | 4806 |
4807 //----- (0048FC00) -------------------------------------------------------- | 4807 //----- (0048FC00) -------------------------------------------------------- |
4808 int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) | 4808 int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) //TODO: move the individual implementations to attribute classes once possible |
4809 { | 4809 { |
4810 int armsMasterBonus; | 4810 int armsMasterBonus; |
4811 | 4811 |
4812 armsMasterBonus = 0; | 4812 armsMasterBonus = 0; |
4813 int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); | 4813 int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); |
4826 } | 4826 } |
4827 | 4827 |
4828 switch(inSkill) | 4828 switch(inSkill) |
4829 { | 4829 { |
4830 case CHARACTER_ATTRIBUTE_HEALTH: | 4830 case CHARACTER_ATTRIBUTE_HEALTH: |
4831 { | 4831 int base_value = pBaseHealthPerLevelByClass[classType]; |
4832 int base_value = pBaseHealthPerLevelByClass[classType]; | 4832 int attrib_modif = GetBodybuilding(); |
4833 int attrib_modif = GetBodybuilding(); | 4833 return base_value * attrib_modif; |
4834 return base_value * attrib_modif; | |
4835 } | |
4836 break; | 4834 break; |
4837 case CHARACTER_ATTRIBUTE_MANA: | 4835 case CHARACTER_ATTRIBUTE_MANA: |
4838 { | 4836 int base_value = pBaseManaPerLevelByClass[classType]; |
4839 int base_value = pBaseManaPerLevelByClass[classType]; | 4837 int attrib_modif = GetMeditation(); |
4840 int attrib_modif = GetMeditation(); | 4838 return base_value * attrib_modif; |
4841 return base_value * attrib_modif; | |
4842 } | |
4843 break; | 4839 break; |
4844 case CHARACTER_ATTRIBUTE_AC_BONUS: | 4840 case CHARACTER_ATTRIBUTE_AC_BONUS: |
4845 { | 4841 bool wearingArmor = false; |
4846 bool wearingArmor = false; | 4842 bool wearingLeather = false; |
4847 bool wearingLeather = false; | 4843 unsigned int ACSum = 0; |
4848 unsigned int ACSum = 0; | 4844 |
4849 | 4845 for (int j = 0; j < 16; ++j) |
4850 for (int j = 0; j < 16; ++j) | 4846 { |
4851 { | 4847 if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken())) |
4852 if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken())) | 4848 { |
4849 int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID; | |
4850 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType; | |
4851 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
4852 int multiplier = 0; | |
4853 switch (itemSkillType) | |
4853 { | 4854 { |
4854 int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID; | 4855 case PLAYER_SKILL_STAFF: |
4855 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType; | 4856 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1); |
4856 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | 4857 break; |
4857 int multiplier = 0; | 4858 case PLAYER_SKILL_SWORD: |
4858 switch (itemSkillType) | 4859 case PLAYER_SKILL_SPEAR: |
4860 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1); | |
4861 break; | |
4862 case PLAYER_SKILL_SHIELD: | |
4863 wearingArmor = true; | |
4864 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); | |
4865 break; | |
4866 case PLAYER_SKILL_LEATHER: | |
4867 wearingLeather = true; | |
4868 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); | |
4869 break; | |
4870 case PLAYER_SKILL_CHAIN: | |
4871 wearingArmor = true; | |
4872 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); | |
4873 break; | |
4874 case PLAYER_SKILL_PLATE: | |
4875 wearingArmor = true; | |
4876 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); | |
4877 break; | |
4878 } | |
4879 ACSum += multiplier * (currArmorSkillLevel & 0x3F); | |
4880 } | |
4881 } | |
4882 | |
4883 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); | |
4884 int dodgeMastery = SkillToMastery(dodgeSkillLevel); | |
4885 int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3); | |
4886 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) | |
4887 { | |
4888 ACSum += multiplier * (dodgeSkillLevel & 0x3F); | |
4889 } | |
4890 return ACSum; | |
4891 break; | |
4892 case CHARACTER_ATTRIBUTE_ATTACK: | |
4893 if ( this->IsUnarmed() ) | |
4894 { | |
4895 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4896 if (!unarmedSkill) | |
4897 { | |
4898 return 0; | |
4899 } | |
4900 int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2); | |
4901 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); | |
4902 } | |
4903 for (int i = 0; i < 16; ++i) | |
4904 { | |
4905 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4906 { | |
4907 int currItemIndex = this->pEquipment.pIndices[i] - 1; | |
4908 if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND) | |
4909 { | |
4910 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType; | |
4911 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
4912 if (currItemSkillType == PLAYER_SKILL_BLASTER) | |
4913 { | |
4914 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); | |
4915 return multiplier * (currentItemSkillLevel & 0x3F); | |
4916 } | |
4917 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
4918 { | |
4919 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4920 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2); | |
4921 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); | |
4922 } | |
4923 else | |
4924 { | |
4925 return armsMasterBonus + (currentItemSkillLevel & 0x3F); | |
4926 } | |
4927 } | |
4928 } | |
4929 } | |
4930 return 0; | |
4931 break; | |
4932 | |
4933 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | |
4934 for (int i = 0; i < 16; i++) | |
4935 { | |
4936 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4937 { | |
4938 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType; | |
4939 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); | |
4940 if ( currentItemSkillType == PLAYER_SKILL_BOW ) | |
4941 { | |
4942 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0); | |
4943 return multiplier * (currentItemSkillLevel & 0x3F); | |
4944 } | |
4945 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) | |
4946 { | |
4947 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); | |
4948 return multiplier * (currentItemSkillLevel & 0x3F); | |
4949 } | |
4950 } | |
4951 } | |
4952 return 0; | |
4953 break; | |
4954 | |
4955 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: | |
4956 if ( this->IsUnarmed() ) | |
4957 { | |
4958 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4959 if ( !unarmedSkillLevel ) | |
4960 { | |
4961 return 0; | |
4962 } | |
4963 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); | |
4964 return multiplier * (unarmedSkillLevel & 0x3F); | |
4965 } | |
4966 for (int i = 0; i < 16; i++) | |
4967 { | |
4968 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4969 { | |
4970 int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID; | |
4971 if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND ) | |
4972 { | |
4973 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType; | |
4974 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
4975 int baseSkillBonus; | |
4976 int multiplier; | |
4977 switch (currItemSkillType) | |
4859 { | 4978 { |
4860 case PLAYER_SKILL_STAFF: | 4979 case PLAYER_SKILL_STAFF: |
4861 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1); | 4980 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) |
4862 break; | |
4863 case PLAYER_SKILL_SWORD: | |
4864 case PLAYER_SKILL_SPEAR: | |
4865 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1); | |
4866 break; | |
4867 case PLAYER_SKILL_SHIELD: | |
4868 wearingArmor = true; | |
4869 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); | |
4870 break; | |
4871 case PLAYER_SKILL_LEATHER: | |
4872 wearingLeather = true; | |
4873 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); | |
4874 break; | |
4875 case PLAYER_SKILL_CHAIN: | |
4876 wearingArmor = true; | |
4877 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); | |
4878 break; | |
4879 case PLAYER_SKILL_PLATE: | |
4880 wearingArmor = true; | |
4881 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); | |
4882 break; | |
4883 } | |
4884 ACSum += multiplier * (currArmorSkillLevel & 0x3F); | |
4885 } | |
4886 } | |
4887 | |
4888 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); | |
4889 int dodgeMastery = SkillToMastery(dodgeSkillLevel); | |
4890 int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3); | |
4891 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) | |
4892 { | |
4893 ACSum += multiplier * (dodgeSkillLevel & 0x3F); | |
4894 } | |
4895 return ACSum; | |
4896 } | |
4897 break; | |
4898 case CHARACTER_ATTRIBUTE_ATTACK: | |
4899 { | |
4900 if ( this->IsUnarmed() ) | |
4901 { | |
4902 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4903 if (!unarmedSkill) | |
4904 { | |
4905 return 0; | |
4906 } | |
4907 int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2); | |
4908 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); | |
4909 } | |
4910 for (int i = 0; i < 16; ++i) | |
4911 { | |
4912 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4913 { | |
4914 int currItemIndex = this->pEquipment.pIndices[i] - 1; | |
4915 if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND) | |
4916 { | |
4917 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType; | |
4918 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
4919 if (currItemSkillType == PLAYER_SKILL_BLASTER) | |
4920 { | |
4921 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); | |
4922 return multiplier * (currentItemSkillLevel & 0x3F); | |
4923 } | |
4924 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
4925 { | 4981 { |
4926 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | 4982 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); |
4927 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2); | 4983 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); |
4928 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); | 4984 return multiplier * (unarmedSkillLevel & 0x3F); |
4929 } | 4985 } |
4930 else | 4986 else |
4931 { | 4987 { |
4932 return armsMasterBonus + (currentItemSkillLevel & 0x3F); | 4988 return armsMasterBonus; |
4933 } | 4989 } |
4990 break; | |
4991 | |
4992 case PLAYER_SKILL_DAGGER: | |
4993 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1); | |
4994 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
4995 return armsMasterBonus + baseSkillBonus; | |
4996 break; | |
4997 case PLAYER_SKILL_SWORD: | |
4998 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0); | |
4999 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5000 return armsMasterBonus + baseSkillBonus; | |
5001 break; | |
5002 case PLAYER_SKILL_MACE: | |
5003 case PLAYER_SKILL_SPEAR: | |
5004 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1); | |
5005 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5006 return armsMasterBonus + baseSkillBonus; | |
5007 break; | |
5008 case PLAYER_SKILL_AXE: | |
5009 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1); | |
5010 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5011 return armsMasterBonus + baseSkillBonus; | |
5012 break; | |
4934 } | 5013 } |
4935 } | 5014 } |
4936 } | 5015 } |
4937 return 0; | 5016 } |
4938 } | 5017 return 0; |
4939 break; | 5018 break; |
4940 | |
4941 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | |
4942 { | |
4943 for (int i = 0; i < 16; i++) | |
4944 { | |
4945 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4946 { | |
4947 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType; | |
4948 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); | |
4949 if ( currentItemSkillType == PLAYER_SKILL_BOW ) | |
4950 { | |
4951 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0); | |
4952 return multiplier * (currentItemSkillLevel & 0x3F); | |
4953 } | |
4954 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) | |
4955 { | |
4956 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); | |
4957 return multiplier * (currentItemSkillLevel & 0x3F); | |
4958 } | |
4959 } | |
4960 } | |
4961 return 0; | |
4962 } | |
4963 break; | |
4964 | |
4965 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: | |
4966 { | |
4967 if ( this->IsUnarmed() ) | |
4968 { | |
4969 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4970 if ( !unarmedSkillLevel ) | |
4971 return 0; | |
4972 { | |
4973 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); | |
4974 return multiplier * (unarmedSkillLevel & 0x3F); | |
4975 } | |
4976 } | |
4977 for (int i = 0; i < 16; i++) | |
4978 { | |
4979 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
4980 { | |
4981 int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID; | |
4982 if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND ) | |
4983 { | |
4984 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType; | |
4985 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
4986 int baseSkillBonus; | |
4987 int multiplier; | |
4988 switch (currItemSkillType) | |
4989 { | |
4990 case PLAYER_SKILL_STAFF: | |
4991 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
4992 { | |
4993 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
4994 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); | |
4995 return multiplier * (unarmedSkillLevel & 0x3F); | |
4996 } | |
4997 else | |
4998 { | |
4999 return armsMasterBonus; | |
5000 } | |
5001 break; | |
5002 | |
5003 case PLAYER_SKILL_DAGGER: | |
5004 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1); | |
5005 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5006 return armsMasterBonus + baseSkillBonus; | |
5007 break; | |
5008 case PLAYER_SKILL_SWORD: | |
5009 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0); | |
5010 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5011 return armsMasterBonus + baseSkillBonus; | |
5012 break; | |
5013 case PLAYER_SKILL_MACE: | |
5014 case PLAYER_SKILL_SPEAR: | |
5015 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1); | |
5016 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5017 return armsMasterBonus + baseSkillBonus; | |
5018 break; | |
5019 case PLAYER_SKILL_AXE: | |
5020 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1); | |
5021 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
5022 return armsMasterBonus + baseSkillBonus; | |
5023 break; | |
5024 } | |
5025 } | |
5026 } | |
5027 } | |
5028 return 0; | |
5029 } | |
5030 default: | 5019 default: |
5031 return 0; | 5020 return 0; |
5032 } | 5021 } |
5033 } | 5022 } |
5034 | 5023 |