Advertisement
Rochet2

Max professions NPC, my version

Oct 13th, 2012
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.74 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. enum Settings
  4. {
  5.     NPC_TEXT            = 44444,// this is the number for text to be displayed on npc, number is controlled via db in npc_text
  6.     GOSSIP_ICON         = 6,    // the icon that pops up by the (Max my blah blah blah)
  7.     DONOR_TOKEN         = 67890,// vote token id in item_template default: 67890, but should be edited to your custom id
  8.     DONOR_TOKEN_COUNT   = 5,    // MOD how much you want maxing a skill to cost.
  9.     MAX_SKILL_LEVEL     = 225   // Max for professions. the numbers go: 75, 150, 225, 300, 375, 450.
  10. };
  11.  
  12. class Pro_Max : public CreatureScript
  13. {
  14. public:
  15.     Pro_Max() : CreatureScript("Pro_Max")
  16.     {
  17.         std::stringstream ss;
  18.         ss << DONOR_TOKEN_COUNT;
  19.         DONOR_TOKEN_COUNT_STR = ss.str();
  20.     }
  21.     std::string DONOR_TOKEN_COUNT_STR;
  22.  
  23.     bool OnGossipHello(Player* player, Creature* creature)
  24.     {
  25.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Engineering("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_ENGINEERING);
  26.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Blacksmithing("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_BLACKSMITHING);
  27.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Alchemy("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_ALCHEMY);
  28.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Leatherworking("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_LEATHERWORKING);
  29.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Tailoring("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_TAILORING);
  30.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Skinning("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_SKINNING);
  31.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Mining("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_MINING);
  32.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Jewelcrafting("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_JEWELCRAFTING);
  33.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Inscriptions("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_INSCRIPTION);
  34.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Herbalism("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_HERBALISM);
  35.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Cooking("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_COOKING);
  36.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my First Aid("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_FIRST_AID);
  37.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON, "Max my Fishing("+DONOR_TOKEN_COUNT_STR+" Donor Tokens)", GOSSIP_SENDER_MAIN, SKILL_FISHING);
  38.         player->SEND_GOSSIP_MENU(NPC_TEXT, creature->GetGUID());
  39.         return true;
  40.     }
  41.  
  42.     bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  43.     {
  44.         player->PlayerTalkClass->ClearMenus();
  45.  
  46.         if (!player->HasSkill(action))
  47.             player->GetSession()->SendNotification("You already know this profession");
  48.         else if (player->GetSkillValue(action) == MAX_SKILL_LEVEL)
  49.             player->GetSession()->SendNotification("This profession is already maxed out");
  50.         else if (!player->HasItemCount(DONOR_TOKEN, DONOR_TOKEN_COUNT, false))
  51.  
  52.             player->GetSession()->SendNotification(("You need "+DONOR_TOKEN_COUNT_STR+" donor tokens").c_str());
  53.         else
  54.         {
  55.             player->DestroyItemCount(DONOR_TOKEN, DONOR_TOKEN_COUNT, true);
  56.             player->SetSkill(action, 0, MAX_SKILL_LEVEL, MAX_SKILL_LEVEL);
  57.         }
  58.         OnGossipHello(player, creature);
  59.         return true;
  60.     }
  61. };
  62.  
  63. void AddSC_Pro_Max()
  64. {
  65.     new Pro_Max();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement