mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7831] Prevent have hunter pet with level greater player levels at level changes. Propertly set hunter pet xp values at level update.
This commit is contained in:
parent
ac67ac8c28
commit
e134b5383b
6 changed files with 44 additions and 8 deletions
|
|
@ -1283,6 +1283,11 @@ bool ChatHandler::HandleNpcChangeLevelCommand(const char* args)
|
||||||
|
|
||||||
if(pCreature->isPet())
|
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);
|
((Pet*)pCreature)->GivePetLevel(lvl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
m_loading = false;
|
m_loading = false;
|
||||||
|
|
||||||
|
SynchronizeLevelWithOwner();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -732,12 +734,11 @@ void Pet::GivePetXP(uint32 xp)
|
||||||
{
|
{
|
||||||
newXP -= nextLvlXP;
|
newXP -= nextLvlXP;
|
||||||
|
|
||||||
SetLevel( level + 1 );
|
GivePetLevel(level+1);
|
||||||
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)/4);
|
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)/4);
|
||||||
|
|
||||||
level = getLevel();
|
level = getLevel();
|
||||||
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
|
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
|
||||||
GivePetLevel(level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
|
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
|
||||||
|
|
@ -1847,3 +1848,29 @@ void Pet::learnSpellHighRank(uint32 spellid)
|
||||||
for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr)
|
for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr)
|
||||||
learnSpellHighRank(itr->second);
|
learnSpellHighRank(itr->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ class Pet : public Creature
|
||||||
HappinessState GetHappinessState();
|
HappinessState GetHappinessState();
|
||||||
void GivePetXP(uint32 xp);
|
void GivePetXP(uint32 xp);
|
||||||
void GivePetLevel(uint32 level);
|
void GivePetLevel(uint32 level);
|
||||||
|
void SynchronizeLevelWithOwner();
|
||||||
bool InitStatsForLevel(uint32 level);
|
bool InitStatsForLevel(uint32 level);
|
||||||
bool HaveInDiet(ItemPrototype const* item) const;
|
bool HaveInDiet(ItemPrototype const* item) const;
|
||||||
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
|
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
|
||||||
|
|
|
||||||
|
|
@ -2302,10 +2302,9 @@ void Player::GiveLevel(uint32 level)
|
||||||
SetPower(POWER_FOCUS, 0);
|
SetPower(POWER_FOCUS, 0);
|
||||||
SetPower(POWER_HAPPINESS, 0);
|
SetPower(POWER_HAPPINESS, 0);
|
||||||
|
|
||||||
// give level to summoned pet
|
// update level to hunter/summon pet
|
||||||
Pet* pet = GetPet();
|
if (Pet* pet = GetPet())
|
||||||
if(pet && pet->getPetType()==SUMMON_PET)
|
pet->SynchronizeLevelWithOwner();
|
||||||
pet->GivePetLevel(level);
|
|
||||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
|
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2491,6 +2490,10 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
||||||
SetPower(POWER_FOCUS, 0);
|
SetPower(POWER_FOCUS, 0);
|
||||||
SetPower(POWER_HAPPINESS, 0);
|
SetPower(POWER_HAPPINESS, 0);
|
||||||
SetPower(POWER_RUNIC_POWER, 0);
|
SetPower(POWER_RUNIC_POWER, 0);
|
||||||
|
|
||||||
|
// update level to hunter/summon pet
|
||||||
|
if (Pet* pet = GetPet())
|
||||||
|
pet->SynchronizeLevelWithOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendInitialSpells()
|
void Player::SendInitialSpells()
|
||||||
|
|
@ -20016,4 +20019,3 @@ bool Player::canSeeSpellClickOn(Creature const *c) const
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -906,6 +906,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
|
|
||||||
void GiveXP(uint32 xp, Unit* victim);
|
void GiveXP(uint32 xp, Unit* victim);
|
||||||
void GiveLevel(uint32 level);
|
void GiveLevel(uint32 level);
|
||||||
|
|
||||||
void InitStatsForLevel(bool reapplyMods = false);
|
void InitStatsForLevel(bool reapplyMods = false);
|
||||||
|
|
||||||
// Played Time Stuff
|
// Played Time Stuff
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7830"
|
#define REVISION_NR "7831"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue