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 ()
 
std::string const & 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 (char const *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (char const *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:210
static bool HandleUnLearnCommand(ChatHandler *handler, SpellInfo const *spell, Optional< EXACT_SEQUENCE("all")> allRanks)
Definition cs_learn.cpp:432
static bool HandleLearnAllRecipesCommand(ChatHandler *handler, WTail namePart)
Definition cs_learn.cpp:337
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:297
static bool HandleLearnAllMyTalentsCommand(ChatHandler *handler)
Definition cs_learn.cpp:161
static bool HandleLearnAllLangCommand(ChatHandler *handler)
Definition cs_learn.cpp:284
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:313
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
314 {
315 Player* target = handler->GetSession()->GetPlayer();
316
317 for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
318 {
319 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
320 if (!skillInfo)
321 continue;
322
323 if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
324 skillInfo->canLink) // only prof. with recipes have
325 {
326 HandleLearnSkillRecipesHelper(target, skillInfo->id);
327
328 uint16 const maxLevel = target->GetPureMaxSkillValue(skillInfo->id);
329 target->SetSkill(skillInfo->id, target->GetSkillStep(skillInfo->id), maxLevel, maxLevel);
330 }
331 }
332
334 return true;
335 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
@ 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
Definition Player.h:1086
uint16 GetSkillStep(uint16 skill) const
Definition Player.cpp:5603
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition Player.cpp:5650
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition Player.cpp:5489
Player * GetPlayer() const
Definition WorldSession.h:480
static void HandleLearnSkillRecipesHelper(Player *player, uint32 skillId)
Definition cs_learn.cpp:397
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(), Player::GetPureMaxSkillValue(), ChatHandler::GetSession(), Player::GetSkillStep(), HandleLearnSkillRecipesHelper(), SkillLineEntry::id, LANG_COMMAND_LEARN_ALL_CRAFT, ChatHandler::SendSysMessage(), Player::SetSkill(), SKILL_CATEGORY_PROFESSION, SKILL_CATEGORY_SECONDARY, and sSkillLineStore.

Referenced by GetCommands().

◆ HandleLearnAllDefaultCommand()

static bool learn_commandscript::HandleLearnAllDefaultCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
298 {
299 if (!player)
300 player = PlayerIdentifier::FromTargetOrSelf(handler);
301 if (!player || !player->IsConnected())
302 return false;
303
304 Player* target = player->GetConnectedPlayer();
305 target->LearnDefaultSkills();
306 target->LearnCustomSpells();
307 target->learnQuestRewardedSpells();
308
310 return true;
311 }
@ 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
void LearnCustomSpells()
Definition Player.cpp:12076
void learnQuestRewardedSpells()
Definition Player.cpp:12221
void LearnDefaultSkills()
Definition Player.cpp:12102
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:847
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition Player.cpp:3412
Definition SpellInfo.h:340
bool IsAbilityOfSkillType(uint32 skillType) const
Definition SpellInfo.cpp:1037
static bool IsSpellValid(SpellInfo const *spellInfo)
Definition SpellMgr.cpp:490

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
285 {
286 for (LanguageDesc const& langDesc : lang_description)
287 if (uint32 langSpellId = langDesc.spell_id)
288 {
289 handler->GetPlayer()->learnSpell(langSpellId);
290 handler->GetPlayer()->SetSkill(langDesc.skill_id, 0, 300, 300);
291 }
292
294 return true;
295 }
@ 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
Definition ObjectMgr.h:696

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
211 {
212 Player* player = handler->GetSession()->GetPlayer();
213
214 Pet* pet = player->GetPet();
215 if (!pet)
216 {
218 return false;
219 }
220
221 CreatureTemplate const* creatureInfo = pet->GetCreatureTemplate();
222 if (!creatureInfo)
223 {
225 return false;
226 }
227
228 CreatureFamilyEntry const* petFamily = sCreatureFamilyStore.LookupEntry(creatureInfo->family);
229 if (!petFamily)
230 {
232 return false;
233 }
234
235 if (petFamily->petTalentType < 0) // not hunter pet
236 {
238 return false;
239 }
240
241 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
242 {
243 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
244 if (!talentInfo)
245 continue;
246
247 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
248 if (!talentTabInfo)
249 continue;
250
251 // prevent learn talent for different family (cheating)
252 if (((1 << petFamily->petTalentType) & talentTabInfo->petTalentMask) == 0)
253 continue;
254
255 // search highest talent rank
256 uint32 spellId = 0;
257
258 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
259 {
260 if (talentInfo->RankID[rank] != 0)
261 {
262 spellId = talentInfo->RankID[rank];
263 break;
264 }
265 }
266
267 if (!spellId) // ??? none spells in talent
268 continue;
269
270 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
271 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
272 continue;
273
274 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
275 pet->learnSpellHighRank(spellId);
276 }
277
278 pet->SetFreeTalentPoints(0);
279
281 return true;
282 }
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:2381
void SetFreeTalentPoints(uint8 points)
Definition Pet.h:132
Pet * GetPet() const
Definition Player.cpp:9137
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:1730
bool SatisfyQuestClass(Quest const *qInfo, bool msg) const
Definition PlayerQuest.cpp:1125
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
162 {
163 Player* player = handler->GetSession()->GetPlayer();
164 uint32 classMask = player->getClassMask();
165
166 for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
167 {
168 TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
169 if (!talentInfo)
170 continue;
171
172 TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
173 if (!talentTabInfo)
174 continue;
175
176 if ((classMask & talentTabInfo->ClassMask) == 0)
177 continue;
178
179 // xinef: search highest talent rank
180 uint32 spellId = 0;
181 uint8 rankId = MAX_TALENT_RANK;
182 for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
183 {
184 if (talentInfo->RankID[rank] != 0)
185 {
186 rankId = rank;
187 spellId = talentInfo->RankID[rank];
188 break;
189 }
190 }
191
192 // xinef: some errors?
193 if (!spellId || rankId == MAX_TALENT_RANK)
194 continue;
195
196 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
197 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
198 continue;
199
200 player->LearnTalent(talentInfo->TalentID, rankId, true);
201 }
202
203 player->SetFreeTalentPoints(0);
204 player->SendTalentsInfoData(false);
205
207 return true;
208 }
std::uint8_t uint8
Definition Define.h:109
@ LANG_COMMAND_LEARN_CLASS_TALENTS
Definition Language.h:472
void SendTalentsInfoData(bool pet)
Definition Player.cpp:14833
void LearnTalent(uint32 talentId, uint32 talentRank, bool command=false)
Definition Player.cpp:14261
void SetFreeTalentPoints(uint32 points)
Definition Player.cpp:3964
uint32 getClassMask() const
Definition Unit.h:846
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 // a script can refuse the learn or force the spell's state, so only go around
150 // again when the spell actually stopped being teachable
151 if (!trainer->CanTeachSpell(player, &trainerSpell))
152 hadNew = true;
153 }
154 }
155 } while (hadNew);
156
158 return true;
159 }
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
@ LANG_COMMAND_LEARN_CLASS_SPELLS
Definition Language.h:471
Definition Trainer.h:66
uint8 getClass() const
Definition Unit.h:844
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:1359
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
338 {
339 // Learns all recipes of specified profession and sets skill to max
340 // Example: .learn all_recipes enchanting
341
342 Player* target = handler->getSelectedPlayer();
343 if (!target)
344 {
346 return false;
347 }
348
349 if (namePart.empty())
350 return false;
351
352 // converting string that we try to find to lower case
353 wstrToLower(namePart);
354
355 SkillLineEntry const* targetSkillInfo = nullptr;
356 char const* name = nullptr;
357 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
358 {
359 SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
360 if (!skillInfo)
361 continue;
362
363 if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION &&
364 skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) ||
365 !skillInfo->canLink) // only prof with recipes have set
366 continue;
367
368 uint8 locale = 0;
369 for (; locale < TOTAL_LOCALES; ++locale)
370 {
371 name = skillInfo->name[locale];
372 if (!name || !*name)
373 continue;
374
375 if (Utf8FitTo(name, namePart))
376 break;
377 }
378
379 if (locale < TOTAL_LOCALES)
380 {
381 targetSkillInfo = skillInfo;
382 break;
383 }
384 }
385
386 if (!(name && targetSkillInfo))
387 return false;
388
389 HandleLearnSkillRecipesHelper(target, targetSkillInfo->id);
390
391 uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
392 target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel);
394 return true;
395 }
@ TOTAL_LOCALES
Definition Common.h:136
@ 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
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
398 {
399 // Rank spells (Apprentice -> Grand Master) must be learned so that the
400 // skill-cleanup loop in Player::SetSkill (which calls removeSpell on the
401 // first spell in each chain) can walk forward and strip every rank on
402 // profession unlearn. Without the first rank in the spellbook that loop
403 // bails out and the leftover rank spells re-grant the skill after relog
404 // (issue #2330).
405 for (uint32 rankSpell : sSpellMgr->GetSkillRankSpells(skillId))
406 player->learnSpell(rankSpell);
407
408 uint32 classmask = player->getClassMask();
409
410 for (SkillLineAbilityEntry const* skillLine : GetSkillLineAbilitiesBySkillLine(skillId))
411 {
412 // not high rank
413 if (skillLine->SupercededBySpell)
414 continue;
415
416 // skip racial skills
417 if (skillLine->RaceMask != 0)
418 continue;
419
420 // skip wrong class skills
421 if (skillLine->ClassMask && (skillLine->ClassMask & classmask) == 0)
422 continue;
423
424 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->Spell);
425 if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
426 continue;
427
428 player->learnSpell(skillLine->Spell);
429 }
430 }
std::vector< SkillLineAbilityEntry const * > 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
433 {
434 Player* target = handler->getSelectedPlayer();
435 if (!target)
436 {
438 return false;
439 }
440
441 return Acore::PlayerCommand::HandleUnlearnSpellCommand(handler, target, spell, allRanks);
442 }
@ 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: