diff options
author | XTZGZoReX <none@none> | 2010-04-05 13:45:35 +0200 |
---|---|---|
committer | XTZGZoReX <none@none> | 2010-04-05 13:45:35 +0200 |
commit | d3e30bab724de6880d7df84b741908ae311e0631 (patch) | |
tree | 53d800f42767c5ac1d519f22bb5f603f167d8c4a /src | |
parent | 1fa2fbc658e5209d3df08e0dc7bb35e91d73b79a (diff) |
Fix pet leveling logic. Patch by click.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Pet.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 5bd42cfa007..0657040e9fd 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -698,31 +698,34 @@ void Pet::GivePetXP(uint32 xp) uint8 level = getLevel(); - // XP to money conversion processed in Player::RewardQuest - if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - return; + // If pet is detected to be equal to player level, don't hand out XP + if ( level >= GetOwner()->getLevel() ) + return; uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); uint32 newXP = curXP + xp; - if(newXP >= nextLvlXP && level+1 > GetOwner()->getLevel()) - { - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, nextLvlXP-1); - return; - } - + // Check how much XP the pet should receive, and hand off have any left from previous levelups while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) { + // Subtract newXP from amount needed for nextlevel newXP -= nextLvlXP; - GivePetLevel(level+1); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)*PET_XP_FACTOR); + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)*PET_XP_FACTOR); + // Make sure we're working with the upgraded levels for the pet XP-levels level = getLevel(); nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); + + // Hitting the pet/playerlevel combolimitation, set UNIT_FIELD_PETEXPERIENCE (current XP) to 0 + if ( level >= GetOwner()->getLevel() ) { + newXP = 0; + SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP); + return; + } } - + // Not affected by special conditions - give it new XP SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP); } |