AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
learn_commandscript Class Reference
Inheritance diagram for learn_commandscript:
CommandScript ScriptObject

Public Member Functions

 learn_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleLearnCommand (ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
 
static bool HandleLearnAllGMCommand (ChatHandler *handler)
 
static bool HandleLearnAllMyClassCommand (ChatHandler *handler)
 
static bool HandleLearnAllMySpellsCommand (ChatHandler *handler)
 
static bool HandleLearnAllMyTalentsCommand (ChatHandler *handler)
 
static bool HandleLearnAllMyPetTalentsCommand (ChatHandler *handler)
 
static bool HandleLearnAllLangCommand (ChatHandler *handler)
 
static bool HandleLearnAllDefaultCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleLearnAllCraftsCommand (ChatHandler *handler)
 
static bool HandleLearnAllRecipesCommand (ChatHandler *handler, WTail namePart)
 
static void HandleLearnSkillRecipesHelper (Player *player, uint32 skillId)
 
static bool HandleUnLearnCommand (ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ learn_commandscript()

learn_commandscript::learn_commandscript ( )
inline
32: CommandScript("learn_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable learn_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

35 {
36 static ChatCommandTable learnAllMyCommandTable =
37 {
38 { "class", HandleLearnAllMyClassCommand, SEC_GAMEMASTER, Console::No },
39 { "pettalents", HandleLearnAllMyPetTalentsCommand, SEC_GAMEMASTER, Console::No },
40 { "spells", HandleLearnAllMySpellsCommand, SEC_GAMEMASTER, Console::No },
41 { "talents", HandleLearnAllMyTalentsCommand, SEC_GAMEMASTER, Console::No }
42 };
43
44 static ChatCommandTable learnAllCommandTable =
45 {
46 { "my", learnAllMyCommandTable },
47 { "gm", HandleLearnAllGMCommand, SEC_GAMEMASTER, Console::No },
48 { "crafts", HandleLearnAllCraftsCommand, SEC_GAMEMASTER, Console::No },
49 { "default", HandleLearnAllDefaultCommand, SEC_GAMEMASTER, Console::No },
50 { "lang", HandleLearnAllLangCommand, SEC_GAMEMASTER, Console::No },
51 { "recipes", HandleLearnAllRecipesCommand, SEC_GAMEMASTER, Console::No },
52 };
53
54 static ChatCommandTable learnCommandTable =
55 {
56 { "all", learnAllCommandTable },
57 { "", HandleLearnCommand, SEC_GAMEMASTER, Console::No }
58 };
59
60 static ChatCommandTable commandTable =
61 {
62 { "learn", learnCommandTable },
63 { "unlearn", HandleUnLearnCommand, SEC_GAMEMASTER, Console::No }
64 };
65 return commandTable;
66 }
@ SEC_GAMEMASTER
Definition Common.h:59
static bool HandleLearnAllMyPetTalentsCommand(ChatHandler *handler)
Definition cs_learn.cpp:200
static bool HandleUnLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition cs_learn.cpp:408
static bool HandleLearnAllRecipesCommand(ChatHandler *handler, WTail namePart)
Definition cs_learn.cpp:322
static bool HandleLearnAllGMCommand(ChatHandler *handler)
Definition cs_learn.cpp:81
static bool HandleLearnAllMyClassCommand(ChatHandler *handler)
Definition cs_learn.cpp:99
static bool HandleLearnAllDefaultCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_learn.cpp:287
static bool HandleLearnAllMyTalentsCommand(ChatHandler *handler)
Definition cs_learn.cpp:151
static bool HandleLearnAllLangCommand(ChatHandler *handler)
Definition cs_learn.cpp:274
static bool HandleLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition cs_learn.cpp:68
static bool HandleLearnAllCraftsCommand(ChatHandler *handler)
Definition cs_learn.cpp:303
static bool HandleLearnAllMySpellsCommand(ChatHandler *handler)
Definition cs_learn.cpp:106
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleLearnAllCraftsCommand(), HandleLearnAllDefaultCommand(), HandleLearnAllGMCommand(), HandleLearnAllLangCommand(), HandleLearnAllMyClassCommand(), HandleLearnAllMyPetTalentsCommand(), HandleLearnAllMySpellsCommand(), HandleLearnAllMyTalentsCommand(), HandleLearnAllRecipesCommand(), HandleLearnCommand(), HandleUnLearnCommand(), and SEC_GAMEMASTER.

◆ HandleLearnAllCraftsCommand()

static bool learn_commandscript::HandleLearnAllCraftsCommand ( ChatHandler handler)
inlinestatic
304 {
305 for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
306 {
307 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
308 if (!skillInfo)
309 continue;
310
311 if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
312 skillInfo->canLink) // only prof. with recipes have
313 {
314 HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(), skillInfo->id);
315 }
316 }
317
319 return true;
320 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
std::uint32_t uint32
Definition Define.h:107
@ LANG_COMMAND_LEARN_ALL_CRAFT
Definition Language.h:466
@ SKILL_CATEGORY_SECONDARY
Definition SharedDefines.h:3076
@ SKILL_CATEGORY_PROFESSION
Definition SharedDefines.h:3078
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
Player * GetPlayer() const
Definition WorldSession.h:376
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition cs_learn.cpp:382
Definition DBCStructure.h:1584
uint32 id
Definition DBCStructure.h:1585
int32 categoryId
Definition DBCStructure.h:1586
uint32 canLink
Definition DBCStructure.h:1595

References SkillLineEntry::canLink, SkillLineEntry::categoryId, WorldSession::GetPlayer(), ChatHandler::GetSession(), HandleLearnSkillRecipesHelper(), SkillLineEntry::id, LANG_COMMAND_LEARN_ALL_CRAFT, ChatHandler::SendSysMessage(), SKILL_CATEGORY_PROFESSION, SKILL_CATEGORY_SECONDARY, and sSkillLineStore.

Referenced by GetCommands().

◆ HandleLearnAllDefaultCommand()

static bool learn_commandscript::HandleLearnAllDefaultCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
288 {
289 if (!player)
290 player = PlayerIdentifier::FromTargetOrSelf(handler);
291 if (!player || !player->IsConnected())
292 return false;
293
294 Player* target = player->GetConnectedPlayer();
295 target->LearnDefaultSkills();
296 target->LearnCustomSpells();
297 target->learnQuestRewardedSpells();
298
300 return true;
301 }
@ LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
Definition Language.h:640
virtual std::string GetNameLink() const
Definition Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
Definition Player.h:1082
void LearnCustomSpells()
Definition Player.cpp:11783
void learnQuestRewardedSpells()
Definition Player.cpp:11925
void LearnDefaultSkills()
Definition Player.cpp:11809
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:184

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::GetNameLink(), LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST, Player::LearnCustomSpells(), Player::LearnDefaultSkills(), Player::learnQuestRewardedSpells(), and ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleLearnAllGMCommand()

static bool learn_commandscript::HandleLearnAllGMCommand ( ChatHandler handler)
inlinestatic
82 {
83 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
84 {
85 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
86 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
87 continue;
88
89 if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL))
90 continue;
91
92 handler->GetSession()->GetPlayer()->learnSpell(i);
93 }
94
96 return true;
97 }
@ LANG_LEARNING_GM_SKILLS
Definition Language.h:527
@ SKILL_INTERNAL
Definition SharedDefines.h:2998
#define sSpellMgr
Definition SpellMgr.h:825
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition Player.cpp:3290
Definition SpellInfo.h:316
bool IsAbilityOfSkillType(uint32 skillType) const
Definition SpellInfo.cpp:1005
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition SpellMgr.cpp:441

References WorldSession::GetPlayer(), ChatHandler::GetSession(), SpellInfo::IsAbilityOfSkillType(), SpellMgr::IsSpellValid(), LANG_LEARNING_GM_SKILLS, Player::learnSpell(), ChatHandler::SendSysMessage(), SKILL_INTERNAL, and sSpellMgr.

Referenced by GetCommands().

◆ HandleLearnAllLangCommand()

static bool learn_commandscript::HandleLearnAllLangCommand ( ChatHandler handler)
inlinestatic
275 {
276 for (LanguageDesc const& langDesc : lang_description)
277 if (uint32 langSpellId = langDesc.spell_id)
278 {
279 handler->GetPlayer()->learnSpell(langSpellId);
280 handler->GetPlayer()->SetSkill(langDesc.skill_id, 0, 300, 300);
281 }
282
284 return true;
285 }
@ LANG_COMMAND_LEARN_ALL_LANG
Definition Language.h:465
LanguageDesc lang_description[LANGUAGES_COUNT]
Definition ObjectMgr.cpp:230
Player * GetPlayer() const
Definition Chat.cpp:36
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition Player.cpp:5336
Definition ObjectMgr.h:691

References ChatHandler::GetPlayer(), LANG_COMMAND_LEARN_ALL_LANG, lang_description, Player::learnSpell(), ChatHandler::SendSysMessage(), and Player::SetSkill().

Referenced by GetCommands().

◆ HandleLearnAllMyClassCommand()

static bool learn_commandscript::HandleLearnAllMyClassCommand ( ChatHandler handler)
inlinestatic
100 {
103 return true;
104 }

References HandleLearnAllMySpellsCommand(), and HandleLearnAllMyTalentsCommand().

Referenced by GetCommands().

◆ HandleLearnAllMyPetTalentsCommand()

static bool learn_commandscript::HandleLearnAllMyPetTalentsCommand ( ChatHandler handler)
inlinestatic
201 {
202 Player* player = handler->GetSession()->GetPlayer();
203
204 Pet* pet = player->GetPet();
205 if (!pet)
206 {
208 return false;
209 }
210
211 CreatureTemplate const* creatureInfo = pet->GetCreatureTemplate();
212 if (!creatureInfo)
213 {
215 return false;
216 }
217
218 CreatureFamilyEntry const* petFamily = sCreatureFamilyStore.LookupEntry(creatureInfo->family);
219 if (!petFamily)
220 {
222 return false;
223 }
224
225 if (petFamily->petTalentType < 0) // not hunter pet
226 {
228 return false;
229 }
230
231 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
232 {
233 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
234 if (!talentInfo)
235 continue;
236
237 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
238 if (!talentTabInfo)
239 continue;
240
241 // prevent learn talent for different family (cheating)
242 if (((1 << petFamily->petTalentType) & talentTabInfo->petTalentMask) == 0)
243 continue;
244
245 // search highest talent rank
246 uint32 spellId = 0;
247
248 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
249 {
250 if (talentInfo->RankID[rank] != 0)
251 {
252 spellId = talentInfo->RankID[rank];
253 break;
254 }
255 }
256
257 if (!spellId) // ??? none spells in talent
258 continue;
259
260 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
261 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
262 continue;
263
264 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
265 pet->learnSpellHighRank(spellId);
266 }
267
268 pet->SetFreeTalentPoints(0);
269
271 return true;
272 }
DBCStorage< TalentTabEntry > sTalentTabStore(TalentTabEntryfmt)
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
#define MAX_TALENT_RANK
Definition DBCStructure.h:1919
std::int8_t int8
Definition Define.h:105
@ LANG_WRONG_PET_TYPE
Definition Language.h:914
@ LANG_COMMAND_LEARN_PET_TALENTS
Definition Language.h:915
@ LANG_NO_PET_FOUND
Definition Language.h:913
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:209
Definition Pet.h:41
void learnSpellHighRank(uint32 spellid)
Definition Pet.cpp:2386
void SetFreeTalentPoints(uint8 points)
Definition Pet.h:132
Pet * GetPet() const
Definition Player.cpp:8917
Definition DBCStructure.h:754
int32 petTalentType
Definition DBCStructure.h:762
Definition CreatureData.h:186
uint32 family
Definition CreatureData.h:217
Definition DBCStructure.h:1924
std::array< uint32, MAX_TALENT_RANK > RankID
Definition DBCStructure.h:1929
uint32 TalentTab
Definition DBCStructure.h:1926
Definition DBCStructure.h:1941
uint32 petTalentMask
Definition DBCStructure.h:1948

References CreatureTemplate::family, Creature::GetCreatureTemplate(), Player::GetPet(), WorldSession::GetPlayer(), ChatHandler::GetSession(), SpellMgr::IsSpellValid(), LANG_COMMAND_LEARN_PET_TALENTS, LANG_NO_PET_FOUND, LANG_WRONG_PET_TYPE, Pet::learnSpellHighRank(), MAX_TALENT_RANK, TalentTabEntry::petTalentMask, CreatureFamilyEntry::petTalentType, TalentEntry::RankID, sCreatureFamilyStore, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), Pet::SetFreeTalentPoints(), sSpellMgr, sTalentStore, sTalentTabStore, and TalentEntry::TalentTab.

Referenced by GetCommands().

◆ HandleLearnAllMySpellsCommand()

static bool learn_commandscript::HandleLearnAllMySpellsCommand ( ChatHandler handler)
inlinestatic
107 {
108 ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass());
109 if (!classEntry)
110 return true;
111 uint32 family = classEntry->spellfamily;
112
113 for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i)
114 {
115 SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i);
116 if (!entry)
117 continue;
118
119 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->Spell);
120 if (!spellInfo)
121 continue;
122
123 // skip server-side/triggered spells
124 if (spellInfo->SpellLevel == 0)
125 continue;
126
127 // skip wrong class/race skills
128 if (!handler->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id))
129 continue;
130
131 // skip other spell families
132 if (spellInfo->SpellFamilyName != family)
133 continue;
134
135 // skip spells with first rank learned as talent (and all talents then also)
136 uint32 firstRank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id);
137 if (GetTalentSpellCost(firstRank) > 0)
138 continue;
139
140 // skip broken spells
141 if (!SpellMgr::IsSpellValid(spellInfo))
142 continue;
143
144 handler->GetSession()->GetPlayer()->learnSpell(spellInfo->Id);
145 }
146
148 return true;
149 }
uint32 GetTalentSpellCost(uint32 spellId)
Definition DBCStores.cpp:686
DBCStorage< SkillLineAbilityEntry > sSkillLineAbilityStore(SkillLineAbilityfmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition Language.h:463
bool IsSpellFitByClassAndRace(uint32 spell_id) const
Definition Player.cpp:12303
uint32 SpellLevel
Definition SpellInfo.h:360
uint32 Id
Definition SpellInfo.h:320
uint32 SpellFamilyName
Definition SpellInfo.h:387
uint8 getClass() const
Definition Unit.h:793
Definition DBCStructure.h:653
uint32 spellfamily
Definition DBCStructure.h:665
Definition DBCStructure.h:1599
uint32 Spell
Definition DBCStructure.h:1602

References Unit::getClass(), WorldSession::GetPlayer(), ChatHandler::GetSession(), GetTalentSpellCost(), SpellInfo::Id, Player::IsSpellFitByClassAndRace(), SpellMgr::IsSpellValid(), LANG_COMMAND_LEARN_CLASS_SPELLS, Player::learnSpell(), sChrClassesStore, ChatHandler::SendSysMessage(), SkillLineAbilityEntry::Spell, ChrClassesEntry::spellfamily, SpellInfo::SpellFamilyName, SpellInfo::SpellLevel, sSkillLineAbilityStore, and sSpellMgr.

Referenced by GetCommands(), and HandleLearnAllMyClassCommand().

◆ HandleLearnAllMyTalentsCommand()

static bool learn_commandscript::HandleLearnAllMyTalentsCommand ( ChatHandler handler)
inlinestatic
152 {
153 Player* player = handler->GetSession()->GetPlayer();
154 uint32 classMask = player->getClassMask();
155
156 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
157 {
158 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
159 if (!talentInfo)
160 continue;
161
162 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
163 if (!talentTabInfo)
164 continue;
165
166 if ((classMask & talentTabInfo->ClassMask) == 0)
167 continue;
168
169 // xinef: search highest talent rank
170 uint32 spellId = 0;
171 uint8 rankId = MAX_TALENT_RANK;
172 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
173 {
174 if (talentInfo->RankID[rank] != 0)
175 {
176 rankId = rank;
177 spellId = talentInfo->RankID[rank];
178 break;
179 }
180 }
181
182 // xinef: some errors?
183 if (!spellId || rankId == MAX_TALENT_RANK)
184 continue;
185
186 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
187 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
188 continue;
189
190 player->LearnTalent(talentInfo->TalentID, rankId, true);
191 }
192
193 player->SetFreeTalentPoints(0);
194 player->SendTalentsInfoData(false);
195
197 return true;
198 }
std::uint8_t uint8
Definition Define.h:109
@ LANG_COMMAND_LEARN_CLASS_TALENTS
Definition Language.h:464
void SendTalentsInfoData(bool pet)
Definition Player.cpp:14362
void LearnTalent(uint32 talentId, uint32 talentRank, bool command=false)
Definition Player.cpp:13884
void SetFreeTalentPoints(uint32 points)
Definition Player.cpp:3798
uint32 getClassMask() const
Definition Unit.h:795
uint32 TalentID
Definition DBCStructure.h:1925
uint32 ClassMask
Definition DBCStructure.h:1947

References TalentTabEntry::ClassMask, Unit::getClassMask(), WorldSession::GetPlayer(), ChatHandler::GetSession(), SpellMgr::IsSpellValid(), LANG_COMMAND_LEARN_CLASS_TALENTS, Player::LearnTalent(), MAX_TALENT_RANK, TalentEntry::RankID, ChatHandler::SendSysMessage(), Player::SendTalentsInfoData(), Player::SetFreeTalentPoints(), sSpellMgr, sTalentStore, sTalentTabStore, TalentEntry::TalentID, and TalentEntry::TalentTab.

Referenced by GetCommands(), and HandleLearnAllMyClassCommand().

◆ HandleLearnAllRecipesCommand()

static bool learn_commandscript::HandleLearnAllRecipesCommand ( ChatHandler handler,
WTail  namePart 
)
inlinestatic
323 {
324 // Learns all recipes of specified profession and sets skill to max
325 // Example: .learn all_recipes enchanting
326
327 Player* target = handler->getSelectedPlayer();
328 if (!target)
329 {
331 return false;
332 }
333
334 if (namePart.empty())
335 return false;
336
337 // converting string that we try to find to lower case
338 wstrToLower(namePart);
339
340 SkillLineEntry const* targetSkillInfo = nullptr;
341 char const* name = nullptr;
342 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
343 {
344 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
345 if (!skillInfo)
346 continue;
347
348 if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION &&
349 skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) ||
350 !skillInfo->canLink) // only prof with recipes have set
351 continue;
352
353 uint8 locale = 0;
354 for (; locale < TOTAL_LOCALES; ++locale)
355 {
356 name = skillInfo->name[locale];
357 if (!name || !*name)
358 continue;
359
360 if (Utf8FitTo(name, namePart))
361 break;
362 }
363
364 if (locale < TOTAL_LOCALES)
365 {
366 targetSkillInfo = skillInfo;
367 break;
368 }
369 }
370
371 if (!(name && targetSkillInfo))
372 return false;
373
374 HandleLearnSkillRecipesHelper(target, targetSkillInfo->id);
375
376 uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
377 target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel);
379 return true;
380 }
@ TOTAL_LOCALES
Definition Common.h:76
std::uint16_t uint16
Definition Define.h:108
@ LANG_COMMAND_LEARN_ALL_RECIPES
Definition Language.h:655
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:540
void wstrToLower(std::wstring &str)
Definition Util.cpp:382
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition Util.cpp:481
Player * getSelectedPlayer() const
Definition Chat.cpp:374
uint16 GetSkillStep(uint16 skill) const
Definition Player.cpp:5445
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition Player.cpp:5492
char const * name[16]
Definition DBCStructure.h:1588

References SkillLineEntry::canLink, SkillLineEntry::categoryId, Player::GetPureMaxSkillValue(), ChatHandler::getSelectedPlayer(), Player::GetSkillStep(), HandleLearnSkillRecipesHelper(), SkillLineEntry::id, LANG_COMMAND_LEARN_ALL_RECIPES, LANG_PLAYER_NOT_FOUND, SkillLineEntry::name, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), Player::SetSkill(), SKILL_CATEGORY_PROFESSION, SKILL_CATEGORY_SECONDARY, sSkillLineStore, TOTAL_LOCALES, Utf8FitTo(), and wstrToLower().

Referenced by GetCommands().

◆ HandleLearnCommand()

static bool learn_commandscript::HandleLearnCommand ( ChatHandler handler,
SpellInfo const *  spell,
Optional< EXACT_SEQUENCE("all")>  allRanks 
)
inlinestatic
69 {
70 Player* targetPlayer = handler->getSelectedPlayer();
71
72 if (!targetPlayer)
73 {
75 return false;
76 }
77
78 return Acore::PlayerCommand::HandleLearnSpellCommand(handler, targetPlayer, spell, allRanks);
79 }
bool HandleLearnSpellCommand(ChatHandler *handler, Player *targetPlayer, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition PlayerCommand.cpp:24

References ChatHandler::getSelectedPlayer(), Acore::PlayerCommand::HandleLearnSpellCommand(), LANG_PLAYER_NOT_FOUND, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleLearnSkillRecipesHelper()

static void learn_commandscript::HandleLearnSkillRecipesHelper ( Player player,
uint32  skillId 
)
inlinestatic
383 {
384 uint32 classmask = player->getClassMask();
385
386 for (SkillLineAbilityEntry const* skillLine : GetSkillLineAbilitiesBySkillLine(skillId))
387 {
388 // not high rank
389 if (skillLine->SupercededBySpell)
390 continue;
391
392 // skip racial skills
393 if (skillLine->RaceMask != 0)
394 continue;
395
396 // skip wrong class skills
397 if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0)
398 continue;
399
400 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell);
401 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
402 continue;
403
404 player->learnSpell(skillLine->Spell);
405 }
406 }
const std::vector< SkillLineAbilityEntry const * > & GetSkillLineAbilitiesBySkillLine(uint32 skillLine)
Definition DBCStores.cpp:916

References Unit::getClassMask(), GetSkillLineAbilitiesBySkillLine(), SpellMgr::IsSpellValid(), Player::learnSpell(), and sSpellMgr.

Referenced by HandleLearnAllCraftsCommand(), and HandleLearnAllRecipesCommand().

◆ HandleUnLearnCommand()

static bool learn_commandscript::HandleUnLearnCommand ( ChatHandler handler,
SpellInfo const *  spell,
Optional< EXACT_SEQUENCE("all")>  allRanks 
)
inlinestatic
409 {
410 Player* target = handler->getSelectedPlayer();
411 if (!target)
412 {
414 return false;
415 }
416
417 return Acore::PlayerCommand::HandleUnlearnSpellCommand(handler, target, spell, allRanks);
418 }
@ LANG_NO_CHAR_SELECTED
Definition Language.h:149
bool HandleUnlearnSpellCommand(ChatHandler *handler, Player *targetPlayer, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition PlayerCommand.cpp:66

References ChatHandler::getSelectedPlayer(), Acore::PlayerCommand::HandleUnlearnSpellCommand(), LANG_NO_CHAR_SELECTED, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().


The documentation for this class was generated from the following file: