Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************
- * Made by Sdyess *
- * *
- * Edit By jameyboor *
- * Release by Ghostcrawler336 *
- * Rewritten by Rochet2 *
- * *
- *************************************
- */
- #include "ScriptPCH.h"
- #include "Language.h"
- #include "Config.h"
- bool CobrarProfession;
- int CobrarProfessionHONOR;
- int IdEmblema;
- float pValor;
- bool pProfissionVIP;
- uint32 nProfissionVIP;
- uint32 qProfissionVIP;
- uint32 qProfissionNormal;
- uint32 IdItemProfissionVIP;
- using namespace std;
- struct MenuProfissao
- {
- uint8 Menu, Submenu, Icone;
- uint32 ValorProf, pSKILL;
- string Nome, Confirmar;
- };
- MenuProfissao mpData[] =
- {
- { 1, 2, 3, 0, 0, "|cff1C1C1C|TInterface/ICONS/achievement_general:30:30:-16:0|t[Profissoes Primarias]|r" },
- { 1, 3, 3, 0, 0, "|cff90EE90|TInterface/ICONS/achievement_general:30:30:-16:0|t[Profissoes Secundarias]|r" },
- // Profissões Primarias
- { 2, 0, 3, pValor, 171, "|TInterface\\icons\\trade_alchemy:30:30:-16:0|t Alchemy.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_ALCHEMY 171
- { 2, 0, 3, pValor, 164,"|TInterface\\icons\\INV_Ingot_05:30:30:-16:0|t Blacksmithing.", "|cff1E90FFTem certeza que quer essa profissao|r" }, // SKILL_BLACKSMITHING 164
- { 2, 0, 3, pValor, 165,"|TInterface\\icons\\INV_Misc_LeatherScrap_02:30:30:-16:0|t Leatherworking.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_LEATHERWORKING 165
- { 2, 0, 3, pValor, 197,"|TInterface\\icons\\INV_Fabric_Felcloth_Ebon:30:30:-16:0|t Tailoring.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_TAILORING 197
- { 2, 0, 3, pValor, 202,"|TInterface\\icons\\inv_misc_wrench_01:30:30:-16:0|t Engineering.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_ENGINEERING 202
- { 2, 0, 3, pValor, 333,"|TInterface\\icons\\trade_engraving:30:30:-16:0|t Enchanting.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_ENCHANTING 333
- { 2, 0, 3, pValor, 755,"|TInterface\\icons\\inv_misc_gem_01:30:30:-16:0|t Jewelcrafting.", "|cff1E90FFTem certeza que quer essa profissao|r" }, // SKILL_JEWELCRAFTING 755
- { 2, 0, 3, pValor, 773,"|TInterface\\icons\\INV_Scroll_08:30:30:-16:0|t Inscription.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_INSCRIPTION 773
- { 2, 0, 3, pValor, 182, "|TInterface\\icons\\INV_Misc_Herb_07:30:30:-16:0|t Herbalism.", "|cff1E90FFTem certeza que quer essa profissao|r" }, // SKILL_HERBALISM 182
- { 2, 0, 3, pValor, 186, "|TInterface\\icons\\trade_mining:30:30:-16:0|t Mining.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_MINING 186
- { 2, 0, 3, pValor, 393, "|TInterface\\icons\\inv_misc_pelt_wolf_01:30:30:-16:0|t Skinning.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_SKINNING 393
- { 2, 1, 3, 0, 0, "|cff0000FF|TInterface\\icons\\inv_misc_questionmark:20:20:-16:0|t<< Voltar" },
- // Profissões Secundarias
- { 3, 0, 3, pValor, 185, "|TInterface/ICONS/INV_Misc_Food_15:30:30:-16:0|t Cooking.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_COOKING 185
- { 3, 0, 3, pValor, 129, "|TInterface/ICONS/spell_holy_sealofsacrifice:30:30:-16:0|t First Aid.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_FIRST_AID 129
- { 3, 0, 3, pValor, 356, "|TInterface/ICONS/Trade_Fishing:30:30:-16:0|t Fishing.", "|cff1E90FFTem certeza que quer essa profissao|r" }, //SKILL_FISHING 356
- { 3, 1, 3, 0, 0, "|cff0000FF|TInterface\\icons\\inv_misc_questionmark:20:20:-16:0|t<< Voltar" },
- };
- class npc_Profissoes : public CreatureScript
- {
- public:
- npc_Profissoes() : CreatureScript("npc_Profissoes") {}
- void GetMenuProfissao(Player* player, Creature* creature, uint32 menuId)
- {
- player->PlayerTalkClass->ClearMenus();
- std::ostringstream Bs;
- bool epMENU = false;
- for (uint8 i = 0; i < (sizeof(mpData) / sizeof(*mpData)); i++)
- {
- if (epMENU && mpData[i].Menu != menuId)
- break;
- if (mpData[i].Menu == menuId )
- {
- if (mpData[i].Submenu != 0)
- player->ADD_GOSSIP_ITEM(mpData[i].Icone, mpData[i].Nome, GOSSIP_SENDER_MAIN, i);
- else
- player->ADD_GOSSIP_ITEM_EXTENDED(mpData[i].Icone, mpData[i].Nome, GOSSIP_SENDER_MAIN, i, mpData[i].Confirmar, 0, false);
- epMENU = true;
- }
- }
- player->SEND_GOSSIP_MENU(907, creature->GetGUID());
- return;
- }
- bool OnGossipHello(Player *pPlayer, Creature* _creature)
- {
- GetMenuProfissao(pPlayer, _creature, 1);
- return true;
- }
- bool OnGossipSelect(Player* pPlayer, Creature* _creature, uint32 uiSender, uint32 SKILL)
- {
- pPlayer->PlayerTalkClass->ClearMenus();
- uint8 ListaMenu;
- switch (SKILL)
- {
- case -1:
- break;
- default:
- ListaMenu = mpData[SKILL].Submenu;
- break;
- }
- if (ListaMenu == 0)
- {
- if (pPlayer->HasSkill(mpData[SKILL].pSKILL)){
- pPlayer->GetSession()->SendNotification("|cffff0000ALERTA: Voce ja tem esta profissao!");
- }else{
- CompleteLearnProfession(pPlayer, (SkillType)mpData[SKILL].pSKILL);
- }
- ListaMenu = mpData[SKILL].Menu;
- }
- GetMenuProfissao(pPlayer, _creature, ListaMenu);
- return true;
- }
- bool IsSecondarySkill(SkillType skill) const
- {
- return skill == SKILL_COOKING || skill == SKILL_FIRST_AID;
- }
- void CompleteLearnProfession(Player *pPlayer, SkillType skill)
- {
- if (PlayerAlreadyHasTwoProfessions(pPlayer) && !IsSecondarySkill(skill))
- pPlayer->GetSession()->SendNotification("|cffff0000ALERTA: Voce ja tem o maximo de profissao permitida!");
- else
- {
- if (CobrarProfession == 1)
- {
- if (CobrarProfessionHONOR == 1){
- if (pPlayer->GetHonorPoints() < pValor)
- {
- pPlayer->GetSession()->SendNotification("|cffff0000ALERTA: Voce nao tem Honor Points suficiente!");
- }
- else
- {
- if (!LearnAllRecipesInProfession(pPlayer, skill))
- pPlayer->GetSession()->SendNotification("Internal error occured!");
- pPlayer->ModifyHonorPoints(-pValor);
- pPlayer->GetSession()->SendNotification("|cff32CD32PARABENS!: Profission atiquirida com sucesso!");
- }
- }
- else if (CobrarProfessionHONOR == 2)
- {
- if (pPlayer->HasItemCount(IdEmblema, pValor))
- {
- if (!LearnAllRecipesInProfession(pPlayer, skill))
- pPlayer->GetSession()->SendNotification("Internal error occured!");
- pPlayer->DestroyItemCount(IdEmblema, pValor, true);
- pPlayer->GetSession()->SendNotification("|cff32CD32PARABENS!: Profissao adiquirida com sucesso!");
- }
- else
- {
- pPlayer->GetSession()->SendNotification("|cffff0000ALERTA: Voce nao tem Item[Token] suficiente!");
- }
- }
- }
- else
- {
- if (!LearnAllRecipesInProfession(pPlayer, skill))
- pPlayer->GetSession()->SendNotification("Internal error occured!");
- pPlayer->GetSession()->SendNotification("|cff32CD32PARABENS!: Profissao adiquirida com sucesso!");
- }
- }
- }
- bool LearnAllRecipesInProfession(Player* pPlayer, SkillType skill)
- {
- SkillLineEntry const *SkillInfo = sSkillLineStore.LookupEntry(skill);
- if (!SkillInfo)
- {
- sLog->outCommand(LANG_SET_SKILL_ERROR, "Profession NPC: received non-valid skill ID (LearnAllRecipesInProfession)");
- return false;
- }
- const char* skill_name = SkillInfo->name[ChatHandler(pPlayer->GetSession()).GetSessionDbcLocale()];
- LearnSkillRecipesHelper(pPlayer, SkillInfo->id);
- pPlayer->SetSkill(SkillInfo->id, pPlayer->GetSkillStep(SkillInfo->id), 450, 450);
- ChatHandler(pPlayer->GetSession()).PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, skill_name);
- return true;
- }
- bool PlayerAlreadyHasTwoProfessions(Player *pPlayer)
- {
- uint32 skillCount = 0;
- if (pPlayer->HasSkill(SKILL_MINING))
- skillCount++;
- if (pPlayer->HasSkill(SKILL_SKINNING))
- skillCount++;
- if (pPlayer->HasSkill(SKILL_HERBALISM))
- skillCount++;
- if (skillCount >= 4)
- return true;
- for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
- {
- SkillLineEntry const *SkillInfo = sSkillLineStore.LookupEntry(i);
- if (!SkillInfo) continue;
- if (SkillInfo->categoryId == SKILL_CATEGORY_SECONDARY) continue;
- if ((SkillInfo->categoryId != SKILL_CATEGORY_PROFESSION) || !SkillInfo->canLink) continue;
- const uint32 skillID = SkillInfo->id;
- if (pPlayer->HasSkill(skillID))
- skillCount++;
- if (pProfissionVIP == 1 && (pPlayer->HasItemCount(IdItemProfissionVIP, 1, true))){
- if (skillCount >= qProfissionVIP) // Numero de profission player vip
- return true;
- }
- else
- {
- if (skillCount >= qProfissionNormal) // Numero de profission de player normal
- return true;
- }
- }
- return false;
- }
- void LearnSkillRecipesHelper(Player *player, uint32 skill_id)
- {
- uint32 classmask = player->getClassMask();
- for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
- {
- SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
- if (!skillLine) continue;
- // wrong skill
- if (skillLine->skillId != skill_id) continue;
- // not high rank
- if (skillLine->forward_spellid) continue;
- // skip racial skills
- if (skillLine->racemask != 0) continue;
- // skip wrong class skills
- if (skillLine->classmask && (skillLine->classmask & classmask) == 0) continue;
- SpellInfo const * spellInfo = sSpellMgr->GetSpellInfo(skillLine->spellId);
- if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false))
- continue;
- player->LearnSpell(skillLine->spellId, false);
- }
- }
- };
- class mod_npc_Profissoes_WorldScript : public WorldScript
- {
- public:
- mod_npc_Profissoes_WorldScript() : WorldScript("mod_npcprofissio_WorldScript") { }
- void OnConfigLoad(bool /*reload*/)
- {
- CobrarProfession = sConfigMgr->GetBoolDefault("Abilitar.Cobrar.Profession", true);
- CobrarProfessionHONOR = sConfigMgr->GetIntDefault("Cobrar.Profession_Honor.ou.Item", 0);
- IdEmblema = sConfigMgr->GetIntDefault("Id_Item", 0);
- pValor = sConfigMgr->GetIntDefault("Valor_A_Cobrar", 0);
- pProfissionVIP = sConfigMgr->GetBoolDefault("ProfessionVIP", false);
- qProfissionVIP = sConfigMgr->GetIntDefault("QuantidadeProfessionVIP", 0);
- qProfissionNormal = sConfigMgr->GetIntDefault("QuantidadeProfessionNormal", 0);
- IdItemProfissionVIP = sConfigMgr->GetIntDefault("Id.ItemVIP", 0);
- }
- };
- void AddSC_npc_Profissoes()
- {
- new npc_Profissoes();
- new mod_npc_Profissoes_WorldScript();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement