[Experience] Change Exp Calculations to be 64 bit where needed. (#2677)

* [Experience] Change Exp Calculations to be 64 bit where needed.

* Fix lua values

* Formatting
This commit is contained in:
Aeadoin 2022-12-30 22:03:30 -05:00 committed by GitHub
parent f962466573
commit 9c3c5b5230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 92 additions and 85 deletions

View File

@ -2497,7 +2497,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
Group *kg = entity_list.GetGroupByClient(give_exp_client); Group *kg = entity_list.GetGroupByClient(give_exp_client);
Raid *kr = entity_list.GetRaidByClient(give_exp_client); Raid *kr = entity_list.GetRaidByClient(give_exp_client);
int32 finalxp = give_exp_client->GetExperienceForKill(this); int64 finalxp = give_exp_client->GetExperienceForKill(this);
finalxp = give_exp_client->mod_client_xp(finalxp, this); finalxp = give_exp_client->mod_client_xp(finalxp, this);
// handle task credit on behalf of the killer // handle task credit on behalf of the killer

View File

@ -625,17 +625,17 @@ public:
void AddCrystals(uint32 Radiant, uint32 Ebon); void AddCrystals(uint32 Radiant, uint32 Ebon);
void SendCrystalCounts(); void SendCrystalCounts();
uint32 GetExperienceForKill(Mob *against); uint64 GetExperienceForKill(Mob *against);
void AddEXP(uint32 in_add_exp, uint8 conlevel = 0xFF, bool resexp = false); void AddEXP(uint64 in_add_exp, uint8 conlevel = 0xFF, bool resexp = false);
uint32 CalcEXP(uint8 conlevel = 0xFF); uint64 CalcEXP(uint8 conlevel = 0xFF);
void CalculateNormalizedAAExp(uint32 &add_aaxp, uint8 conlevel, bool resexp); void CalculateNormalizedAAExp(uint64 &add_aaxp, uint8 conlevel, bool resexp);
void CalculateStandardAAExp(uint32 &add_aaxp, uint8 conlevel, bool resexp); void CalculateStandardAAExp(uint64 &add_aaxp, uint8 conlevel, bool resexp);
void CalculateLeadershipExp(uint32 &add_exp, uint8 conlevel); void CalculateLeadershipExp(uint64 &add_exp, uint8 conlevel);
void CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp, uint8 conlevel, bool resexp); void CalculateExp(uint64 in_add_exp, uint64 &add_exp, uint64 &add_aaxp, uint8 conlevel, bool resexp);
void SetEXP(uint32 set_exp, uint32 set_aaxp, bool resexp=false); void SetEXP(uint64 set_exp, uint64 set_aaxp, bool resexp=false);
void AddLevelBasedExp(uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false); void AddLevelBasedExp(uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false);
void SetLeadershipEXP(uint32 group_exp, uint32 raid_exp); void SetLeadershipEXP(uint64 group_exp, uint64 raid_exp);
void AddLeadershipEXP(uint32 group_exp, uint32 raid_exp); void AddLeadershipEXP(uint64 group_exp, uint64 raid_exp);
void SendLeadershipEXPUpdate(); void SendLeadershipEXPUpdate();
bool IsLeadershipEXPOn(); bool IsLeadershipEXPOn();
inline int GetLeadershipAA(int AAID) { return m_pp.leader_abilities.ranks[AAID]; } inline int GetLeadershipAA(int AAID) { return m_pp.leader_abilities.ranks[AAID]; }
@ -1608,7 +1608,7 @@ public:
void mod_client_death_npc(Mob* killerMob); void mod_client_death_npc(Mob* killerMob);
void mod_client_death_duel(Mob* killerMob); void mod_client_death_duel(Mob* killerMob);
void mod_client_death_env(); void mod_client_death_env();
int32 mod_client_xp(int32 in_exp, NPC *npc); int64 mod_client_xp(int64 in_exp, NPC *npc);
uint32 mod_client_xp_for_level(uint32 xp, uint16 check_level); uint32 mod_client_xp_for_level(uint32 xp, uint16 check_level);
int mod_client_haste_cap(int cap); int mod_client_haste_cap(int cap);
int mod_consume(EQ::ItemData *item, EQ::item::ItemType type, int change); int mod_consume(EQ::ItemData *item, EQ::item::ItemType type, int change);

View File

@ -38,7 +38,7 @@
extern QueryServ* QServ; extern QueryServ* QServ;
static uint32 ScaleAAXPBasedOnCurrentAATotal(int earnedAA, uint32 add_aaxp) static uint64 ScaleAAXPBasedOnCurrentAATotal(int earnedAA, uint64 add_aaxp)
{ {
float baseModifier = RuleR(AA, ModernAAScalingStartPercent); float baseModifier = RuleR(AA, ModernAAScalingStartPercent);
int aaMinimum = RuleI(AA, ModernAAScalingAAMinimum); int aaMinimum = RuleI(AA, ModernAAScalingAAMinimum);
@ -64,7 +64,7 @@ static uint32 ScaleAAXPBasedOnCurrentAATotal(int earnedAA, uint32 add_aaxp)
float normalizedScale = (float)remainingAA / scaleRange; float normalizedScale = (float)remainingAA / scaleRange;
// Scale. // Scale.
uint32 totalWithExpMod = add_aaxp * (baseModifier / 100) * normalizedScale; uint64 totalWithExpMod = add_aaxp * (baseModifier / 100) * normalizedScale;
// Are we so close to the scale limit that we're earning more XP without scaling? This // Are we so close to the scale limit that we're earning more XP without scaling? This
// will happen when we get very close to the limit. In this case, just grant the unscaled // will happen when we get very close to the limit. In this case, just grant the unscaled
@ -104,13 +104,13 @@ static uint32 MaxBankedRaidLeadershipPoints(int Level)
return 10; return 10;
} }
uint32 Client::CalcEXP(uint8 conlevel) { uint64 Client::CalcEXP(uint8 conlevel) {
uint32 in_add_exp = EXP_FORMULA; uint64 in_add_exp = EXP_FORMULA;
if((XPRate != 0)) if((XPRate != 0))
in_add_exp = static_cast<uint32>(in_add_exp * (static_cast<float>(XPRate) / 100.0f)); in_add_exp = static_cast<uint64>(in_add_exp * (static_cast<float>(XPRate) / 100.0f));
float totalmod = 1.0; float totalmod = 1.0;
float zemmod = 1.0; float zemmod = 1.0;
@ -139,7 +139,7 @@ uint32 Client::CalcEXP(uint8 conlevel) {
totalmod += RuleR(Zone, HotZoneBonus); totalmod += RuleR(Zone, HotZoneBonus);
} }
in_add_exp = uint32(float(in_add_exp) * totalmod * zemmod); in_add_exp = uint64(float(in_add_exp) * totalmod * zemmod);
if(RuleB(Character,UseXPConScaling)) if(RuleB(Character,UseXPConScaling))
{ {
@ -202,10 +202,10 @@ uint32 Client::CalcEXP(uint8 conlevel) {
return in_add_exp; return in_add_exp;
} }
uint32 Client::GetExperienceForKill(Mob *against) uint64 Client::GetExperienceForKill(Mob *against)
{ {
#ifdef LUA_EQEMU #ifdef LUA_EQEMU
uint32 lua_ret = 0; uint64 lua_ret = 0;
bool ignoreDefault = false; bool ignoreDefault = false;
lua_ret = LuaParser::Instance()->GetExperienceForKill(this, against, ignoreDefault); lua_ret = LuaParser::Instance()->GetExperienceForKill(this, against, ignoreDefault);
@ -216,7 +216,7 @@ uint32 Client::GetExperienceForKill(Mob *against)
if (against && against->IsNPC()) { if (against && against->IsNPC()) {
uint32 level = (uint32)against->GetLevel(); uint32 level = (uint32)against->GetLevel();
uint32 ret = EXP_FORMULA; uint64 ret = EXP_FORMULA;
auto mod = against->GetKillExpMod(); auto mod = against->GetKillExpMod();
if(mod >= 0) { if(mod >= 0) {
@ -257,7 +257,7 @@ float static GetConLevelModifierPercent(uint8 conlevel)
} }
} }
void Client::CalculateNormalizedAAExp(uint32 &add_aaxp, uint8 conlevel, bool resexp) void Client::CalculateNormalizedAAExp(uint64 &add_aaxp, uint8 conlevel, bool resexp)
{ {
// Functionally this is the same as having the case in the switch, but this is // Functionally this is the same as having the case in the switch, but this is
// cleaner to read. // cleaner to read.
@ -281,7 +281,7 @@ void Client::CalculateNormalizedAAExp(uint32 &add_aaxp, uint8 conlevel, bool res
add_aaxp = percentToAAXp * (xpPerAA / (whiteConKillsPerAA / colorModifier)); add_aaxp = percentToAAXp * (xpPerAA / (whiteConKillsPerAA / colorModifier));
} }
void Client::CalculateStandardAAExp(uint32 &add_aaxp, uint8 conlevel, bool resexp) void Client::CalculateStandardAAExp(uint64 &add_aaxp, uint8 conlevel, bool resexp)
{ {
if (!resexp) if (!resexp)
{ {
@ -332,26 +332,26 @@ void Client::CalculateStandardAAExp(uint32 &add_aaxp, uint8 conlevel, bool resex
add_aaxp *= GetAAEXPModifier(zone->GetZoneID(), zone->GetInstanceVersion()); add_aaxp *= GetAAEXPModifier(zone->GetZoneID(), zone->GetInstanceVersion());
} }
add_aaxp = (uint32)(RuleR(Character, AAExpMultiplier) * add_aaxp * aatotalmod); add_aaxp = (uint64)(RuleR(Character, AAExpMultiplier) * add_aaxp * aatotalmod);
} }
void Client::CalculateLeadershipExp(uint32 &add_exp, uint8 conlevel) void Client::CalculateLeadershipExp(uint64 &add_exp, uint8 conlevel)
{ {
if (IsLeadershipEXPOn() && (conlevel == CON_BLUE || conlevel == CON_WHITE || conlevel == CON_YELLOW || conlevel == CON_RED)) if (IsLeadershipEXPOn() && (conlevel == CON_BLUE || conlevel == CON_WHITE || conlevel == CON_YELLOW || conlevel == CON_RED))
{ {
add_exp = static_cast<uint32>(static_cast<float>(add_exp) * 0.8f); add_exp = static_cast<uint64>(static_cast<float>(add_exp) * 0.8f);
if (GetGroup()) if (GetGroup())
{ {
if (m_pp.group_leadership_points < MaxBankedGroupLeadershipPoints(GetLevel()) if (m_pp.group_leadership_points < MaxBankedGroupLeadershipPoints(GetLevel())
&& RuleI(Character, KillsPerGroupLeadershipAA) > 0) && RuleI(Character, KillsPerGroupLeadershipAA) > 0)
{ {
uint32 exp = GROUP_EXP_PER_POINT / RuleI(Character, KillsPerGroupLeadershipAA); uint64 exp = GROUP_EXP_PER_POINT / RuleI(Character, KillsPerGroupLeadershipAA);
Client *mentoree = GetGroup()->GetMentoree(); Client *mentoree = GetGroup()->GetMentoree();
if (GetGroup()->GetMentorPercent() && mentoree && if (GetGroup()->GetMentorPercent() && mentoree &&
mentoree->GetGroupPoints() < MaxBankedGroupLeadershipPoints(mentoree->GetLevel())) mentoree->GetGroupPoints() < MaxBankedGroupLeadershipPoints(mentoree->GetLevel()))
{ {
uint32 mentor_exp = exp * (GetGroup()->GetMentorPercent() / 100.0f); uint64 mentor_exp = exp * (GetGroup()->GetMentorPercent() / 100.0f);
exp -= mentor_exp; exp -= mentor_exp;
mentoree->AddLeadershipEXP(mentor_exp, 0); // ends up rounded down mentoree->AddLeadershipEXP(mentor_exp, 0); // ends up rounded down
mentoree->MessageString(Chat::LeaderShip, GAIN_GROUP_LEADERSHIP_EXP); mentoree->MessageString(Chat::LeaderShip, GAIN_GROUP_LEADERSHIP_EXP);
@ -391,12 +391,12 @@ void Client::CalculateLeadershipExp(uint32 &add_exp, uint8 conlevel)
&& RuleI(Character, KillsPerGroupLeadershipAA) > 0) && RuleI(Character, KillsPerGroupLeadershipAA) > 0)
{ {
uint32 group_id = raid->GetGroup(this); uint32 group_id = raid->GetGroup(this);
uint32 exp = GROUP_EXP_PER_POINT / RuleI(Character, KillsPerGroupLeadershipAA); uint64 exp = GROUP_EXP_PER_POINT / RuleI(Character, KillsPerGroupLeadershipAA);
Client *mentoree = raid->GetMentoree(group_id); Client *mentoree = raid->GetMentoree(group_id);
if (raid->GetMentorPercent(group_id) && mentoree && if (raid->GetMentorPercent(group_id) && mentoree &&
mentoree->GetGroupPoints() < MaxBankedGroupLeadershipPoints(mentoree->GetLevel())) mentoree->GetGroupPoints() < MaxBankedGroupLeadershipPoints(mentoree->GetLevel()))
{ {
uint32 mentor_exp = exp * (raid->GetMentorPercent(group_id) / 100.0f); uint64 mentor_exp = exp * (raid->GetMentorPercent(group_id) / 100.0f);
exp -= mentor_exp; exp -= mentor_exp;
mentoree->AddLeadershipEXP(mentor_exp, 0); mentoree->AddLeadershipEXP(mentor_exp, 0);
mentoree->MessageString(Chat::LeaderShip, GAIN_GROUP_LEADERSHIP_EXP); mentoree->MessageString(Chat::LeaderShip, GAIN_GROUP_LEADERSHIP_EXP);
@ -416,13 +416,13 @@ void Client::CalculateLeadershipExp(uint32 &add_exp, uint8 conlevel)
} }
} }
void Client::CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp, uint8 conlevel, bool resexp) void Client::CalculateExp(uint64 in_add_exp, uint64 &add_exp, uint64 &add_aaxp, uint8 conlevel, bool resexp)
{ {
add_exp = in_add_exp; add_exp = in_add_exp;
if (!resexp && (XPRate != 0)) if (!resexp && (XPRate != 0))
{ {
add_exp = static_cast<uint32>(in_add_exp * (static_cast<float>(XPRate) / 100.0f)); add_exp = static_cast<uint64>(in_add_exp * (static_cast<float>(XPRate) / 100.0f));
} }
// Make sure it was initialized. // Make sure it was initialized.
@ -466,7 +466,7 @@ void Client::CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp,
totalmod += RuleR(Zone, HotZoneBonus); totalmod += RuleR(Zone, HotZoneBonus);
} }
add_exp = uint32(float(add_exp) * totalmod * zemmod); add_exp = uint64(float(add_exp) * totalmod * zemmod);
//if XP scaling is based on the con of a monster, do that now. //if XP scaling is based on the con of a monster, do that now.
if (RuleB(Character, UseXPConScaling)) if (RuleB(Character, UseXPConScaling))
@ -503,20 +503,21 @@ void Client::CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp,
auto experience_for_level = (GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel())); 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)); auto exp_percent = static_cast<uint32>(std::ceil(static_cast<float>(add_exp / experience_for_level) * 100.0f));
if (exp_percent > kill_percent_xp_cap) { if (exp_percent > kill_percent_xp_cap) {
add_exp = static_cast<uint32>(std::floor(experience_for_level * (kill_percent_xp_cap / 100.0f))); add_exp = static_cast<uint64>(std::floor(experience_for_level * (kill_percent_xp_cap / 100.0f)));
} }
} }
} }
void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { void Client::AddEXP(uint64 in_add_exp, uint8 conlevel, bool resexp) {
if (!IsEXPEnabled()) { if (!IsEXPEnabled()) {
return; return;
} }
EVENT_ITEM_ScriptStopReturn(); EVENT_ITEM_ScriptStopReturn();
uint32 exp = 0; uint64 exp = 0;
uint32 aaexp = 0; uint64 aaexp = 0;
if (m_epp.perAA < 0 || m_epp.perAA > 100) { if (m_epp.perAA < 0 || m_epp.perAA > 100) {
m_epp.perAA = 0; // stop exploit with sanity check m_epp.perAA = 0; // stop exploit with sanity check
@ -583,7 +584,7 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) {
SetEXP(exp, aaexp, resexp); SetEXP(exp, aaexp, resexp);
} }
void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
LogDebug("Attempting to Set Exp for [{}] (XP: [{}], AAXP: [{}], Rez: [{}])", GetCleanName(), set_exp, set_aaxp, isrezzexp ? "true" : "false"); LogDebug("Attempting to Set Exp for [{}] (XP: [{}], AAXP: [{}], Rez: [{}])", GetCleanName(), set_exp, set_aaxp, isrezzexp ? "true" : "false");
auto max_AAXP = GetRequiredAAExperience(); auto max_AAXP = GetRequiredAAExperience();
@ -604,15 +605,21 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) {
if ((set_exp + set_aaxp) > (m_pp.exp+m_pp.expAA)) { if ((set_exp + set_aaxp) > (m_pp.exp+m_pp.expAA)) {
uint32 exp_gained = set_exp - m_pp.exp; uint64 exp_gained = set_exp - m_pp.exp;
uint32 aaxp_gained = set_aaxp - m_pp.expAA; uint64 aaxp_gained = set_aaxp - m_pp.expAA;
float exp_percent = (float)((float)exp_gained / (float)(GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel())))*(float)100; //EXP needed for level 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 aaxp_percent = (float)((float)aaxp_gained / (float)(RuleI(AA, ExpPerPoint)))*(float)100; //AAEXP needed for level
std::string exp_amount_message = ""; std::string exp_amount_message = "";
if (RuleI(Character, ShowExpValues) >= 1) { if (RuleI(Character, ShowExpValues) >= 1) {
if (exp_gained > 0 && aaxp_gained > 0) exp_amount_message = StringFormat("%u, %u AA", exp_gained, aaxp_gained); if (exp_gained > 0 && aaxp_gained > 0) {
else if (exp_gained > 0) exp_amount_message = StringFormat("%u", exp_gained); exp_amount_message = fmt::format("({}) ({})", exp_gained, aaxp_gained);
else exp_amount_message = StringFormat("%u AA", aaxp_gained); }
else if (exp_gained > 0) {
exp_amount_message = fmt::format("({})", exp_gained);
}
else {
exp_amount_message = fmt::format("({}) AA", aaxp_gained);
}
} }
std::string exp_percent_message = ""; std::string exp_percent_message = "";
@ -645,7 +652,7 @@ void Client::SetEXP(uint32 set_exp, uint32 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. 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.
uint32 exp_lost = m_pp.exp - set_exp; uint64 exp_lost = m_pp.exp - set_exp;
float exp_percent = (float)((float)exp_lost / (float)(GetEXPForLevel(GetLevel() + 1) - GetEXPForLevel(GetLevel())))*(float)100; 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); if (RuleI(Character, ShowExpValues) == 1 && exp_lost > 0) Message(Chat::Yellow, "You have lost %i experience.", exp_lost);
@ -1017,7 +1024,7 @@ uint32 Client::GetEXPForLevel(uint16 check_level)
racemod = 0.95; racemod = 0.95;
} }
finalxp = uint32(finalxp * racemod); finalxp = uint64(finalxp * racemod);
} }
if(RuleB(Character,UseOldClassExpPenalties)) if(RuleB(Character,UseOldClassExpPenalties))
@ -1035,7 +1042,7 @@ uint32 Client::GetEXPForLevel(uint16 check_level)
classmod = 0.9; classmod = 0.9;
} }
finalxp = uint32(finalxp * classmod); finalxp = uint64(finalxp * classmod);
} }
finalxp = mod_client_xp_for_level(finalxp, check_level); finalxp = mod_client_xp_for_level(finalxp, check_level);
@ -1045,8 +1052,8 @@ uint32 Client::GetEXPForLevel(uint16 check_level)
void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods) void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods)
{ {
uint32 award; uint64 award;
uint32 xp_for_level; uint64 xp_for_level;
if (exp_percentage > 100) if (exp_percentage > 100)
{ {
@ -1071,11 +1078,11 @@ void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore
award *= RuleR(Character, FinalExpMultiplier); award *= RuleR(Character, FinalExpMultiplier);
} }
uint32 newexp = GetEXP() + award; uint64 newexp = GetEXP() + award;
SetEXP(newexp, GetAAXP()); SetEXP(newexp, GetAAXP());
} }
void Group::SplitExp(uint32 exp, Mob* other) { void Group::SplitExp(uint64 exp, Mob* other) {
if( other->CastToNPC()->MerchantType != 0 ) // Ensure NPC isn't a merchant if( other->CastToNPC()->MerchantType != 0 ) // Ensure NPC isn't a merchant
return; return;
@ -1083,7 +1090,7 @@ void Group::SplitExp(uint32 exp, Mob* other) {
return; return;
unsigned int i; unsigned int i;
uint32 groupexp = exp; uint64 groupexp = exp;
uint8 membercount = 0; uint8 membercount = 0;
uint8 maxlevel = 1; uint8 maxlevel = 1;
@ -1104,7 +1111,7 @@ void Group::SplitExp(uint32 exp, Mob* other) {
else else
groupmod = 1.0; groupmod = 1.0;
if(membercount > 1 && membercount <= 6) if(membercount > 1 && membercount <= 6)
groupexp += (uint32)((float)exp * groupmod * (RuleR(Character, GroupExpMultiplier))); groupexp += (uint64)((float)exp * groupmod * (RuleR(Character, GroupExpMultiplier)));
int conlevel = Mob::GetLevelCon(maxlevel, other->GetLevel()); int conlevel = Mob::GetLevelCon(maxlevel, other->GetLevel());
if(conlevel == CON_GRAY) if(conlevel == CON_GRAY)
@ -1123,22 +1130,22 @@ void Group::SplitExp(uint32 exp, Mob* other) {
if(maxdiff > -5) if(maxdiff > -5)
maxdiff = -5; maxdiff = -5;
if (diff >= (maxdiff)) { /*Instead of person who killed the mob, the person who has the highest level in the group*/ if (diff >= (maxdiff)) { /*Instead of person who killed the mob, the person who has the highest level in the group*/
uint32 tmp = (cmember->GetLevel()+3) * (cmember->GetLevel()+3) * 75 * 35 / 10; uint64 tmp = (cmember->GetLevel()+3) * (cmember->GetLevel()+3) * 75 * 35 / 10;
uint32 tmp2 = groupexp / membercount; uint64 tmp2 = groupexp / membercount;
cmember->AddEXP( tmp < tmp2 ? tmp : tmp2, conlevel ); cmember->AddEXP( tmp < tmp2 ? tmp : tmp2, conlevel );
} }
} }
} }
} }
void Raid::SplitExp(uint32 exp, Mob* other) { void Raid::SplitExp(uint64 exp, Mob* other) {
if( other->CastToNPC()->MerchantType != 0 ) // Ensure NPC isn't a merchant if( other->CastToNPC()->MerchantType != 0 ) // Ensure NPC isn't a merchant
return; return;
if(other->GetOwner() && other->GetOwner()->IsClient()) // Ensure owner isn't pc if(other->GetOwner() && other->GetOwner()->IsClient()) // Ensure owner isn't pc
return; return;
uint32 groupexp = exp; uint64 groupexp = exp;
uint8 membercount = 0; uint8 membercount = 0;
uint8 maxlevel = 1; uint8 maxlevel = 1;
@ -1151,7 +1158,7 @@ void Raid::SplitExp(uint32 exp, Mob* other) {
} }
} }
groupexp = (uint32)((float)groupexp * (1.0f-(RuleR(Character, RaidExpMultiplier)))); groupexp = (uint64)((float)groupexp * (1.0f-(RuleR(Character, RaidExpMultiplier))));
int conlevel = Mob::GetLevelCon(maxlevel, other->GetLevel()); int conlevel = Mob::GetLevelCon(maxlevel, other->GetLevel());
if(conlevel == CON_GRAY) if(conlevel == CON_GRAY)
@ -1170,15 +1177,15 @@ void Raid::SplitExp(uint32 exp, Mob* other) {
if(maxdiff > -5) if(maxdiff > -5)
maxdiff = -5; maxdiff = -5;
if (diff >= (maxdiff)) { /*Instead of person who killed the mob, the person who has the highest level in the group*/ if (diff >= (maxdiff)) { /*Instead of person who killed the mob, the person who has the highest level in the group*/
uint32 tmp = (cmember->GetLevel()+3) * (cmember->GetLevel()+3) * 75 * 35 / 10; uint64 tmp = (cmember->GetLevel()+3) * (cmember->GetLevel()+3) * 75 * 35 / 10;
uint32 tmp2 = (groupexp / membercount) + 1; uint64 tmp2 = (groupexp / membercount) + 1;
cmember->AddEXP( tmp < tmp2 ? tmp : tmp2, conlevel ); cmember->AddEXP( tmp < tmp2 ? tmp : tmp2, conlevel );
} }
} }
} }
} }
void Client::SetLeadershipEXP(uint32 group_exp, uint32 raid_exp) { void Client::SetLeadershipEXP(uint64 group_exp, uint64 raid_exp) {
while(group_exp >= GROUP_EXP_PER_POINT) { while(group_exp >= GROUP_EXP_PER_POINT) {
group_exp -= GROUP_EXP_PER_POINT; group_exp -= GROUP_EXP_PER_POINT;
m_pp.group_leadership_points++; m_pp.group_leadership_points++;
@ -1196,7 +1203,7 @@ void Client::SetLeadershipEXP(uint32 group_exp, uint32 raid_exp) {
SendLeadershipEXPUpdate(); SendLeadershipEXPUpdate();
} }
void Client::AddLeadershipEXP(uint32 group_exp, uint32 raid_exp) { void Client::AddLeadershipEXP(uint64 group_exp, uint64 raid_exp) {
SetLeadershipEXP(GetGroupEXP() + group_exp, GetRaidEXP() + raid_exp); SetLeadershipEXP(GetGroupEXP() + group_exp, GetRaidEXP() + raid_exp);
} }

View File

@ -71,7 +71,7 @@ public:
bool IsGroup() { return true; } bool IsGroup() { return true; }
void SendGroupJoinOOZ(Mob* NewMember); void SendGroupJoinOOZ(Mob* NewMember);
void CastGroupSpell(Mob* caster,uint16 spellid); void CastGroupSpell(Mob* caster,uint16 spellid);
void SplitExp(uint32 exp, Mob* other); void SplitExp(uint64 exp, Mob* other);
void GroupMessage(Mob* sender,uint8 language,uint8 lang_skill,const char* message); void GroupMessage(Mob* sender,uint8 language,uint8 lang_skill,const char* message);
void GroupMessageString(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0); void GroupMessageString(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0);
uint32 GetTotalGroupDamage(Mob* other); uint32 GetTotalGroupDamage(Mob* other);

View File

@ -266,12 +266,12 @@ void Lua_Client::AddEXP(uint32 add_exp, int conlevel, bool resexp) {
self->AddEXP(add_exp, conlevel, resexp); self->AddEXP(add_exp, conlevel, resexp);
} }
void Lua_Client::SetEXP(uint32 set_exp, uint32 set_aaxp) { void Lua_Client::SetEXP(uint64 set_exp, uint64 set_aaxp) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->SetEXP(set_exp, set_aaxp); self->SetEXP(set_exp, set_aaxp);
} }
void Lua_Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool resexp) { void Lua_Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool resexp) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->SetEXP(set_exp, set_aaxp, resexp); self->SetEXP(set_exp, set_aaxp, resexp);
} }
@ -3418,8 +3418,8 @@ luabind::scope lua_register_client() {
.def("SetDeity", (void(Lua_Client::*)(int))&Lua_Client::SetDeity) .def("SetDeity", (void(Lua_Client::*)(int))&Lua_Client::SetDeity)
.def("SetDuelTarget", (void(Lua_Client::*)(int))&Lua_Client::SetDuelTarget) .def("SetDuelTarget", (void(Lua_Client::*)(int))&Lua_Client::SetDuelTarget)
.def("SetDueling", (void(Lua_Client::*)(bool))&Lua_Client::SetDueling) .def("SetDueling", (void(Lua_Client::*)(bool))&Lua_Client::SetDueling)
.def("SetEXP", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetEXP) .def("SetEXP", (void(Lua_Client::*)(uint64,uint64))&Lua_Client::SetEXP)
.def("SetEXP", (void(Lua_Client::*)(uint32,uint32,bool))&Lua_Client::SetEXP) .def("SetEXP", (void(Lua_Client::*)(uint64,uint64,bool))&Lua_Client::SetEXP)
.def("SetEXPEnabled", (void(Lua_Client::*)(bool))&Lua_Client::SetEXPEnabled) .def("SetEXPEnabled", (void(Lua_Client::*)(bool))&Lua_Client::SetEXPEnabled)
.def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier) .def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier)
.def("SetEXPModifier", (void(Lua_Client::*)(uint32,double,int16))&Lua_Client::SetEXPModifier) .def("SetEXPModifier", (void(Lua_Client::*)(uint32,double,int16))&Lua_Client::SetEXPModifier)

View File

@ -92,8 +92,8 @@ public:
void AddEXP(uint32 add_exp); void AddEXP(uint32 add_exp);
void AddEXP(uint32 add_exp, int conlevel); void AddEXP(uint32 add_exp, int conlevel);
void AddEXP(uint32 add_exp, int conlevel, bool resexp); void AddEXP(uint32 add_exp, int conlevel, bool resexp);
void SetEXP(uint32 set_exp, uint32 set_aaxp); void SetEXP(uint64 set_exp, uint64 set_aaxp);
void SetEXP(uint32 set_exp, uint32 set_aaxp, bool resexp); void SetEXP(uint64 set_exp, uint64 set_aaxp, bool resexp);
void SetBindPoint(); void SetBindPoint();
void SetBindPoint(int to_zone); void SetBindPoint(int to_zone);
void SetBindPoint(int to_zone, int to_instance); void SetBindPoint(int to_zone, int to_instance);

View File

@ -34,7 +34,7 @@ void Lua_Group::CastGroupSpell(Lua_Mob caster, int spell_id) {
self->CastGroupSpell(caster, spell_id); self->CastGroupSpell(caster, spell_id);
} }
void Lua_Group::SplitExp(uint32 exp, Lua_Mob other) { void Lua_Group::SplitExp(uint64 exp, Lua_Mob other) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->SplitExp(exp, other); self->SplitExp(exp, other);
} }

View File

@ -34,7 +34,7 @@ public:
bool IsGroupMember(const char* name); bool IsGroupMember(const char* name);
bool IsGroupMember(Lua_Mob c); bool IsGroupMember(Lua_Mob c);
void CastGroupSpell(Lua_Mob caster, int spell_id); void CastGroupSpell(Lua_Mob caster, int spell_id);
void SplitExp(uint32 exp, Lua_Mob other); void SplitExp(uint64 exp, Lua_Mob other);
void GroupMessage(Lua_Mob sender, const char* message); void GroupMessage(Lua_Mob sender, const char* message);
void GroupMessage(Lua_Mob sender, int language, const char* message); void GroupMessage(Lua_Mob sender, int language, const char* message);
uint32 GetTotalGroupDamage(Lua_Mob other); uint32 GetTotalGroupDamage(Lua_Mob other);

View File

@ -581,10 +581,10 @@ void LuaMod::GetEXPForLevel(Client *self, uint16 level, uint32 &returnValue, boo
} }
} }
void LuaMod::GetExperienceForKill(Client *self, Mob *against, uint32 &returnValue, bool &ignoreDefault) void LuaMod::GetExperienceForKill(Client *self, Mob *against, uint64 &returnValue, bool &ignoreDefault)
{ {
int start = lua_gettop(L); int start = lua_gettop(L);
uint32 retval = 0; uint64 retval = 0;
try { try {
if (!m_has_get_experience_for_kill) { if (!m_has_get_experience_for_kill) {

View File

@ -25,7 +25,7 @@ public:
void TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault); void TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
void GetRequiredAAExperience(Client *self, uint32 &returnValue, bool &ignoreDefault); void GetRequiredAAExperience(Client *self, uint32 &returnValue, bool &ignoreDefault);
void GetEXPForLevel(Client *self, uint16 level, uint32 &returnValue, bool &ignoreDefault); void GetEXPForLevel(Client *self, uint16 level, uint32 &returnValue, bool &ignoreDefault);
void GetExperienceForKill(Client *self, Mob *against, uint32 &returnValue, bool &ignoreDefault); void GetExperienceForKill(Client *self, Mob *against, uint64 &returnValue, bool &ignoreDefault);
private: private:
LuaParser *parser_; LuaParser *parser_;
lua_State *L; lua_State *L;

View File

@ -1484,9 +1484,9 @@ uint32 LuaParser::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault
return retval; return retval;
} }
uint32 LuaParser::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault) uint64 LuaParser::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault)
{ {
uint32 retval = 0; uint64 retval = 0;
for (auto &mod : mods_) { for (auto &mod : mods_) {
mod.GetExperienceForKill(self, against, retval, ignoreDefault); mod.GetExperienceForKill(self, against, retval, ignoreDefault);
} }

View File

@ -206,7 +206,7 @@ public:
void CommonOutgoingHitSuccess(Mob *self, Mob* other, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault); void CommonOutgoingHitSuccess(Mob *self, Mob* other, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
uint32 GetRequiredAAExperience(Client *self, bool &ignoreDefault); uint32 GetRequiredAAExperience(Client *self, bool &ignoreDefault);
uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault); uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault);
uint32 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault); uint64 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault);
private: private:
LuaParser(); LuaParser();

View File

@ -48,7 +48,7 @@ int Lua_Raid::GetGroup(Lua_Client c) {
return self->GetGroup(c); return self->GetGroup(c);
} }
void Lua_Raid::SplitExp(uint32 exp, Lua_Mob other) { void Lua_Raid::SplitExp(uint64 exp, Lua_Mob other) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->SplitExp(exp, other); self->SplitExp(exp, other);
} }

View File

@ -33,7 +33,7 @@ public:
int RaidCount(); int RaidCount();
int GetGroup(const char *c); int GetGroup(const char *c);
int GetGroup(Lua_Client c); int GetGroup(Lua_Client c);
void SplitExp(uint32 exp, Lua_Mob other); void SplitExp(uint64 exp, Lua_Mob other);
uint32 GetTotalRaidDamage(Lua_Mob other); uint32 GetTotalRaidDamage(Lua_Mob other);
void SplitMoney(uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum); void SplitMoney(uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum);
void SplitMoney(uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Lua_Client splitter); void SplitMoney(uint32 gid, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Lua_Client splitter);

View File

@ -99,7 +99,7 @@ void Client::mod_client_death_duel(Mob* killerMob) { return; }
void Client::mod_client_death_env() { return; } void Client::mod_client_death_env() { return; }
//Calculated xp before consider modifier, called whenever a client gets XP for killing a mob. //Calculated xp before consider modifier, called whenever a client gets XP for killing a mob.
int32 Client::mod_client_xp(int32 in_xp, NPC *npc) { return(in_xp); } int64 Client::mod_client_xp(int64 in_xp, NPC *npc) { return(in_xp); }
//Client XP formula. Changes here will cause clients to change level after gaining or losing xp. //Client XP formula. Changes here will cause clients to change level after gaining or losing xp.
//Either modify this before your server goes live, or be prepared to write a quest script that fixes levels. //Either modify this before your server goes live, or be prepared to write a quest script that fixes levels.

View File

@ -104,7 +104,7 @@ void Client::mod_client_death_duel(Mob* killerMob) { return; }
void Client::mod_client_death_env() { return; } void Client::mod_client_death_env() { return; }
//Calculated xp before consider modifier, called whenever a client gets XP for killing a mob. //Calculated xp before consider modifier, called whenever a client gets XP for killing a mob.
int32 Client::mod_client_xp(int32 in_xp, NPC *npc) { return(in_xp); } int64 Client::mod_client_xp(int64 in_xp, NPC *npc) { return(in_xp); }
//Client XP formula. Changes here will cause clients to change level after gaining or losing xp. //Client XP formula. Changes here will cause clients to change level after gaining or losing xp.
//Either modify this before your server goes live, or be prepared to write a quest script that fixes levels. //Either modify this before your server goes live, or be prepared to write a quest script that fixes levels.

View File

@ -234,12 +234,12 @@ void Perl_Client_AddEXP(Client* self, uint32 add_exp, uint8 conlevel, bool resex
self->AddEXP(add_exp, conlevel, resexp); self->AddEXP(add_exp, conlevel, resexp);
} }
void Perl_Client_SetEXP(Client* self, uint32 set_exp, uint32 set_aaxp) // @categories Experience and Level void Perl_Client_SetEXP(Client* self, uint64 set_exp, uint64 set_aaxp) // @categories Experience and Level
{ {
self->SetEXP(set_exp, set_aaxp); self->SetEXP(set_exp, set_aaxp);
} }
void Perl_Client_SetEXP(Client* self, uint32 set_exp, uint32 set_aaxp, bool resexp) // @categories Experience and Level void Perl_Client_SetEXP(Client* self, uint64 set_exp, uint64 set_aaxp, bool resexp) // @categories Experience and Level
{ {
self->SetEXP(set_exp, set_aaxp, resexp); self->SetEXP(set_exp, set_aaxp, resexp);
} }
@ -3286,8 +3286,8 @@ void perl_register_client()
package.add("SetDeity", &Perl_Client_SetDeity); package.add("SetDeity", &Perl_Client_SetDeity);
package.add("SetDuelTarget", &Perl_Client_SetDuelTarget); package.add("SetDuelTarget", &Perl_Client_SetDuelTarget);
package.add("SetDueling", &Perl_Client_SetDueling); package.add("SetDueling", &Perl_Client_SetDueling);
package.add("SetEXP", (void(*)(Client*, uint32, uint32))&Perl_Client_SetEXP); package.add("SetEXP", (void(*)(Client*, uint64, uint64))&Perl_Client_SetEXP);
package.add("SetEXP", (void(*)(Client*, uint32, uint32, bool))&Perl_Client_SetEXP); package.add("SetEXP", (void(*)(Client*, uint64, uint64, bool))&Perl_Client_SetEXP);
package.add("SetEXPModifier", (void(*)(Client*, uint32, double))&Perl_Client_SetEXPModifier); package.add("SetEXPModifier", (void(*)(Client*, uint32, double))&Perl_Client_SetEXPModifier);
package.add("SetEXPModifier", (void(*)(Client*, uint32, double, int16))&Perl_Client_SetEXPModifier); package.add("SetEXPModifier", (void(*)(Client*, uint32, double, int16))&Perl_Client_SetEXPModifier);
package.add("SetEbonCrystals", &Perl_Client_SetEbonCrystals); package.add("SetEbonCrystals", &Perl_Client_SetEbonCrystals);

View File

@ -156,7 +156,7 @@ public:
void RaidMessageString(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0); void RaidMessageString(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0);
void CastGroupSpell(Mob* caster,uint16 spellid, uint32 gid); void CastGroupSpell(Mob* caster,uint16 spellid, uint32 gid);
void SplitExp(uint32 exp, Mob* other); void SplitExp(uint64 exp, Mob* other);
uint32 GetTotalRaidDamage(Mob* other); uint32 GetTotalRaidDamage(Mob* other);
void BalanceHP(int32 penalty, uint32 gid, float range = 0, Mob* caster = nullptr, int32 limit = 0); void BalanceHP(int32 penalty, uint32 gid, float range = 0, Mob* caster = nullptr, int32 limit = 0);
void BalanceMana(int32 penalty, uint32 gid, float range = 0, Mob* caster = nullptr, int32 limit = 0); void BalanceMana(int32 penalty, uint32 gid, float range = 0, Mob* caster = nullptr, int32 limit = 0);