mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Core/Player: Introduce separate level caps for each expansion
This commit is contained in:
@@ -883,18 +883,18 @@ uint32 DBCManager::GetMaxLevelForExpansion(uint32 expansion)
|
||||
{
|
||||
switch (expansion)
|
||||
{
|
||||
case CONTENT_1_60:
|
||||
case EXPANSION_CLASSIC:
|
||||
return 60;
|
||||
case CONTENT_61_70:
|
||||
case EXPANSION_THE_BURNING_CRUSADE:
|
||||
return 70;
|
||||
case CONTENT_71_80:
|
||||
case EXPANSION_WRATH_OF_THE_LICH_KING:
|
||||
return 80;
|
||||
case CONTENT_81_85:
|
||||
case EXPANSION_CATACLYSM:
|
||||
return 85;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return DEFAULT_MAX_LEVEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2276,7 +2276,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
|
||||
sScriptMgr->OnGivePlayerXP(this, xp, victim);
|
||||
|
||||
// XP to money conversion processed in Player::RewardQuest
|
||||
if (level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (IsMaxLevel())
|
||||
return;
|
||||
|
||||
uint32 bonus_xp;
|
||||
@@ -2294,11 +2294,11 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
|
||||
uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
|
||||
uint32 newXP = curXP + xp + bonus_xp;
|
||||
|
||||
while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
while (newXP >= nextLvlXP && !IsMaxLevel())
|
||||
{
|
||||
newXP -= nextLvlXP;
|
||||
|
||||
if (level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!IsMaxLevel())
|
||||
GiveLevel(level + 1);
|
||||
|
||||
level = getLevel();
|
||||
@@ -2407,6 +2407,11 @@ void Player::GiveLevel(uint8 level)
|
||||
sScriptMgr->OnPlayerLevelChanged(this, oldLevel);
|
||||
}
|
||||
|
||||
bool Player::IsMaxLevel() const
|
||||
{
|
||||
return getLevel() >= GetUInt32Value(PLAYER_FIELD_MAX_LEVEL);
|
||||
}
|
||||
|
||||
void Player::InitTalentForLevel()
|
||||
{
|
||||
uint8 level = getLevel();
|
||||
@@ -2458,7 +2463,12 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
||||
PlayerLevelInfo info;
|
||||
sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
|
||||
uint8 exp_max_lvl = DBCManager::GetMaxLevelForExpansion(GetSession()->GetExpansion());
|
||||
uint8 conf_max_lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
|
||||
if (exp_max_lvl == DEFAULT_MAX_LEVEL || exp_max_lvl >= conf_max_lvl)
|
||||
SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, conf_max_lvl);
|
||||
else
|
||||
SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, exp_max_lvl);
|
||||
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
|
||||
|
||||
// reset before any aura state sources (health set/aura apply)
|
||||
@@ -6138,10 +6148,8 @@ void Player::CheckAreaExploreAndOutdoor()
|
||||
|
||||
if (areaEntry->ExplorationLevel > 0)
|
||||
{
|
||||
if (getLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
{
|
||||
if (IsMaxLevel())
|
||||
SendExplorationExperience(areaId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int32 diff = int32(getLevel()) - areaEntry->ExplorationLevel;
|
||||
@@ -14968,7 +14976,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
AddPct(XP, (*i)->GetAmount());
|
||||
|
||||
if (getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!IsMaxLevel())
|
||||
GiveXP(XP, nullptr);
|
||||
|
||||
if (Guild* guild = GetGuild())
|
||||
@@ -16591,7 +16599,7 @@ void Player::SendQuestReward(Quest const* quest, Creature const* questGiver, uin
|
||||
sGameEventMgr->HandleQuestComplete(questId);
|
||||
|
||||
uint32 XP = 0;
|
||||
if (getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!IsMaxLevel())
|
||||
XP = xp;
|
||||
|
||||
WorldPackets::Quest::QuestGiverQuestComplete packet;
|
||||
@@ -21653,7 +21661,7 @@ void Player::LeaveAllArenaTeams(ObjectGuid guid)
|
||||
void Player::SetRestBonus(float rest_bonus_new)
|
||||
{
|
||||
// Prevent resting on max level
|
||||
if (getLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (IsMaxLevel())
|
||||
rest_bonus_new = 0;
|
||||
|
||||
if (rest_bonus_new < 0)
|
||||
|
||||
@@ -1103,6 +1103,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
|
||||
void GiveXP(uint32 xp, Unit* victim, float group_rate=1.0f);
|
||||
void GiveLevel(uint8 level);
|
||||
bool IsMaxLevel() const;
|
||||
|
||||
void InitStatsForLevel(bool reapplyMods = false);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!player->IsMaxLevel())
|
||||
{
|
||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
||||
else
|
||||
{
|
||||
/// @todo find correct opcode
|
||||
if (_player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!_player->IsMaxLevel())
|
||||
{
|
||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||
return;
|
||||
@@ -491,7 +491,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData)
|
||||
|
||||
if (type != GUILD_CHARTER_TYPE)
|
||||
{
|
||||
if (_player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!_player->IsMaxLevel())
|
||||
{
|
||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||
return;
|
||||
@@ -650,7 +650,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
|
||||
|
||||
if (type != GUILD_CHARTER_TYPE)
|
||||
{
|
||||
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!player->IsMaxLevel())
|
||||
{
|
||||
// player is too low level to join an arena team
|
||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||
|
||||
@@ -281,7 +281,7 @@ int32 Quest::GetRewOrReqMoney(Player const* player) const
|
||||
return _rewardMoney;
|
||||
|
||||
// RewardMoney: the positive amount
|
||||
if (!player || player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
if (!player || !player->IsMaxLevel())
|
||||
return int32(_rewardMoney * sWorld->getRate(RATE_MONEY_QUEST));
|
||||
else // At level cap, the money reward is the maximum amount between normal and bonus money reward
|
||||
return std::max(int32(GetRewMoneyMaxLevel()), int32(_rewardMoney * sWorld->getRate(RATE_MONEY_QUEST)));
|
||||
|
||||
Reference in New Issue
Block a user