mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
feat(Core/Player) Option to adjust max rest bonus via config (#20836)
This commit is contained in:
@@ -2106,14 +2106,17 @@ Rate.Loyalty = 1
|
||||
# Rate.Rest.InGame
|
||||
# Rate.Rest.Offline.InTavernOrCity
|
||||
# Rate.Rest.Offline.InWilderness
|
||||
# Rate.Rest.MaxBonus
|
||||
# Description: Resting points grow rates.
|
||||
# Default: 1 - (Rate.Rest.InGame)
|
||||
# 1 - (Rate.Rest.Offline.InTavernOrCity)
|
||||
# 1 - (Rate.Rest.Offline.InWilderness)
|
||||
# 1.5 - (Rate.Rest.MaxBonus)
|
||||
|
||||
Rate.Rest.InGame = 1
|
||||
Rate.Rest.Offline.InTavernOrCity = 1
|
||||
Rate.Rest.Offline.InWilderness = 1
|
||||
Rate.Rest.MaxBonus = 1.5
|
||||
|
||||
#
|
||||
# Rate.MissChanceMultiplier.Creature
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1209,7 +1209,7 @@ public:
|
||||
void RemoveRestState();
|
||||
uint32 GetXPRestBonus(uint32 xp);
|
||||
[[nodiscard]] float GetRestBonus() const { return _restBonus; }
|
||||
void SetRestBonus(float rest_bonus_new);
|
||||
void SetRestBonus(float restBonusNew);
|
||||
|
||||
[[nodiscard]] bool HasRestFlag(RestFlag restFlag) const { return (_restFlagMask & restFlag) != 0; }
|
||||
void SetRestFlag(RestFlag restFlag, uint32 triggerId = 0);
|
||||
|
||||
@@ -501,6 +501,7 @@ enum Rates
|
||||
RATE_REST_INGAME,
|
||||
RATE_REST_OFFLINE_IN_TAVERN_OR_CITY,
|
||||
RATE_REST_OFFLINE_IN_WILDERNESS,
|
||||
RATE_REST_MAX_BONUS,
|
||||
RATE_DAMAGE_FALL,
|
||||
RATE_AUCTION_TIME,
|
||||
RATE_AUCTION_DEPOSIT,
|
||||
|
||||
@@ -556,6 +556,7 @@ void World::LoadConfigSettings(bool reload)
|
||||
_rate_values[RATE_REST_INGAME] = sConfigMgr->GetOption<float>("Rate.Rest.InGame", 1.0f);
|
||||
_rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = sConfigMgr->GetOption<float>("Rate.Rest.Offline.InTavernOrCity", 1.0f);
|
||||
_rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = sConfigMgr->GetOption<float>("Rate.Rest.Offline.InWilderness", 1.0f);
|
||||
_rate_values[RATE_REST_MAX_BONUS] = sConfigMgr->GetOption<float>("Rate.Rest.MaxBonus", 1.5f);
|
||||
_rate_values[RATE_DAMAGE_FALL] = sConfigMgr->GetOption<float>("Rate.Damage.Fall", 1.0f);
|
||||
_rate_values[RATE_AUCTION_TIME] = sConfigMgr->GetOption<float>("Rate.Auction.Time", 1.0f);
|
||||
_rate_values[RATE_AUCTION_DEPOSIT] = sConfigMgr->GetOption<float>("Rate.Auction.Deposit", 1.0f);
|
||||
|
||||
Reference in New Issue
Block a user