[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:
VladimirMangos 2010-12-17 18:47:41 +03:00
parent 07172bc5ae
commit 8d7cc36098
3 changed files with 16 additions and 27 deletions

View file

@ -1736,14 +1736,7 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args)
} }
if (pCreature->IsPet()) 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); ((Pet*)pCreature)->GivePetLevel(lvl);
}
else else
{ {
pCreature->SetMaxHealth(100 + 30*lvl); pCreature->SetMaxHealth(100 + 30*lvl);

View file

@ -752,40 +752,40 @@ void Pet::GivePetXP(uint32 xp)
return; return;
uint32 level = getLevel(); uint32 level = getLevel();
uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel());
// XP to money conversion processed in Player::RewardQuest // pet not receive xp for level equal to owner level
if(level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) if (level >= maxlevel)
return; return;
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
uint32 newXP = curXP + xp; uint32 newXP = curXP + xp;
if(newXP >= nextLvlXP && level+1 > GetOwner()->getLevel()) while( newXP >= nextLvlXP && level < maxlevel)
{
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, nextLvlXP-1);
return;
}
while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) )
{ {
newXP -= nextLvlXP; newXP -= nextLvlXP;
++level;
GivePetLevel(level+1); GivePetLevel(level); // also update UNIT_FIELD_PETNEXTLEVELEXP and UNIT_FIELD_PETEXPERIENCE to level start
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level+1));
level = getLevel();
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
} }
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, level < maxlevel ? newXP : 0);
} }
void Pet::GivePetLevel(uint32 level) void Pet::GivePetLevel(uint32 level)
{ {
if(!level) if (!level || level == getLevel())
return; return;
if (getPetType()==HUNTER_PET)
{
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level));
}
InitStatsForLevel(level); InitStatsForLevel(level);
InitLevelupSpellsForLevel(); InitLevelupSpellsForLevel();
InitTalentForLevel(); InitTalentForLevel();
@ -2023,11 +2023,7 @@ void Pet::SynchronizeLevelWithOwner()
// can't be greater owner level // can't be greater owner level
case HUNTER_PET: case HUNTER_PET:
if(getLevel() > owner->getLevel()) if(getLevel() > owner->getLevel())
{
GivePetLevel(owner->getLevel()); GivePetLevel(owner->getLevel());
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(owner->getLevel()));
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP)-1);
}
break; break;
default: default:
break; break;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10883" #define REVISION_NR "10884"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__