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

Member Function Documentation

◆ GetCommands()

ChatCommandTable learn_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

36 {
37 static ChatCommandTable learnAllMyCommandTable =
38 {
44 };
45
46 static ChatCommandTable learnAllCommandTable =
47 {
48 { "my", learnAllMyCommandTable },
54 };
55
56 static ChatCommandTable learnCommandTable =
57 {
58 { "all", learnAllCommandTable },
60 };
61
62 static ChatCommandTable commandTable =
63 {
64 { "learn", learnCommandTable },
65 { "unlearn", HandleUnLearnCommand, rbac::RBAC_PERM_COMMAND_UNLEARN, Console::No }
66 };
67 return commandTable;
68 }
static bool HandleLearnAllMyTrainerSpellsCommand(ChatHandler *handler)
Definition cs_learn.cpp:122
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:83
static bool HandleLearnAllMyClassCommand(ChatHandler *handler)
Definition cs_learn.cpp:101
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:70
static bool HandleLearnAllCraftsCommand(ChatHandler *handler)
Definition cs_learn.cpp:310
static bool HandleLearnAllMyQuestSpells(ChatHandler *handler)
Definition cs_learn.cpp:109
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_UNLEARN
Definition RBAC.h:262
@ RBAC_PERM_COMMAND_LEARN_ALL_LANG
Definition RBAC.h:260
@ RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS
Definition RBAC.h:258
@ RBAC_PERM_COMMAND_LEARN_ALL_RECIPES
Definition RBAC.h:261
@ RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS
Definition RBAC.h:253
@ RBAC_PERM_COMMAND_LEARN_ALL_TALENTS
Definition RBAC.h:256
@ RBAC_PERM_COMMAND_LEARN
Definition RBAC.h:251
@ RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS
Definition RBAC.h:255
@ RBAC_PERM_COMMAND_LEARN_ALL_GM
Definition RBAC.h:257
@ RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT
Definition RBAC.h:259
@ RBAC_PERM_COMMAND_LEARN_MY_PETTALENTS
Definition RBAC.h:254

References HandleLearnAllCraftsCommand(), HandleLearnAllDefaultCommand(), HandleLearnAllGMCommand(), HandleLearnAllLangCommand(), HandleLearnAllMyClassCommand(), HandleLearnAllMyPetTalentsCommand(), HandleLearnAllMyQuestSpells(), HandleLearnAllMyTalentsCommand(), HandleLearnAllMyTrainerSpellsCommand(), HandleLearnAllRecipesCommand(), HandleLearnCommand(), HandleUnLearnCommand(), rbac::RBAC_PERM_COMMAND_LEARN, rbac::RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS, rbac::RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT, rbac::RBAC_PERM_COMMAND_LEARN_ALL_GM, rbac::RBAC_PERM_COMMAND_LEARN_ALL_LANG, rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS, rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS, rbac::RBAC_PERM_COMMAND_LEARN_ALL_RECIPES, rbac::RBAC_PERM_COMMAND_LEARN_ALL_TALENTS, rbac::RBAC_PERM_COMMAND_LEARN_MY_PETTALENTS, and rbac::RBAC_PERM_COMMAND_UNLEARN.

◆ 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 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
std::uint32_t uint32
Definition Define.h:107
@ LANG_COMMAND_LEARN_ALL_CRAFT
Definition Language.h:474
@ SKILL_CATEGORY_SECONDARY
Definition SharedDefines.h:3309
@ SKILL_CATEGORY_PROFESSION
Definition SharedDefines.h:3311
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
Player * GetPlayer() const
Definition WorldSession.h:454
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition cs_learn.cpp:389
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
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:648
virtual std::string GetNameLink() const
Definition Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
Definition Player.h:1084
void LearnCustomSpells()
Definition Player.cpp:11827
void learnQuestRewardedSpells()
Definition Player.cpp:11972
void LearnDefaultSkills()
Definition Player.cpp:11853
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:189

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
84 {
85 for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
86 {
87 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
88 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
89 continue;
90
91 if (!spellInfo->IsAbilityOfSkillType(SKILL_INTERNAL))
92 continue;
93
94 handler->GetSession()->GetPlayer()->learnSpell(i);
95 }
96
98 return true;
99 }
@ LANG_LEARNING_GM_SKILLS
Definition Language.h:535
@ SKILL_INTERNAL
Definition SharedDefines.h:3231
#define sSpellMgr
Definition SpellMgr.h:836
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition Player.cpp:3293
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
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 }
@ LANG_COMMAND_LEARN_ALL_LANG
Definition Language.h:473
LanguageDesc lang_description[LANGUAGES_COUNT]
Definition ObjectMgr.cpp:231
Player * GetPlayer() const
Definition Chat.cpp:37
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition Player.cpp:5326
Definition ObjectMgr.h:694

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
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 }
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:925
@ LANG_COMMAND_LEARN_PET_TALENTS
Definition Language.h:926
@ LANG_NO_PET_FOUND
Definition Language.h:924
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
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:8961
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
110 {
111 Player* player = handler->GetPlayer();
112 for (auto const& questPair : sObjectMgr->GetQuestTemplates())
113 {
114 Quest const* quest = questPair.second;
115 if (quest->GetRequiredClasses() && player->SatisfyQuestClass(quest, false))
116 player->learnQuestRewardedSpells(quest);
117 }
118
119 return true;
120 }
#define sObjectMgr
Definition ObjectMgr.h:1723
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
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:472
void SendTalentsInfoData(bool pet)
Definition Player.cpp:14572
void LearnTalent(uint32 talentId, uint32 talentRank, bool command=false)
Definition Player.cpp:14000
void SetFreeTalentPoints(uint32 points)
Definition Player.cpp:3801
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
123 {
124 if (!sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()))
125 return true;
126
127 Player* player = handler->GetPlayer();
128 std::vector<Trainer::Trainer const*> const& trainers = sObjectMgr->GetClassTrainers(player->getClass());
129
130 bool hadNew;
131 do
132 {
133 hadNew = false;
134 for (Trainer::Trainer const* trainer : trainers)
135 {
136 if (!trainer->IsTrainerValidForPlayer(player))
137 continue;
138
139 for (Trainer::Spell const& trainerSpell : trainer->GetSpells())
140 {
141 if (!trainer->CanTeachSpell(player, &trainerSpell))
142 continue;
143
144 if (trainerSpell.IsCastable())
145 player->CastSpell(player, trainerSpell.SpellId, true);
146 else
147 player->learnSpell(trainerSpell.SpellId, false);
148
149 hadNew = true;
150 }
151 }
152 } while (hadNew);
153
155 return true;
156 }
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition Language.h:471
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:1375
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
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:128
std::uint16_t uint16
Definition Define.h:108
@ LANG_COMMAND_LEARN_ALL_RECIPES
Definition Language.h:663
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:548
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:382
uint16 GetSkillStep(uint16 skill) const
Definition Player.cpp:5438
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition Player.cpp:5485
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
71 {
72 Player* targetPlayer = handler->getSelectedPlayer();
73
74 if (!targetPlayer)
75 {
77 return false;
78 }
79
80 return Acore::PlayerCommand::HandleLearnSpellCommand(handler, targetPlayer, spell, allRanks);
81 }
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
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
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:152
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: