mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Bug Fix] Resolve XP Calculation Bug introduced w/ recent Rule addition (#2703)
* [Bug Fix] Resolve XP Calculation Bug introduced w/ recent Rule addition * Camel case. Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
parent
c1ad086eaf
commit
ebf69e9b6e
38
zone/exp.cpp
38
zone/exp.cpp
@ -480,17 +480,18 @@ void Client::CalculateExp(uint64 in_add_exp, uint64 &add_exp, uint64 &add_aaxp,
|
||||
add_exp *= GetEXPModifier(zone->GetZoneID(), zone->GetInstanceVersion());
|
||||
}
|
||||
|
||||
add_exp = GetEXP() + add_exp;
|
||||
|
||||
//Enforce Percent XP Cap per kill, if rule is enabled
|
||||
int kill_percent_xp_cap = RuleI(Character, ExperiencePercentCapPerKill);
|
||||
if (kill_percent_xp_cap >= 0) {
|
||||
auto experience_for_level = (GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel()));
|
||||
auto exp_percent = static_cast<uint32>(std::ceil(static_cast<float>(add_exp / experience_for_level) * 100.0f));
|
||||
float exp_percent = (float)((float)add_exp / (float)(GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel()))) * (float)100; //EXP needed for level
|
||||
if (exp_percent > kill_percent_xp_cap) {
|
||||
add_exp = static_cast<uint64>(std::floor(experience_for_level * (kill_percent_xp_cap / 100.0f)));
|
||||
add_exp = GetEXP() + static_cast<uint64>(std::floor(experience_for_level * (kill_percent_xp_cap / 100.0f)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
add_exp = GetEXP() + add_exp;
|
||||
}
|
||||
|
||||
void Client::AddEXP(uint64 in_add_exp, uint8 conlevel, bool resexp) {
|
||||
@ -510,7 +511,6 @@ void Client::AddEXP(uint64 in_add_exp, uint8 conlevel, bool resexp) {
|
||||
|
||||
// Calculate regular XP
|
||||
CalculateExp(in_add_exp, exp, aaexp, conlevel, resexp);
|
||||
|
||||
// Calculate regular AA XP
|
||||
if (!RuleB(AA, NormalizedAAEnabled))
|
||||
{
|
||||
@ -588,32 +588,34 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((set_exp + set_aaxp) > (m_pp.exp+m_pp.expAA)) {
|
||||
|
||||
uint64 exp_gained = set_exp - m_pp.exp;
|
||||
uint64 aaxp_gained = set_aaxp - m_pp.expAA;
|
||||
uint64 current_exp = GetEXP();
|
||||
uint64 current_aa_exp = GetAAXP();
|
||||
uint64 total_current_exp = current_exp + current_aa_exp;
|
||||
uint64 total_add_exp = set_exp + set_aaxp;
|
||||
if (total_add_exp > total_current_exp) {
|
||||
uint64 exp_gained = set_exp - current_exp;
|
||||
uint64 aa_exp_gained = set_aaxp - current_aa_exp;
|
||||
float exp_percent = (float)((float)exp_gained / (float)(GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel())))*(float)100; //EXP needed for level
|
||||
float aaxp_percent = (float)((float)aaxp_gained / (float)(RuleI(AA, ExpPerPoint)))*(float)100; //AAEXP needed for level
|
||||
float aa_exp_percent = (float)((float)aa_exp_gained / (float)(RuleI(AA, ExpPerPoint)))*(float)100; //AAEXP needed for level
|
||||
std::string exp_amount_message = "";
|
||||
if (RuleI(Character, ShowExpValues) >= 1) {
|
||||
if (exp_gained > 0 && aaxp_gained > 0) {
|
||||
exp_amount_message = fmt::format("({}) ({})", exp_gained, aaxp_gained);
|
||||
if (exp_gained > 0 && aa_exp_gained > 0) {
|
||||
exp_amount_message = fmt::format("({}) ({})", exp_gained, aa_exp_gained);
|
||||
}
|
||||
else if (exp_gained > 0) {
|
||||
exp_amount_message = fmt::format("({})", exp_gained);
|
||||
}
|
||||
else {
|
||||
exp_amount_message = fmt::format("({}) AA", aaxp_gained);
|
||||
exp_amount_message = fmt::format("({}) AA", aa_exp_gained);
|
||||
}
|
||||
}
|
||||
|
||||
std::string exp_percent_message = "";
|
||||
if (RuleI(Character, ShowExpValues) >= 2) {
|
||||
if (exp_gained > 0 && aaxp_gained > 0) exp_percent_message = StringFormat("(%.3f%%, %.3f%%AA)", exp_percent, aaxp_percent);
|
||||
if (exp_gained > 0 && aa_exp_gained > 0) exp_percent_message = StringFormat("(%.3f%%, %.3f%%AA)", exp_percent, aa_exp_percent);
|
||||
else if (exp_gained > 0) exp_percent_message = StringFormat("(%.3f%%)", exp_percent);
|
||||
else exp_percent_message = StringFormat("(%.3f%%AA)", aaxp_percent);
|
||||
else exp_percent_message = StringFormat("(%.3f%%AA)", aa_exp_percent);
|
||||
}
|
||||
|
||||
if (isrezzexp) {
|
||||
if (RuleI(Character, ShowExpValues) > 0)
|
||||
Message(Chat::Experience, "You regain %s experience from resurrection. %s", exp_amount_message.c_str(), exp_percent_message.c_str());
|
||||
@ -636,8 +638,8 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if((set_exp + set_aaxp) < (m_pp.exp+m_pp.expAA)){ //only loss message if you lose exp, no message if you gained/lost nothing.
|
||||
uint64 exp_lost = m_pp.exp - set_exp;
|
||||
else if(total_add_exp < total_current_exp){ //only loss message if you lose exp, no message if you gained/lost nothing.
|
||||
uint64 exp_lost = current_exp - set_exp;
|
||||
float exp_percent = (float)((float)exp_lost / (float)(GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel())))*(float)100;
|
||||
|
||||
if (RuleI(Character, ShowExpValues) == 1 && exp_lost > 0) Message(Chat::Yellow, "You have lost %i experience.", exp_lost);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user