mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(Scripts/Commands): Fixed command learn all my talents for chars… (#13529)
fix(Scripts/Commands): Fixed command `learn all my talents` for chars with 255 level. Fixes #4788
This commit is contained in:
@@ -13621,16 +13621,23 @@ void Player::CompletedAchievement(AchievementEntry const* entry)
|
||||
m_achievementMgr->CompletedAchievement(entry);
|
||||
}
|
||||
|
||||
void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
void Player::LearnTalent(uint32 talentId, uint32 talentRank, bool command /*= false*/)
|
||||
{
|
||||
uint32 CurTalentPoints = GetFreeTalentPoints();
|
||||
|
||||
// xinef: check basic data
|
||||
if (CurTalentPoints == 0)
|
||||
return;
|
||||
if (!command)
|
||||
{
|
||||
// xinef: check basic data
|
||||
if (!CurTalentPoints)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (talentRank >= MAX_TALENT_RANK)
|
||||
return;
|
||||
if (talentRank >= MAX_TALENT_RANK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
|
||||
if (!talentInfo)
|
||||
@@ -13659,10 +13666,15 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
if (currentTalentRank >= talentRank + 1)
|
||||
return;
|
||||
|
||||
// xinef: check if we have enough free talent points
|
||||
uint32 talentPointsChange = (talentRank - currentTalentRank + 1);
|
||||
if (CurTalentPoints < talentPointsChange)
|
||||
return;
|
||||
if (!command)
|
||||
{
|
||||
// xinef: check if we have enough free talent points
|
||||
if (CurTalentPoints < talentPointsChange)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// xinef: check if talent deponds on another talent
|
||||
if (talentInfo->DependsOn > 0)
|
||||
@@ -13684,23 +13696,26 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
return;
|
||||
}
|
||||
|
||||
// xinef: check amount of points spent in current talent tree
|
||||
// xinef: be smart and quick
|
||||
uint32 spentPoints = 0;
|
||||
if (talentInfo->Row > 0)
|
||||
if (!command)
|
||||
{
|
||||
const PlayerTalentMap& talentMap = GetTalentMap();
|
||||
for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
|
||||
if (TalentSpellPos const* talentPos = GetTalentSpellPos(itr->first))
|
||||
if (TalentEntry const* itrTalentInfo = sTalentStore.LookupEntry(talentPos->talent_id))
|
||||
if (itrTalentInfo->TalentTab == talentInfo->TalentTab)
|
||||
if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(GetActiveSpec())) // pussywizard
|
||||
spentPoints += talentPos->rank + 1;
|
||||
}
|
||||
// xinef: check amount of points spent in current talent tree
|
||||
// xinef: be smart and quick
|
||||
uint32 spentPoints = 0;
|
||||
if (talentInfo->Row > 0)
|
||||
{
|
||||
const PlayerTalentMap& talentMap = GetTalentMap();
|
||||
for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
|
||||
if (TalentSpellPos const* talentPos = GetTalentSpellPos(itr->first))
|
||||
if (TalentEntry const* itrTalentInfo = sTalentStore.LookupEntry(talentPos->talent_id))
|
||||
if (itrTalentInfo->TalentTab == talentInfo->TalentTab)
|
||||
if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(GetActiveSpec())) // pussywizard
|
||||
spentPoints += talentPos->rank + 1;
|
||||
}
|
||||
|
||||
// xinef: we do not have enough talent points to add talent of this tier
|
||||
if (spentPoints < (talentInfo->Row * MAX_TALENT_RANK))
|
||||
return;
|
||||
// xinef: we do not have enough talent points to add talent of this tier
|
||||
if (spentPoints < (talentInfo->Row * MAX_TALENT_RANK))
|
||||
return;
|
||||
}
|
||||
|
||||
// xinef: hacking attempt, tries to learn unknown rank
|
||||
uint32 spellId = talentInfo->RankID[talentRank];
|
||||
@@ -13733,7 +13748,11 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
|
||||
// xinef: update free talent points count
|
||||
m_usedTalentCount += talentPointsChange;
|
||||
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
|
||||
}
|
||||
|
||||
sScriptMgr->OnPlayerLearnTalents(this, talentId, talentRank, spellId);
|
||||
}
|
||||
|
||||
@@ -1677,7 +1677,7 @@ public:
|
||||
void BuildPlayerTalentsInfoData(WorldPacket* data);
|
||||
void BuildPetTalentsInfoData(WorldPacket* data);
|
||||
void SendTalentsInfoData(bool pet);
|
||||
void LearnTalent(uint32 talentId, uint32 talentRank);
|
||||
void LearnTalent(uint32 talentId, uint32 talentRank, bool command = false);
|
||||
void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank);
|
||||
|
||||
bool addTalent(uint32 spellId, uint8 addSpecMask, uint8 oldTalentRank);
|
||||
|
||||
@@ -195,9 +195,12 @@ public:
|
||||
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
|
||||
continue;
|
||||
|
||||
player->LearnTalent(talentInfo->TalentID, rankId);
|
||||
player->LearnTalent(talentInfo->TalentID, rankId, true);
|
||||
}
|
||||
|
||||
player->SetFreeTalentPoints(0);
|
||||
player->SendTalentsInfoData(false);
|
||||
|
||||
handler->SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user