mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 03:31:08 +00:00
[Experience] Add SetExp/SetAAExp lua mods (#4292)
This commit is contained in:
+31
-13
@@ -497,7 +497,7 @@ void Client::CalculateExp(uint64 in_add_exp, uint64 &add_exp, uint64 &add_aaxp,
|
||||
add_exp = GetEXP() + add_exp;
|
||||
}
|
||||
|
||||
void Client::AddEXP(uint64 in_add_exp, uint8 conlevel, bool resexp) {
|
||||
void Client::AddEXP(ExpSource exp_source, uint64 in_add_exp, uint8 conlevel, bool resexp) {
|
||||
if (!IsEXPEnabled()) {
|
||||
return;
|
||||
}
|
||||
@@ -569,10 +569,32 @@ void Client::AddEXP(uint64 in_add_exp, uint8 conlevel, bool resexp) {
|
||||
}
|
||||
|
||||
// Now update our character's normal and AA xp
|
||||
SetEXP(exp, aaexp, resexp);
|
||||
SetEXP(exp_source, exp, aaexp, resexp);
|
||||
}
|
||||
|
||||
void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
void Client::SetEXP(ExpSource exp_source, uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
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;
|
||||
|
||||
#ifdef LUA_EQEMU
|
||||
uint64 lua_ret = 0;
|
||||
bool ignore_default = false;
|
||||
lua_ret = LuaParser::Instance()->SetEXP(this, exp_source, current_exp, set_exp, isrezzexp, ignore_default);
|
||||
if (ignore_default) {
|
||||
set_exp = lua_ret;
|
||||
}
|
||||
|
||||
lua_ret = 0;
|
||||
ignore_default = false;
|
||||
lua_ret = LuaParser::Instance()->SetAAEXP(this, exp_source, current_aa_exp, set_aaxp, isrezzexp, ignore_default);
|
||||
if (ignore_default) {
|
||||
set_aaxp = lua_ret;
|
||||
}
|
||||
total_add_exp = set_exp + set_aaxp;
|
||||
#endif
|
||||
|
||||
LogDebug("Attempting to Set Exp for [{}] (XP: [{}], AAXP: [{}], Rez: [{}])", GetCleanName(), set_exp, set_aaxp, isrezzexp ? "true" : "false");
|
||||
|
||||
auto max_AAXP = GetRequiredAAExperience();
|
||||
@@ -591,10 +613,6 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -1084,7 +1102,7 @@ uint32 Client::GetEXPForLevel(uint16 check_level)
|
||||
return finalxp;
|
||||
}
|
||||
|
||||
void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods)
|
||||
void Client::AddLevelBasedExp(ExpSource exp_source, uint8 exp_percentage, uint8 max_level, bool ignore_mods)
|
||||
{
|
||||
uint64 award;
|
||||
uint64 xp_for_level;
|
||||
@@ -1113,10 +1131,10 @@ void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore
|
||||
}
|
||||
|
||||
uint64 newexp = GetEXP() + award;
|
||||
SetEXP(newexp, GetAAXP());
|
||||
SetEXP(exp_source, newexp, GetAAXP());
|
||||
}
|
||||
|
||||
void Group::SplitExp(const uint64 exp, Mob* other) {
|
||||
void Group::SplitExp(ExpSource exp_source, const uint64 exp, Mob* other) {
|
||||
if (other->CastToNPC()->MerchantType != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1174,13 +1192,13 @@ void Group::SplitExp(const uint64 exp, Mob* other) {
|
||||
if (diff >= max_diff) {
|
||||
const uint64 tmp = (m->GetLevel() + 3) * (m->GetLevel() + 3) * 75 * 35 / 10;
|
||||
const uint64 tmp2 = group_experience / member_count;
|
||||
m->CastToClient()->AddEXP(tmp < tmp2 ? tmp : tmp2, consider_level);
|
||||
m->CastToClient()->AddEXP(exp_source, tmp < tmp2 ? tmp : tmp2, consider_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Raid::SplitExp(const uint64 exp, Mob* other) {
|
||||
void Raid::SplitExp(ExpSource exp_source, const uint64 exp, Mob* other) {
|
||||
if (other->CastToNPC()->MerchantType != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1225,7 +1243,7 @@ void Raid::SplitExp(const uint64 exp, Mob* other) {
|
||||
if (diff >= max_diff) {
|
||||
const uint64 tmp = (m.member->GetLevel() + 3) * (m.member->GetLevel() + 3) * 75 * 35 / 10;
|
||||
const uint64 tmp2 = (raid_experience / member_modifier) + 1;
|
||||
m.member->AddEXP(tmp < tmp2 ? tmp : tmp2, consider_level);
|
||||
m.member->AddEXP(exp_source, tmp < tmp2 ? tmp : tmp2, consider_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user