1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 10:47:45 +00:00

Calculate and display character stats correctly

This commit is contained in:
Mordred 2019-03-20 21:29:34 +01:00
parent 704a9df6ed
commit 986a692fcd
2 changed files with 85 additions and 91 deletions

View file

@ -254,7 +254,6 @@ void Sapphire::Entity::Player::calculateStats()
auto tribeInfo = pExdData->get< Sapphire::Data::Tribe >( tribe ); auto tribeInfo = pExdData->get< Sapphire::Data::Tribe >( tribe );
auto paramGrowthInfo = pExdData->get< Sapphire::Data::ParamGrow >( level ); auto paramGrowthInfo = pExdData->get< Sapphire::Data::ParamGrow >( level );
// TODO: put formula somewhere else...
float base = Math::CalcStats::calculateBaseStat( getAsPlayer() ); float base = Math::CalcStats::calculateBaseStat( getAsPlayer() );
m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierStrength ) / 100 ) + m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierStrength ) / 100 ) +
@ -270,6 +269,8 @@ void Sapphire::Entity::Player::calculateStats()
m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierPiety ) / 100 ) + m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo->modifierPiety ) / 100 ) +
tribeInfo->pIE ); tribeInfo->pIE );
m_baseStats.determination = static_cast< uint32_t >( base );
m_baseStats.pie = static_cast< uint32_t >( base );
m_baseStats.skillSpeed = paramGrowthInfo->baseSpeed; m_baseStats.skillSpeed = paramGrowthInfo->baseSpeed;
m_baseStats.spellSpeed = paramGrowthInfo->baseSpeed; m_baseStats.spellSpeed = paramGrowthInfo->baseSpeed;
m_baseStats.accuracy = paramGrowthInfo->baseSpeed; m_baseStats.accuracy = paramGrowthInfo->baseSpeed;
@ -278,6 +279,10 @@ void Sapphire::Entity::Player::calculateStats()
m_baseStats.healingPotMagic = paramGrowthInfo->baseSpeed; m_baseStats.healingPotMagic = paramGrowthInfo->baseSpeed;
m_baseStats.tenacity = paramGrowthInfo->baseSpeed; m_baseStats.tenacity = paramGrowthInfo->baseSpeed;
m_baseStats.attack = m_baseStats.str;
m_baseStats.attackPotMagic = m_baseStats.inte;
m_baseStats.healingPotMagic = m_baseStats.mnd;
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer(), m_pFw ); m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer(), m_pFw );
m_baseStats.max_hp = Math::CalcStats::calculateMaxHp( getAsPlayer(), m_pFw ); m_baseStats.max_hp = Math::CalcStats::calculateMaxHp( getAsPlayer(), m_pFw );
@ -288,9 +293,6 @@ void Sapphire::Entity::Player::calculateStats()
if( m_hp > m_baseStats.max_hp ) if( m_hp > m_baseStats.max_hp )
m_hp = m_baseStats.max_hp; m_hp = m_baseStats.max_hp;
m_baseStats.determination = static_cast< uint32_t >( base );
} }
@ -327,10 +329,10 @@ void Sapphire::Entity::Player::sendStats()
statPacket->data().spellSpeed1 = m_baseStats.spellSpeed; statPacket->data().spellSpeed1 = m_baseStats.spellSpeed;
statPacket->data().spellSpeedMod = 100; statPacket->data().spellSpeedMod = 100;
statPacket->data().criticalHitRate = m_baseStats.spellSpeed; statPacket->data().criticalHitRate = m_baseStats.critHitRate;
statPacket->data().defense = m_baseStats.spellSpeed; statPacket->data().defense = m_baseStats.defense;
statPacket->data().magicDefense = m_baseStats.spellSpeed; statPacket->data().magicDefense = m_baseStats.magicDefense;
statPacket->data().attack = m_baseStats.spellSpeed; statPacket->data().tenacity = m_baseStats.tenacity;
queuePacket( statPacket ); queuePacket( statPacket );
} }

View file

@ -13,80 +13,81 @@
using namespace Sapphire::Math; using namespace Sapphire::Math;
using namespace Sapphire::Entity; using namespace Sapphire::Entity;
const int levelTable[70][8] = const int levelTable[70][7] =
{ {
// PIE, MP, MAIN,SUB,DIV,HP,ELMT,THREAT // PIE, MP, MAIN,SUB,DIV,HP,ELMT,THREAT
{ 50, 104, 20, 56, 56, 0, 52, 2 }, { 50, 104, 20, 56, 56, 0, 52 },
{ 55, 114, 21, 57, 57, 0, 54, 2 }, { 55, 114, 21, 57, 57, 0, 54 },
{ 60, 123, 22, 60, 60, 0, 56, 3 }, { 60, 123, 22, 60, 60, 0, 56 },
{ 65,133,24,62,62,0,58 }, { 65, 133, 24, 62, 62, 0, 58 },
{ 70,142,26,65,65,0,60 }, { 70, 142, 26, 65, 65, 0, 60 },
{ 75,152,27,68,68,0,62 }, { 75, 152, 27, 68, 68, 0, 62 },
{ 80,161,29,70,70,0,64}, { 80, 161, 29, 70, 70, 0, 64 },
{ 85,171,31,73,73,0,66}, { 85, 171, 31, 73, 73, 0, 66 },
{ 90,180,33,76,76,0,68}, { 90, 180, 33, 76, 76, 0, 68 },
{ 95,190,35,78,78,0,70}, { 95, 190, 35, 78, 78, 0, 70 },
{ 100,209,36,82,82,0,73}, { 100, 209, 36, 82, 82, 0, 73 },
{ 105,228,38,85,85,0,75}, { 105, 228, 38, 85, 85, 0, 75 },
{ 110,247,41,89,89,0,78}, { 110, 247, 41, 89, 89, 0, 78 },
{ 115,266,44,93,93,0,81}, { 115, 266, 44, 93, 93, 0, 81 },
{ 120,285,46,96,96,0,84}, { 120, 285, 46, 96, 96, 0, 84 },
{ 125,304,49,100,100,0,86}, { 125, 304, 49, 100, 100, 0, 86 },
{ 130,323,52,104,104,0,89}, { 130, 323, 52, 104, 104, 0, 89 },
{ 135,342,54,109,109,0,93}, { 135, 342, 54, 109, 109, 0, 93 },
{ 140,361,57,113,113,0,95}, { 140, 361, 57, 113, 113, 0, 95 },
{ 145,380,60,116,116,0,98}, { 145, 380, 60, 116, 116, 0, 98 },
{ 150,418,63,122,122,0,102}, { 150, 418, 63, 122, 122, 0, 102 },
{ 155,456,67,127,127,0,105}, { 155, 456, 67, 127, 127, 0, 105 },
{ 160,494,71,133,133,0,109}, { 160, 494, 71, 133, 133, 0, 109 },
{ 165,532,74,138,138,0,113}, { 165, 532, 74, 138, 138, 0, 113 },
{ 170,570,78,144,144,0,117}, { 170, 570, 78, 144, 144, 0, 117 },
{ 175,608,81,150,150,0,121}, { 175, 608, 81, 150, 150, 0, 121 },
{ 180,646,85,155,155,0,125}, { 180, 646, 85, 155, 155, 0, 125 },
{ 185,684,89,162,162,0,129}, { 185, 684, 89, 162, 162, 0, 129 },
{ 190,722,92,168,168,0,133}, { 190, 722, 92, 168, 168, 0, 133 },
{ 195,760,97,173,173,0,137}, { 195, 760, 97, 173, 173, 0, 137 },
{ 200,826,101,181,181,0,143}, { 200, 826, 101, 181, 181, 0, 143 },
{ 205,893,106,188,188,0,148}, { 205, 893, 106, 188, 188, 0, 148 },
{ 210,959,110,194,194,0,153}, { 210, 959, 110, 194, 194, 0, 153 },
{ 215,1026,115,202,202,0,159}, { 215, 1026, 115, 202, 202, 0, 159 },
{ 220,1092,119,209,209,0,165}, { 220, 1092, 119, 209, 209, 0, 165 },
{ 225,1159,124,215,215,0,170}, { 225, 1159, 124, 215, 215, 0, 170 },
{ 230,1225,128,223,223,0,176}, { 230, 1225, 128, 223, 223, 0, 176 },
{ 235,1292,134,229,229,0,181}, { 235, 1292, 134, 229, 229, 0, 181 },
{ 240,1358,139,236,236,0,186}, { 240, 1358, 139, 236, 236, 0, 186 },
{ 245,1425,144,244,244,0,192}, { 245, 1425, 144, 244, 244, 0, 192 },
{ 250,1548,150,253,253,0,200}, { 250, 1548, 150, 253, 253, 0, 200 },
{ 255,1672,155,263,263,0,207}, { 255, 1672, 155, 263, 263, 0, 207 },
{ 260,1795,161,272,272,0,215}, { 260, 1795, 161, 272, 272, 0, 215 },
{ 265,1919,166,283,283,0,223}, { 265, 1919, 166, 283, 283, 0, 223 },
{ 270,2042,171,292,292,0,231}, { 270, 2042, 171, 292, 292, 0, 231 },
{ 275,2166,177,302,302,0,238}, { 275, 2166, 177, 302, 302, 0, 238 },
{ 280,2289,183,311,311,0,246}, { 280, 2289, 183, 311, 311, 0, 246 },
{ 285,2413,189,322,322,0,254}, { 285, 2413, 189, 322, 322, 0, 254 },
{ 290,2536,196,331,331,0,261}, { 290, 2536, 196, 331, 331, 0, 261 },
{ 300,2660,202,341,341,1700,269}, { 300, 2660, 202, 341, 341, 1700, 269 },
{ 315,3000,204,342,393,1774,270}, { 315, 3000, 204, 342, 393, 1774, 270 },
{ 330,3380,205,344,444,1851,271}, { 330, 3380, 205, 344, 444, 1851, 271 },
{ 360,3810,207,345,496,1931,273}, { 360, 3810, 207, 345, 496, 1931, 273 },
{ 390,4300,209,346,548,2015,274}, { 390, 4300, 209, 346, 548, 2015, 274 },
{ 420,4850,210,347,600,2102,275}, { 420, 4850, 210, 347, 600, 2102, 275 },
{ 450,5470,212,349,651,2194,276}, { 450, 5470, 212, 349, 651, 2194, 276 },
{ 480,6170,214,350,703,2289,278}, { 480, 6170, 214, 350, 703, 2289, 278 },
{ 510,6950,215,351,755,2388,279}, { 510, 6950, 215, 351, 755, 2388, 279 },
{ 540,7840,217,352,806,2492,280}, { 540, 7840, 217, 352, 806, 2492, 280 },
{ 620,8840,218,354,858,2600,282}, { 620, 8840, 218, 354, 858, 2600, 282 },
{ 650,8980,224,355,941,2700,283}, { 650, 8980, 224, 355, 941, 2700, 283 },
{ 680,9150,228,356,1032,2800,284}, { 680, 9150, 228, 356, 1032, 2800, 284 },
{ 710,9350,236,357,1133,2900,286}, { 710, 9350, 236, 357, 1133, 2900, 286 },
{ 740,9590,244,358,1243,3000,287}, { 740, 9590, 244, 358, 1243, 3000, 287 },
{ 770,9870,252,359,1364,3100,288}, { 770, 9870, 252, 359, 1364, 3100, 288 },
{ 800,10190,260,360,1497,3200,290}, { 800, 10190, 260, 360, 1497, 3200, 290 },
{ 830,10560,268,361,1643,3300,292}, { 830, 10560, 268, 361, 1643, 3300, 292 },
{ 860,10980,276,362,1802,3400,293}, { 860, 10980, 276, 362, 1802, 3400, 293 },
{ 890,11450,284,363,1978,3500,294}, { 890, 11450, 284, 363, 1978, 3500, 294 },
{ 890,12000,292,364,2170,3600,295} { 890, 12000, 292, 364, 2170, 3600, 295 }
}; };
/* /*
Class used for battle-related formulas and calculations. Class used for battle-related formulas and calculations.
Big thanks to the Theoryjerks group! Big thanks to the Theoryjerks group!
@ -111,19 +112,10 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
float base = 0.0f; float base = 0.0f;
uint8_t level = pPlayer->getLevel(); uint8_t level = pPlayer->getLevel();
// SB Base Stat Formula (Aligned) if( level > 70 )
if( level > 60 ) level = 70;
{
base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8 ) );
}
// HW Base Stat Formula (Aligned)
else if( level > 50 )
base = 1.63f * level + 121.02f;
// ARR Base Stat Formula (Off by one in several cases)
else
base = 0.052602f * ( level * level ) + ( 1.0179f * level ) + 19.6f;
return base; return static_cast< float >( levelTable[level][2] );
} }
// Leggerless' HP Formula // Leggerless' HP Formula