aboutsummaryrefslogtreecommitdiff
path: root/src/game/Pet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Pet.cpp')
-rw-r--r--src/game/Pet.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 7edc9144bdc..72a4ef5be07 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -362,6 +362,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
}
m_loading = false;
+
+ SynchronizeLevelWithOwner();
return true;
}
@@ -727,12 +729,11 @@ void Pet::GivePetXP(uint32 xp)
{
newXP -= nextLvlXP;
- SetLevel( level + 1 );
+ GivePetLevel(level+1);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)*PET_XP_FACTOR);
level = getLevel();
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
- GivePetLevel(level);
}
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
@@ -1793,3 +1794,29 @@ void Pet::learnSpellHighRank(uint32 spellid)
if(uint32 next = spellmgr.GetNextSpellInChain(spellid))
learnSpellHighRank(next);
}
+
+void Pet::SynchronizeLevelWithOwner()
+{
+ Unit* owner = GetOwner();
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ return;
+
+ switch(getPetType())
+ {
+ // always same level
+ case SUMMON_PET:
+ GivePetLevel(owner->getLevel());
+ break;
+ // can't be greater owner level
+ case HUNTER_PET:
+ if(getLevel() > owner->getLevel())
+ {
+ GivePetLevel(owner->getLevel());
+ SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(owner->getLevel())/4);
+ SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP)-1);
+ }
+ break;
+ default:
+ break;
+ }
+}