Last active
October 6, 2020 01:35
-
-
Save irancore/e8b30bca005cb2a5bda29266c0cbbd8a to your computer and use it in GitHub Desktop.
script set default active all talents for new players
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* developed by irancore.ir | |
* | |
* Default All Talent Active For + Lvl 10 | |
* | |
* My Discord : Ac_Dev#8552 | |
*/ | |
#include "GameObject.h" | |
#include "SpellInfo.h" | |
#include "SpellMgr.h" | |
#include "WorldSession.h" | |
#include "Player.h" | |
#include "DBCStores.h" | |
class Default_Talent_Active : public PlayerScript | |
{ | |
public: | |
Default_Talent_Active() : PlayerScript("Default_Talent_Active") { } | |
// Called when a player is created. | |
void OnCreate(Player* player) | |
{ | |
uint32 classMask = player->GetClassMask(); | |
for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) | |
{ | |
TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); | |
if (!talentInfo) | |
continue; | |
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TabID); | |
if (!talentTabInfo) | |
continue; | |
if ((classMask & talentTabInfo->ClassMask) == 0) | |
continue; | |
// search highest talent rank | |
uint32 spellId = 0; | |
for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) | |
{ | |
if (talentInfo->SpellRank[rank] != 0) | |
{ | |
spellId = talentInfo->SpellRank[rank]; | |
break; | |
} | |
} | |
if (!spellId) // ??? none spells in talent | |
continue; | |
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); | |
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player->GetSession()->GetPlayer(), false)) | |
continue; | |
// learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) | |
player->LearnSpellHighestRank(spellId); | |
player->AddTalent(spellId, player->GetActiveSpec(), true); | |
} | |
player->SetFreeTalentPoints(0); | |
player->SaveToDB(); | |
} | |
}; | |
void Default_All_Talents() | |
{ | |
new Default_Talent_Active(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment