feat(Core/Player) Option to adjust max rest bonus via config (#20836)

This commit is contained in:
Exitare
2024-12-14 11:51:28 -08:00
committed by GitHub
parent 7164422883
commit 98b426bf3a
5 changed files with 18 additions and 10 deletions

View File

@@ -10228,22 +10228,25 @@ void Player::LeaveAllArenaTeams(ObjectGuid guid)
} while (result->NextRow());
}
void Player::SetRestBonus(float rest_bonus_new)
void Player::SetRestBonus(float restBonusNew)
{
// Prevent resting on max level
if (GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
rest_bonus_new = 0;
restBonusNew = 0;
if (rest_bonus_new < 0)
rest_bonus_new = 0;
if (restBonusNew < 0)
restBonusNew = 0;
float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * 1.5f / 2;
// Fetch rest bonus multiplier from cached configuration
float restBonusMultiplier = sWorld->getRate(RATE_REST_MAX_BONUS);
if (rest_bonus_new > rest_bonus_max)
_restBonus = rest_bonus_max;
// Calculate rest bonus max using the multiplier
float restBonusMax = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * restBonusMultiplier / 2;
if (restBonusNew > restBonusMax)
_restBonus = restBonusMax;
else
_restBonus = rest_bonus_new;
_restBonus = restBonusNew;
// update data for client
if ((GetsRecruitAFriendBonus(true) && (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0)))
SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RAF_LINKED);