[7125] Work under pet talents

Coorrect update Talent Points on levelup / leveldown
Unlearn other ranks of learned talent
Fix typo in Pet::HasSpell (wrong result for removed spell)
Allow .reset talents reset pet talent
Implement SPELL_AURA_MOD_PET_TALENT_POINTS aura (hunter talent)
Only reset pet talent from trainer unlearn.

Signed-off-by: DiSlord <dislord@nomail.com>
This commit is contained in:
DiSlord 2009-01-21 00:14:39 +03:00
parent ca7ac74134
commit 921914f87e
10 changed files with 225 additions and 72 deletions

View file

@ -487,11 +487,11 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
sLog.outDetail("CMSG_PET_UNLEARN");
uint64 guid;
recvPacket >> guid;
recvPacket >> guid; // Pet guid
Pet* pet = _player->GetPet();
if(!pet || pet->getPetType() != HUNTER_PET || pet->m_spells.size() <= 1)
if(!pet || pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0)
return;
if(guid != pet->GetGUID())
@ -506,37 +506,7 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
sLog.outError("WorldSession::HandlePetUnlearnOpcode: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
return;
}
uint32 cost = pet->resetTalentsCost();
if (GetPlayer()->GetMoney() < cost)
{
GetPlayer()->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
return;
}
for(PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end();)
{
uint32 spell_id = itr->first; // Pet::removeSpell can invalidate iterator at erase NEW spell
++itr;
//pet->removeSpell(spell_id);
pet->unlearnSpell(spell_id);
}
for(uint8 i = 0; i < 10; i++)
{
if(charmInfo->GetActionBarEntry(i)->SpellOrAction && charmInfo->GetActionBarEntry(i)->Type == ACT_ENABLED || charmInfo->GetActionBarEntry(i)->Type == ACT_DISABLED)
charmInfo->GetActionBarEntry(i)->SpellOrAction = 0;
}
// relearn pet passives
pet->LearnPetPassives();
pet->m_resetTalentsTime = time(NULL);
pet->m_resetTalentsCost = cost;
GetPlayer()->ModifyMoney(-(int32)cost);
GetPlayer()->PetSpellInitialize();
pet->resetTalents();
}
void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
@ -809,7 +779,4 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
// learn! (other talent ranks will unlearned at learning)
pet->learnSpell(spellid);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talent_id, requested_rank, spellid);
// update free talent points
pet->SetFreeTalentPoints(CurTalentPoints - 1);
}