Added optional 'ignore_mods' parameter to AddLevelBasedExp() in Perl and Lua.

This commit is contained in:
Kinglykrab 2019-10-31 23:37:05 -04:00
parent 754ed71f9a
commit 15609ab1e8
5 changed files with 18 additions and 7 deletions

View File

@ -603,7 +603,7 @@ public:
void CalculateLeadershipExp(uint32 &add_exp, uint8 conlevel);
void CalculateExp(uint32 in_add_exp, uint32 &add_exp, uint32 &add_aaxp, uint8 conlevel, bool resexp);
void SetEXP(uint32 set_exp, uint32 set_aaxp, bool resexp=false);
void AddLevelBasedExp(uint8 exp_percentage, uint8 max_level=0);
void AddLevelBasedExp(uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false);
void SetLeadershipEXP(uint32 group_exp, uint32 raid_exp);
void AddLeadershipEXP(uint32 group_exp, uint32 raid_exp);
void SendLeadershipEXPUpdate();

View File

@ -940,7 +940,7 @@ uint32 Client::GetEXPForLevel(uint16 check_level)
return finalxp;
}
void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level)
void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level, bool ignore_mods)
{
uint32 award;
uint32 xp_for_level;
@ -958,7 +958,7 @@ void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level)
xp_for_level = GetEXPForLevel(max_level + 1) - GetEXPForLevel(max_level);
award = xp_for_level * exp_percentage / 100;
if(RuleB(Zone, LevelBasedEXPMods))
if(RuleB(Zone, LevelBasedEXPMods) && !ignore_mods)
{
if(zone->level_exp_mod[GetLevel()].ExpMod)
{

View File

@ -1065,6 +1065,11 @@ void Lua_Client::AddLevelBasedExp(int exp_pct, int max_level) {
self->AddLevelBasedExp(exp_pct, max_level);
}
void Lua_Client::AddLevelBasedExp(int exp_pct, int max_level, bool ignore_mods) {
Lua_Safe_Call_Void();
self->AddLevelBasedExp(exp_pct, max_level, ignore_mods);
}
void Lua_Client::IncrementAA(int aa) {
Lua_Safe_Call_Void();
self->IncrementAlternateAdvancementRank(aa);
@ -1741,6 +1746,7 @@ luabind::scope lua_register_client() {
.def("GetIP", (uint32(Lua_Client::*)(void))&Lua_Client::GetIP)
.def("AddLevelBasedExp", (void(Lua_Client::*)(int))&Lua_Client::AddLevelBasedExp)
.def("AddLevelBasedExp", (void(Lua_Client::*)(int,int))&Lua_Client::AddLevelBasedExp)
.def("AddLevelBasedExp", (void(Lua_Client::*)(int,int,bool))&Lua_Client::AddLevelBasedExp)
.def("IncrementAA", (void(Lua_Client::*)(int))&Lua_Client::IncrementAA)
.def("GrantAlternateAdvancementAbility", (bool(Lua_Client::*)(int, int))&Lua_Client::GrantAlternateAdvancementAbility)
.def("GrantAlternateAdvancementAbility", (bool(Lua_Client::*)(int, int, bool))&Lua_Client::GrantAlternateAdvancementAbility)

View File

@ -240,6 +240,7 @@ public:
uint32 GetIP();
void AddLevelBasedExp(int exp_pct);
void AddLevelBasedExp(int exp_pct, int max_level);
void AddLevelBasedExp(int exp_pct, int max_level, bool ignore_mods);
void IncrementAA(int aa);
bool GrantAlternateAdvancementAbility(int aa_id, int points);
bool GrantAlternateAdvancementAbility(int aa_id, int points, bool ignore_cost);

View File

@ -4768,12 +4768,13 @@ XS(XS_Client_GetIP) {
XS(XS_Client_AddLevelBasedExp);
XS(XS_Client_AddLevelBasedExp) {
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Client::AddLevelBasedExp(THIS, uint8 exp_percentage, uint8 max_level = 0)");
if (items < 2 || items > 4)
Perl_croak(aTHX_ "Usage: Client::AddLevelBasedExp(THIS, uint8 exp_percentage, uint8 max_level = 0, bool ignore_mods = false)");
{
Client *THIS;
uint8 exp_percentage = (uint8) SvUV(ST(1));
uint8 max_level = 0;
bool ignore_mods = false;
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
@ -4785,8 +4786,11 @@ XS(XS_Client_AddLevelBasedExp) {
if (items > 2)
max_level = (uint8) SvUV(ST(2));
if (items > 3)
ignore_mods = (bool) SvTRUE(ST(3));
THIS->AddLevelBasedExp(exp_percentage, max_level);
THIS->AddLevelBasedExp(exp_percentage, max_level, ignore_mods);
}
XSRETURN_EMPTY;
}
@ -6339,7 +6343,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "AddAlternateCurrencyValue"), XS_Client_AddAlternateCurrencyValue, file, "$$$");
newXSproto(strcpy(buf, "AddCrystals"), XS_Client_AddCrystals, file, "$$");
newXSproto(strcpy(buf, "AddEXP"), XS_Client_AddEXP, file, "$$;$$");
newXSproto(strcpy(buf, "AddLevelBasedExp"), XS_Client_AddLevelBasedExp, file, "$$;$");
newXSproto(strcpy(buf, "AddLevelBasedExp"), XS_Client_AddLevelBasedExp, file, "$$;$$");
newXSproto(strcpy(buf, "AddMoneyToPP"), XS_Client_AddMoneyToPP, file, "$$$$$$");
newXSproto(strcpy(buf, "AddPVPPoints"), XS_Client_AddPVPPoints, file, "$$");
newXSproto(strcpy(buf, "AddSkill"), XS_Client_AddSkill, file, "$$$");