diff --git a/common/ruletypes.h b/common/ruletypes.h index dca913e58..cc5fefd59 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -686,6 +686,7 @@ RULE_REAL(AA, ModernAAScalingStartPercent, 1000, "1000% or 10x AA experience at RULE_INT(AA, ModernAAScalingAAMinimum, 0, "The minimum number of earned AA before AA experience scaling begins") RULE_INT(AA, ModernAAScalingAALimit, 4000, "The number of earned AA when AA experience scaling ends") RULE_BOOL(AA, SoundForAAEarned, false, "Play sound when AA point earned") +RULE_INT(AA, UnusedAAPointCap, -1, "Cap for Unused AA Points. Default: -1. NOTE: DO NOT LOWER THIS WITHOUT KNOWING WHAT YOU ARE DOING. MAY RESULT IN PLAYERS LOSING AAs.") RULE_CATEGORY_END() RULE_CATEGORY(Console) diff --git a/zone/exp.cpp b/zone/exp.cpp index e2d42c721..9372cef9c 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -505,8 +505,9 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { uint32 exp = 0; uint32 aaexp = 0; - if (m_epp.perAA<0 || m_epp.perAA>100) - m_epp.perAA=0; // stop exploit with sanity check + if (m_epp.perAA < 0 || m_epp.perAA > 100) { + m_epp.perAA = 0; // stop exploit with sanity check + } // Calculate regular XP CalculateExp(in_add_exp, exp, aaexp, conlevel, resexp); @@ -541,6 +542,23 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { aaexp = had_aaexp; //watch for wrap } + // Check for Unused AA Cap. If at or above cap, set AAs to cap, set aaexp to 0 and set aa percentage to 0. + // Doing this here means potentially one kill wasted worth of experience, but easiest to put it here than to rewrite this function. + int aa_cap = RuleI(AA, UnusedAAPointCap); + + if (aa_cap >= 0 && aaexp > 0) { + if (m_pp.aapoints == aa_cap) { + MessageString(Chat::Red, AA_CAP); + aaexp = 0; + m_epp.perAA = 0; + } else if (m_pp.aapoints > aa_cap) { + MessageString(Chat::Red, OVER_AA_CAP, fmt::format_int(aa_cap).c_str(), fmt::format_int(aa_cap).c_str()); + m_pp.aapoints = aa_cap; + aaexp = 0; + m_epp.perAA = 0; + } + } + // AA Sanity Checking for players who set aa exp and deleveled below allowed aa level. if (GetLevel() <= 50 && m_epp.perAA > 0) { Message(Chat::Yellow, "You are below the level allowed to gain AA Experience. AA Experience set to 0%"); diff --git a/zone/string_ids.h b/zone/string_ids.h index 8e4ed762a..8f44cb48c 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -181,6 +181,7 @@ #define PET_SPELLHOLD_SET_ON 702 //The pet spellhold mode has been set to on. #define PET_SPELLHOLD_SET_OFF 703 //The pet spellhold mode has been set to off. #define GUILD_NAME_IN_USE 711 //You cannot create a guild with that name, that guild already exists on this server. +#define AA_CAP 1000 //You have reached the AA point cap, and cannot gain any further experience until some of your stored AA point pool is used. #define GM_GAINXP 1002 //[GM] You have gained %1 AXP and %2 EXP (%3). #define MALE_SLAYUNDEAD 1007 //%1's holy blade cleanses his target!(%2) #define FEMALE_SLAYUNDEAD 1008 //%1's holy blade cleanses her target!(%2) @@ -295,6 +296,7 @@ #define ALREADY_SHIELDING 3280 //Either you or your target is already shielding another. #define START_SHIELDING 3281 //%1 begins to use %2 as a living shield! #define END_SHIELDING 3282 //%1 ceases protecting %2. +#define OVER_AA_CAP 3374 //Warning: You are currently over the earned Advancement point limit of %1. Please spend some of your stored AA points. The NEXT time you zone all of your AA points over %2 will be deleted. You MUST spend the extra points now. #define TRADESKILL_MISSING_ITEM 3455 //You are missing a %1. #define TRADESKILL_MISSING_COMPONENTS 3456 //Sorry, but you don't have everything you need for this recipe in your general inventory. #define TRADESKILL_LEARN_RECIPE 3457 //You have learned the recipe %1!