Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- #include "ObjectMgr.h"
- #include "SpellMgr.h"
- #include "Chat.h"
- #include "SpellInfo.h"
- // TO DO:
- // Make the NPC give recipes for the main profession and for each specialization separately.
- enum Spells
- {
- SPELL_BS = 2018,
- ARMORSMITH = 9790,
- WEAPONSMITH = 9789,
- SPELL_JC = 25229,
- SPELL_ENCH = 7411,
- SPELL_ALCHEM = 2259,
- SPELL_ENGI = 4036,
- SPELL_GNOMISH_ENGI = 20220,
- SPELL_GOBLIN_ENGI = 20221,
- SPELL_INSCRIPTION = 45357,
- SPELL_TAILORING = 3908,
- SPELLFIRE = 26796,
- MOONCLOTH = 26798,
- SHADOWEAVE = 26800,
- SPELL_MINING = 2575,
- SPELL_HERBALISM = 9134,
- SPELL_LW = 2108,
- DRAGONSCALE = 10657,
- ELEMENTAL = 10659,
- TRIBAL = 10661,
- SPELL_SKINNING = 8613,
- SKILL_BLACKS = 164,
- SKILL_JEWELC = 755,
- SKILL_ENCHA = 333,
- SKILL_ALCH = 171,
- SKILL_ENG = 202,
- SKILL_INSC = 773,
- SKILL_TAIL = 197,
- SKILL_MIN = 186,
- SKILL_HERB = 182,
- SKILL_LEATHERW = 165,
- SKILL_SKIN = 393
- };
- //#define MAIN_MENU "Hello, $n. Are you here to learn your professions?"
- class npc_profession : public CreatureScript
- {
- public:
- npc_profession() : CreatureScript("npc_profession") { }
- static void HandleLearnSkillRecipesHelper(Player* player, uint32 skillId)
- {
- 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 != skillId)
- 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);
- }
- }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM( 3, "Alchemy." , GOSSIP_SENDER_MAIN, 1000);
- player->ADD_GOSSIP_ITEM( 3, "Blacksmithing." , GOSSIP_SENDER_MAIN, 1001);
- player->ADD_GOSSIP_ITEM( 3, "Enchanting." , GOSSIP_SENDER_MAIN, 1002);
- player->ADD_GOSSIP_ITEM( 3, "Engineering." , GOSSIP_SENDER_MAIN, 1003);
- player->ADD_GOSSIP_ITEM( 3, "Herbalism." , GOSSIP_SENDER_MAIN, 1004);
- player->ADD_GOSSIP_ITEM( 3, "Inscription." , GOSSIP_SENDER_MAIN, 1005);
- player->ADD_GOSSIP_ITEM( 3, "Jewelcrafting." , GOSSIP_SENDER_MAIN, 1006);
- player->ADD_GOSSIP_ITEM( 3, "Leatherworking." , GOSSIP_SENDER_MAIN, 1007);
- player->ADD_GOSSIP_ITEM( 3, "Mining" , GOSSIP_SENDER_MAIN, 1008);
- player->ADD_GOSSIP_ITEM( 3, "Skinning." , GOSSIP_SENDER_MAIN, 1009);
- player->ADD_GOSSIP_ITEM( 3, "Tailoring" , GOSSIP_SENDER_MAIN, 1010);
- player->ADD_GOSSIP_ITEM( 0, "Nevermind." , GOSSIP_SENDER_MAIN, 1011);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
- {
- if (player->isInCombat())
- {
- player->CLOSE_GOSSIP_MENU();
- creature->MonsterWhisper("You are in combat!", player->GetGUID(), false);
- return false;
- }
- int SkillCount = 0;
- //Check if player already has 2 professions
- if (player->HasSkill(SKILL_BLACKS))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_JEWELC))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_ENCHA))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_ALCH))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_ENG))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_INSC))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_TAIL))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_MIN))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_HERB))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_LEATHERW))
- {
- SkillCount++;
- }
- if (player->HasSkill(SKILL_SKIN))
- {
- SkillCount++;
- }
- if (SkillCount < 2)
- {
- switch (action)
- {
- case 1000:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_ALCHEM);
- player->UpdateSkill(SKILL_ALCH, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_ALCH);
- creature->MonsterWhisper("You have learned Alchemy!", player->GetGUID(),true);
- break;
- case 1001:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_BS);
- player->UpdateSkill(SKILL_BLACKS, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_BLACKS);
- creature->MonsterWhisper("You have learned Blacksmithing!", player->GetGUID(),true);
- break;
- case 1002:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_ENCH);
- player->UpdateSkill(SKILL_ENCHA, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_ENCHA);
- creature->MonsterWhisper("You have learned Enchanting!", player->GetGUID(),true);
- break;
- case 1003:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_ENGI);
- player->UpdateSkill(SKILL_ENG, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_ENG);
- creature->MonsterWhisper("You have learned Engineering!", player->GetGUID(),true);
- break;
- case 1004:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_HERBALISM);
- player->UpdateSkill(SKILL_HERB, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_HERB);
- creature->MonsterWhisper("You have learned Herbalism!", player->GetGUID(),true);
- break;
- case 1005:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_INSCRIPTION);
- player->UpdateSkill(SKILL_INSC, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_INSC);
- creature->MonsterWhisper("You have learned Inscription!", player->GetGUID(),true);
- break;
- case 1006:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_JC);
- player->UpdateSkill(SKILL_JEWELC, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_JEWELC);
- creature->MonsterWhisper("You have learned Jewelcrafting!", player->GetGUID(),true);
- break;
- case 1007:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_LW);
- player->UpdateSkill(SKILL_LEATHERW, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_LEATHERW);
- creature->MonsterWhisper("You have learned Leatherworking!", player->GetGUID(),true);
- break;
- case 1008:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_MINING);
- player->UpdateSkill(SKILL_MIN, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_MIN);
- creature->MonsterWhisper("You have learned Mining!", player->GetGUID(),true);
- break;
- case 1009:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_SKINNING);
- player->UpdateSkill(SKILL_SKIN, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_SKIN);
- creature->MonsterWhisper("You have learned Skinning!", player->GetGUID(),true);
- break;
- case 1010:
- player->CLOSE_GOSSIP_MENU();
- player->learnSpellHighRank(SPELL_TAILORING);
- player->UpdateSkill(SKILL_TAIL, 450);
- HandleLearnSkillRecipesHelper(player, SKILL_TAIL);
- creature->MonsterWhisper("You have learned Tailoring!", player->GetGUID(),true);
- break;
- case 1011:
- player->CLOSE_GOSSIP_MENU();
- break;
- }
- }
- else
- {
- creature->MonsterWhisper("You already have two professions!", player->GetGUID(), false);
- player->CLOSE_GOSSIP_MENU();
- }
- switch (action)
- {
- case 1011:
- player->CLOSE_GOSSIP_MENU();
- break;
- }
- return true;
- }
- };
- void AddSC_npc_profession()
- {
- new npc_profession;
- }
Add Comment
Please, Sign In to add comment