[7558] Implement command: .learn all_mypettalents

Also output more correct messages at use .reset talents to pet
This commit is contained in:
VladimirMangos 2009-03-28 03:23:32 +03:00
parent 4e66d61da9
commit 2dd36d688f
11 changed files with 125 additions and 8 deletions

View file

@ -1791,6 +1791,82 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/)
return true;
}
bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/)
{
Player* player = m_session->GetPlayer();
Pet* pet = player->GetPet();
if(!pet)
{
SendSysMessage(LANG_NO_PET_FOUND);
SetSentErrorMessage(true);
return false;
}
CreatureInfo const *ci = pet->GetCreatureInfo();
if(!ci)
{
SendSysMessage(LANG_WRONG_PET_TYPE);
SetSentErrorMessage(true);
return false;
}
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
if(!pet_family)
{
SendSysMessage(LANG_WRONG_PET_TYPE);
SetSentErrorMessage(true);
return false;
}
if(pet_family->petTalentType < 0) // not hunter pet
{
SendSysMessage(LANG_WRONG_PET_TYPE);
SetSentErrorMessage(true);
return false;
}
for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++)
{
TalentEntry const *talentInfo = sTalentStore.LookupEntry(i);
if(!talentInfo)
continue;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab );
if(!talentTabInfo)
continue;
// prevent learn talent for different family (cheating)
if(((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)==0)
continue;
// search highest talent rank
uint32 spellid = 0;
for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
{
if(talentInfo->RankID[rank]!=0)
{
spellid = talentInfo->RankID[rank];
break;
}
}
if(!spellid) // ??? none spells in talent
continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false))
continue;
// learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
pet->learnSpellHighRank(spellid);
}
SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS);
return true;
}
bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
{
// skipping UNIVERSAL language (0)
@ -4644,9 +4720,9 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
{
player = (Player *)owner;
ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS);
ChatHandler(player).SendSysMessage(LANG_RESET_PET_TALENTS);
if(m_session->GetPlayer()!=player)
PSendSysMessage(LANG_RESET_TALENTS_ONLINE,GetNameLink(player).c_str());
PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE,GetNameLink(player).c_str());
}
return true;
}