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 HandleLearnAllMyQuestSpells (ChatHandler *handler)
 
static bool HandleLearnAllMyTrainerSpellsCommand (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 { "trainer", HandleLearnAllMyTrainerSpellsCommand, SEC_GAMEMASTER, Console::No },
41 { "talents", HandleLearnAllMyTalentsCommand, SEC_GAMEMASTER, Console::No },
42 { "quest", HandleLearnAllMyQuestSpells, SEC_GAMEMASTER, Console::No }
43 };
44
45 static ChatCommandTable learnAllCommandTable =
46 {
47 { "my", learnAllMyCommandTable },
48 { "gm", HandleLearnAllGMCommand, SEC_GAMEMASTER, Console::No },
49 { "crafts", HandleLearnAllCraftsCommand, SEC_GAMEMASTER, Console::No },
50 { "default", HandleLearnAllDefaultCommand, SEC_GAMEMASTER, Console::No },
51 { "lang", HandleLearnAllLangCommand, SEC_GAMEMASTER, Console::No },
52 { "recipes", HandleLearnAllRecipesCommand, SEC_GAMEMASTER, Console::No },
53 };
54
55 static ChatCommandTable learnCommandTable =
56 {
57 { "all", learnAllCommandTable },
58 { "", HandleLearnCommand, SEC_GAMEMASTER, Console::No }
59 };
60
61 static ChatCommandTable commandTable =
62 {
63 { "learn", learnCommandTable },
64 { "unlearn", HandleUnLearnCommand, SEC_GAMEMASTER, Console::No }
65 };
66 return commandTable;
67 }
@ SEC_GAMEMASTER
Definition Common.h:59
static bool HandleLearnAllMyTrainerSpellsCommand(ChatHandler *handler)
Definition cs_learn.cpp:121
static bool HandleLearnAllMyPetTalentsCommand(ChatHandler *handler)
Definition cs_learn.cpp:206
static bool HandleUnLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition cs_learn.cpp:414
static bool HandleLearnAllRecipesCommand(ChatHandler *handler, WTail namePart)
Definition cs_learn.cpp:328
static bool HandleLearnAllGMCommand(ChatHandler *handler)
Definition cs_learn.cpp:82
static bool HandleLearnAllMyClassCommand(ChatHandler *handler)
Definition cs_learn.cpp:100
static bool HandleLearnAllDefaultCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_learn.cpp:293
static bool HandleLearnAllMyTalentsCommand(ChatHandler *handler)
Definition cs_learn.cpp:157
static bool HandleLearnAllLangCommand(ChatHandler *handler)
Definition cs_learn.cpp:280
static bool HandleLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition cs_learn.cpp:69
static bool HandleLearnAllCraftsCommand(ChatHandler *handler)
Definition cs_learn.cpp:309
static bool HandleLearnAllMyQuestSpells(ChatHandler *handler)
Definition cs_learn.cpp:108
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

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

◆ HandleLearnAllCraftsCommand()

static bool learn_commandscript::HandleLearnAllCraftsCommand ( ChatHandler handler)
inlinestatic
310 {
311 for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
312 {
313 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
314 if (!skillInfo)
315 continue;
316
317 if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
318 skillInfo->canLink) // only prof. with recipes have
319 {
320 HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(), skillInfo->id);
321 }
322 }
323
325 return true;
326 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
std::uint32_t uint32
Definition Define.h:107
@ LANG_COMMAND_LEARN_ALL_CRAFT
Definition Language.h:471
@ SKILL_CATEGORY_SECONDARY
Definition SharedDefines.h:3311
@ SKILL_CATEGORY_PROFESSION
Definition SharedDefines.h:3313
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:444
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition cs_learn.cpp:388
Definition DBCStructure.h:1583
uint32 id
Definition DBCStructure.h:1584
int32 categoryId
Definition DBCStructure.h:1585
uint32 canLink
Definition DBCStructure.h:1594

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
294 {
295 if (!player)
296 player = PlayerIdentifier::FromTargetOrSelf(handler);
297 if (!player || !player->IsConnected())
298 return false;
299
300 Player* target = player->GetConnectedPlayer();
301 target->LearnDefaultSkills();
302 target->LearnCustomSpells();
303 target->learnQuestRewardedSpells();
304
306 return true;
307 }
@ LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
Definition Language.h:645
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:1084
void LearnCustomSpells()
Definition Player.cpp:11793
void learnQuestRewardedSpells()
Definition Player.cpp:11938
void LearnDefaultSkills()
Definition Player.cpp:11819
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
83 {
84 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
85 {
86 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
87 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
88 continue;
89
90 if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL))
91 continue;
92
93 handler->GetSession()->GetPlayer()->learnSpell(i);
94 }
95
97 return true;
98 }
@ LANG_LEARNING_GM_SKILLS
Definition Language.h:532
@ SKILL_INTERNAL
Definition SharedDefines.h:3233
#define sSpellMgr
Definition SpellMgr.h:836
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition Player.cpp:3281
Definition SpellInfo.h:340
bool IsAbilityOfSkillType(uint32 skillType) const
Definition SpellInfo.cpp:1037
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition SpellMgr.cpp:488

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
281 {
282 for (LanguageDesc const& langDesc : lang_description)
283 if (uint32 langSpellId = langDesc.spell_id)
284 {
285 handler->GetPlayer()->learnSpell(langSpellId);
286 handler->GetPlayer()->SetSkill(langDesc.skill_id, 0, 300, 300);
287 }
288
290 return true;
291 }
@ LANG_COMMAND_LEARN_ALL_LANG
Definition Language.h:470
LanguageDesc lang_description[LANGUAGES_COUNT]
Definition ObjectMgr.cpp:231
Player * GetPlayer() const
Definition Chat.cpp:36
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition Player.cpp:5314
Definition ObjectMgr.h:693

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

◆ HandleLearnAllMyPetTalentsCommand()

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

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().

◆ HandleLearnAllMyQuestSpells()

static bool learn_commandscript::HandleLearnAllMyQuestSpells ( ChatHandler handler)
inlinestatic
109 {
110 Player* player = handler->GetPlayer();
111 for (auto const& questPair : sObjectMgr->GetQuestTemplates())
112 {
113 Quest const* quest = questPair.second;
114 if (quest->GetRequiredClasses() && player->SatisfyQuestClass(quest, false))
115 player->learnQuestRewardedSpells(quest);
116 }
117
118 return true;
119 }
#define sObjectMgr
Definition ObjectMgr.h:1712
bool SatisfyQuestClass(Quest const *qInfo, bool msg) const
Definition PlayerQuest.cpp:1086
Definition QuestDef.h:210
uint32 GetRequiredClasses() const
Definition QuestDef.h:235

References ChatHandler::GetPlayer(), Quest::GetRequiredClasses(), Player::learnQuestRewardedSpells(), Player::SatisfyQuestClass(), and sObjectMgr.

Referenced by GetCommands(), and HandleLearnAllMyClassCommand().

◆ HandleLearnAllMyTalentsCommand()

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

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().

◆ HandleLearnAllMyTrainerSpellsCommand()

static bool learn_commandscript::HandleLearnAllMyTrainerSpellsCommand ( ChatHandler handler)
inlinestatic
122 {
123 if (!sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()))
124 return true;
125
126 Player* player = handler->GetPlayer();
127 std::vector<Trainer::Trainer const*> const& trainers = sObjectMgr->GetClassTrainers(player->getClass());
128
129 bool hadNew;
130 do
131 {
132 hadNew = false;
133 for (Trainer::Trainer const* trainer : trainers)
134 {
135 if (!trainer->IsTrainerValidForPlayer(player))
136 continue;
137
138 for (Trainer::Spell const& trainerSpell : trainer->GetSpells())
139 {
140 if (!trainer->CanTeachSpell(player, &trainerSpell))
141 continue;
142
143 if (trainerSpell.IsCastable())
144 player->CastSpell(player, trainerSpell.SpellId, true);
145 else
146 player->learnSpell(trainerSpell.SpellId, false);
147
148 hadNew = true;
149 }
150 }
151 } while (hadNew);
152
154 return true;
155 }
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition Language.h:468
Definition Trainer.h:66
uint8 getClass() const
Definition Unit.h:843
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1350
Definition Trainer.h:54

References Unit::CastSpell(), Unit::getClass(), ChatHandler::GetPlayer(), WorldSession::GetPlayer(), ChatHandler::GetSession(), LANG_COMMAND_LEARN_CLASS_SPELLS, Player::learnSpell(), sChrClassesStore, ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by GetCommands(), and HandleLearnAllMyClassCommand().

◆ HandleLearnAllRecipesCommand()

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

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
70 {
71 Player* targetPlayer = handler->getSelectedPlayer();
72
73 if (!targetPlayer)
74 {
76 return false;
77 }
78
79 return Acore::PlayerCommand::HandleLearnSpellCommand(handler, targetPlayer, spell, allRanks);
80 }
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
389 {
390 uint32 classmask = player->getClassMask();
391
392 for (SkillLineAbilityEntry const* skillLine : GetSkillLineAbilitiesBySkillLine(skillId))
393 {
394 // not high rank
395 if (skillLine->SupercededBySpell)
396 continue;
397
398 // skip racial skills
399 if (skillLine->RaceMask != 0)
400 continue;
401
402 // skip wrong class skills
403 if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0)
404 continue;
405
406 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell);
407 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
408 continue;
409
410 player->learnSpell(skillLine->Spell);
411 }
412 }
const std::vector< SkillLineAbilityEntry const * > & GetSkillLineAbilitiesBySkillLine(uint32 skillLine)
Definition DBCStores.cpp:916
Definition DBCStructure.h:1598

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
415 {
416 Player* target = handler->getSelectedPlayer();
417 if (!target)
418 {
420 return false;
421 }
422
423 return Acore::PlayerCommand::HandleUnlearnSpellCommand(handler, target, spell, allRanks);
424 }
@ 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: