comparison Player.cpp @ 1535:a18076b22fb7

Player::GetSkillBonus continuing cleanup
author Grumpy7
date Sat, 07 Sep 2013 04:13:22 +0200
parents d4bc1cb9d953
children e264ce95f27d
comparison
equal deleted inserted replaced
1534:d4bc1cb9d953 1535:a18076b22fb7
4817 PlayerEquipment *v9; // ebx@19 4817 PlayerEquipment *v9; // ebx@19
4818 Player *v10; // ecx@20 4818 Player *v10; // ecx@20
4819 PLAYER_SKILL_TYPE v11; // edi@21 4819 PLAYER_SKILL_TYPE v11; // edi@21
4820 int v12; // eax@21 4820 int v12; // eax@21
4821 int v13; // edi@21 4821 int v13; // edi@21
4822 char v14; // di@25
4823 signed int v15; // esi@25 4822 signed int v15; // esi@25
4824 char v16; // al@32 4823 char v16; // al@32
4825 int v18; // eax@36 4824 int v18; // eax@36
4826 unsigned int v19; // eax@37 4825 unsigned int v19; // eax@37
4827 ITEM_EQUIP_TYPE v20; // edi@40 4826 unsigned int v20; // edi@40
4828 int v21; // edx@41 4827 int v21; // edx@41
4829 int v22; // eax@42 4828 int v22; // eax@42
4830 PLAYER_SKILL_TYPE v23; // edi@45 4829 PLAYER_SKILL_TYPE v23; // edi@45
4831 unsigned __int16 v24; // ax@45 4830 unsigned __int16 v24; // ax@45
4832 unsigned __int16 v25; // bx@45 4831 unsigned __int16 v25; // bx@45
4873 int v66; // [sp+14h] [bp-18h]@104 4872 int v66; // [sp+14h] [bp-18h]@104
4874 int v67; // [sp+18h] [bp-14h]@104 4873 int v67; // [sp+18h] [bp-14h]@104
4875 int v68; // [sp+1Ch] [bp-10h]@69 4874 int v68; // [sp+1Ch] [bp-10h]@69
4876 //PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1 4875 //PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1
4877 int skill_bonus; // [sp+24h] [bp-8h]@1 4876 int skill_bonus; // [sp+24h] [bp-8h]@1
4878 ITEM_EQUIP_TYPE v71; // [sp+28h] [bp-4h]@1 4877 int v71; // [sp+28h] [bp-4h]@1
4879 int a1; // [sp+34h] [bp+8h]@21 4878 int a1; // [sp+34h] [bp+8h]@21
4880 int a1a; // [sp+34h] [bp+8h]@74 4879 int a1a; // [sp+34h] [bp+8h]@74
4881 signed int a1b; // [sp+34h] [bp+8h]@94 4880 signed int a1b; // [sp+34h] [bp+8h]@94
4882 int multiplier; 4881 int multiplier;
4883 int arm_bonus; 4882 int arm_bonus;
4886 v2 = this; 4885 v2 = this;
4887 skill_bonus = 0; 4886 skill_bonus = 0;
4888 //v69 = 0; 4887 //v69 = 0;
4889 multiplier =0; 4888 multiplier =0;
4890 arm_bonus =0; 4889 arm_bonus =0;
4891 v71 = (ITEM_EQUIP_TYPE)0; 4890 v71 = 0;
4892 armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); 4891 armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER);
4893 v4 = armmaster_skill; 4892 v4 = armmaster_skill;
4894 v5 = 1; 4893 v5 = 1;
4895 if ( armmaster_skill ) 4894 if ( armmaster_skill )
4896 { 4895 {
4929 } 4928 }
4930 break; 4929 break;
4931 case CHARACTER_ATTRIBUTE_AC_BONUS: 4930 case CHARACTER_ATTRIBUTE_AC_BONUS:
4932 { 4931 {
4933 a1b = 0; 4932 a1b = 0;
4934 v71 = (ITEM_EQUIP_TYPE)0; 4933 v71 = 0;
4935 4934
4936 for (j=0; j<16; ++j) 4935 for (j=0; j<16; ++j)
4937 { 4936 {
4938 if (pEquipment.pIndices[j]&&(!pOwnItems[ pEquipment.pIndices[j]].Broken())) 4937 if (pEquipment.pIndices[j]&&(!pOwnItems[ pEquipment.pIndices[j]].Broken()))
4939 { 4938 {
4961 lvl_avl[1]=0; 4960 lvl_avl[1]=0;
4962 lvl_avl[2]=1; 4961 lvl_avl[2]=1;
4963 lvl_avl[3]=0; 4962 lvl_avl[3]=0;
4964 break; 4963 break;
4965 case PLAYER_SKILL_LEATHER: 4964 case PLAYER_SKILL_LEATHER:
4966 v71 = (ITEM_EQUIP_TYPE)1; 4965 v71 = 1;
4967 lvl_avl[0]=1; 4966 lvl_avl[0]=1;
4968 lvl_avl[1]=0; 4967 lvl_avl[1]=0;
4969 lvl_avl[2]=1; 4968 lvl_avl[2]=1;
4970 lvl_avl[3]=0; 4969 lvl_avl[3]=0;
4971 4970
5023 case CHARACTER_ATTRIBUTE_ATTACK: 5022 case CHARACTER_ATTRIBUTE_ATTACK:
5024 { 5023 {
5025 if ( v2->IsUnarmed() == 1 ) 5024 if ( v2->IsUnarmed() == 1 )
5026 { 5025 {
5027 v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 5026 v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5028 v34 = v33; 5027 if (!v33)
5029 if ( !v33 ) 5028 {
5030 return skill_bonus; 5029 return 0;
5031 if ( SkillToMastery(v33) >= 3 ) 5030 }
5031 v34 = SkillToMastery(v33);
5032 if (v34 >= 3)
5033 {
5032 multiplier = 2; 5034 multiplier = 2;
5035 }
5033 else 5036 else
5034 multiplier=1; 5037 {
5035 v30 = multiplier * (v34 & 0x3F); 5038 multiplier = 1;
5039 }
5040 v30 = multiplier * (v33 & 0x3F);
5036 return arm_bonus + v30; 5041 return arm_bonus + v30;
5037 } 5042 }
5038 v35 = (ITEM_EQUIP_TYPE)0; 5043 v35 = (ITEM_EQUIP_TYPE)0;
5039 v68 = 0; 5044 v68 = 0;
5040 for (i=0; i<16 ; ++i) 5045 for (i=0; i<16 ; ++i)
5045 if ( pItemsTable->pItems[v37].uEquipType <= EQUIP_MAIN_HAND) 5050 if ( pItemsTable->pItems[v37].uEquipType <= EQUIP_MAIN_HAND)
5046 break; 5051 break;
5047 } 5052 }
5048 } 5053 }
5049 if ( i >= 16 ) 5054 if ( i >= 16 )
5050 return skill_bonus; 5055 return 0;
5051 5056
5052 v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType; 5057 v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType;
5053 a1a = v2->GetActualSkillLevel(v38); 5058 a1a = v2->GetActualSkillLevel(v38);
5054 v39= SkillToMastery(a1a); 5059 if (v38 == PLAYER_SKILL_BLASTER)
5055 v71 = (ITEM_EQUIP_TYPE)0; 5060 {
5056 switch (v38) 5061 v39 = SkillToMastery(a1a);
5057 { 5062 switch (v39)
5058 case PLAYER_SKILL_STAFF:
5059 v71 = (ITEM_EQUIP_TYPE)1;
5060 if ( v39 == 4 )
5061 { 5063 {
5062 v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 5064 case 1: multiplier=1; break;
5063 v41 = v40; 5065 case 2: multiplier=2; break;
5064 5066 case 3: multiplier=3; break;
5065 if ( v40 ) 5067 case 4: multiplier=5; break;
5068 }
5069 return multiplier * (a1a & 0x3F);
5070 }
5071 else if (v38 == PLAYER_SKILL_STAFF && v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
5072 {
5073 v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5074 if ( SkillToMastery(v40) >= 3 )
5075 multiplier = 2;
5076 else
5077 multiplier = 1;
5078 return multiplier * (v40 & 0x3F) + arm_bonus + (a1a & 0x3F);
5079 }
5080 else
5081 {
5082 return arm_bonus + (a1a & 0x3F);
5083 }
5084 }
5085 break;
5086
5087 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
5088 {
5089 for (int i = 0; i < 16; i++)
5090 {
5091 if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)v71) )
5092 {
5093 v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[v2->pEquipment.pIndices[v71] - 1].uItemID].uSkillType;
5094 v12 = this->GetActualSkillLevel(v11);
5095 if ( v11 == PLAYER_SKILL_BOW )
5066 { 5096 {
5067 if ( SkillToMastery(v40) >= 3 ) 5097 return v12 & 0x3F;
5068 multiplier = 2; 5098 }
5069 else 5099 else if ( v11 == PLAYER_SKILL_BLASTER )
5070 multiplier=1; 5100 {
5071 v68 = multiplier * (v41 & 0x3F); 5101 v39 = SkillToMastery(a1);
5102 switch (v39)
5103 {
5104 case 1: multiplier=1; break;
5105 case 2: multiplier=2; break;
5106 case 3: multiplier=3; break;
5107 case 4: multiplier=5; break;
5108 }
5109 return multiplier * (v11 & 0x3F);
5072 } 5110 }
5073 } 5111 }
5074 break; 5112 }
5075 case PLAYER_SKILL_SWORD: 5113 return 0;
5076 case PLAYER_SKILL_DAGGER: 5114 }
5077 case PLAYER_SKILL_AXE: 5115 break;
5078 case PLAYER_SKILL_SPEAR: 5116
5079 case PLAYER_SKILL_MACE: 5117 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
5080 v71 = (ITEM_EQUIP_TYPE)1; 5118 {
5081 break; 5119 if ( v2->IsUnarmed() )
5082 case PLAYER_SKILL_BLASTER: 5120 {
5083 5121 v18 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5084 switch (v39) 5122 if ( !v18 )
5123 return 0;
5085 { 5124 {
5086 case 0: multiplier=1; break; 5125 v39 = SkillToMastery(v18);
5087 case 1: multiplier=3; break; 5126 switch (v39)
5088 case 3: multiplier=3; break; 5127 {
5089 case 4: multiplier=5; break; 5128 case 1: multiplier=0; break;
5129 case 2: multiplier=1; break;
5130 case 3: multiplier=1; break;
5131 case 4: multiplier=2; break;
5132 }
5133 return multiplier * (v18 & 0x3F);
5090 } 5134 }
5091 v5 = multiplier; 5135 }
5092 return v5 * (a1a & 0x3F); 5136 v20 = 0;
5093 break;
5094 }
5095
5096 v30 = v68 + v71 * (a1a & 0x3F);
5097 return arm_bonus + v30;
5098 }
5099 break;
5100
5101 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
5102 {
5103 v71 = (ITEM_EQUIP_TYPE)0;
5104 v9 = &v2->pEquipment;
5105 while ( 1 ) 5137 while ( 1 )
5106 { 5138 {
5107 if ( v2->HasItemEquipped(v71) ) 5139 if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)v20) )
5108 {
5109 v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[*(_DWORD *)v9].uItemID].uEquipType;
5110 LOBYTE(v12) = this->GetActualSkillLevel(v11);
5111 a1 = v12;
5112 SkillToMastery(v12);
5113 v13 = v11 - 5;
5114 if ( !v13 )
5115 return a1 & 0x3F;
5116 if ( v13 == 2 )
5117 break;
5118 }
5119 v71 = (ITEM_EQUIP_TYPE)((int)v71 + 1);
5120 v9 = (PlayerEquipment *)((char *)v9 + 4);
5121 if ( (signed int)v71 >= 16 )
5122 return skill_bonus;
5123 }
5124 v14 = a1;
5125 v15 = 1;
5126 if ( (signed int)SkillToMastery(a1) >= 4 )
5127 {
5128 v62 = 5;
5129 v15 = v62;
5130 v16 = v14;
5131 return v15 * (v16 & 0x3F);
5132 }
5133 if ( (signed int)SkillToMastery(a1) >= 3 )
5134 {
5135 v62 = 3;
5136 v15 = v62;
5137 v16 = v14;
5138 return v15 * (v16 & 0x3F);
5139 }
5140 if ( (signed int)SkillToMastery(a1) < 2 )
5141 {
5142 v16 = v14;
5143 return v15 * (v16 & 0x3F);
5144 }
5145 v62 = 2;
5146 v15 = v62;
5147 v16 = v14;
5148 return v15 * (v16 & 0x3F);
5149 }
5150 break;
5151
5152 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
5153 {
5154 if ( v2->IsUnarmed() )
5155 {
5156 LOBYTE(v18) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5157 v14 = v18;
5158 if ( !v18 )
5159 return skill_bonus;
5160 v15 = 0;
5161 v19 = SkillToMastery(v18);
5162 if ( (signed int)v19 < 3 )
5163 {
5164 if ( (signed int)v19 >= 2 )
5165 v15 = 1;
5166 v16 = v14;
5167 return v15 * (v16 & 0x3F);
5168 }
5169 v62 = 2;
5170 v15 = v62;
5171 v16 = v14;
5172 return v15 * (v16 & 0x3F);
5173 }
5174 v20 = (ITEM_EQUIP_TYPE)0;
5175 while ( 1 )
5176 {
5177 if ( v2->HasItemEquipped(v20) )
5178 { 5140 {
5179 v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID; 5141 v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID;
5180 if ( pItemsTable->pItems[v22].uEquipType <= 1u ) 5142 if ( pItemsTable->pItems[v22].uEquipType <= 1u )
5181 break; 5143 break;
5182 } 5144 }
5183 v20 = (ITEM_EQUIP_TYPE)((int)v20 + 1); 5145 v20++;
5184 if ( (signed int)v20 >= 16 ) 5146 if ( (signed int)v20 >= 16 )
5185 return skill_bonus; 5147 return 0;
5186 } 5148 }
5187 v71 = (ITEM_EQUIP_TYPE)0; 5149 v71 = 0;
5188 v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType; 5150 v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType;
5189 LOBYTE(v24) = v2->GetActualSkillLevel(v23); 5151 v25 = v2->GetActualSkillLevel(v23);
5190 v25 = v24; 5152 v26 = SkillToMastery(v25);
5191 v26 = SkillToMastery(v24); 5153 switch (v23)
5192 if ( v23 == PLAYER_SKILL_STAFF) 5154 {
5193 { 5155 case PLAYER_SKILL_STAFF:
5194 if ( (signed int)SkillToMastery(v25) >= 4 ) 5156 if ( (signed int)SkillToMastery(v25) >= 4 && v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
5195 {
5196 LOBYTE(v31) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5197 LOBYTE(v25) = v31;
5198 if ( v31 )
5199 { 5157 {
5200 v15 = 0; 5158 v31 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
5201 v32 = SkillToMastery(v31); 5159 multiplier = GetMultiplierForMastery(v31, 0, 1, 2, 2);
5202 if ( (signed int)v32 < 3 ) 5160 return multiplier * (v31 & 0x3F);
5203 {
5204 if ( (signed int)v32 >= 2 )
5205 v15 = 1;
5206 }
5207 else
5208 {
5209 v15 = 2;
5210 }
5211 v16 = v25;
5212 return v15 * (v16 & 0x3F);
5213 } 5161 }
5214 } 5162 else
5215 v30 = v71 * (v25 & 0x3F); 5163 {
5216 return arm_bonus + v30; 5164 return arm_bonus;
5217 } 5165 }
5218 if ( v23 == PLAYER_SKILL_DAGGER ) 5166 break;
5219 { 5167
5220 v29 = SkillToMastery(v25); 5168 case PLAYER_SKILL_DAGGER:
5221 v28 = __OFSUB__(v29, 4); 5169 multiplier = GetMultiplierForMastery(v25, 0, 0, 0, 1);
5222 v27 = ((v29 - 4) & 0x80000000u) != 0; 5170 v30 = multiplier * (v29 & 0x3F);
5223 }
5224 else
5225 {
5226 if ( v23 <= PLAYER_SKILL_DAGGER )
5227 {
5228 v30 = v71 * (v25 & 0x3F);
5229 return arm_bonus + v30; 5171 return arm_bonus + v30;
5230 } 5172 break;
5231 if ( v23 > PLAYER_SKILL_SPEAR ) 5173 case PLAYER_SKILL_SWORD:
5232 { 5174 return arm_bonus;
5233 if ( v23 == PLAYER_SKILL_MACE ) 5175 break;
5234 { 5176 case PLAYER_SKILL_MACE:
5235 v28 = __OFSUB__(v26, 2); 5177 case PLAYER_SKILL_SPEAR:
5236 v27 = v26 - 2 < 0; 5178 multiplier = GetMultiplierForMastery(v25, 0, 1, 1, 1);
5237 if ( !(v27 ^ v28) ) 5179 v30 = multiplier * (v29 & 0x3F);
5238 v71 = (ITEM_EQUIP_TYPE)1;
5239 v30 = v71 * (v25 & 0x3F);
5240 return arm_bonus + v30;
5241 }
5242 v30 = v71 * (v25 & 0x3F);
5243 return arm_bonus + v30; 5180 return arm_bonus + v30;
5244 } 5181 break;
5245 v28 = __OFSUB__(v26, 3); 5182 case PLAYER_SKILL_AXE:
5246 v27 = v26 - 3 < 0; 5183 multiplier = GetMultiplierForMastery(v25, 0, 0, 1, 1);
5247 } 5184 v30 = multiplier * (v29 & 0x3F);
5248 if ( !(v27 ^ v28) ) 5185 return arm_bonus + v30;
5249 v71 = (ITEM_EQUIP_TYPE)1; 5186 break;
5250 v30 = v71 * (v25 & 0x3F); 5187 }
5251 return arm_bonus + v30;
5252 } 5188 }
5253 default: 5189 default:
5254 return 0; 5190 return 0;
5255 } 5191 }
5256 5192 }
5257 } 5193
5258 5194 unsigned int Player::GetMultiplierForMastery(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4)
5195 {
5196 int masteryLvl = SkillToMastery(skillValue);
5197 switch (masteryLvl)
5198 {
5199 case 1: return mult1;
5200 case 2: return mult2;
5201 case 3: return mult3;
5202 case 4: return mult4;
5203 }
5204 }
5259 //----- (00490109) -------------------------------------------------------- 5205 //----- (00490109) --------------------------------------------------------
5260 // faces are: 0 1 2 3 human males 5206 // faces are: 0 1 2 3 human males
5261 // 4 5 6 7 human females 5207 // 4 5 6 7 human females
5262 // 8 9 elf males 5208 // 8 9 elf males
5263 // 10 11 elf females 5209 // 10 11 elf females