static bool HandleLearnAllRecipesCommand(ChatHandler* handler, char const* args) { // Learns all recipes of specified profession and sets skill to max // Example: .learn all_recipes enchanting Player* target = handler->getSelectedPlayer(); if (!target) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); return false; } if (!*args) return false; std::wstring namePart; if (!Utf8toWStr(args, namePart)) return false; // converting string that we try to find to lower case wstrToLower(namePart); std::string name; SkillLineEntry const* targetSkillInfo = NULL; for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) continue; if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || !skillInfo->canLink) // only prof with recipes have set continue; name = skillInfo->name; if (name.empty()) continue; if (!Utf8FitTo(name, namePart)) continue; targetSkillInfo = skillInfo; } if (!targetSkillInfo) return false; HandleLearnSkillRecipesHelper(target, targetSkillInfo->id); uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); return true; }
static bool HandleLearnAllCraftsCommand(ChatHandler* handler, const char* /*args*/) { for(uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); if(!skillInfo) continue; if((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && skillInfo->canLink) // only prof. with recipes have { HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(), skillInfo->id); } } handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); return true; }
static bool HandleLearnAllCraftsCommand(ChatHandler* handler, char const* args) { Player* target; if (!handler->extractPlayerTarget((char*)args, &target)) return false; for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) continue; if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && skillInfo->canLink) // only prof. with recipes have { HandleLearnSkillRecipesHelper(target, skillInfo->id); } } handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); return true; }
static bool HandleLearnAllRecipesCommand(ChatHandler* handler, char const* args) { // Learns all recipes of specified profession and sets skill to max // Example: .learn all_recipes enchanting Player* target = handler->getSelectedPlayer(); if (!target) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); return false; } if (!target->GetCommandStatus(TOGGLE_MODIFY) && !handler->GetSession()->GetPlayer()->IsAdmin() && handler->GetSession()->GetPlayer()->GetGUID() != target->GetGUID()) { handler->PSendSysMessage("%s has modify disabled. You can't use commands on them.", target->GetName().c_str()); return true; } if (!*args) return false; std::wstring namePart; if (!Utf8toWStr(args, namePart)) return false; // converting string that we try to find to lower case wstrToLower(namePart); std::string name; SkillLineEntry const* targetSkillInfo = NULL; for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) continue; if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || !skillInfo->canLink) // only prof with recipes have set continue; int locale = handler->GetSessionDbcLocale(); name = skillInfo->name[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, namePart)) { locale = 0; for (; locale < TOTAL_LOCALES; ++locale) { if (locale == handler->GetSessionDbcLocale()) continue; name = skillInfo->name[locale]; if (name.empty()) continue; if (Utf8FitTo(name, namePart)) break; } } if (locale < TOTAL_LOCALES) { targetSkillInfo = skillInfo; break; } } if (!targetSkillInfo) return false; HandleLearnSkillRecipesHelper(target, targetSkillInfo->id); uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); return true; }