Mercurial > mm7
diff Player.cpp @ 1535:a18076b22fb7
Player::GetSkillBonus continuing cleanup
author | Grumpy7 |
---|---|
date | Sat, 07 Sep 2013 04:13:22 +0200 |
parents | d4bc1cb9d953 |
children | e264ce95f27d |
line wrap: on
line diff
--- a/Player.cpp Sat Sep 07 02:42:54 2013 +0200 +++ b/Player.cpp Sat Sep 07 04:13:22 2013 +0200 @@ -4819,12 +4819,11 @@ PLAYER_SKILL_TYPE v11; // edi@21 int v12; // eax@21 int v13; // edi@21 - char v14; // di@25 signed int v15; // esi@25 char v16; // al@32 int v18; // eax@36 unsigned int v19; // eax@37 - ITEM_EQUIP_TYPE v20; // edi@40 + unsigned int v20; // edi@40 int v21; // edx@41 int v22; // eax@42 PLAYER_SKILL_TYPE v23; // edi@45 @@ -4875,7 +4874,7 @@ int v68; // [sp+1Ch] [bp-10h]@69 //PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1 int skill_bonus; // [sp+24h] [bp-8h]@1 - ITEM_EQUIP_TYPE v71; // [sp+28h] [bp-4h]@1 + int v71; // [sp+28h] [bp-4h]@1 int a1; // [sp+34h] [bp+8h]@21 int a1a; // [sp+34h] [bp+8h]@74 signed int a1b; // [sp+34h] [bp+8h]@94 @@ -4888,7 +4887,7 @@ //v69 = 0; multiplier =0; arm_bonus =0; - v71 = (ITEM_EQUIP_TYPE)0; + v71 = 0; armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); v4 = armmaster_skill; v5 = 1; @@ -4931,7 +4930,7 @@ case CHARACTER_ATTRIBUTE_AC_BONUS: { a1b = 0; - v71 = (ITEM_EQUIP_TYPE)0; + v71 = 0; for (j=0; j<16; ++j) { @@ -4963,7 +4962,7 @@ lvl_avl[3]=0; break; case PLAYER_SKILL_LEATHER: - v71 = (ITEM_EQUIP_TYPE)1; + v71 = 1; lvl_avl[0]=1; lvl_avl[1]=0; lvl_avl[2]=1; @@ -5025,14 +5024,20 @@ if ( v2->IsUnarmed() == 1 ) { v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v34 = v33; - if ( !v33 ) - return skill_bonus; - if ( SkillToMastery(v33) >= 3 ) + if (!v33) + { + return 0; + } + v34 = SkillToMastery(v33); + if (v34 >= 3) + { multiplier = 2; + } else - multiplier=1; - v30 = multiplier * (v34 & 0x3F); + { + multiplier = 1; + } + v30 = multiplier * (v33 & 0x3F); return arm_bonus + v30; } v35 = (ITEM_EQUIP_TYPE)0; @@ -5047,105 +5052,65 @@ } } if ( i >= 16 ) - return skill_bonus; + return 0; v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType; a1a = v2->GetActualSkillLevel(v38); - v39= SkillToMastery(a1a); - v71 = (ITEM_EQUIP_TYPE)0; - switch (v38) - { - case PLAYER_SKILL_STAFF: - v71 = (ITEM_EQUIP_TYPE)1; - if ( v39 == 4 ) - { - v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v41 = v40; - - if ( v40 ) - { - if ( SkillToMastery(v40) >= 3 ) - multiplier = 2; - else - multiplier=1; - v68 = multiplier * (v41 & 0x3F); - } - } - break; - case PLAYER_SKILL_SWORD: - case PLAYER_SKILL_DAGGER: - case PLAYER_SKILL_AXE: - case PLAYER_SKILL_SPEAR: - case PLAYER_SKILL_MACE: - v71 = (ITEM_EQUIP_TYPE)1; - break; - case PLAYER_SKILL_BLASTER: - + if (v38 == PLAYER_SKILL_BLASTER) + { + v39 = SkillToMastery(a1a); switch (v39) { - case 0: multiplier=1; break; - case 1: multiplier=3; break; - case 3: multiplier=3; break; - case 4: multiplier=5; break; + case 1: multiplier=1; break; + case 2: multiplier=2; break; + case 3: multiplier=3; break; + case 4: multiplier=5; break; } - v5 = multiplier; - return v5 * (a1a & 0x3F); - break; - } - - v30 = v68 + v71 * (a1a & 0x3F); - return arm_bonus + v30; + return multiplier * (a1a & 0x3F); + } + else if (v38 == PLAYER_SKILL_STAFF && v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) + { + v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + if ( SkillToMastery(v40) >= 3 ) + multiplier = 2; + else + multiplier = 1; + return multiplier * (v40 & 0x3F) + arm_bonus + (a1a & 0x3F); + } + else + { + return arm_bonus + (a1a & 0x3F); + } } break; case CHARACTER_ATTRIBUTE_RANGED_ATTACK: { - v71 = (ITEM_EQUIP_TYPE)0; - v9 = &v2->pEquipment; - while ( 1 ) - { - if ( v2->HasItemEquipped(v71) ) + for (int i = 0; i < 16; i++) + { + if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)v71) ) { - v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[*(_DWORD *)v9].uItemID].uEquipType; - LOBYTE(v12) = this->GetActualSkillLevel(v11); - a1 = v12; - SkillToMastery(v12); - v13 = v11 - 5; - if ( !v13 ) - return a1 & 0x3F; - if ( v13 == 2 ) - break; + v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[v2->pEquipment.pIndices[v71] - 1].uItemID].uSkillType; + v12 = this->GetActualSkillLevel(v11); + if ( v11 == PLAYER_SKILL_BOW ) + { + return v12 & 0x3F; + } + else if ( v11 == PLAYER_SKILL_BLASTER ) + { + v39 = SkillToMastery(a1); + switch (v39) + { + case 1: multiplier=1; break; + case 2: multiplier=2; break; + case 3: multiplier=3; break; + case 4: multiplier=5; break; + } + return multiplier * (v11 & 0x3F); + } } - v71 = (ITEM_EQUIP_TYPE)((int)v71 + 1); - v9 = (PlayerEquipment *)((char *)v9 + 4); - if ( (signed int)v71 >= 16 ) - return skill_bonus; - } - v14 = a1; - v15 = 1; - if ( (signed int)SkillToMastery(a1) >= 4 ) - { - v62 = 5; - v15 = v62; - v16 = v14; - return v15 * (v16 & 0x3F); - } - if ( (signed int)SkillToMastery(a1) >= 3 ) - { - v62 = 3; - v15 = v62; - v16 = v14; - return v15 * (v16 & 0x3F); - } - if ( (signed int)SkillToMastery(a1) < 2 ) - { - v16 = v14; - return v15 * (v16 & 0x3F); - } - v62 = 2; - v15 = v62; - v16 = v14; - return v15 * (v16 & 0x3F); + } + return 0; } break; @@ -5153,109 +5118,90 @@ { if ( v2->IsUnarmed() ) { - LOBYTE(v18) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v14 = v18; + v18 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); if ( !v18 ) - return skill_bonus; - v15 = 0; - v19 = SkillToMastery(v18); - if ( (signed int)v19 < 3 ) + return 0; { - if ( (signed int)v19 >= 2 ) - v15 = 1; - v16 = v14; - return v15 * (v16 & 0x3F); + v39 = SkillToMastery(v18); + switch (v39) + { + case 1: multiplier=0; break; + case 2: multiplier=1; break; + case 3: multiplier=1; break; + case 4: multiplier=2; break; + } + return multiplier * (v18 & 0x3F); } - v62 = 2; - v15 = v62; - v16 = v14; - return v15 * (v16 & 0x3F); - } - v20 = (ITEM_EQUIP_TYPE)0; + } + v20 = 0; while ( 1 ) { - if ( v2->HasItemEquipped(v20) ) + if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)v20) ) { v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID; if ( pItemsTable->pItems[v22].uEquipType <= 1u ) break; } - v20 = (ITEM_EQUIP_TYPE)((int)v20 + 1); + v20++; if ( (signed int)v20 >= 16 ) - return skill_bonus; - } - v71 = (ITEM_EQUIP_TYPE)0; + return 0; + } + v71 = 0; v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType; - LOBYTE(v24) = v2->GetActualSkillLevel(v23); - v25 = v24; - v26 = SkillToMastery(v24); - if ( v23 == PLAYER_SKILL_STAFF) - { - if ( (signed int)SkillToMastery(v25) >= 4 ) - { - LOBYTE(v31) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - LOBYTE(v25) = v31; - if ( v31 ) + v25 = v2->GetActualSkillLevel(v23); + v26 = SkillToMastery(v25); + switch (v23) + { + case PLAYER_SKILL_STAFF: + if ( (signed int)SkillToMastery(v25) >= 4 && v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { - v15 = 0; - v32 = SkillToMastery(v31); - if ( (signed int)v32 < 3 ) - { - if ( (signed int)v32 >= 2 ) - v15 = 1; - } - else - { - v15 = 2; - } - v16 = v25; - return v15 * (v16 & 0x3F); + v31 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + multiplier = GetMultiplierForMastery(v31, 0, 1, 2, 2); + return multiplier * (v31 & 0x3F); + } + else + { + return arm_bonus; } - } - v30 = v71 * (v25 & 0x3F); - return arm_bonus + v30; - } - if ( v23 == PLAYER_SKILL_DAGGER ) - { - v29 = SkillToMastery(v25); - v28 = __OFSUB__(v29, 4); - v27 = ((v29 - 4) & 0x80000000u) != 0; - } - else - { - if ( v23 <= PLAYER_SKILL_DAGGER ) - { - v30 = v71 * (v25 & 0x3F); + break; + + case PLAYER_SKILL_DAGGER: + multiplier = GetMultiplierForMastery(v25, 0, 0, 0, 1); + v30 = multiplier * (v29 & 0x3F); return arm_bonus + v30; - } - if ( v23 > PLAYER_SKILL_SPEAR ) - { - if ( v23 == PLAYER_SKILL_MACE ) - { - v28 = __OFSUB__(v26, 2); - v27 = v26 - 2 < 0; - if ( !(v27 ^ v28) ) - v71 = (ITEM_EQUIP_TYPE)1; - v30 = v71 * (v25 & 0x3F); - return arm_bonus + v30; - } - v30 = v71 * (v25 & 0x3F); + break; + case PLAYER_SKILL_SWORD: + return arm_bonus; + break; + case PLAYER_SKILL_MACE: + case PLAYER_SKILL_SPEAR: + multiplier = GetMultiplierForMastery(v25, 0, 1, 1, 1); + v30 = multiplier * (v29 & 0x3F); return arm_bonus + v30; - } - v28 = __OFSUB__(v26, 3); - v27 = v26 - 3 < 0; - } - if ( !(v27 ^ v28) ) - v71 = (ITEM_EQUIP_TYPE)1; - v30 = v71 * (v25 & 0x3F); - return arm_bonus + v30; + break; + case PLAYER_SKILL_AXE: + multiplier = GetMultiplierForMastery(v25, 0, 0, 1, 1); + v30 = multiplier * (v29 & 0x3F); + return arm_bonus + v30; + break; + } } default: return 0; } - -} - +} + +unsigned int Player::GetMultiplierForMastery(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4) +{ + int masteryLvl = SkillToMastery(skillValue); + switch (masteryLvl) + { + case 1: return mult1; + case 2: return mult2; + case 3: return mult3; + case 4: return mult4; + } +} //----- (00490109) -------------------------------------------------------- // faces are: 0 1 2 3 human males // 4 5 6 7 human females