[Quest API] Add GetAAEXPPercentage() and GetEXPPercentage() to Perl/Lua (#4044)

* Initial Push

* Push

* Push.
This commit is contained in:
Alex King
2024-02-04 18:16:28 -05:00
committed by GitHub
parent 3f9a604c5c
commit 0ffea36905
5 changed files with 53 additions and 0 deletions
+22
View File
@@ -12097,3 +12097,25 @@ void Client::SetEXPModifier(uint32 zone_id, float exp_modifier, int16 instance_v
database.LoadCharacterEXPModifier(this);
}
int Client::GetAAEXPPercentage()
{
int scaled = static_cast<int>(330.0f * static_cast<float>(GetAAXP()) / GetRequiredAAExperience());
return static_cast<int>(std::round(scaled * 100.0 / 330.0));
}
int Client::GetEXPPercentage()
{
float norm = 0.0f;
uint32_t min = GetEXPForLevel(GetLevel());
uint32_t max = GetEXPForLevel(GetLevel() + 1);
if (min != max) {
norm = static_cast<float>(GetEXP() - min) / (max - min);
}
int scaled = static_cast<int>(330.0f * norm); // scale and truncate
return static_cast<int>(std::round(scaled * 100.0 / 330.0)); // unscaled pct
}