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
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ learn_commandscript()

learn_commandscript::learn_commandscript ( )
inline
39: CommandScript("learn_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ GetCommands()

ChatCommandTable learn_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable learnAllMyCommandTable =
44 {
45 { "class", HandleLearnAllMyClassCommand, SEC_GAMEMASTER, Console::No },
46 { "pettalents", HandleLearnAllMyPetTalentsCommand, SEC_GAMEMASTER, Console::No },
47 { "spells", HandleLearnAllMySpellsCommand, SEC_GAMEMASTER, Console::No },
48 { "talents", HandleLearnAllMyTalentsCommand, SEC_GAMEMASTER, Console::No }
49 };
50
51 static ChatCommandTable learnAllCommandTable =
52 {
53 { "my", learnAllMyCommandTable },
54 { "gm", HandleLearnAllGMCommand, SEC_GAMEMASTER, Console::No },
55 { "crafts", HandleLearnAllCraftsCommand, SEC_GAMEMASTER, Console::No },
56 { "default", HandleLearnAllDefaultCommand, SEC_GAMEMASTER, Console::No },
57 { "lang", HandleLearnAllLangCommand, SEC_GAMEMASTER, Console::No },
58 { "recipes", HandleLearnAllRecipesCommand, SEC_GAMEMASTER, Console::No },
59 };
60
61 static ChatCommandTable learnCommandTable =
62 {
63 { "all", learnAllCommandTable },
64 { "", HandleLearnCommand, SEC_GAMEMASTER, Console::No }
65 };
66
67 static ChatCommandTable commandTable =
68 {
69 { "learn", learnCommandTable },
70 { "unlearn", HandleUnLearnCommand, SEC_GAMEMASTER, Console::No }
71 };
72 return commandTable;
73 }
@ SEC_GAMEMASTER
Definition: Common.h:68
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleLearnAllMyPetTalentsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:208
static bool HandleUnLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition: cs_learn.cpp:425
static bool HandleLearnAllRecipesCommand(ChatHandler *handler, WTail namePart)
Definition: cs_learn.cpp:331
static bool HandleLearnAllGMCommand(ChatHandler *handler)
Definition: cs_learn.cpp:89
static bool HandleLearnAllMyClassCommand(ChatHandler *handler)
Definition: cs_learn.cpp:107
static bool HandleLearnAllDefaultCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_learn.cpp:296
static bool HandleLearnAllMyTalentsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:159
static bool HandleLearnAllLangCommand(ChatHandler *handler)
Definition: cs_learn.cpp:286
static bool HandleLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition: cs_learn.cpp:75
static bool HandleLearnAllCraftsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:312
static bool HandleLearnAllMySpellsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:114

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

◆ HandleLearnAllCraftsCommand()

static bool learn_commandscript::HandleLearnAllCraftsCommand ( ChatHandler handler)
inlinestatic
313 {
314 for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
315 {
316 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
317 if (!skillInfo)
318 continue;
319
320 if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
321 skillInfo->canLink) // only prof. with recipes have
322 {
323 HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(), skillInfo->id);
324 }
325 }
326
328 return true;
329 }
std::uint32_t uint32
Definition: Define.h:108
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ LANG_COMMAND_LEARN_ALL_CRAFT
Definition: Language.h:448
@ SKILL_CATEGORY_SECONDARY
Definition: SharedDefines.h:3048
@ SKILL_CATEGORY_PROFESSION
Definition: SharedDefines.h:3050
WorldSession * GetSession()
Definition: Chat.h:122
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
Player * GetPlayer() const
Definition: WorldSession.h:361
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition: cs_learn.cpp:391
Definition: DBCStructure.h:1556
uint32 id
Definition: DBCStructure.h:1557
int32 categoryId
Definition: DBCStructure.h:1558
uint32 canLink
Definition: DBCStructure.h:1567

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
297 {
298 if (!player)
299 player = PlayerIdentifier::FromTargetOrSelf(handler);
300 if (!player || !player->IsConnected())
301 return false;
302
303 Player* target = player->GetConnectedPlayer();
304 target->LearnDefaultSkills();
305 target->LearnCustomSpells();
306 target->learnQuestRewardedSpells();
307
308 handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST, handler->GetNameLink(target).c_str());
309 return true;
310 }
@ LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
Definition: Language.h:622
virtual std::string GetNameLink() const
Definition: Chat.h:84
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:189
Definition: Player.h:1046
void LearnCustomSpells()
Definition: Player.cpp:11732
void learnQuestRewardedSpells()
Definition: Player.cpp:11874
void LearnDefaultSkills()
Definition: Player.cpp:11758

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
90 {
91 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
92 {
93 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
94 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
95 continue;
96
97 if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL))
98 continue;
99
100 handler->GetSession()->GetPlayer()->learnSpell(i);
101 }
102
104 return true;
105 }
@ LANG_LEARNING_GM_SKILLS
Definition: Language.h:509
#define sSpellMgr
Definition: SpellMgr.h:818
@ SKILL_INTERNAL
Definition: SharedDefines.h:2970
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition: Player.cpp:3230
Definition: SpellInfo.h:314
bool IsAbilityOfSkillType(uint32 skillType) const
Definition: SpellInfo.cpp:989
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition: SpellMgr.cpp:442

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
287 {
288 // skipping UNIVERSAL language (0)
289 for (uint8 i = 1; i < LANGUAGES_COUNT; ++i)
290 handler->GetSession()->GetPlayer()->learnSpell(lang_description[i].spell_id);
291
293 return true;
294 }
std::uint8_t uint8
Definition: Define.h:110
LanguageDesc lang_description[LANGUAGES_COUNT]
Definition: ObjectMgr.cpp:286
@ LANG_COMMAND_LEARN_ALL_LANG
Definition: Language.h:447
#define LANGUAGES_COUNT
Definition: SharedDefines.h:728

References WorldSession::GetPlayer(), ChatHandler::GetSession(), LANG_COMMAND_LEARN_ALL_LANG, lang_description, LANGUAGES_COUNT, Player::learnSpell(), and ChatHandler::SendSysMessage().

Referenced by GetCommands().

◆ HandleLearnAllMyClassCommand()

static bool learn_commandscript::HandleLearnAllMyClassCommand ( ChatHandler handler)
inlinestatic
108 {
111 return true;
112 }

References HandleLearnAllMySpellsCommand(), and HandleLearnAllMyTalentsCommand().

Referenced by GetCommands().

◆ HandleLearnAllMyPetTalentsCommand()

static bool learn_commandscript::HandleLearnAllMyPetTalentsCommand ( ChatHandler handler)
inlinestatic
209 {
210 Player* player = handler->GetSession()->GetPlayer();
211
212 Pet* pet = player->GetPet();
213 if (!pet)
214 {
216 handler->SetSentErrorMessage(true);
217 return false;
218 }
219
220 CreatureTemplate const* creatureInfo = pet->GetCreatureTemplate();
221 if (!creatureInfo)
222 {
224 handler->SetSentErrorMessage(true);
225 return false;
226 }
227
228 CreatureFamilyEntry const* petFamily = sCreatureFamilyStore.LookupEntry(creatureInfo->family);
229 if (!petFamily)
230 {
232 handler->SetSentErrorMessage(true);
233 return false;
234 }
235
236 if (petFamily->petTalentType < 0) // not hunter pet
237 {
239 handler->SetSentErrorMessage(true);
240 return false;
241 }
242
243 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
244 {
245 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
246 if (!talentInfo)
247 continue;
248
249 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
250 if (!talentTabInfo)
251 continue;
252
253 // prevent learn talent for different family (cheating)
254 if (((1 << petFamily->petTalentType) & talentTabInfo->petTalentMask) == 0)
255 continue;
256
257 // search highest talent rank
258 uint32 spellId = 0;
259
260 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
261 {
262 if (talentInfo->RankID[rank] != 0)
263 {
264 spellId = talentInfo->RankID[rank];
265 break;
266 }
267 }
268
269 if (!spellId) // ??? none spells in talent
270 continue;
271
272 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
273 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
274 continue;
275
276 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
277 pet->learnSpellHighRank(spellId);
278 }
279
280 pet->SetFreeTalentPoints(0);
281
283 return true;
284 }
std::int8_t int8
Definition: Define.h:106
DBCStorage< TalentTabEntry > sTalentTabStore(TalentTabEntryfmt)
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
@ LANG_WRONG_PET_TYPE
Definition: Language.h:886
@ LANG_COMMAND_LEARN_PET_TALENTS
Definition: Language.h:887
@ LANG_NO_PET_FOUND
Definition: Language.h:885
#define MAX_TALENT_RANK
Definition: DBCStructure.h:1894
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:197
Definition: CreatureData.h:176
uint32 family
Definition: CreatureData.h:210
Definition: Pet.h:40
void learnSpellHighRank(uint32 spellid)
Definition: Pet.cpp:2332
void SetFreeTalentPoints(uint8 points)
Definition: Pet.h:131
Pet * GetPet() const
Definition: Player.cpp:8784
Definition: DBCStructure.h:754
int32 petTalentType
Definition: DBCStructure.h:762
Definition: DBCStructure.h:1899
std::array< uint32, MAX_TALENT_RANK > RankID
Definition: DBCStructure.h:1904
uint32 TalentTab
Definition: DBCStructure.h:1901
Definition: DBCStructure.h:1916
uint32 petTalentMask
Definition: DBCStructure.h:1923

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::SendSysMessage(), Pet::SetFreeTalentPoints(), ChatHandler::SetSentErrorMessage(), sSpellMgr, sTalentStore, sTalentTabStore, and TalentEntry::TalentTab.

Referenced by GetCommands().

◆ HandleLearnAllMySpellsCommand()

static bool learn_commandscript::HandleLearnAllMySpellsCommand ( ChatHandler handler)
inlinestatic
115 {
116 ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass());
117 if (!classEntry)
118 return true;
119 uint32 family = classEntry->spellfamily;
120
121 for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i)
122 {
123 SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i);
124 if (!entry)
125 continue;
126
127 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->Spell);
128 if (!spellInfo)
129 continue;
130
131 // skip server-side/triggered spells
132 if (spellInfo->SpellLevel == 0)
133 continue;
134
135 // skip wrong class/race skills
136 if (!handler->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id))
137 continue;
138
139 // skip other spell families
140 if (spellInfo->SpellFamilyName != family)
141 continue;
142
143 // skip spells with first rank learned as talent (and all talents then also)
144 uint32 firstRank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id);
145 if (GetTalentSpellCost(firstRank) > 0)
146 continue;
147
148 // skip broken spells
149 if (!SpellMgr::IsSpellValid(spellInfo))
150 continue;
151
152 handler->GetSession()->GetPlayer()->learnSpell(spellInfo->Id);
153 }
154
156 return true;
157 }
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:679
DBCStorage< SkillLineAbilityEntry > sSkillLineAbilityStore(SkillLineAbilityfmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition: Language.h:445
bool IsSpellFitByClassAndRace(uint32 spell_id) const
Definition: Player.cpp:12258
uint8 getClass() const
Definition: Unit.h:1426
uint32 SpellLevel
Definition: SpellInfo.h:358
uint32 Id
Definition: SpellInfo.h:318
uint32 SpellFamilyName
Definition: SpellInfo.h:385
Definition: DBCStructure.h:653
uint32 spellfamily
Definition: DBCStructure.h:665
Definition: DBCStructure.h:1571
uint32 Spell
Definition: DBCStructure.h:1574

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
160 {
161 Player* player = handler->GetSession()->GetPlayer();
162 uint32 classMask = player->getClassMask();
163
164 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
165 {
166 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
167 if (!talentInfo)
168 continue;
169
170 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
171 if (!talentTabInfo)
172 continue;
173
174 if ((classMask & talentTabInfo->ClassMask) == 0)
175 continue;
176
177 // xinef: search highest talent rank
178 uint32 spellId = 0;
179 uint8 rankId = MAX_TALENT_RANK;
180 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
181 {
182 if (talentInfo->RankID[rank] != 0)
183 {
184 rankId = rank;
185 spellId = talentInfo->RankID[rank];
186 break;
187 }
188 }
189
190 // xinef: some errors?
191 if (!spellId || rankId == MAX_TALENT_RANK)
192 continue;
193
194 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
195 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
196 continue;
197
198 player->LearnTalent(talentInfo->TalentID, rankId, true);
199 }
200
201 player->SetFreeTalentPoints(0);
202 player->SendTalentsInfoData(false);
203
205 return true;
206 }
@ LANG_COMMAND_LEARN_CLASS_TALENTS
Definition: Language.h:446
void SendTalentsInfoData(bool pet)
Definition: Player.cpp:14305
void LearnTalent(uint32 talentId, uint32 talentRank, bool command=false)
Definition: Player.cpp:13823
void SetFreeTalentPoints(uint32 points)
Definition: Player.cpp:3738
uint32 getClassMask() const
Definition: Unit.h:1427
uint32 TalentID
Definition: DBCStructure.h:1900
uint32 ClassMask
Definition: DBCStructure.h:1922

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
332 {
333 // Learns all recipes of specified profession and sets skill to max
334 // Example: .learn all_recipes enchanting
335
336 Player* target = handler->getSelectedPlayer();
337 if (!target)
338 {
340 return false;
341 }
342
343 if (namePart.empty())
344 return false;
345
346 // converting string that we try to find to lower case
347 wstrToLower(namePart);
348
349 SkillLineEntry const* targetSkillInfo = nullptr;
350 char const* name = nullptr;
351 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
352 {
353 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
354 if (!skillInfo)
355 continue;
356
357 if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION &&
358 skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) ||
359 !skillInfo->canLink) // only prof with recipes have set
360 continue;
361
362 uint8 locale = 0;
363 for (; locale < TOTAL_LOCALES; ++locale)
364 {
365 name = skillInfo->name[locale];
366 if (!name || !*name)
367 continue;
368
369 if (Utf8FitTo(name, namePart))
370 break;
371 }
372
373 if (locale < TOTAL_LOCALES)
374 {
375 targetSkillInfo = skillInfo;
376 break;
377 }
378 }
379
380 if (!(name && targetSkillInfo))
381 return false;
382
383 HandleLearnSkillRecipesHelper(target, targetSkillInfo->id);
384
385 uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
386 target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel);
388 return true;
389 }
@ TOTAL_LOCALES
Definition: Common.h:85
std::uint16_t uint16
Definition: Define.h:109
void wstrToLower(std::wstring &str)
Definition: Util.cpp:383
bool Utf8FitTo(std::string_view str, std::wstring_view search)
Definition: Util.cpp:477
@ LANG_COMMAND_LEARN_ALL_RECIPES
Definition: Language.h:637
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
Player * getSelectedPlayer() const
Definition: Chat.cpp:301
uint16 GetSkillStep(uint16 skill) const
Definition: Player.cpp:5342
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5389
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5231
char const * name[16]
Definition: DBCStructure.h:1560

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
76 {
77 Player* targetPlayer = handler->getSelectedPlayer();
78
79 if (!targetPlayer)
80 {
82 handler->SetSentErrorMessage(true);
83 return false;
84 }
85
86 return Acore::PlayerCommand::HandleLearnSpellCommand(handler, targetPlayer, spell, allRanks);
87 }
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, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleLearnSkillRecipesHelper()

static void learn_commandscript::HandleLearnSkillRecipesHelper ( Player player,
uint32  skillId 
)
inlinestatic
392 {
393 uint32 classmask = player->getClassMask();
394
395 for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
396 {
397 SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j);
398 if (!skillLine)
399 continue;
400
401 // wrong skill
402 if (skillLine->SkillLine != skillId)
403 continue;
404
405 // not high rank
406 if (skillLine->SupercededBySpell)
407 continue;
408
409 // skip racial skills
410 if (skillLine->RaceMask != 0)
411 continue;
412
413 // skip wrong class skills
414 if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0)
415 continue;
416
417 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell);
418 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
419 continue;
420
421 player->learnSpell(skillLine->Spell);
422 }
423 }
uint32 SkillLine
Definition: DBCStructure.h:1573
uint32 SupercededBySpell
Definition: DBCStructure.h:1580
uint32 ClassMask
Definition: DBCStructure.h:1576
uint32 RaceMask
Definition: DBCStructure.h:1575

References SkillLineAbilityEntry::ClassMask, Unit::getClassMask(), SpellMgr::IsSpellValid(), Player::learnSpell(), SkillLineAbilityEntry::RaceMask, SkillLineAbilityEntry::SkillLine, SkillLineAbilityEntry::Spell, sSkillLineAbilityStore, sSpellMgr, and SkillLineAbilityEntry::SupercededBySpell.

Referenced by HandleLearnAllCraftsCommand(), and HandleLearnAllRecipesCommand().

◆ HandleUnLearnCommand()

static bool learn_commandscript::HandleUnLearnCommand ( ChatHandler handler,
SpellInfo const *  spell,
Optional< EXACT_SEQUENCE("all")>  allRanks 
)
inlinestatic
426 {
427 Player* target = handler->getSelectedPlayer();
428 if (!target)
429 {
431 handler->SetSentErrorMessage(true);
432 return false;
433 }
434
435 return Acore::PlayerCommand::HandleUnlearnSpellCommand(handler, target, spell, allRanks);
436 }
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
bool HandleUnlearnSpellCommand(ChatHandler *handler, Player *targetPlayer, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition: PlayerCommand.cpp:68

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

Referenced by GetCommands().