diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 3cc18f3b6..b9ad728ce 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1736,14 +1736,7 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args) } if (pCreature->IsPet()) - { - if (((Pet*)pCreature)->getPetType()==HUNTER_PET) - { - pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(lvl)); - pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - } ((Pet*)pCreature)->GivePetLevel(lvl); - } else { pCreature->SetMaxHealth(100 + 30*lvl); diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 11bca3158..d1ded96d8 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -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; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b0b3628a7..4f8ca6cfb 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10883" + #define REVISION_NR "10884" #endif // __REVISION_NR_H__