[9216] Fixed hunter pet XP requirements.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

Also move calculation to function. And avoid use operator[] for access to per-area base xp table data.
This commit is contained in:
Lightguard 2010-01-20 04:59:20 +03:00 committed by VladimirMangos
parent 2b891624c6
commit 0088d1300c
5 changed files with 13 additions and 11 deletions

View file

@ -1275,7 +1275,7 @@ bool ChatHandler::HandleNpcChangeLevelCommand(const char* args)
{ {
if(((Pet*)pCreature)->getPetType()==HUNTER_PET) if(((Pet*)pCreature)->getPetType()==HUNTER_PET)
{ {
pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(lvl)/4); pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(lvl));
pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
} }
((Pet*)pCreature)->GivePetLevel(lvl); ((Pet*)pCreature)->GivePetLevel(lvl);

View file

@ -6129,12 +6129,13 @@ void ObjectMgr::LoadExplorationBaseXP()
sLog.outString( ">> Loaded %u BaseXP definitions", count ); sLog.outString( ">> Loaded %u BaseXP definitions", count );
} }
uint32 ObjectMgr::GetBaseXP(uint32 level) uint32 ObjectMgr::GetBaseXP(uint32 level) const
{ {
return mBaseXPTable[level] ? mBaseXPTable[level] : 0; BaseXPMap::const_iterator itr = mBaseXPTable.find(level);
return itr != mBaseXPTable.end() ? itr->second : 0;
} }
uint32 ObjectMgr::GetXPForLevel(uint32 level) uint32 ObjectMgr::GetXPForLevel(uint32 level) const
{ {
if (level < mPlayerXPperLevel.size()) if (level < mPlayerXPperLevel.size())
return mPlayerXPperLevel[level]; return mPlayerXPperLevel[level];

View file

@ -637,8 +637,9 @@ class ObjectMgr
void LoadTrainerSpell(); void LoadTrainerSpell();
std::string GeneratePetName(uint32 entry); std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint32 level); uint32 GetBaseXP(uint32 level) const;
uint32 GetXPForLevel(uint32 level); uint32 GetXPForLevel(uint32 level) const;
uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level)/20; }
int32 GetFishingBaseSkillLevel(uint32 entry) const int32 GetFishingBaseSkillLevel(uint32 entry) const
{ {

View file

@ -715,7 +715,7 @@ void Pet::GivePetXP(uint32 xp)
newXP -= nextLvlXP; newXP -= nextLvlXP;
GivePetLevel(level+1); GivePetLevel(level+1);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(level+1)/4); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level+1));
level = getLevel(); level = getLevel();
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
@ -777,7 +777,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
setPowerType(POWER_FOCUS); setPowerType(POWER_FOCUS);
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(creature->getLevel())/4); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(creature->getLevel()));
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
if(CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) if(CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family))
@ -922,7 +922,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
} }
case HUNTER_PET: case HUNTER_PET:
{ {
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(petlevel)/4); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(petlevel));
//these formula may not be correct; however, it is designed to be close to what it should be //these formula may not be correct; however, it is designed to be close to what it should be
//this makes dps 0.5 of pets level //this makes dps 0.5 of pets level
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) ); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) );
@ -1945,7 +1945,7 @@ void Pet::SynchronizeLevelWithOwner()
if(getLevel() > owner->getLevel()) if(getLevel() > owner->getLevel())
{ {
GivePetLevel(owner->getLevel()); GivePetLevel(owner->getLevel());
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(owner->getLevel())/4); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(owner->getLevel()));
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP)-1); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP)-1);
} }
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 "9215" #define REVISION_NR "9216"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__