[7831] Prevent have hunter pet with level greater player levels at level changes. Propertly set hunter pet xp values at level update. Author: VladimirMangos
--HG-- branch : trunk
This commit is contained in:
@@ -1329,6 +1329,11 @@ bool ChatHandler::HandleNpcChangeLevelCommand(const char* args)
|
||||
|
||||
if(pCreature->isPet())
|
||||
{
|
||||
if(((Pet*)pCreature)->getPetType()==HUNTER_PET)
|
||||
{
|
||||
pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(lvl)/4);
|
||||
pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
|
||||
}
|
||||
((Pet*)pCreature)->GivePetLevel(lvl);
|
||||
}
|
||||
else
|
||||
|
||||
+29
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ class Pet : public Guardian
|
||||
HappinessState GetHappinessState();
|
||||
void GivePetXP(uint32 xp);
|
||||
void GivePetLevel(uint32 level);
|
||||
void SynchronizeLevelWithOwner();
|
||||
bool HaveInDiet(ItemPrototype const* item) const;
|
||||
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
|
||||
void SetDuration(int32 dur) { m_duration = dur; }
|
||||
|
||||
+7
-5
@@ -2370,10 +2370,9 @@ void Player::GiveLevel(uint32 level)
|
||||
SetPower(POWER_FOCUS, 0);
|
||||
SetPower(POWER_HAPPINESS, 0);
|
||||
|
||||
// give level to summoned pet
|
||||
Pet* pet = GetPet();
|
||||
if(pet && pet->getPetType()==SUMMON_PET)
|
||||
pet->GivePetLevel(level);
|
||||
// update level to hunter/summon pet
|
||||
if (Pet* pet = GetPet())
|
||||
pet->SynchronizeLevelWithOwner();
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
|
||||
}
|
||||
|
||||
@@ -2559,6 +2558,10 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
||||
SetPower(POWER_FOCUS, 0);
|
||||
SetPower(POWER_HAPPINESS, 0);
|
||||
SetPower(POWER_RUNIC_POWER, 0);
|
||||
|
||||
// update level to hunter/summon pet
|
||||
if (Pet* pet = GetPet())
|
||||
pet->SynchronizeLevelWithOwner();
|
||||
}
|
||||
|
||||
void Player::SendInitialSpells()
|
||||
@@ -20653,4 +20656,3 @@ bool Player::canSeeSpellClickOn(Creature const *c) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -884,6 +884,7 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
|
||||
void GiveXP(uint32 xp, Unit* victim);
|
||||
void GiveLevel(uint32 level);
|
||||
|
||||
void InitStatsForLevel(bool reapplyMods = false);
|
||||
|
||||
// Played Time Stuff
|
||||
|
||||
Reference in New Issue
Block a user