Skip to content

Instantly share code, notes, and snippets.

@Natureknight
Created December 25, 2015 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Natureknight/64192acccc05fad6d36c to your computer and use it in GitHub Desktop.
Save Natureknight/64192acccc05fad6d36c to your computer and use it in GitHub Desktop.
diff --git a/src/server/scripts/Custom/copyGearCommands.cpp b/src/server/scripts/Custom/copyGearCommands.cpp
index f05e3e3..51f2564 100644
--- a/src/server/scripts/Custom/copyGearCommands.cpp
+++ b/src/server/scripts/Custom/copyGearCommands.cpp
@@ -155,12 +155,6 @@ public:
return false;
}
- if (player->GetFreeTalentPoints() < 71)
- {
- handler->PSendSysMessage("You need to reset your talents first.");
- return false;
- }
-
if (player->getClass() != target->getClass())
{
handler->PSendSysMessage("Target's class doesn't match your class.");
@@ -209,12 +203,6 @@ public:
return false;
}
- if (player->GetFreeTalentPoints() < 71)
- {
- handler->PSendSysMessage("You need to reset your talents first.");
- return false;
- }
-
if (player->getClass() != target->getClass())
{
handler->PSendSysMessage("Target's class doesn't match your class.");
@@ -298,46 +286,43 @@ private:
static void CopyTalents(Player* player, Player* target)
{
- target->SaveToDB();
- QueryResult result = CharacterDatabase.PQuery("SELECT spell FROM character_talent WHERE guid = '%u' "
- "AND spec = '%u';", target->GetGUID(), target->GetActiveSpec());
-
- if (!result)
+ // Reset talents if player already have some talent points spent
+ if (player->GetFreeTalentPoints() < 71)
{
- ChatHandler(player).PSendSysMessage("%s doesn't have any talents yet.",
- target->GetName());
- return;
+ player->resetTalents(true);
+ player->SendTalentsInfoData(false);
}
- do
+ for (uint32 talentEntry = 0; talentEntry < sTalentStore.GetNumRows(); ++talentEntry)
{
- Field* fields = result->Fetch();
- uint32 spell = fields[0].GetUInt32();
+ TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentEntry);
- player->learnSpell(spell, false);
- player->AddTalent(spell, player->GetActiveSpec(), true);
+ if (!talentInfo)
+ continue;
- } while (result->NextRow());
+ for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
+ {
+ if (talentInfo->RankID[rank] == 0)
+ continue;
+ if (target->HasTalent(talentInfo->RankID[rank], target->GetActiveSpec()))
+ {
+ player->learnSpell(talentInfo->RankID[rank], false);
+ player->AddTalent(talentInfo->RankID[rank], player->GetActiveSpec(), true);
+ }
+ }
+ }
CopyGlyphs(player, target);
- player->SetFreeTalentPoints(0);
+ player->SetFreeTalentPoints(target->GetFreeTalentPoints());
player->SendTalentsInfoData(false);
}
static void CopyGlyphs(Player* player, Player* target)
{
- QueryResult result = CharacterDatabase.PQuery("SELECT glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 "
- "FROM character_glyphs WHERE guid = '%u' AND spec = '%u';", target->GetGUID(), target->GetActiveSpec());
-
- if (!result)
- return;
-
- Field* fields = result->Fetch();
-
for (uint8 slot = 0; slot < MAX_GLYPH_SLOT_INDEX; ++slot)
{
- uint32 glyph = fields[slot].GetUInt32();
+ uint32 glyph = target->GetGlyph(slot);
// Skip empty slots
if (glyph == 0)
warning: LF will be replaced by CRLF in src/server/scripts/Custom/copyGearCommands.cpp.
The file will have its original line endings in your working directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment