Guest User

Untitled

a guest
Jul 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "ObjectMgr.h"
  3. #include "SpellMgr.h"
  4. #include "Chat.h"
  5. #include "SpellInfo.h"
  6. // TO DO:
  7. // Make the NPC give recipes for the main profession and for each specialization separately.
  8.  
  9. enum Spells
  10. {
  11. SPELL_BS = 2018,
  12. ARMORSMITH = 9790,
  13. WEAPONSMITH = 9789,
  14. SPELL_JC = 25229,
  15. SPELL_ENCH = 7411,
  16. SPELL_ALCHEM = 2259,
  17. SPELL_ENGI = 4036,
  18. SPELL_GNOMISH_ENGI = 20220,
  19. SPELL_GOBLIN_ENGI = 20221,
  20. SPELL_INSCRIPTION = 45357,
  21. SPELL_TAILORING = 3908,
  22. SPELLFIRE = 26796,
  23. MOONCLOTH = 26798,
  24. SHADOWEAVE = 26800,
  25. SPELL_MINING = 2575,
  26. SPELL_HERBALISM = 9134,
  27. SPELL_LW = 2108,
  28. DRAGONSCALE = 10657,
  29. ELEMENTAL = 10659,
  30. TRIBAL = 10661,
  31. SPELL_SKINNING = 8613,
  32.  
  33. SKILL_BLACKS = 164,
  34. SKILL_JEWELC = 755,
  35. SKILL_ENCHA = 333,
  36. SKILL_ALCH = 171,
  37. SKILL_ENG = 202,
  38. SKILL_INSC = 773,
  39. SKILL_TAIL = 197,
  40. SKILL_MIN = 186,
  41. SKILL_HERB = 182,
  42. SKILL_LEATHERW = 165,
  43. SKILL_SKIN = 393
  44. };
  45.  
  46. //#define MAIN_MENU "Hello, $n. Are you here to learn your professions?"
  47.  
  48.  
  49.  
  50. class npc_profession : public CreatureScript
  51. {
  52. public:
  53. npc_profession() : CreatureScript("npc_profession") { }
  54.  
  55. static void HandleLearnSkillRecipesHelper(Player* player, uint32 skillId)
  56. {
  57. uint32 classmask = player->getClassMask();
  58.  
  59. for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
  60. {
  61. SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j);
  62. if (!skillLine)
  63. continue;
  64.  
  65. // wrong skill
  66. if (skillLine->skillId != skillId)
  67. continue;
  68.  
  69. // not high rank
  70. if (skillLine->forward_spellid)
  71. continue;
  72.  
  73. // skip racial skills
  74. if (skillLine->racemask != 0)
  75. continue;
  76.  
  77. // skip wrong class skills
  78. if (skillLine->classmask && (skillLine->classmask & classmask) == 0)
  79. continue;
  80.  
  81. SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(skillLine->spellId);
  82. if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false))
  83. continue;
  84.  
  85. player->learnSpell(skillLine->spellId, false);
  86. }
  87. }
  88.  
  89. bool OnGossipHello(Player* player, Creature* creature)
  90. {
  91. player->ADD_GOSSIP_ITEM( 3, "Alchemy." , GOSSIP_SENDER_MAIN, 1000);
  92. player->ADD_GOSSIP_ITEM( 3, "Blacksmithing." , GOSSIP_SENDER_MAIN, 1001);
  93. player->ADD_GOSSIP_ITEM( 3, "Enchanting." , GOSSIP_SENDER_MAIN, 1002);
  94. player->ADD_GOSSIP_ITEM( 3, "Engineering." , GOSSIP_SENDER_MAIN, 1003);
  95. player->ADD_GOSSIP_ITEM( 3, "Herbalism." , GOSSIP_SENDER_MAIN, 1004);
  96. player->ADD_GOSSIP_ITEM( 3, "Inscription." , GOSSIP_SENDER_MAIN, 1005);
  97. player->ADD_GOSSIP_ITEM( 3, "Jewelcrafting." , GOSSIP_SENDER_MAIN, 1006);
  98. player->ADD_GOSSIP_ITEM( 3, "Leatherworking." , GOSSIP_SENDER_MAIN, 1007);
  99. player->ADD_GOSSIP_ITEM( 3, "Mining" , GOSSIP_SENDER_MAIN, 1008);
  100. player->ADD_GOSSIP_ITEM( 3, "Skinning." , GOSSIP_SENDER_MAIN, 1009);
  101. player->ADD_GOSSIP_ITEM( 3, "Tailoring" , GOSSIP_SENDER_MAIN, 1010);
  102. player->ADD_GOSSIP_ITEM( 0, "Nevermind." , GOSSIP_SENDER_MAIN, 1011);
  103. player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  104. return true;
  105.  
  106. }
  107.  
  108. bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
  109. {
  110. if (player->isInCombat())
  111. {
  112. player->CLOSE_GOSSIP_MENU();
  113. creature->MonsterWhisper("You are in combat!", player->GetGUID(), false);
  114. return false;
  115. }
  116.  
  117. int SkillCount = 0;
  118. //Check if player already has 2 professions
  119. if (player->HasSkill(SKILL_BLACKS))
  120. {
  121. SkillCount++;
  122. }
  123. if (player->HasSkill(SKILL_JEWELC))
  124. {
  125. SkillCount++;
  126. }
  127. if (player->HasSkill(SKILL_ENCHA))
  128. {
  129. SkillCount++;
  130. }
  131. if (player->HasSkill(SKILL_ALCH))
  132. {
  133. SkillCount++;
  134. }
  135. if (player->HasSkill(SKILL_ENG))
  136. {
  137. SkillCount++;
  138. }
  139. if (player->HasSkill(SKILL_INSC))
  140. {
  141. SkillCount++;
  142. }
  143. if (player->HasSkill(SKILL_TAIL))
  144. {
  145. SkillCount++;
  146. }
  147. if (player->HasSkill(SKILL_MIN))
  148. {
  149. SkillCount++;
  150. }
  151. if (player->HasSkill(SKILL_HERB))
  152. {
  153. SkillCount++;
  154. }
  155. if (player->HasSkill(SKILL_LEATHERW))
  156. {
  157. SkillCount++;
  158. }
  159. if (player->HasSkill(SKILL_SKIN))
  160. {
  161. SkillCount++;
  162. }
  163.  
  164.  
  165. if (SkillCount < 2)
  166. {
  167. switch (action)
  168. {
  169. case 1000:
  170. player->CLOSE_GOSSIP_MENU();
  171. player->learnSpellHighRank(SPELL_ALCHEM);
  172. player->UpdateSkill(SKILL_ALCH, 450);
  173. HandleLearnSkillRecipesHelper(player, SKILL_ALCH);
  174. creature->MonsterWhisper("You have learned Alchemy!", player->GetGUID(),true);
  175. break;
  176. case 1001:
  177. player->CLOSE_GOSSIP_MENU();
  178. player->learnSpellHighRank(SPELL_BS);
  179. player->UpdateSkill(SKILL_BLACKS, 450);
  180. HandleLearnSkillRecipesHelper(player, SKILL_BLACKS);
  181. creature->MonsterWhisper("You have learned Blacksmithing!", player->GetGUID(),true);
  182. break;
  183. case 1002:
  184. player->CLOSE_GOSSIP_MENU();
  185. player->learnSpellHighRank(SPELL_ENCH);
  186. player->UpdateSkill(SKILL_ENCHA, 450);
  187. HandleLearnSkillRecipesHelper(player, SKILL_ENCHA);
  188. creature->MonsterWhisper("You have learned Enchanting!", player->GetGUID(),true);
  189. break;
  190. case 1003:
  191. player->CLOSE_GOSSIP_MENU();
  192. player->learnSpellHighRank(SPELL_ENGI);
  193. player->UpdateSkill(SKILL_ENG, 450);
  194. HandleLearnSkillRecipesHelper(player, SKILL_ENG);
  195. creature->MonsterWhisper("You have learned Engineering!", player->GetGUID(),true);
  196. break;
  197. case 1004:
  198. player->CLOSE_GOSSIP_MENU();
  199. player->learnSpellHighRank(SPELL_HERBALISM);
  200. player->UpdateSkill(SKILL_HERB, 450);
  201. HandleLearnSkillRecipesHelper(player, SKILL_HERB);
  202. creature->MonsterWhisper("You have learned Herbalism!", player->GetGUID(),true);
  203. break;
  204. case 1005:
  205. player->CLOSE_GOSSIP_MENU();
  206. player->learnSpellHighRank(SPELL_INSCRIPTION);
  207. player->UpdateSkill(SKILL_INSC, 450);
  208. HandleLearnSkillRecipesHelper(player, SKILL_INSC);
  209. creature->MonsterWhisper("You have learned Inscription!", player->GetGUID(),true);
  210. break;
  211. case 1006:
  212. player->CLOSE_GOSSIP_MENU();
  213. player->learnSpellHighRank(SPELL_JC);
  214. player->UpdateSkill(SKILL_JEWELC, 450);
  215. HandleLearnSkillRecipesHelper(player, SKILL_JEWELC);
  216. creature->MonsterWhisper("You have learned Jewelcrafting!", player->GetGUID(),true);
  217. break;
  218. case 1007:
  219. player->CLOSE_GOSSIP_MENU();
  220. player->learnSpellHighRank(SPELL_LW);
  221. player->UpdateSkill(SKILL_LEATHERW, 450);
  222. HandleLearnSkillRecipesHelper(player, SKILL_LEATHERW);
  223. creature->MonsterWhisper("You have learned Leatherworking!", player->GetGUID(),true);
  224. break;
  225. case 1008:
  226. player->CLOSE_GOSSIP_MENU();
  227. player->learnSpellHighRank(SPELL_MINING);
  228. player->UpdateSkill(SKILL_MIN, 450);
  229. HandleLearnSkillRecipesHelper(player, SKILL_MIN);
  230. creature->MonsterWhisper("You have learned Mining!", player->GetGUID(),true);
  231. break;
  232. case 1009:
  233. player->CLOSE_GOSSIP_MENU();
  234. player->learnSpellHighRank(SPELL_SKINNING);
  235. player->UpdateSkill(SKILL_SKIN, 450);
  236. HandleLearnSkillRecipesHelper(player, SKILL_SKIN);
  237. creature->MonsterWhisper("You have learned Skinning!", player->GetGUID(),true);
  238. break;
  239. case 1010:
  240. player->CLOSE_GOSSIP_MENU();
  241. player->learnSpellHighRank(SPELL_TAILORING);
  242. player->UpdateSkill(SKILL_TAIL, 450);
  243. HandleLearnSkillRecipesHelper(player, SKILL_TAIL);
  244. creature->MonsterWhisper("You have learned Tailoring!", player->GetGUID(),true);
  245. break;
  246. case 1011:
  247. player->CLOSE_GOSSIP_MENU();
  248. break;
  249. }
  250. }
  251. else
  252. {
  253. creature->MonsterWhisper("You already have two professions!", player->GetGUID(), false);
  254. player->CLOSE_GOSSIP_MENU();
  255. }
  256.  
  257. switch (action)
  258. {
  259. case 1011:
  260. player->CLOSE_GOSSIP_MENU();
  261. break;
  262. }
  263. return true;
  264. }
  265. };
  266.  
  267. void AddSC_npc_profession()
  268. {
  269. new npc_profession;
  270. }
Add Comment
Please, Sign In to add comment