Mercurial > mm7
diff Player.cpp @ 1325:d9e4c0bbb2d2
GetActual(stat) common code extracted
author | Grumpy7 |
---|---|
date | Tue, 02 Jul 2013 01:15:03 +0200 |
parents | 78f0f74eab1d |
children | 1e35cfed7928 1434b36f4bdb |
line wrap: on
line diff
--- a/Player.cpp Tue Jul 02 00:39:26 2013 +0200 +++ b/Player.cpp Tue Jul 02 01:15:03 2013 +0200 @@ -91,21 +91,23 @@ unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6}; -unsigned char pConditionStrengthMultiplier[19] = {100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; -unsigned char pConditionIntelligenceMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; -unsigned char pConditionWillpowerMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; -unsigned char pConditionEnduranceMultiplier[19] = {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; -unsigned char pConditionAccuracyMultiplier[19] = {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; -unsigned char pConditionSpeedMultiplier[19] = {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; -unsigned char pConditionLuckMultiplier[19] = {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; - -unsigned char pAgeingStrengthMultiplier[4] = {100, 75, 40, 10}; -unsigned char pAgeingIntelligenceMultiplier[4] = {100, 150, 100, 10}; -unsigned char pAgeingWillpowerMultiplier[4] = {100, 150, 100, 10}; -unsigned char pAgeingEnduranceMultiplier[4] = {100, 75, 40, 10}; -unsigned char pAgeingAccuracyMultiplier[4] = {100, 100, 40, 10}; -unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10}; -unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100}; +unsigned char pConditionAttributeModifier[7][19] = +{{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might + {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence + {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower + {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance + {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy + {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed + {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck + +unsigned char pAgingAttributeModifier[7][4] = +{{100, 75, 40, 10}, //Might + {100, 150, 100, 10}, //Intelligence + {100, 150, 100, 10}, //Willpower + {100, 75, 40, 10}, //Endurance + {100, 100, 40, 10}, //Accuracy + {100, 100, 40, 10}, //Speed + {100, 100, 100, 100}}; //Luck signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; @@ -422,11 +424,11 @@ { return 1; } - else if (GetMajorConditionIdx() == 18) + else if (GetMajorConditionIdx() == Condition_Good) { return 0; } - else if (GetMajorConditionIdx() == 17 && (v2 == 78 || v2 > 80) && v2 <= 82) + else if (GetMajorConditionIdx() == Condition_Zombie && (v2 == 78 || v2 == 81 || v2 == 82)) { return 0; } @@ -2402,104 +2404,37 @@ //----- (0048C93C) -------------------------------------------------------- int Player::GetActualMight() { - 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; + return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH); } //----- (0048C9C2) -------------------------------------------------------- int Player::GetActualIntelligence() { - 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) - + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0) - + uIntelligenceBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE); } //----- (0048CA3F) -------------------------------------------------------- int Player::GetActualWillpower() { - uint uActualAge = GetBaseAge() + sAgeModifier; - uint uAgeingMultiplier = 100; - for (uint i = 0; i < 4; ++i) - if (uActualAge >= pAgeingTable[i]) - uAgeingMultiplier = pAgeingWillpowerMultiplier[i]; - else break; - - auto uConditionMult = pConditionWillpowerMultiplier[GetMajorConditionIdx()]; - return uConditionMult * uAgeingMultiplier * uWillpower / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_WILLPOWER) - + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER, 0) - + uWillpowerBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER); } //----- (0048CABC) -------------------------------------------------------- int Player::GetActualEndurance() { - uint uActualAge = GetBaseAge() + sAgeModifier; - uint uAgeingMultiplier = 100; - for (uint i = 0; i < 4; ++i) - if (uActualAge >= pAgeingTable[i]) - uAgeingMultiplier = pAgeingEnduranceMultiplier[i]; - else break; - - auto uConditionMult = pConditionEnduranceMultiplier[GetMajorConditionIdx()]; - return uConditionMult * uAgeingMultiplier * uEndurance / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_ENDURANCE) - + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) - + uEnduranceBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE); } //----- (0048CB39) -------------------------------------------------------- int Player::GetActualAccuracy() { - - 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) - + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0) - + uAccuracyBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY); } //----- (0048CBB6) -------------------------------------------------------- int Player::GetActualSpeed() { - 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) - + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0) - + uSpeedBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED); } //----- (0048CC33) -------------------------------------------------------- @@ -2515,19 +2450,66 @@ if ( CheckHiredNPCSpeciality(Psychic) ) npc_luck_bonus += 10; + return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK) + + npc_luck_bonus; +} + +//----- (new function) -------------------------------------------------------- +int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId ) +{ + unsigned __int16 attrValue = 0; + unsigned __int16 attrBonus = 0; + switch (attrId) + { + case CHARACTER_ATTRIBUTE_STRENGTH: + attrValue = uMight; + attrBonus = uMightBonus; + break; + case CHARACTER_ATTRIBUTE_INTELLIGENCE: + attrValue = uIntelligence; + attrBonus = uIntelligenceBonus; + break; + case CHARACTER_ATTRIBUTE_WILLPOWER: + attrValue = uWillpower; + attrBonus = uWillpowerBonus; + break; + case CHARACTER_ATTRIBUTE_ENDURANCE: + attrValue = uEndurance; + attrBonus = uEnduranceBonus; + break; + case CHARACTER_ATTRIBUTE_ACCURACY: + attrValue = uAccuracy; + attrBonus = uAccuracyBonus; + break; + case CHARACTER_ATTRIBUTE_SPEED: + attrValue = uSpeed; + attrBonus = uSpeedBonus; + break; + case CHARACTER_ATTRIBUTE_LUCK: + attrValue = uLuck; + attrBonus = uLuckBonus; + break; + default: + return 0; + } + 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; + uAgeingMultiplier = pAgingAttributeModifier[attrId][i]; + else + break; + } + + auto uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()]; + int magicBonus = GetMagicalBonus(attrId); + int itemBonus = GetItemsBonus(attrId, 0); + return uConditionMult * uAgeingMultiplier * attrValue / 100 / 100 + + magicBonus + + magicBonus + + attrBonus; } //----- (0048CCF5) --------------------------------------------------------