Someone asked me:
How to calculate player skill percent on www?
I wrote for him example code. Maybe someone else needs it too:
How to calculate player skill percent on www?
I wrote for him example code. Maybe someone else needs it too:
PHP:
<?php
function getSkillPercent($skillId, $vocationId, $playerSkillValue, $playerSkillCount)
{
// information about skills multipliers for vocations from vocations.xml
$vocSkillInfo = [
0 => [1.5, 2.0, 2.0, 2.0, 2.0, 1.5, 1.1],
1 => [1.5, 2.0, 2.0, 2.0, 2.0, 1.5, 1.1],
2 => [1.5, 1.8, 1.8, 1.8, 1.8, 1.5, 1.1],
3 => [1.2, 1.2, 1.2, 1.2, 1.1, 1.1, 1.1],
4 => [1.1, 1.1, 1.1, 1.1, 1.4, 1.1, 1.1],
5 => [1.5, 2.0, 2.0, 2.0, 2.0, 1.5, 1.1],
6 => [1.5, 1.8, 1.8, 1.8, 1.8, 1.5, 1.1],
7 => [1.2, 1.2, 1.2, 1.2, 1.1, 1.1, 1.1],
8 => [1.1, 1.1, 1.1, 1.1, 1.4, 1.1, 1.1],
];
// skill base, same for all Tibia servers
$skillBase = [50, 50, 50, 50, 30, 100, 20];
$playerNextSkillValue = $playerSkillValue + 1;
$nextSkillTries = $skillBase[$skillId] * pow($vocSkillInfo[$vocationId][$skillId], $playerNextSkillValue - 11);
return floor(($playerSkillCount / $nextSkillTries) * 100);
}
// distance skill (4), royal paladin (7), 70 distance, 11111 tries
echo getSkillPercent(4, 7, 70, 11111) . '%';