mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Quest API] Add GetAAEXPPercentage() and GetEXPPercentage() to Perl/Lua (#4044)
* Initial Push * Push * Push.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user