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
 
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
39: CommandScript("learn_commandscript") { }
Definition: CommandScript.h:25

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:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleLearnAllMyPetTalentsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:207
static bool HandleUnLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition: cs_learn.cpp:415
static bool HandleLearnAllRecipesCommand(ChatHandler *handler, WTail namePart)
Definition: cs_learn.cpp:329
static bool HandleLearnAllGMCommand(ChatHandler *handler)
Definition: cs_learn.cpp:88
static bool HandleLearnAllMyClassCommand(ChatHandler *handler)
Definition: cs_learn.cpp:106
static bool HandleLearnAllDefaultCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_learn.cpp:294
static bool HandleLearnAllMyTalentsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:158
static bool HandleLearnAllLangCommand(ChatHandler *handler)
Definition: cs_learn.cpp:281
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:310
static bool HandleLearnAllMySpellsCommand(ChatHandler *handler)
Definition: cs_learn.cpp:113

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

◆ HandleLearnAllCraftsCommand()

static bool learn_commandscript::HandleLearnAllCraftsCommand ( ChatHandler handler)
inlinestatic
311 {
312 for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
313 {
314 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
315 if (!skillInfo)
316 continue;
317
318 if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
319 skillInfo->canLink) // only prof. with recipes have
320 {
321 HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(), skillInfo->id);
322 }
323 }
324
326 return true;
327 }
std::uint32_t uint32
Definition: Define.h:107
@ SKILL_CATEGORY_SECONDARY
Definition: SharedDefines.h:3076
@ SKILL_CATEGORY_PROFESSION
Definition: SharedDefines.h:3078
@ LANG_COMMAND_LEARN_ALL_CRAFT
Definition: Language.h:465
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
WorldSession * GetSession()
Definition: Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
Player * GetPlayer() const
Definition: WorldSession.h:362
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition: cs_learn.cpp:389
Definition: DBCStructure.h:1582
uint32 id
Definition: DBCStructure.h:1583
int32 categoryId
Definition: DBCStructure.h:1584
uint32 canLink
Definition: DBCStructure.h:1593

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
295 {
296 if (!player)
297 player = PlayerIdentifier::FromTargetOrSelf(handler);
298 if (!player || !player->IsConnected())
299 return false;
300
301 Player* target = player->GetConnectedPlayer();
302 target->LearnDefaultSkills();
303 target->LearnCustomSpells();
304 target->learnQuestRewardedSpells();
305
307 return true;
308 }
@ LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
Definition: Language.h:639
virtual std::string GetNameLink() const
Definition: Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184
Definition: Player.h:1081
void LearnCustomSpells()
Definition: Player.cpp:11869
void learnQuestRewardedSpells()
Definition: Player.cpp:12011
void LearnDefaultSkills()
Definition: Player.cpp:11895

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
89 {
90 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
91 {
92 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
93 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
94 continue;
95
96 if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL))
97 continue;
98
99 handler->GetSession()->GetPlayer()->learnSpell(i);
100 }
101
103 return true;
104 }
@ SKILL_INTERNAL
Definition: SharedDefines.h:2998
#define sSpellMgr
Definition: SpellMgr.h:825
@ LANG_LEARNING_GM_SKILLS
Definition: Language.h:526
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition: Player.cpp:3304
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
282 {
283 for (LanguageDesc const& langDesc : lang_description)
284 if (uint32 langSpellId = langDesc.spell_id)
285 {
286 handler->GetPlayer()->learnSpell(langSpellId);
287 handler->GetPlayer()->SetSkill(langDesc.skill_id, 0, 300, 300);
288 }
289
291 return true;
292 }
LanguageDesc lang_description[LANGUAGES_COUNT]
Definition: ObjectMgr.cpp:230
@ LANG_COMMAND_LEARN_ALL_LANG
Definition: Language.h:464
Player * GetPlayer() const
Definition: Chat.cpp:35
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5347
Definition: ObjectMgr.h:692

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
107 {
110 return true;
111 }

References HandleLearnAllMySpellsCommand(), and HandleLearnAllMyTalentsCommand().

Referenced by GetCommands().

◆ HandleLearnAllMyPetTalentsCommand()

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

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
114 {
115 ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass());
116 if (!classEntry)
117 return true;
118 uint32 family = classEntry->spellfamily;
119
120 for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i)
121 {
122 SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i);
123 if (!entry)
124 continue;
125
126 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->Spell);
127 if (!spellInfo)
128 continue;
129
130 // skip server-side/triggered spells
131 if (spellInfo->SpellLevel == 0)
132 continue;
133
134 // skip wrong class/race skills
135 if (!handler->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id))
136 continue;
137
138 // skip other spell families
139 if (spellInfo->SpellFamilyName != family)
140 continue;
141
142 // skip spells with first rank learned as talent (and all talents then also)
143 uint32 firstRank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id);
144 if (GetTalentSpellCost(firstRank) > 0)
145 continue;
146
147 // skip broken spells
148 if (!SpellMgr::IsSpellValid(spellInfo))
149 continue;
150
151 handler->GetSession()->GetPlayer()->learnSpell(spellInfo->Id);
152 }
153
155 return true;
156 }
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition: Language.h:462
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:686
DBCStorage< SkillLineAbilityEntry > sSkillLineAbilityStore(SkillLineAbilityfmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
bool IsSpellFitByClassAndRace(uint32 spell_id) const
Definition: Player.cpp:12389
uint8 getClass() const
Definition: Unit.h:800
uint32 SpellLevel
Definition: SpellInfo.h:360
uint32 Id
Definition: SpellInfo.h:320
uint32 SpellFamilyName
Definition: SpellInfo.h:387
Definition: DBCStructure.h:652
uint32 spellfamily
Definition: DBCStructure.h:664
Definition: DBCStructure.h:1597
uint32 Spell
Definition: DBCStructure.h:1600

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

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

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 return false;
83 }
84
85 return Acore::PlayerCommand::HandleLearnSpellCommand(handler, targetPlayer, spell, allRanks);
86 }
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
390 {
391 uint32 classmask = player->getClassMask();
392
393 for (SkillLineAbilityEntry const* skillLine : GetSkillLineAbilitiesBySkillLine(skillId))
394 {
395 // not high rank
396 if (skillLine->SupercededBySpell)
397 continue;
398
399 // skip racial skills
400 if (skillLine->RaceMask != 0)
401 continue;
402
403 // skip wrong class skills
404 if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0)
405 continue;
406
407 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell);
408 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
409 continue;
410
411 player->learnSpell(skillLine->Spell);
412 }
413 }
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
416 {
417 Player* target = handler->getSelectedPlayer();
418 if (!target)
419 {
421 return false;
422 }
423
424 return Acore::PlayerCommand::HandleUnlearnSpellCommand(handler, target, spell, allRanks);
425 }
@ 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:66

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

Referenced by GetCommands().