comparison Player.cpp @ 1553:b98812ead5d9

Get(skillname) functions cleaned up, using GetMultiplierForSkillLevel instead of nested conditions
author Grumpy7
date Sat, 07 Sep 2013 21:00:02 +0200
parents d253172de469
children e303d8a9bcdc
comparison
equal deleted inserted replaced
1552:d253172de469 1553:b98812ead5d9
1125 1125
1126 //----- (0049107D) -------------------------------------------------------- 1126 //----- (0049107D) --------------------------------------------------------
1127 int Player::GetBodybuilding() 1127 int Player::GetBodybuilding()
1128 { 1128 {
1129 int v1; // al@1 1129 int v1; // al@1
1130 int v2; // ecx@1
1131 int v4; // eax@3
1132 signed int v6; // [sp-4h] [bp-4h]@2
1133 1130
1134 v1 = GetActualSkillLevel(PLAYER_SKILL_BODYBUILDING); 1131 v1 = GetActualSkillLevel(PLAYER_SKILL_BODYBUILDING);
1135 v2 = v1 & 0x3F; 1132 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5);
1136 if ( v1 & 0x100 ) 1133 return multiplier * (v1 & 0x3F);
1137 {
1138 v6 = 5;
1139 }
1140 else
1141 {
1142 if ( (v1&0xFF) >= 0 )
1143 {
1144 v4 = ((v1 & 0x40) != 0) + 1;
1145 return v2 * v4;
1146 }
1147 v6 = 3;
1148 }
1149 v4 = v6;
1150 return v2 * v4;
1151 } 1134 }
1152 1135
1153 //----- (004910A8) -------------------------------------------------------- 1136 //----- (004910A8) --------------------------------------------------------
1154 int Player::GetMeditation() 1137 int Player::GetMeditation()
1155 { 1138 {
1156 int v1; // al@1 1139 int v1; // al@1
1157 int base_level; // ecx@1
1158 int v4; // eax@3
1159 signed int v6; // [sp-4h] [bp-4h]@2
1160 1140
1161 v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION); 1141 v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION);
1162 base_level = v1 & 0x3F; 1142 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5);
1163 if ( v1 & 0x100 ) 1143 return multiplier * (v1 & 0x3F);
1164 {
1165 v6 = 5;
1166 }
1167 else
1168 {
1169 if ( (v1&0xFF) >= 0 )
1170 {
1171 v4 = ((v1 & 0x40) != 0) + 1;
1172 return base_level * v4;
1173 }
1174 v6 = 3;
1175 }
1176 v4 = v6;
1177 return base_level * v4;
1178 } 1144 }
1179 1145
1180 //----- (004910D3) -------------------------------------------------------- 1146 //----- (004910D3) --------------------------------------------------------
1181 int Player::CanIdentify(ItemGen *pItem) 1147 bool Player::CanIdentify( ItemGen *pItem )
1182 { 1148 {
1183 unsigned __int16 v2; // ax@1 1149 unsigned __int16 v2; // ax@1
1184 unsigned __int16 v3; // bx@1
1185 int uSkillMult; // eax@3
1186 int v5; // edi@7 1150 int v5; // edi@7
1187 signed int v6; // ebp@7
1188 char *v7; // esi@7
1189 signed int uSkillMultiplier; // [sp-4h] [bp-14h]@2
1190 1151
1191 if (CheckHiredNPCSpeciality(Scholar)) 1152 if (CheckHiredNPCSpeciality(Scholar))
1192 return true; 1153 return true;
1193 1154
1194 v2 = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); 1155 v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID);
1195 v3 = v2; 1156 if ( (signed int)SkillToMastery(v2) >= 4 )
1196 if ( v2 & 1 ) 1157 return true;
1197 { 1158
1198 uSkillMultiplier = 5; 1159 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1199 } 1160 v5 = multiplier * (v2 & 0x3F);
1200 else 1161 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St;
1201 {
1202 if ( (v2 & 0x80u) == 0 )
1203 {
1204 uSkillMult = ((v2 & 0x40) != 0) + 1;
1205 v5 = uSkillMult * (v3 & 0x3F);
1206 v6 = 0;
1207 v7 = (char *)&pItemsTable->pItems[pItem->uItemID].pIconName;
1208
1209 if ( (signed int)SkillToMastery(v3) >= 4 )
1210 v6 = 1;
1211 if ( v5 >= (unsigned __int8)v7[46] )
1212 v6 = 1;
1213 return v6;
1214 }
1215 uSkillMultiplier = 3;
1216 }
1217 uSkillMult = uSkillMultiplier;
1218 v5 = uSkillMult * (v3 & 0x3F);
1219 v6 = 0;
1220 v7 = (char *)&pItemsTable->pItems[pItem->uItemID].pIconName;
1221
1222 if ( (signed int)SkillToMastery(v3) >= 4 )
1223 v6 = 1;
1224 if ( v5 >= (unsigned __int8)v7[46] )
1225 v6 = 1;
1226 return v6;
1227 } 1162 }
1228 1163
1229 //----- (00491151) -------------------------------------------------------- 1164 //----- (00491151) --------------------------------------------------------
1230 int Player::CanRepair(ItemGen *a2) 1165 bool Player::CanRepair( ItemGen *pItem )
1231 { 1166 {
1232 unsigned __int16 v2; // ax@1 1167 unsigned __int16 v2; // ax@1
1233 unsigned __int16 v3; // bx@1
1234 int v4; // eax@3
1235 int v5; // edi@7 1168 int v5; // edi@7
1236 signed int v6; // ebp@7 1169
1237 signed int v10; // [sp-4h] [bp-14h]@2 1170 ItemDesc* v7 = &pItemsTable->pItems[pItem->uItemID];
1238
1239
1240 auto v7 = &pItemsTable->pItems[a2->uItemID];
1241 if (CheckHiredNPCSpeciality(Smith) && v7->uEquipType <= 2 || 1171 if (CheckHiredNPCSpeciality(Smith) && v7->uEquipType <= 2 ||
1242 CheckHiredNPCSpeciality(Armorer) && v7->uEquipType >= 3 && v7->uEquipType <= 9 || 1172 CheckHiredNPCSpeciality(Armorer) && v7->uEquipType >= 3 && v7->uEquipType <= 9 ||
1243 CheckHiredNPCSpeciality(Alchemist) && v7->uEquipType >= 9 ) 1173 CheckHiredNPCSpeciality(Alchemist) && v7->uEquipType >= 9 )
1244 return true; 1174 return true;
1245 1175
1246 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR); 1176 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR);
1247 v3 = v2; 1177 if ( (signed int)SkillToMastery(v2) >= 4 )
1248 if (v2 & 0x100 )
1249 {
1250 v10 = 5;
1251 }
1252 else
1253 {
1254 if ( (v2 & 0x80u) == 0 )
1255 {
1256 v4 = ((v2 & 0x40) != 0) + 1;
1257 goto LABEL_7;
1258 }
1259 v10 = 3;
1260 }
1261 v4 = v10;
1262 LABEL_7:
1263 v5 = v4 * (v3 & 0x3F);
1264 v6 = 0;
1265 if ( (signed int)SkillToMastery(v3) >= 4 )
1266 return true; 1178 return true;
1267 if ( v5 >= *((char *)(v7 + 1) + 2) ) 1179
1268 { 1180 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1269 __debugbreak(); // really odd 1181 v5 = multiplier * (v2 & 0x3F);
1270 return true; 1182 return v5 >= v7->uItemID_Rep_St;
1271 }
1272 return false;
1273 } 1183 }
1274 1184
1275 //----- (004911F3) -------------------------------------------------------- 1185 //----- (004911F3) --------------------------------------------------------
1276 int Player::GetMerchant() 1186 int Player::GetMerchant()
1277 { 1187 {
1278 Player *v1; // edi@1
1279 unsigned __int16 v2; // ax@1 1188 unsigned __int16 v2; // ax@1
1280 unsigned __int16 v3; // bx@1
1281 int v4; // esi@1
1282 int v5; // edi@1 1189 int v5; // edi@1
1283 int v7; // eax@3 1190 int v7; // eax@3
1284 int v8; // ecx@7 1191
1285 signed int v9; // [sp-4h] [bp-10h]@6
1286
1287 v1 = this;
1288 v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); 1192 v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT);
1289 v3 = v1->pActiveSkills[PLAYER_SKILL_MERCHANT]; 1193 if ( SkillToMastery(v2) >= 4 )
1290 v4 = v2 & 0x003F; 1194 return 10000;
1291 v5 = v1->pActiveSkills[PLAYER_SKILL_MERCHANT] & 0x3F; 1195
1196 v7 = GetPartyReputation();
1197 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1198 v5 = multiplier * (v2 & 0x3F);
1199 if (v5 == 0)
1200 {
1201 return -v7;
1202 }
1203 return v5 - v7 + 7;
1204 }
1205
1206 //----- (0049125A) --------------------------------------------------------
1207 int Player::GetPerception()
1208 {
1209 unsigned __int16 v2; // ax@1
1210 int v5; // edi@1
1211
1212 v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
1213 if ( SkillToMastery(v2) >= 4 )
1214 return 10000;
1215
1216 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1217 v5 = multiplier * (v2 & 0x3F);
1218 return v5;
1219 }
1220
1221 //----- (004912B0) --------------------------------------------------------
1222 int Player::GetDisarmTrap()
1223 {
1224 unsigned __int16 v2; // ax@1
1225 int v5; // edi@1
1226
1227 v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM);
1292 if ( (signed int)SkillToMastery(v2) >= 4 ) 1228 if ( (signed int)SkillToMastery(v2) >= 4 )
1293 return 10000; 1229 return 10000;
1294 v7 = GetPartyReputation(); 1230
1295 if ( !v4 ) 1231 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1296 return -v7; 1232 if ( HasEnchantedItemEquipped(35) ) //only the real skill level is supposed to be added again, not the multiplied value
1297 if ( v3 & 0x100 ) 1233 multiplier++;
1298 { 1234 v5 = multiplier * (v2 & 0x3F);
1299 v9 = 5; 1235 return v5;
1300 }
1301 else
1302 {
1303 if ( (v3 & 0x80u) == 0 )
1304 {
1305 v8 = ((v3 & 0x40) != 0) + 1;
1306 return v5 * (v8 - 1) - v7 + v4 + 7;
1307 }
1308 v9 = 3;
1309 }
1310 v8 = v9;
1311 return v5 * (v8 - 1) - v7 + v4 + 7;
1312 }
1313
1314 //----- (0049125A) --------------------------------------------------------
1315 int Player::GetPerception()
1316 {
1317 Player *v1; // edi@1
1318 unsigned __int16 v2; // ax@1
1319 unsigned __int16 v3; // bx@1
1320 int v4; // esi@1
1321 int v5; // edi@1
1322 int v7; // eax@5
1323 signed int v8; // [sp-4h] [bp-10h]@4
1324
1325 v1 = this;
1326 v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
1327 v3 = v1->pActiveSkills[PLAYER_SKILL_PERCEPTION];
1328 v4 = v2 & 0x3F;
1329 v5 = v1->pActiveSkills[PLAYER_SKILL_PERCEPTION] & 0x3F;
1330 if ( (signed int)SkillToMastery(v2) >= 4 )
1331 return 10000;
1332 if ( v3 & 0x100 )
1333 {
1334 v8 = 5;
1335 }
1336 else
1337 {
1338 if ( (v3 & 0x80u) == 0 )
1339 {
1340 v7 = ((v3 & 0x40) != 0) + 1;
1341 return v4 + v5 * (v7 - 1);
1342 }
1343 v8 = 3;
1344 }
1345 v7 = v8;
1346 return v4 + v5 * (v7 - 1);
1347 }
1348
1349 //----- (004912B0) --------------------------------------------------------
1350 int Player::GetDisarmTrap()
1351 {
1352 Player *v1; // ebp@1
1353 unsigned __int16 v2; // ax@1
1354 unsigned __int16 v3; // bx@1
1355 int v4; // esi@1
1356 int v5; // edi@1
1357 int v7; // eax@7
1358 signed int v8; // [sp-4h] [bp-14h]@6
1359
1360 v1 = this;
1361 v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM);
1362 v3 = v1->pActiveSkills[29];
1363 v4 = v2 & 0x3F;
1364 v5 = v1->pActiveSkills[29] & 0x3F;
1365 if ( (signed int)SkillToMastery(v2) >= 4 )
1366 return 10000;
1367 if ( HasEnchantedItemEquipped(35) )
1368 v4 *= 2;
1369 if ( v3 & 0x100 )
1370 {
1371 v8 = 5;
1372 }
1373 else
1374 {
1375 if ( (v3 & 0x80u) == 0 )
1376 {
1377 v7 = ((v3 & 0x40) != 0) + 1;
1378 return v4 + v5 * (v7 - 1);
1379 }
1380 v8 = 3;
1381 }
1382 v7 = v8;
1383 return v4 + v5 * (v7 - 1);
1384 } 1236 }
1385 1237
1386 //----- (00491317) -------------------------------------------------------- 1238 //----- (00491317) --------------------------------------------------------
1387 char Player::GetLearningPercent() 1239 char Player::GetLearningPercent()
1388 { 1240 {
1389 Player *v1; // esi@1
1390 int v2; // eax@1 1241 int v2; // eax@1
1391 unsigned __int16 v3; // bx@1 1242
1392 int v4; // ecx@1
1393 int v5; // eax@4
1394 signed int v7; // [sp-4h] [bp-Ch]@3
1395
1396 v1 = this;
1397 v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING); 1243 v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING);
1398 v3 = v1->pActiveSkills[36]; 1244 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
1399 v4 = v2 & 0x3F; 1245 return multiplier * v2 + 9;
1400 if ( v2 )
1401 {
1402 if (v3 & 0x100 )
1403 {
1404 v7 = 5;
1405 }
1406 else
1407 {
1408 if ( (v3 & 0x80u) == 0 )
1409 {
1410 v5 = ((v3 & 0x40) != 0) + 1;
1411 goto LABEL_8;
1412 }
1413 v7 = 3;
1414 }
1415 v5 = v7;
1416 LABEL_8:
1417 v2 = (v1->pActiveSkills[36] & 0x3F) * (v5 - 1) + v4 + 9;
1418 }
1419 return v2;
1420 } 1246 }
1421 1247
1422 //----- (0048C6AF) -------------------------------------------------------- 1248 //----- (0048C6AF) --------------------------------------------------------
1423 Player::Player() 1249 Player::Player()
1424 { 1250 {
4619 if ( armmaster_skill > 0 ) 4445 if ( armmaster_skill > 0 )
4620 { 4446 {
4621 int multiplier = 0; 4447 int multiplier = 0;
4622 if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) 4448 if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS )
4623 { 4449 {
4624 multiplier = GetMultiplierForMastery(armmaster_skill, 0, 0, 1, 2); 4450 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 0, 1, 2);
4625 } 4451 }
4626 else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK ) 4452 else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK )
4627 { 4453 {
4628 multiplier = GetMultiplierForMastery(armmaster_skill, 0, 1, 1, 2); 4454 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 1, 1, 2);
4629 } 4455 }
4630 armsMasterBonus = multiplier * (armmaster_skill & 0x3F); 4456 armsMasterBonus = multiplier * (armmaster_skill & 0x3F);
4631 } 4457 }
4632 4458
4633 switch(inSkill) 4459 switch(inSkill)
4634 { 4460 {
4635 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: 4461 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS:
4636 if (HasItemEquipped(EQUIP_BOW)) 4462 if (HasItemEquipped(EQUIP_BOW))
4637 { 4463 {
4638 int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); 4464 int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
4639 int multiplier = GetMultiplierForMastery(bowSkillLevel, 0, 0, 0, 1); 4465 int multiplier = GetMultiplierForSkillLevel(bowSkillLevel, 0, 0, 0, 1);
4640 return multiplier * (bowSkillLevel & 0x3F); 4466 return multiplier * (bowSkillLevel & 0x3F);
4641 } 4467 }
4642 return 0; 4468 return 0;
4643 break; 4469 break;
4644 case CHARACTER_ATTRIBUTE_HEALTH: 4470 case CHARACTER_ATTRIBUTE_HEALTH:
4670 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); 4496 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
4671 int multiplier = 0; 4497 int multiplier = 0;
4672 switch (itemSkillType) 4498 switch (itemSkillType)
4673 { 4499 {
4674 case PLAYER_SKILL_STAFF: 4500 case PLAYER_SKILL_STAFF:
4675 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1); 4501 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 1, 1, 1);
4676 break; 4502 break;
4677 case PLAYER_SKILL_SWORD: 4503 case PLAYER_SKILL_SWORD:
4678 case PLAYER_SKILL_SPEAR: 4504 case PLAYER_SKILL_SPEAR:
4679 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1); 4505 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 0, 0, 1);
4680 break; 4506 break;
4681 case PLAYER_SKILL_SHIELD: 4507 case PLAYER_SKILL_SHIELD:
4682 wearingArmor = true; 4508 wearingArmor = true;
4683 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); 4509 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2);
4684 break; 4510 break;
4685 case PLAYER_SKILL_LEATHER: 4511 case PLAYER_SKILL_LEATHER:
4686 wearingLeather = true; 4512 wearingLeather = true;
4687 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); 4513 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2);
4688 break; 4514 break;
4689 case PLAYER_SKILL_CHAIN: 4515 case PLAYER_SKILL_CHAIN:
4690 wearingArmor = true; 4516 wearingArmor = true;
4691 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); 4517 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1);
4692 break; 4518 break;
4693 case PLAYER_SKILL_PLATE: 4519 case PLAYER_SKILL_PLATE:
4694 wearingArmor = true; 4520 wearingArmor = true;
4695 multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); 4521 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1);
4696 break; 4522 break;
4697 } 4523 }
4698 ACSum += multiplier * (currArmorSkillLevel & 0x3F); 4524 ACSum += multiplier * (currArmorSkillLevel & 0x3F);
4699 } 4525 }
4700 } 4526 }
4701 4527
4702 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); 4528 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
4703 int dodgeMastery = SkillToMastery(dodgeSkillLevel); 4529 int dodgeMastery = SkillToMastery(dodgeSkillLevel);
4704 int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3); 4530 int multiplier = GetMultiplierForSkillLevel(dodgeSkillLevel, 1, 2, 3, 3);
4705 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) 4531 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) )
4706 { 4532 {
4707 ACSum += multiplier * (dodgeSkillLevel & 0x3F); 4533 ACSum += multiplier * (dodgeSkillLevel & 0x3F);
4708 } 4534 }
4709 return ACSum; 4535 return ACSum;
4715 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 4541 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
4716 if (!unarmedSkill) 4542 if (!unarmedSkill)
4717 { 4543 {
4718 return 0; 4544 return 0;
4719 } 4545 }
4720 int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2); 4546 int multiplier = GetMultiplierForSkillLevel(unarmedSkill, 0, 1, 2, 2);
4721 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); 4547 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F);
4722 } 4548 }
4723 for (int i = 0; i < 16; ++i) 4549 for (int i = 0; i < 16; ++i)
4724 { 4550 {
4725 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) 4551 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
4729 { 4555 {
4730 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem.uSkillType; 4556 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem.uSkillType;
4731 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); 4557 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
4732 if (currItemSkillType == PLAYER_SKILL_BLASTER) 4558 if (currItemSkillType == PLAYER_SKILL_BLASTER)
4733 { 4559 {
4734 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); 4560 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5);
4735 return multiplier * (currentItemSkillLevel & 0x3F); 4561 return multiplier * (currentItemSkillLevel & 0x3F);
4736 } 4562 }
4737 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) 4563 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
4738 { 4564 {
4739 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 4565 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
4740 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2); 4566 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 2, 2);
4741 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); 4567 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F);
4742 } 4568 }
4743 else 4569 else
4744 { 4570 {
4745 return armsMasterBonus + (currentItemSkillLevel & 0x3F); 4571 return armsMasterBonus + (currentItemSkillLevel & 0x3F);
4757 { 4583 {
4758 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType; 4584 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType;
4759 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); 4585 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType);
4760 if ( currentItemSkillType == PLAYER_SKILL_BOW ) 4586 if ( currentItemSkillType == PLAYER_SKILL_BOW )
4761 { 4587 {
4762 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 1, 1); 4588 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1);
4763 return multiplier * (currentItemSkillLevel & 0x3F); 4589 return multiplier * (currentItemSkillLevel & 0x3F);
4764 } 4590 }
4765 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) 4591 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER )
4766 { 4592 {
4767 int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); 4593 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5);
4768 return multiplier * (currentItemSkillLevel & 0x3F); 4594 return multiplier * (currentItemSkillLevel & 0x3F);
4769 } 4595 }
4770 } 4596 }
4771 } 4597 }
4772 return 0; 4598 return 0;
4778 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 4604 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
4779 if ( !unarmedSkillLevel ) 4605 if ( !unarmedSkillLevel )
4780 { 4606 {
4781 return 0; 4607 return 0;
4782 } 4608 }
4783 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); 4609 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2);
4784 return multiplier * (unarmedSkillLevel & 0x3F); 4610 return multiplier * (unarmedSkillLevel & 0x3F);
4785 } 4611 }
4786 for (int i = 0; i < 16; i++) 4612 for (int i = 0; i < 16; i++)
4787 { 4613 {
4788 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) 4614 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
4798 { 4624 {
4799 case PLAYER_SKILL_STAFF: 4625 case PLAYER_SKILL_STAFF:
4800 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) 4626 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
4801 { 4627 {
4802 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); 4628 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
4803 int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); 4629 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2);
4804 return multiplier * (unarmedSkillLevel & 0x3F); 4630 return multiplier * (unarmedSkillLevel & 0x3F);
4805 } 4631 }
4806 else 4632 else
4807 { 4633 {
4808 return armsMasterBonus; 4634 return armsMasterBonus;
4809 } 4635 }
4810 break; 4636 break;
4811 4637
4812 case PLAYER_SKILL_DAGGER: 4638 case PLAYER_SKILL_DAGGER:
4813 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1); 4639 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 1);
4814 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); 4640 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
4815 return armsMasterBonus + baseSkillBonus; 4641 return armsMasterBonus + baseSkillBonus;
4816 break; 4642 break;
4817 case PLAYER_SKILL_SWORD: 4643 case PLAYER_SKILL_SWORD:
4818 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0); 4644 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 0);
4819 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); 4645 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
4820 return armsMasterBonus + baseSkillBonus; 4646 return armsMasterBonus + baseSkillBonus;
4821 break; 4647 break;
4822 case PLAYER_SKILL_MACE: 4648 case PLAYER_SKILL_MACE:
4823 case PLAYER_SKILL_SPEAR: 4649 case PLAYER_SKILL_SPEAR:
4824 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1); 4650 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 1, 1, 1);
4825 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); 4651 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
4826 return armsMasterBonus + baseSkillBonus; 4652 return armsMasterBonus + baseSkillBonus;
4827 break; 4653 break;
4828 case PLAYER_SKILL_AXE: 4654 case PLAYER_SKILL_AXE:
4829 multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1); 4655 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 1, 1);
4830 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); 4656 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
4831 return armsMasterBonus + baseSkillBonus; 4657 return armsMasterBonus + baseSkillBonus;
4832 break; 4658 break;
4833 } 4659 }
4834 } 4660 }
4839 default: 4665 default:
4840 return 0; 4666 return 0;
4841 } 4667 }
4842 } 4668 }
4843 4669
4844 unsigned int Player::GetMultiplierForMastery(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4) 4670 unsigned int Player::GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4)
4845 { 4671 {
4846 int masteryLvl = SkillToMastery(skillValue); 4672 int masteryLvl = SkillToMastery(skillValue);
4847 switch (masteryLvl) 4673 switch (masteryLvl)
4848 { 4674 {
4849 case 1: return mult1; 4675 case 1: return mult1;