[Feature] AA Cap Limit (#2423)

* [Feature] AA Cap Limit

Will force unused AA points to the cap if they exceed the cap. Will also force AA Percentage to 0%. NOTE: The variable, UnusedAAPointCap, should NOT be lowered once implemented without first checking the DB for how many Unused AAs people have.  The next time they gain any EXP, it WILL drop them to cap.  Also, PCs should be given warning prior to this patch going to Live, to ensure they have a chance to spend any AAs above the cap, else they will lose them.

* Fix formatting on strings

* Fixes

* Change ConvertArray to fmt

* Fix formating and >= 0 aa_cap per review
This commit is contained in:
Michael
2022-10-12 21:14:44 -04:00
committed by GitHub
parent 3de65d46b4
commit d7097e84ff
3 changed files with 23 additions and 2 deletions
+20 -2
View File
@@ -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%");