Mercurial > mm7
changeset 1064:655fde266d96
GetSkillBonus cleaning in progress
author | Gloval |
---|---|
date | Fri, 24 May 2013 08:16:36 +0400 |
parents | 0e0f1192aa57 |
children | e86b4951da70 |
files | Player.cpp mm7_2.cpp mm7_data.h |
diffstat | 3 files changed, 217 insertions(+), 219 deletions(-) [+] |
line wrap: on
line diff
--- a/Player.cpp Fri May 24 00:53:48 2013 +0600 +++ b/Player.cpp Fri May 24 08:16:36 2013 +0400 @@ -5407,43 +5407,38 @@ //----- (0048F882) -------------------------------------------------------- int 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 - CHARACTER_ATTRIBUTE_TYPE v8; // [sp-4h] [bp-14h]@68 - //Player *v9; // [sp+Ch] [bp-4h]@1 + signed int bonus_value; // esi@1 + unsigned __int16 skill_value; // ax@126 + int result; // al@127 - v2 = 0; + bonus_value = 0; switch (uSkillType) { case PLAYER_SKILL_MONSTER_ID: { if ( CheckHiredNPCSpeciality(Hunter) ) - v2 = 6; + bonus_value = 6; if ( CheckHiredNPCSpeciality(Sage) ) - v2 += 6; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 0); + bonus_value += 6; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 0); } break; case PLAYER_SKILL_ARMSMASTER: { if ( CheckHiredNPCSpeciality(Armsmaster) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Weaponsmaster) ) - v2 += 3; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 0); + bonus_value += 3; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 0); } break; case PLAYER_SKILL_STEALING: { if (CheckHiredNPCSpeciality(Burglar)) - v2 = 8; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING, 0); + bonus_value = 8; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING, 0); } break; @@ -5451,185 +5446,188 @@ case PLAYER_SKILL_ALCHEMY: { if ( CheckHiredNPCSpeciality(Herbalist) ) - v2 = 4; + bonus_value = 4; if ( CheckHiredNPCSpeciality(Apothecary) ) - v2 += 8; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 0); + bonus_value += 8; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 0); } break; case PLAYER_SKILL_LEARNING: { if ( CheckHiredNPCSpeciality(Teacher) ) - v2 = 10; + bonus_value = 10; if ( CheckHiredNPCSpeciality(Instructor) ) - v2 += 15; + bonus_value += 15; if ( CheckHiredNPCSpeciality(Scholar) ) - v2 += 5; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING, 0); + bonus_value += 5; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING, 0); } break; case PLAYER_SKILL_UNARMED: { if (CheckHiredNPCSpeciality(Monk) ) - v2 = 2; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 0); + bonus_value = 2; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 0); } break; case PLAYER_SKILL_DODGE: { if ( CheckHiredNPCSpeciality(Monk) ) - v2 = 2; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE, 0); + bonus_value = 2; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE, 0); } break; case PLAYER_SKILL_BOW: - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW, 0); break; case PLAYER_SKILL_SHIELD: - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 0); break; case PLAYER_SKILL_EARTH: if ( CheckHiredNPCSpeciality(Apprentice) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) - v2 += 4; + bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) - v2 += 3; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH, 0); + bonus_value += 3; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH, 0); break; case PLAYER_SKILL_FIRE: if ( CheckHiredNPCSpeciality(Apprentice) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) - v2 += 4; + bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) - v2 += 3; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0); + bonus_value += 3; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0); break; case PLAYER_SKILL_AIR: if ( CheckHiredNPCSpeciality(Apprentice) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) - v2 += 4; + bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) - v2 += 3; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR, 0); + bonus_value += 3; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR, 0); break; case PLAYER_SKILL_WATER: if ( CheckHiredNPCSpeciality(Apprentice) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Mystic) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Spellmaster) ) - v2 += 4; + bonus_value += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) - v2 += 3; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER, 0); + bonus_value += 3; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER, 0); break; case PLAYER_SKILL_SPIRIT: if ( CheckHiredNPCSpeciality(Acolyte2) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) - v2 += 4; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0); + bonus_value += 4; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0); break; case PLAYER_SKILL_MIND: if ( CheckHiredNPCSpeciality(Acolyte2) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) - v2 += 4; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND, 0); + bonus_value += 4; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND, 0); break; case PLAYER_SKILL_BODY: if ( CheckHiredNPCSpeciality(Acolyte2) ) - v2 = 2; + bonus_value = 2; if ( CheckHiredNPCSpeciality(Initiate) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Prelate) ) - v2 += 4; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY, 0); + bonus_value += 4; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY, 0); break; case PLAYER_SKILL_LIGHT: - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0); break; case PLAYER_SKILL_DARK: { - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK, 0); } break; case PLAYER_SKILL_MERCHANT: { if ( CheckHiredNPCSpeciality(Trader) ) - v2 = 4; + bonus_value = 4; if ( CheckHiredNPCSpeciality(Merchant) ) - v2 += 6; + bonus_value += 6; if ( CheckHiredNPCSpeciality(Gypsy) ) - v2 += 3; + bonus_value += 3; if ( CheckHiredNPCSpeciality(Duper) ) - v2 += 8; + bonus_value += 8; } break; case PLAYER_SKILL_PERCEPTION: { if ( CheckHiredNPCSpeciality(Scout) ) - v2 = 6; + bonus_value = 6; if ( CheckHiredNPCSpeciality(Psychic) ) - v2 += 5; + bonus_value += 5; } break; case PLAYER_SKILL_ITEM_ID: - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 0); break; case PLAYER_SKILL_MEDITATION: - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 0); + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 0); break; case PLAYER_SKILL_TRAP_DISARM: { if ( CheckHiredNPCSpeciality(Tinker) ) - v2 = 4; + bonus_value = 4; if ( CheckHiredNPCSpeciality(Locksmith) ) - v2 += 6; + bonus_value += 6; if ( CheckHiredNPCSpeciality(Burglar) ) - v2 += 8; - v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 0); + bonus_value += 8; + bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 0); } break; } - v3 = pActiveSkills[uSkillType]; - if ( v2 + (v3 & 0x3F) < 60 ) - result = v2 + v3; + skill_value = pActiveSkills[uSkillType]; + if ( bonus_value + (skill_value & 0x3F) < 60 ) + result = bonus_value + skill_value; else - result = v3 & 0xFFFC | 0x3C; //al + result = skill_value & 0xFFFC | 0x3C; //al return result; } //----- (0048FC00) -------------------------------------------------------- int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE a2) { + + + Player *v2; // esi@1 - int v3; // eax@1 + int armmaster_skill; // eax@1 char v4; // di@1 signed int v5; // ebx@1 - unsigned int v6; // eax@2 + unsigned int armaster_mastery; // eax@2 unsigned __int8 v7; // sf@5 unsigned __int8 v8; // of@5 PlayerEquipment *v9; // ebx@19 @@ -5682,8 +5680,8 @@ unsigned int v57; // eax@118 int v58; // esi@121 signed int j; // ecx@121 - int v60; // edi@126 - int v61; // eax@126 + int base_value; // edi@126 + int attrib_modif; // eax@126 signed int v62; // [sp-4h] [bp-30h]@26 signed int v63; // [sp-4h] [bp-30h]@80 int v64; // [sp+Ch] [bp-20h]@104 @@ -5697,56 +5695,148 @@ int a1; // [sp+34h] [bp+8h]@21 int a1a; // [sp+34h] [bp+8h]@74 signed int a1b; // [sp+34h] [bp+8h]@94 + int multiplier; + int arm_bonus; + int lvl_avl[4]; v2 = this; v70 = 0; v69 = 0; + multiplier =0; + arm_bonus =0; v71 = (ITEM_EQUIP_TYPE)0; - LOBYTE(v3) = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); - v4 = v3; + armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); + v4 = armmaster_skill; v5 = 1; - if ( v3 ) - { - v6 = SkillToMastery(v3); + if ( armmaster_skill ) + { + armaster_mastery = SkillToMastery(armmaster_skill); if ( a2 == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) { - if ( (signed int)v6 >= 4 ) - goto LABEL_4; - v8 = __OFSUB__(v6, 3); - v7 = ((v6 - 3) & 0x80000000u) != 0; - } - else - { - if ( a2 != CHARACTER_ATTRIBUTE_ATTACK ) - goto LABEL_11; - if ( (signed int)v6 >= 4 ) - { -LABEL_4: - v71 = (ITEM_EQUIP_TYPE)2; -LABEL_11: - v69 = (PlayerEquipment *)(v71 * (v4 & 0x3F)); - goto LABEL_12; - } - v8 = __OFSUB__(v6, 2); - v7 = ((v6 - 2) & 0x80000000u) != 0; - } - if ( !(v7 ^ v8) ) - v71 = (ITEM_EQUIP_TYPE)1; - goto LABEL_11; - } -LABEL_12: + if ( armaster_mastery == 4 ) + multiplier =2; + else if ( armaster_mastery == 3 ) + multiplier =1; + } + else if ( a2 == CHARACTER_ATTRIBUTE_ATTACK ) + { + if ( armaster_mastery == 4 ) + multiplier =2; + else if ( armaster_mastery >= 2 ) + multiplier =1; + } + arm_bonus=(armmaster_skill&0x3F)*multiplier; + } + + if ( a2 == CHARACTER_ATTRIBUTE_HEALTH ) { - v60 = pBaseHealthPerLevelByClass[v2->classType]; - v61 = v2->GetBodybuilding(); - return v60 * v61; + base_value = pBaseHealthPerLevelByClass[classType]; + attrib_modif = GetBodybuilding(); + return base_value * attrib_modif; } if ( a2 == CHARACTER_ATTRIBUTE_MANA ) { - v60 = pBaseManaPerLevelByClass[v2->classType]; - v61 = v2->GetMeditation(); - return v60 * v61; - } + base_value = pBaseManaPerLevelByClass[classType]; + attrib_modif = GetMeditation(); + return base_value * attrib_modif; + } + if ( a2 == CHARACTER_ATTRIBUTE_AC_BONUS ) + { + a1b = 0; + v71 = (ITEM_EQUIP_TYPE)0; + + for (j=0; j<16; ++j) + { + if (pEquipment.pIndices[j]&&(!pOwnItems[ pEquipment.pIndices[j]].Broken())) + { + int curr_item =pOwnItems[pEquipment.pIndices[j]].uItemID; + v44=pItemsTable->pItems[curr_item].uSkillType; + switch (v44) + { + + case PLAYER_SKILL_STAFF: + + lvl_avl[0]=0; + lvl_avl[1]=1; + lvl_avl[2]=0; + lvl_avl[3]=0; + break; + case PLAYER_SKILL_SWORD: + case PLAYER_SKILL_SPEAR: + lvl_avl[0]=0; + lvl_avl[1]=0; + lvl_avl[2]=0; + lvl_avl[3]=1; + break; + case PLAYER_SKILL_SHIELD: + a1b = 1; + lvl_avl[0]=1; + lvl_avl[1]=0; + lvl_avl[2]=1; + lvl_avl[3]=0; + break; + case PLAYER_SKILL_LEATHER: + v71 = (ITEM_EQUIP_TYPE)1; + lvl_avl[0]=1; + lvl_avl[1]=0; + lvl_avl[2]=1; + lvl_avl[3]=0; + + break; + case PLAYER_SKILL_CHAIN: + a1b = 1; + lvl_avl[0]=1; + lvl_avl[1]=0; + lvl_avl[2]=0; + lvl_avl[3]=0; + break; + case PLAYER_SKILL_PLATE: + a1b = 1; + lvl_avl[0]=1; + lvl_avl[1]=0; + lvl_avl[2]=0; + lvl_avl[3]=0; + break; + default: + continue; + } + + v50= GetActualSkillLevel((PLAYER_SKILL_TYPE)v44); + v51 = v50; + v52 = SkillToMastery(v50); + v53 = v51 & 0x3F; + for ( i = 0; i < (signed int)v52; ++i ) + { + if ( lvl_avl[i] ) + v70 += v53; + } + + } + } + + lvl_avl[0]=1; + lvl_avl[1]=1; + lvl_avl[2]=1; + lvl_avl[3]=0; + + v55 = GetActualSkillLevel(PLAYER_SKILL_DODGE); + v56 = v55; + v57 = SkillToMastery(v55); + if ( !a1b && (!v71 || v57 == 4) ) + { + v58 = v56 & 0x3F; + for ( j = 0; j < (signed int)v57; ++j ) + { + if ( lvl_avl[i] ) + v70 += v58; + } + } + return v70; + + + } + if ( a2 != 9 ) { if ( a2 != CHARACTER_ATTRIBUTE_ATTACK ) @@ -5906,7 +5996,7 @@ { if ( v2->HasItemEquipped(v35) ) { - v37 = *(int *)&v2->pInventoryItems[v35].uItemID; + v37 = v2->pInventoryItems[v35].uItemID; if ( pItemsTable->pItems[v37].uEquipType <= 1u ) break; } @@ -5972,99 +6062,7 @@ v30 = v68 + v71 * (a1a & 0x3F); return (int)((char *)v69 + v30); } - a1b = 0; - v71 = (ITEM_EQUIP_TYPE)0; - v68 = 16; - v69 = &v2->pEquipment; - do - { - if ( !v69->uShield || (v42 = (int)((char *)v2 + 36 * v69->uShield), *(char *)(v42 + 516) & 2) ) - goto LABEL_117; - v43 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[*(int *)(v42 + 496)].uSkillType; - v44 = pItemsTable->pItems[*(int *)(v42 + 496)].uSkillType; - if ( !v44 ) - { - v64 = 0; - v65 = 1; -LABEL_111: - v66 = 0; - goto LABEL_112; - } - v45 = v44 - 1; - if ( !v45 || (v46 = v45 - 3) == 0 ) - { - v64 = 0; - v65 = 0; - v66 = 0; - v67 = 1; - goto LABEL_113; - } - v47 = v46 - 4; - if ( v47 ) - { - v48 = v47 - 1; - if ( v48 ) - { - v49 = v48 - 1; - if ( v49 ) - { - if ( v49 != 1 ) - goto LABEL_117; - a1b = 1; - v64 = 1; - v65 = 0; - v66 = 0; - v67 = 0; - goto LABEL_113; - } - a1b = 1; - v64 = 1; - v65 = 0; - goto LABEL_111; - } - v71 = (ITEM_EQUIP_TYPE)1; - } - else - { - a1b = 1; - } - v64 = 1; - v65 = 0; - v66 = 1; -LABEL_112: - v67 = 0; -LABEL_113: - LOBYTE(v50) = v2->GetActualSkillLevel(v43); - v51 = v50; - v52 = SkillToMastery(v50); - v53 = v51 & 0x3F; - for ( i = 0; i < (signed int)v52; ++i ) - { - if ( *(&v64 + i) ) - v70 += v53; - } -LABEL_117: - v69 = (PlayerEquipment *)((char *)v69 + 4); - --v68; - } - while ( v68 ); - v64 = 1; - v65 = 1; - v66 = 1; - v67 = 0; - LOBYTE(v55) = v2->GetActualSkillLevel(PLAYER_SKILL_DODGE); - v56 = v55; - v57 = SkillToMastery(v55); - if ( !a1b && (!v71 || v57 == 4) ) - { - v58 = v56 & 0x3F; - for ( j = 0; j < (signed int)v57; ++j ) - { - if ( *(&v64 + j) ) - v70 += v58; - } - } - return v70; + } //----- (00490109) --------------------------------------------------------
--- a/mm7_2.cpp Fri May 24 00:53:48 2013 +0600 +++ b/mm7_2.cpp Fri May 24 08:16:36 2013 +0400 @@ -5445,9 +5445,9 @@ } //----- (00458244) -------------------------------------------------------- -unsigned int SkillToMastery(unsigned int value) -{ - switch (value & 0x1C0) +int SkillToMastery( unsigned int skill_value ) + { + switch (skill_value & 0x1C0) { case 0x100: return 4; // Grandmaster case 0x80: return 3; // Master
--- a/mm7_data.h Fri May 24 00:53:48 2013 +0600 +++ b/mm7_data.h Fri May 24 08:16:36 2013 +0400 @@ -1425,7 +1425,7 @@ int __cdecl j_SetSomeItemsNames(); -unsigned int SkillToMastery(unsigned int skill_value); +int SkillToMastery(unsigned int skill_value); unsigned int __fastcall GetSpellColor(signed int a1); void *__thiscall unknown_vdtor_6(void *_this, bool a2); unsigned short * MakeScreenshot(signed int width, signed int height);