aboutsummaryrefslogtreecommitdiff
path: root/src/game/Level3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Level3.cpp')
-rw-r--r--src/game/Level3.cpp80
1 files changed, 78 insertions, 2 deletions
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index d3aa1d1a070..e1dd468158e 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -2324,6 +2324,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)
@@ -5224,9 +5300,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;
}