From 0088d1300c2eb27489e4ad5ec772d4026f0dbfc2 Mon Sep 17 00:00:00 2001 From: Lightguard Date: Wed, 20 Jan 2010 04:59:20 +0300 Subject: [PATCH] [9216] Fixed hunter pet XP requirements. Signed-off-by: VladimirMangos Also move calculation to function. And avoid use operator[] for access to per-area base xp table data. --- src/game/Level2.cpp | 2 +- src/game/ObjectMgr.cpp | 7 ++++--- src/game/ObjectMgr.h | 5 +++-- src/game/Pet.cpp | 8 ++++---- src/shared/revision_nr.h | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 39131e03a..ff82b8c42 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1275,7 +1275,7 @@ bool ChatHandler::HandleNpcChangeLevelCommand(const char* args) { 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); } ((Pet*)pCreature)->GivePetLevel(lvl); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index a51f10e0d..d527183a0 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -6129,12 +6129,13 @@ void ObjectMgr::LoadExplorationBaseXP() 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()) return mPlayerXPperLevel[level]; diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index e45fa9f32..093ea750b 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -637,8 +637,9 @@ class ObjectMgr void LoadTrainerSpell(); std::string GeneratePetName(uint32 entry); - uint32 GetBaseXP(uint32 level); - uint32 GetXPForLevel(uint32 level); + uint32 GetBaseXP(uint32 level) const; + uint32 GetXPForLevel(uint32 level) const; + uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level)/20; } int32 GetFishingBaseSkillLevel(uint32 entry) const { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 0044a8a45..926655d98 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -715,7 +715,7 @@ void Pet::GivePetXP(uint32 xp) newXP -= nextLvlXP; GivePetLevel(level+1); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(level+1)/4); + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level+1)); level = getLevel(); nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); @@ -777,7 +777,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) setPowerType(POWER_FOCUS); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 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); if(CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) @@ -922,7 +922,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) } 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 //this makes dps 0.5 of pets level SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) ); @@ -1945,7 +1945,7 @@ void Pet::SynchronizeLevelWithOwner() if(getLevel() > 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); } break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0650b080c..1ac2c09a1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9215" + #define REVISION_NR "9216" #endif // __REVISION_NR_H__