mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 01:37:04 +00:00
[10884] Pet with same level as owner must have xp = 0
Thanks to Click for original patch and problem description.
This commit is contained in:
parent
07172bc5ae
commit
8d7cc36098
3 changed files with 16 additions and 27 deletions
|
|
@ -752,40 +752,40 @@ void Pet::GivePetXP(uint32 xp)
|
|||
return;
|
||||
|
||||
uint32 level = getLevel();
|
||||
uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel());
|
||||
|
||||
// XP to money conversion processed in Player::RewardQuest
|
||||
if(level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
||||
// pet not receive xp for level equal to owner level
|
||||
if (level >= maxlevel)
|
||||
return;
|
||||
|
||||
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
|
||||
uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
|
||||
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
|
||||
uint32 newXP = curXP + xp;
|
||||
|
||||
if(newXP >= nextLvlXP && level+1 > GetOwner()->getLevel())
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, nextLvlXP-1);
|
||||
return;
|
||||
}
|
||||
|
||||
while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) )
|
||||
while( newXP >= nextLvlXP && level < maxlevel)
|
||||
{
|
||||
newXP -= nextLvlXP;
|
||||
++level;
|
||||
|
||||
GivePetLevel(level+1);
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level+1));
|
||||
GivePetLevel(level); // also update UNIT_FIELD_PETNEXTLEVELEXP and UNIT_FIELD_PETEXPERIENCE to level start
|
||||
|
||||
level = getLevel();
|
||||
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
|
||||
}
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, level < maxlevel ? newXP : 0);
|
||||
}
|
||||
|
||||
void Pet::GivePetLevel(uint32 level)
|
||||
{
|
||||
if(!level)
|
||||
if (!level || level == getLevel())
|
||||
return;
|
||||
|
||||
if (getPetType()==HUNTER_PET)
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level));
|
||||
}
|
||||
|
||||
InitStatsForLevel(level);
|
||||
InitLevelupSpellsForLevel();
|
||||
InitTalentForLevel();
|
||||
|
|
@ -2023,11 +2023,7 @@ void Pet::SynchronizeLevelWithOwner()
|
|||
// can't be greater owner level
|
||||
case HUNTER_PET:
|
||||
if(getLevel() > owner->getLevel())
|
||||
{
|
||||
GivePetLevel(owner->getLevel());
|
||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(owner->getLevel()));
|
||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP)-1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue