AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::PlayerCommand Namespace Reference

Functions

bool HandleLearnSpellCommand (ChatHandler *handler, Player *targetPlayer, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
 
bool HandleUnlearnSpellCommand (ChatHandler *handler, Player *targetPlayer, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
 

Function Documentation

◆ HandleLearnSpellCommand()

bool Acore::PlayerCommand::HandleLearnSpellCommand ( ChatHandler handler,
Player targetPlayer,
SpellInfo const *  spell,
Optional< EXACT_SEQUENCE("all")>  allRanks 
)
25{
26 if (!SpellMgr::IsSpellValid(spell))
27 {
29 return false;
30 }
31
32 if (!allRanks && targetPlayer->HasSpell(spell->Id))
33 {
34 if (targetPlayer == handler->GetPlayer())
35 {
37 }
38 else
39 {
40 handler->SendErrorMessage(LANG_TARGET_KNOWN_SPELL, handler->GetNameLink(targetPlayer).c_str());
41 }
42
43 return false;
44 }
45
46 targetPlayer->learnSpell(spell->Id, false);
47
48 if (allRanks)
49 {
50 uint32 spellId = spell->Id;
51
52 while ((spellId = sSpellMgr->GetNextSpellInChain(spellId)))
53 {
54 targetPlayer->learnSpell(spellId, false);
55 }
56 }
57
58 if (GetTalentSpellCost(spell->GetFirstRankSpell()->Id))
59 {
60 targetPlayer->SendTalentsInfoData(false);
61 }
62
63 return true;
64}
std::uint32_t uint32
Definition: Define.h:107
#define sSpellMgr
Definition: SpellMgr.h:825
@ LANG_YOU_KNOWN_SPELL
Definition: Language.h:527
@ LANG_COMMAND_SPELL_BROKEN
Definition: Language.h:520
@ LANG_TARGET_KNOWN_SPELL
Definition: Language.h:528
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:686
virtual std::string GetNameLink() const
Definition: Chat.h:198
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
Player * GetPlayer() const
Definition: Chat.cpp:35
void SendTalentsInfoData(bool pet)
Definition: Player.cpp:14454
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition: Player.cpp:3304
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3892
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition: SpellMgr.cpp:441

References SpellInfo::GetFirstRankSpell(), ChatHandler::GetNameLink(), ChatHandler::GetPlayer(), GetTalentSpellCost(), Player::HasSpell(), SpellInfo::Id, SpellMgr::IsSpellValid(), LANG_COMMAND_SPELL_BROKEN, LANG_TARGET_KNOWN_SPELL, LANG_YOU_KNOWN_SPELL, Player::learnSpell(), ChatHandler::SendErrorMessage(), Player::SendTalentsInfoData(), and sSpellMgr.

Referenced by learn_commandscript::HandleLearnCommand(), and player_commandscript::HandlePlayerLearnCommand().

◆ HandleUnlearnSpellCommand()

bool Acore::PlayerCommand::HandleUnlearnSpellCommand ( ChatHandler handler,
Player targetPlayer,
SpellInfo const *  spell,
Optional< EXACT_SEQUENCE("all")>  allRanks 
)
67{
68 uint32 spellId = spell->Id;
69
70 if (allRanks)
71 {
72 spellId = sSpellMgr->GetFirstSpellInChain(spellId);
73 }
74
75 if (target->HasSpell(spellId))
76 {
77 target->removeSpell(spellId, SPEC_MASK_ALL, false);
78 }
79 else
80 {
82 }
83
84 if (GetTalentSpellCost(spellId))
85 {
86 target->SendTalentsInfoData(false);
87 }
88
89 return true;
90}
@ LANG_FORGET_SPELL
Definition: Language.h:530
#define SPEC_MASK_ALL
Definition: Player.h:177
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159

References GetTalentSpellCost(), Player::HasSpell(), SpellInfo::Id, LANG_FORGET_SPELL, Player::removeSpell(), ChatHandler::SendSysMessage(), Player::SendTalentsInfoData(), SPEC_MASK_ALL, and sSpellMgr.

Referenced by player_commandscript::HandlePlayerUnLearnCommand(), and learn_commandscript::HandleUnLearnCommand().