mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 19:37:04 +00:00
[7092] Work vs XP per level data
Add new table "player_xp_for_level" for this Fill table data 1-79 level Remove old code Signed-off-by: DiSlord <dislord@nomail.com>
This commit is contained in:
parent
7cded2ed9c
commit
014ab283dd
12 changed files with 273 additions and 74 deletions
|
|
@ -116,66 +116,6 @@ namespace MaNGOS
|
|||
return (uint32)(xp_gain*sWorld.getRate(RATE_XP_KILL));
|
||||
}
|
||||
|
||||
inline uint32 xp_Diff(uint32 lvl)
|
||||
{
|
||||
if( lvl < 29 )
|
||||
return 0;
|
||||
if( lvl == 29 )
|
||||
return 1;
|
||||
if( lvl == 30 )
|
||||
return 3;
|
||||
if( lvl == 31 )
|
||||
return 6;
|
||||
else
|
||||
return (5*(lvl-30));
|
||||
}
|
||||
|
||||
inline uint32 mxp(uint32 lvl)
|
||||
{
|
||||
if (lvl < 60)
|
||||
{
|
||||
return (45 + (5*lvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (235 + (5*lvl));
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32 xp_to_level(uint32 lvl)
|
||||
{
|
||||
uint32 xp = 0;
|
||||
if (lvl < 60)
|
||||
{
|
||||
xp = (8*lvl + xp_Diff(lvl)) * mxp(lvl);
|
||||
}
|
||||
else if (lvl == 60)
|
||||
{
|
||||
xp = (155 + mxp(lvl) * (1344 - 70 - ((69 - lvl) * (7 + (69 - lvl) * 8 - 1)/2)));
|
||||
}
|
||||
else if (lvl < 70)
|
||||
{
|
||||
xp = (155 + mxp(lvl) * (1344 - ((69-lvl) * (7 + (69 - lvl) * 8 - 1)/2)));
|
||||
}else
|
||||
{
|
||||
// level higher than 70 is not supported
|
||||
xp = (uint32)(779700 * (pow(sWorld.getRate(RATE_XP_PAST_70), (int32)lvl - 69)));
|
||||
return ((xp < 0x7fffffff) ? xp : 0x7fffffff);
|
||||
}
|
||||
|
||||
// The XP to Level is always rounded to the nearest 100 points (50 rounded to high).
|
||||
xp = ((xp + 50) / 100) * 100; // use additional () for prevent free association operations in C++
|
||||
|
||||
if ((lvl > 10) && (lvl < 60)) // compute discount added in 2.3.x
|
||||
{
|
||||
uint32 discount = (lvl < 28) ? (lvl - 10) : 18;
|
||||
xp = (xp * (100 - discount)) / 100; // apply discount
|
||||
xp = (xp / 100) * 100; // floor to hundreds
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
inline float xp_in_group_rate(uint32 count, bool isRaid)
|
||||
{
|
||||
if(isRaid)
|
||||
|
|
|
|||
|
|
@ -2559,6 +2559,67 @@ void ObjectMgr::LoadPlayerInfo()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loading xp per level data
|
||||
{
|
||||
mPlayerXPperLevel.resize(sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
|
||||
for (uint32 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
|
||||
mPlayerXPperLevel[level] = 0;
|
||||
|
||||
// 0 1
|
||||
QueryResult *result = WorldDatabase.Query("SELECT lvl, xp_for_next_level FROM player_xp_for_level");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u xp for level definitions", count );
|
||||
sLog.outErrorDb( "Error loading `player_xp_for_level` table or empty table.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
barGoLink bar( result->GetRowCount() );
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 current_level = fields[0].GetUInt32();
|
||||
uint32 current_xp = fields[1].GetUInt32();
|
||||
|
||||
if(current_level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
{
|
||||
if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
|
||||
sLog.outErrorDb("Wrong (> %u) level %u in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL,current_level);
|
||||
else
|
||||
sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_xp_for_levels` table, ignoring.",current_level);
|
||||
continue;
|
||||
}
|
||||
//PlayerXPperLevel
|
||||
mPlayerXPperLevel[current_level] = current_xp;
|
||||
bar.step();
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u xp for level definitions", count );
|
||||
}
|
||||
|
||||
// fill level gaps
|
||||
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
|
||||
{
|
||||
if( mPlayerXPperLevel[level] == 0)
|
||||
{
|
||||
sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.",level+1, level);
|
||||
mPlayerXPperLevel[level] = mPlayerXPperLevel[level-1]+100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const
|
||||
|
|
@ -5714,6 +5775,13 @@ uint32 ObjectMgr::GetBaseXP(uint32 level)
|
|||
return mBaseXPTable[level] ? mBaseXPTable[level] : 0;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GetXPForLevel(uint32 level)
|
||||
{
|
||||
if (level < mPlayerXPperLevel.size())
|
||||
return mPlayerXPperLevel[level];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPetNames()
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
|
|
|||
|
|
@ -568,6 +568,7 @@ class ObjectMgr
|
|||
|
||||
std::string GeneratePetName(uint32 entry);
|
||||
uint32 GetBaseXP(uint32 level);
|
||||
uint32 GetXPForLevel(uint32 level);
|
||||
|
||||
int32 GetFishingBaseSkillLevel(uint32 entry) const
|
||||
{
|
||||
|
|
@ -862,6 +863,9 @@ class ObjectMgr
|
|||
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
|
||||
PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES];
|
||||
|
||||
typedef std::vector<uint32> PlayerXPperLevel; // [level]
|
||||
PlayerXPperLevel mPlayerXPperLevel;
|
||||
|
||||
typedef std::map<uint32,uint32> BaseXPMap; // [area level][base xp]
|
||||
BaseXPMap mBaseXPTable;
|
||||
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ void Pet::GivePetXP(uint32 xp)
|
|||
newXP -= nextLvlXP;
|
||||
|
||||
SetLevel( level + 1 );
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32((MaNGOS::XP::xp_to_level(level+1))/4));
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)/4);
|
||||
|
||||
level = getLevel();
|
||||
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
|
||||
|
|
@ -763,7 +763,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
|
|||
setPowerType(POWER_FOCUS);
|
||||
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32((MaNGOS::XP::xp_to_level(creature->getLevel()))/4));
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(creature->getLevel())/4);
|
||||
SetUInt32Value(UNIT_NPC_FLAGS, 0);
|
||||
|
||||
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(creature->GetCreatureInfo()->family);
|
||||
|
|
@ -906,7 +906,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
|
|||
}
|
||||
case HUNTER_PET:
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32((MaNGOS::XP::xp_to_level(petlevel))/4));
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(petlevel)/4);
|
||||
learnLevelupSpells();
|
||||
//these formula may not be correct; however, it is designed to be close to what it should be
|
||||
//this makes dps 0.5 of pets level
|
||||
|
|
|
|||
|
|
@ -2182,7 +2182,7 @@ void Player::GiveLevel(uint32 level)
|
|||
|
||||
GetSession()->SendPacket(&data);
|
||||
|
||||
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(level));
|
||||
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, objmgr.GetXPForLevel(level));
|
||||
|
||||
//update level, max level of skills
|
||||
if(getLevel()!= level)
|
||||
|
|
@ -2261,7 +2261,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
|||
objmgr.GetPlayerLevelInfo(getRace(),getClass(),getLevel(),&info);
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) );
|
||||
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(getLevel()));
|
||||
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, objmgr.GetXPForLevel(getLevel()));
|
||||
|
||||
UpdateSkillsForLevel ();
|
||||
|
||||
|
|
|
|||
|
|
@ -464,7 +464,6 @@ void World::LoadConfigSettings(bool reload)
|
|||
rate_values[RATE_XP_KILL] = sConfig.GetFloatDefault("Rate.XP.Kill", 1.0f);
|
||||
rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f);
|
||||
rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f);
|
||||
rate_values[RATE_XP_PAST_70] = sConfig.GetFloatDefault("Rate.XP.PastLevel70", 1.0f);
|
||||
rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f);
|
||||
rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f);
|
||||
rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ enum Rates
|
|||
RATE_XP_KILL,
|
||||
RATE_XP_QUEST,
|
||||
RATE_XP_EXPLORE,
|
||||
RATE_XP_PAST_70,
|
||||
RATE_REPUTATION_GAIN,
|
||||
RATE_CREATURE_NORMAL_HP,
|
||||
RATE_CREATURE_ELITE_ELITE_HP,
|
||||
|
|
|
|||
|
|
@ -973,10 +973,6 @@ Visibility.Distance.Grey.Object = 10
|
|||
# XP rates
|
||||
# Default: 1
|
||||
#
|
||||
# Rate.XP.PastLevel70
|
||||
# XP needed per level past 70 (Rates below 1 not recommended)
|
||||
# Default: 1
|
||||
#
|
||||
# Rate.Rest.InGame
|
||||
# Rate.Rest.Offline.InTavernOrCity
|
||||
# Rate.Rest.Offline.InWilderness
|
||||
|
|
@ -1086,7 +1082,6 @@ Rate.Drop.Money = 1
|
|||
Rate.XP.Kill = 1
|
||||
Rate.XP.Quest = 1
|
||||
Rate.XP.Explore = 1
|
||||
Rate.XP.PastLevel70 = 1
|
||||
Rate.Rest.InGame = 1
|
||||
Rate.Rest.Offline.InTavernOrCity = 1
|
||||
Rate.Rest.Offline.InWilderness = 1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7091"
|
||||
#define REVISION_NR "7092"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue