Mercurial > mm7
changeset 1601:5ac59bcb68e9
started extracting enchantment effects to a helper class
author | Grumpy7 |
---|---|
date | Thu, 12 Sep 2013 09:53:41 +0200 |
parents | 0016b08ab621 |
children | 96a1f5e0b6cd |
files | Player.cpp Player.h |
diffstat | 2 files changed, 380 insertions(+), 437 deletions(-) [+] |
line wrap: on
line diff
--- a/Player.cpp Wed Sep 11 04:27:36 2013 +0200 +++ b/Player.cpp Thu Sep 12 09:53:41 2013 +0200 @@ -156,7 +156,328 @@ 30 // PLAYER_SKILL_PLATE }; - +#include <map> +#include <list> + +typedef struct CEnchantment +{ + CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = NULL): + statBonus(bonus), + statPtr(skillPtr) + { + } + int statBonus; + unsigned __int16 Player::* statPtr; +} CEnchantment; + +#define NEWBONUSINTOSPECIALLIST(x,y) AddToMap(specialBonusMap, enchId, x, y); +#define NEWBONUSINTOSPECIALLIST2(x,y,z) AddToMap(specialBonusMap, enchId, x, y, z); + +#define NEWBONUSINTOREGULARLIST(x) AddToMap(regularBonusMap, enchId, x); + +#define NEWBONUSINTOARTIFACTLIST(x,y) AddToMap(artifactBonusMap, enchId, x, y); +#define NEWBONUSINTOARTIFACTLIST2(x,y,z) AddToMap(artifactBonusMap, enchId, x, y, z); + +std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > regularBonusMap; +std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > specialBonusMap; +std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > artifactBonusMap; +//------------------------------------------------------------------------- + +void AddToMap(std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > &maptoadd, + int enchId, + CHARACTER_ATTRIBUTE_TYPE attrId, + int bonusValue = 0, + unsigned __int16 Player::* skillPtr = NULL) +{ + auto key = maptoadd.find(enchId); + std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currMap; + if (key == maptoadd.end()) + { + currMap = new std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>; + maptoadd[enchId] = currMap; + } + else + { + currMap = key->second; + } + Assert(currMap->find(attrId) == currMap->end(), "Attribute %d already present for enchantment %d", attrId, enchId); + (*currMap)[attrId] = new CEnchantment(bonusValue, skillPtr); +} +//------------------------------------------------------------------------- + +void PopulateSpecialBonusMap() +{ + int enchId = 1;// of Protection, +10 to all Resistances + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 10); + NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_AIR, 10); + NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_WATER, 10); + NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_EARTH, 10); + NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_MIND, 10); + NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_BODY, 10); + + enchId = 2;//of The Gods, +10 to all Seven Statistics + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10); + + enchId = 26;//of Air Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_AIR,0, &Player::skillAir); + + enchId = 27;//of Body Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY,0, &Player::skillBody); + + enchId = 28;//of Dark Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK,0, &Player::skillDark); + + enchId = 29;//of Earth Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_EARTH,0, &Player::skillEarth); + + enchId = 30;//of Fire Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE,0, &Player::skillFire); + + enchId = 31;//of Light Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT,0, &Player::skillLight); + + enchId = 32;//of Mind Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND,0, &Player::skillMind); + + enchId = 33;//of Spirit Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT,0, &Player::skillSpirit); + + enchId = 34;//of Water Magic + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER,0, &Player::skillWater); + + enchId = 42;//of Doom + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, 1); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, 1); + + enchId = 43;//of Earth + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10); + + enchId = 44;//of Life + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10); + + enchId = 45;//Rogues + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 5); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 5); + + enchId = 46;//of The Dragon + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 25); + + enchId = 47;//of The Eclipse + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10); + + enchId = 48;//of The Golem + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5); + + enchId = 49;//of The Moon + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10); + + enchId = 50;//of The Phoenix + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 30); + + enchId = 51;//of The Sky + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); + + enchId = 52;//of The Stars + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10); + + enchId = 53;//of The Sun + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10); + + enchId = 54;//of The Troll + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15); + + enchId = 55;//of The Unicorn + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 15); + + enchId = 56;//Warriors + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 5); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 5); + + enchId = 57;//Wizards + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 5); + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 5); + + enchId = 60;//Monks' + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DODGE, 3, &Player::skillDodge); + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 3, &Player::skillUnarmed); + + enchId = 61;//Thieves' + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 3, &Player::skillStealing); + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_STEALING, 3, &Player::skillDisarmTrap); + + enchId = 62;//of Identifying + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 3, &Player::skillItemId); + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 3, &Player::skillMonsterId); + + enchId = 67;//Assassins' + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 2, &Player::skillDisarmTrap); + + enchId = 68;//Barbarians' + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5); + + enchId = 69;//of the Storm + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 20); + + enchId = 70;//of the Ocean + NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 10); + NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 2, &Player::skillAlchemy); +} +//------------------------------------------------------------------------- + +void PopulateRegularBonusMap() +{ + int enchId = 1;//of Might + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_STRENGTH); + + enchId = 2;//of Thought + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE); + + enchId = 3;//of Charm + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_WILLPOWER); + + enchId = 4;//of Vigor + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ENDURANCE); + + enchId = 5;//of Precision + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ACCURACY); + + enchId = 6;//of Speed + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SPEED); + + enchId = 7;//of Luck + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_LUCK); + + enchId = 8;//of Health + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_HEALTH); + + enchId = 9;//of Magic + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_MANA); + + enchId = 10;//of Defense + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_AC_BONUS); + + enchId = 11;//of Fire Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE); + + enchId = 12;//of Air Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_AIR); + + enchId = 13;//of Water Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_WATER); + + enchId = 14;//of Earth Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH); + + enchId = 15;//of Mind Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_MIND); + + enchId = 16;//of Body Resistance + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_BODY); + + enchId = 17;//of Alchemy + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY); + + enchId = 18;//of Stealing + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_STEALING); + + enchId = 19;//of Disarming + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM); + + enchId = 20;//of Items + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID); + + enchId = 21;//of Monsters + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID); + + enchId = 22;//of Arms + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER); + + enchId = 23;//of Dodging + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_DODGE); + + enchId = 24;//of the Fist + NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_UNARMED); +} + +//------------------------------------------------------------------------- +void PopulateArtifactBonusMap() +{ + int enchId = 1;//of Might + NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 5); +} +//------------------------------------------------------------------------- + +void Player::GetItemBonusSpecialEnchantment(int enchantmentId, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus) +{ + auto bonusList = specialBonusMap.find(enchantmentId); + if (bonusList == specialBonusMap.end()) + { + return; + } + std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second; + if (currList->find(attrToGet) != currList->end()) + { + CEnchantment* currBonus = (*currList)[attrToGet]; + if (currBonus->statPtr != NULL) + { + if (currBonus->statBonus == 0) + { + *halfSkillBonus = this->*currBonus->statPtr / 2; + } + else + { + if (*additiveBonus < currBonus->statBonus) + { + *additiveBonus = currBonus->statBonus; + } + } + } + else + { + *additiveBonus += currBonus->statBonus; + } + } +} + +//------------------------------------------------------------------------- +bool IsRegularEnchanmentForAttribute(int enchantmentId, CHARACTER_ATTRIBUTE_TYPE attrToGet) +{ + auto bonusList = specialBonusMap.find(enchantmentId); + if (bonusList == specialBonusMap.end()) + { + return false; + } + std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second; + return (currList->find(attrToGet) != currList->end()); +} //----- (00490913) -------------------------------------------------------- int PlayerCreation_GetUnspentAttributePointCount() @@ -1240,6 +1561,11 @@ //----- (0048C6AF) -------------------------------------------------------- Player::Player() { + if (specialBonusMap.empty()) + { + PopulateSpecialBonusMap(); + } + memset(&pEquipment, 0, sizeof(PlayerEquipment)); memset(pInventoryMatrix, 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) @@ -3272,27 +3598,24 @@ } v63 = (int)((char *)this + 36 * v31); attra = (ItemGen *)(v63 + 532); - if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(v63 + 532)) == 1 + if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(attra)) == 1 && !pItemsTable->IsMaterialSpecial(attra) ) { v34 = attra->uItemID; switch ( attra->uItemID ) { case ITEM_ARTIFACT_PUCK: - v35 = attr == 5; - if ( v35 ) + if ( attr == 5 ) v5 += 50; goto LABEL_361; case ITEM_ARTIFACT_IRON_FEATHER: - v36 = attr == 0; - if ( v36 ) + if ( attr == 0 ) v5 += 40; goto LABEL_361; case ITEM_ARTIFACT_WALLACE: if ( attr == 21 ) v61 += 10; - v36 = attr == 2; - if ( v36 ) + if ( attr == 2 ) v5 += 40; goto LABEL_361; case ITEM_ARTIFACT_CORSAIR: @@ -3300,29 +3623,23 @@ v61 += 5; if ( attr == 18 ) v61 += 5; - v36 = attr == 6; - if ( v36 ) + if ( attr == 6 ) v5 += 40; goto LABEL_361; case ITEM_ARTICACT_GOVERNONS_ARMOR: if (attr <= 6) - { v5 += 10; - goto LABEL_361; - } + goto LABEL_361; case ITEM_ARTIFACT_YORUBA: - v40 = attr == 3; - if ( v40 ) + if ( attr == 3 ) v5 += 25; goto LABEL_361; case ITEM_ARTIFACT_SPLITTER: - v35 = attr == 10; - if ( v35 ) + if ( attr == 10 ) v5 += 50; goto LABEL_361; case ITEM_ARTEFACT_ULLYSES: - v35 = attr == 4; - if ( v35 ) + if ( attr == 4 ) v5 += 50; goto LABEL_361; case ITEM_ARTEFACT_HANDS_OF_THE_MASTER: @@ -3334,42 +3651,39 @@ case ITEM_ARTIFACT_LEAGUE_BOOTS: if ( attr == 36 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[14]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_WATER]; + v62 = (v32 / 2) & 0x1F; } - v36 = attr == 5; - if ( v36 ) + if ( attr == 5 ) v5 += 40; goto LABEL_361; case ITEM_ARTIFACT_RULERS_RING: if ( attr == 39 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[17]); - v34 = ((unsigned int)v34 >> 1) & 0x1F; - v62 = v34; + v34 = this->pActiveSkills[PLAYER_SKILL_MIND]; + v62 = (v34 / 2 ) & 0x1F; } if ( attr == 42 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[20]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_DARK]; + v62 = (v34 / 2 ) & 0x1F; } goto LABEL_361; case ITEM_RELIC_MASH: - if ( !attr ) + if ( attr == 0 ) v5 += 150; if ( attr == 1 ) v5 -= 40; if ( attr == 2 ) v5 -= 40; - v41 = attr == 5; - if ( v41 ) + if ( attr == 5 ) v5 -= 40; goto LABEL_361; case ITEM_RELIC_ETHRICS_STAFF: if ( attr == 42 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[20]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_DARK]; + v62 = (v34 / 2 ) & 0x1F; } if ( attr == 43 ) v61 += 15; @@ -3386,8 +3700,7 @@ v5 -= 10; goto LABEL_361; } - v42 = attr == 15; - if ( v42 ) + if ( attr == 15 ) v5 -= 10; goto LABEL_361; case ITEM_RELIC_OLD_NICK: @@ -3395,12 +3708,11 @@ v61 += 5; goto LABEL_361; case ITEM_RELIC_AMUCK: - if ( !attr ) + if ( attr == 0) v5 += 100; if ( attr == 3 ) v5 += 100; - v43 = attr == 9; - if ( v43 ) + if ( attr == 9 ) v5 -= 15; goto LABEL_361; case ITEM_RELIC_GLORY_SHIELD: @@ -3408,13 +3720,11 @@ v61 += 5; if ( attr == 15 ) v5 -= 10; - v42 = attr == 14; - if ( v42 ) + if ( attr == 14 ) v5 -= 10; goto LABEL_361; case ITEM_RELIC_KELEBRIM: - v35 = attr == 3; - if ( v35 ) + if ( attr == 3 ) v5 += 50; goto LABEL_361; case ITEM_RELIC_TALEDONS_HELM: @@ -3422,36 +3732,32 @@ v5 += 15; if ( !attr ) v5 += 15; - v41 = attr == 6; - if ( v41 ) + if ( attr == 6 ) v5 -= 40; goto LABEL_361; case ITEM_RELIC_SCHOLARS_CAP: if ( attr == 46 ) v61 += 15; - v44 = attr == 3; - if ( v44 ) + if ( attr == 3 ) v5 -= 50; goto LABEL_361; case ITEM_RELIC_PHYNAXIAN_CROWN: if ( attr == 34 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[12]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_FIRE]; + v62 = (v34 / 2 ) & 0x1F; } if ( attr == 12 ) v5 += 50; if ( attr == 2 ) v5 += 30; - v45 = attr == 9; - if ( v45 ) + if ( attr == 9 ) v5 -= 20; goto LABEL_361; case ITEM_RILIC_TITANS_BELT: if ( !attr ) v5 += 75; - v41 = attr == 5; - if ( v41 ) + if ( attr == 5 ) v5 -= 40; goto LABEL_361; case ITEM_RELIC_TWILIGHT: @@ -3464,8 +3770,7 @@ v5 -= 15; goto LABEL_361; } - v43 = attr == 15; - if ( v43 ) + if ( attr == 15 ) v5 -= 15; goto LABEL_361; case ITEM_RELIC_ANIA_SELVING: @@ -3479,29 +3784,26 @@ case ITEM_RELIC_JUSTICE: if ( attr == 39 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[17]); - v34 = ((unsigned int)v34 >> 1) & 0x1F; - v62 = v34; + v34 = this->pActiveSkills[PLAYER_SKILL_MIND]; + v62 = (v34 / 2 ) & 0x1F; } if ( attr == 40 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[18]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_BODY]; + v62 = (v34 / 2 ) & 0x1F; } - v41 = attr == 5; - if ( v41 ) + if ( attr == 5 ) v5 -= 40; goto LABEL_361; case ITEM_RELIC_MEKORIGS_HAMMER: if ( attr == 38 ) { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[16]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; + v34 = this->pActiveSkills[PLAYER_SKILL_SPIRIT]; + v62 = ( v34 / 2 ) & 0x1F; } - if ( !attr ) + if ( attr == 0 ) v5 += 75; - v44 = attr == 11; - if ( v44 ) + if ( attr == 11 ) v5 -= 50; goto LABEL_361; case ITEM_ARTIFACT_HERMES_SANDALS: @@ -3509,56 +3811,47 @@ v5 += 100; if ( attr == 4 ) v5 += 50; - v35 = attr == 11; - if ( v35 ) + if ( attr == 11 ) v5 += 50; goto LABEL_361; case ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP: if ( attr == 1 ) v5 -= 20; - v45 = attr == 2; - if ( v45 ) + if ( attr == 2 ) v5 -= 20; goto LABEL_361; case ITEM_ARTIFACT_MINDS_EYE: if ( attr == 1 ) v5 += 15; - v46 = attr == 2; - if ( v46 ) + if ( attr == 2 ) v5 += 15; goto LABEL_361; case ITEM_ELVEN_CHAINMAIL: if ( attr == 5 ) v5 += 15; - v46 = attr == 4; - if ( v46 ) + if ( attr == 4 ) v5 += 15; goto LABEL_361; case ITEM_FORGE_GAUNTLETS: if ( attr == 10 ) v5 += 30; - if ( !attr ) + if ( attr == 0 ) v5 += 15; - v46 = attr == 3; - if ( v46 ) + if ( attr == 3 ) v5 += 15; goto LABEL_361; case ITEM_ARTIFACT_HEROS_BELT: if ( attr == 21 ) v61 += 5; - if ( !attr ) + if ( attr == 0 ) v5 += 15; if (attr >= 10 && attr <= 15) - { v5 += 10; - } goto LABEL_361; case ITEM_ARTIFACT_LADYS_ESCORT: if (attr >= 10 && attr <= 15) - { v5 += 10; - goto LABEL_361; - } + goto LABEL_361; default: goto LABEL_361; } @@ -3578,364 +3871,13 @@ v5 = this->pOwnItems[v65].m_enchantmentStrength; } } - goto LABEL_361; - } - v34 = this->pOwnItems[v65].uSpecEnchantmentType; - if ( v34 > 48 ) - { - switch ( v34 ) - { - case 54: - v46 = attr == 3; - if ( v46 ) - v5 += 15; - goto LABEL_361; - case 49: - if ( attr == 6 ) - { - v5 += 10; - goto LABEL_361; - } - v50 = attr == 1; - if (v50) - v5 += 10; - goto LABEL_361; - case 51: - if ( attr != 5 && attr != 1 ) - { - v50 = attr == 8; - if (v50) - v5 += 10; - goto LABEL_361; - } - v5 += 10; - goto LABEL_361; - case 52: - if ( attr == 3 ) - { - v5 += 10; - goto LABEL_361; - } - v50 = attr == 4; - if (v50) - v5 += 10; - goto LABEL_361; - case 53: - if ( !attr ) - { - v5 += 10; - goto LABEL_361; - } - v50 = attr == 2; - if (v50) - v5 += 10; - goto LABEL_361; - case 55: - v46 = attr == 6; - if ( v46 ) - v5 += 15; - goto LABEL_361; - case 56: - if ( !attr ) - { - v5 += 5; - goto LABEL_361; - } - v53 = attr == 3; - if ( v53 ) - v5 += 5; - goto LABEL_361; - case 57: - if ( attr == 1 ) - { - v5 += 5; - goto LABEL_361; - } - v53 = attr == 2; - if ( v53 ) - v5 += 5; - goto LABEL_361; - case 50: - if ( attr == 10 ) - v5 += 30; - goto LABEL_361; - case 60: - if ( attr != 23 ) - { - v54 = attr == 22; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - } - if ( v5 >= 3 ) - goto LABEL_361; - v5 = 3; - v54 = attr == 22; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - case 61: - if ( attr != 17 ) - { - v54 = attr == 18; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - } - if ( v5 >= 3 ) - goto LABEL_361; - v5 = 3; - v54 = attr == 18; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - case 62: - if ( attr != 19 ) - { - v54 = attr == 20; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - } - if ( v5 >= 3 ) - goto LABEL_361; - v5 = 3; - v54 = attr == 20; - if ( !v54 ) - goto LABEL_361; - if ( v5 >= 3 ) - goto LABEL_361; - v60 = 3; - v5 = v60; - break; - case 67: - v55 = attr == 18; - if ( v55 && v5 < 2 ) - { - v60 = 2; - v5 = v60; - } - break; - case 68: - v53 = attr == 9; - if ( v53 ) - v5 += 5; - goto LABEL_361; - case 69: - if ( attr == 11 ) - v5 += 20; - break; - case 70: - if ( attr == 12 ) - v5 += 10; - v55 = attr == 16; - if ( v55 && v5 < 2 ) - { - v60 = 2; - v5 = v60; - } - break; - default: - goto LABEL_361; - } - goto LABEL_361; - } - if ( v34 == 48 ) - { - if ( attr == 9 ) - v5 += 5; - v46 = attr == 3; - if ( v46 ) - v5 += 15; - goto LABEL_361; - } - if ( v34 > 32 ) - { - if ( v34 > 44 ) - { - v51 = v34 - 45; - if ( !v51 ) - { - if ( attr == 5 ) - v5 += 5; - goto LABEL_361; - v53 = attr == 4; - if ( v53 ) - v5 += 5; - goto LABEL_361; - } - v52 = v51 - 1; - if ( !v52 ) - { - v40 = attr == 0; - if ( v40 ) - v5 += 25; - goto LABEL_361; - } - if ( v52 == 1 ) - { - v50 = attr == 8; - if (v50) - v5 += 10; - goto LABEL_361; - } - } - else - { - if ( v34 == 44 ) - { - v50 = attr == 7; - if (v50) - v5 += 10; - goto LABEL_361; - } - v34 -= 33; - if ( !v34 ) - { - if ( attr != 38 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[16]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - --v34; - if ( !v34 ) - { - if ( attr != 36 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[14]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - v49 = v34 - 8; - if ( !v49 ) - { - if ( (signed int)attr >= 0 && (signed int)attr <= 15 ) - ++v5; - goto LABEL_361; - } - if ( v49 == 1 ) - { - if ( attr != 3 && attr != 7 ) - { - v50 = attr == 9; - if ( !v50 ) - goto LABEL_361; - } - v5 += 10; - goto LABEL_361; - } - } } else { - if ( v34 == 32 ) - { - if ( attr != 39 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[17]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - if ( v34 > 28 ) - { - v34 -= 29; - if ( v34 ) - { - --v34; - if ( v34 ) - { - --v34; - if ( v34 || attr != 41 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[19]); - } - else - { - if ( attr != 34 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[12]); - } - } - else - { - if ( attr != 37 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[15]); - } - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - if ( v34 == 28 ) - { - if ( attr == 42 ) - { - LOBYTE(v34) = LOBYTE(this->pActiveSkills[20]); - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - } - else - { - v47 = v34 - 1; - if ( v47 ) - { - v48 = v47 - 1; - if ( v48 ) - { - v34 = v48 - 24; - if ( v34 ) - { - --v34; - if ( v34 || attr != 40 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[18]); - } - else - { - if ( attr != 35 ) - goto LABEL_361; - LOBYTE(v34) = LOBYTE(this->pActiveSkills[13]); - } - v62 = ((unsigned int)v34 >> 1) & 0x1F; - goto LABEL_361; - } - if (attr >= 0 && attr <= 6) - { - v5 += 10; - goto LABEL_361; - } - } - else - { - if (attr >= 10 && attr <= 15) - { - v5 += 10; - goto LABEL_361; - } - } - } + v34 = this->pOwnItems[v65].uSpecEnchantmentType; + GetItemBonusSpecialEnchantment(v34, attr, &v5, &v61); } + LABEL_361: ++v65; if ( (signed int)v65 >= 16 )
--- a/Player.h Wed Sep 11 04:27:36 2013 +0200 +++ b/Player.h Thu Sep 12 09:53:41 2013 +0200 @@ -627,6 +627,7 @@ inline bool IsMale() { return GetSexByVoice() == SEX_MALE;} inline bool IsFemale() { return !IsMale();} + void GetItemBonusSpecialEnchantment(int enchantmentId, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus); __int64 pConditions[20]; unsigned __int64 uExperience; char pName[16];