[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:
+10
-4
@@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
|
||||
CREATE TABLE `db_version` (
|
||||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`required_7823_01_mangos_item_template` bit(1) default NULL
|
||||
`required_7830_01_mangos_spell_chain` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
@@ -14496,7 +14496,7 @@ INSERT INTO spell_chain VALUES
|
||||
/*------------------
|
||||
--(189)Pet-Felhunter
|
||||
------------------*/
|
||||
/*DevourMagic*/
|
||||
/*Devour Magic*/
|
||||
(19505,0,19505,1,0),
|
||||
(19731,19505,19505,2,0),
|
||||
(19734,19731,19505,3,0),
|
||||
@@ -14504,13 +14504,19 @@ INSERT INTO spell_chain VALUES
|
||||
(27276,19736,19505,5,0),
|
||||
(27277,27276,19505,6,0),
|
||||
(48011,27277,19505,7,0),
|
||||
/*ShadowBite*/
|
||||
/*Fel Intelligence*/
|
||||
(54424,0,54424,1,0),
|
||||
(57564,54424,54424,2,0),
|
||||
(57565,57564,54424,3,0),
|
||||
(57566,57565,54424,4,0),
|
||||
(57567,57566,54424,5,0),
|
||||
/*Shadow Bite*/
|
||||
(54049,0,54049,1,0),
|
||||
(54050,54049,54049,2,0),
|
||||
(54051,54050,54049,3,0),
|
||||
(54052,54051,54049,4,0),
|
||||
(54053,54052,54049,5,0),
|
||||
/*SpellLock*/
|
||||
/*Spell Lock*/
|
||||
(19244,0,19244,1,0),
|
||||
(19647,19244,19244,2,0),
|
||||
/*------------------
|
||||
|
||||
@@ -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