Guest User

Title Vendor

a guest
May 10th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.96 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. struct Rochet2
  4. {
  5.   uint8 icon;
  6.   std::string name;
  7.     uint32 HK, titleID;
  8. };
  9.  
  10. /********************************************************
  11. Possible icons:
  12. 0, //white chat bubble
  13. 1, //brown bag
  14. 2, //flight
  15. 3, //book
  16. 4, //interaction wheel
  17. 5, //interaction wheel
  18. 6, //brown bag with yellow dot
  19. 7, //white chat bubble with black dots
  20. 8, //tabard
  21. 9, //two swords
  22. 10, //yellow dot
  23.  
  24. Example Gossip Option: {iconID (see above), "title name", honorable_kills_required (set to whatever you require the player to have to get this rank), titleID (from database)}
  25. ***********************************************************/
  26.  
  27. Rochet2 Titles [] =
  28. {
  29.  
  30.     {9,     "Private",                  50,         1   },
  31.     {9,     "Corporal",                 100,        2   },
  32.     {9,     "Sergeant",                 250,        3   },
  33.     {9,     "Master Sergeant",          500,        4   },
  34.     {9,     "Sergeant Major",           750,        5   },
  35.     {9,     "Knight",                   1000,       6   },
  36.     {9,     "Knight-Lieutenant",        1500,       7   },
  37.     {9,     "Knight-Captain",           2000,       8   },
  38.     {9,     "Knight-Champion",          2500,       9   },
  39.     {9,     "Lieutenant Commander",     3000,       10  },
  40.     {9,     "Commander",                3500,       11  },
  41.     {9,     "Marshal",                  4000,       12  },
  42.     {9,     "Field Marshal",            4500,       13  },
  43.     {9,     "Grand Marshal",            5000,       14  },
  44.  
  45.     {9,     "Scout",                    50,       15    },
  46.     {9,     "Grunt",                    100,        16  },
  47.     {9,     "Sergeant",                 250,        17  },
  48.     {9,     "Senior Sergeant",          500,        18  },
  49.     {9,     "First Sergeant",           750,        19  },
  50.     {9,     "Stone Guard",              1000,       20  },
  51.     {9,     "Blood Guard",              1500,       21  },
  52.     {9,     "Legionnaire",              2000,       22  },
  53.     {9,     "Centurion",                2500,       23  },
  54.     {9,     "Champion",                 3000,       24  },
  55.     {9,     "Lieutenant General",       3500,       25  },
  56.     {9,     "General",                  4000,       26  },
  57.     {9,     "Warlord",                  4500,       27  },
  58.     {9,     "High Warlord",             5000,       28  },
  59. };
  60.  
  61. enum eEnums
  62. {
  63.     Amount  =   sizeof Titles/sizeof(*Titles),
  64.  
  65.     // npc_text ID
  66.     Greetings_A =   1,
  67.     Greetings_H =   2,
  68. };
  69.  
  70. #define ERROR_HASTITLE  "|cffff0000You already have this title|r" // Error message that shows up when a player already has the title
  71. #define ERROR_CASH "|cffff0000You don't have enough honorable kills|r" // Error message if player does not have enough honorable kills
  72.  
  73.  
  74. class Title_gossip_codebox : public CreatureScript
  75. {
  76.     public:
  77.     Title_gossip_codebox()
  78.     : CreatureScript("Title_gossip_codebox")
  79.     {
  80.     }
  81.  
  82.     bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  83.     {
  84.         uint32 txt  = Greetings_A;
  85.         uint32 i    = 0;
  86.         uint32 m    = Amount/2;
  87.         if(pPlayer->GetTeam() == HORDE)
  88.         {
  89.             txt = Greetings_H;
  90.             i = Amount/2;
  91.             m = Amount;
  92.         }
  93.         for (i; i<m; i++)
  94.         {
  95.             std::ostringstream ss;
  96.             ss << Titles[i].name << " - " << Titles[i].HK << " HKs";
  97.             std::string showcoolshit = ss.str();
  98.             ss.str(" ");
  99.             ss.clear();
  100.             ss << "Are you sure?\nYou will be granted the title: " << Titles[i].name;
  101.             std::string showcoolshit2 = ss.str();
  102.             // ADD_GOSSIP_ITEM_EXTENDED Parameters: (icon, label, GOSSIP_SENDER_MAIN (Sender), Title ID ? (action - Sends info to OnGossipSelect), popup, coppercost, code (codebox))
  103.             pPlayer->ADD_GOSSIP_ITEM_EXTENDED(Titles[i].icon, showcoolshit.c_str(), GOSSIP_SENDER_MAIN, i, showcoolshit2, 0, false);
  104.         }
  105.         pPlayer->PlayerTalkClass->SendGossipMenu(txt, pCreature->GetGUID());
  106.         return true;
  107.     }
  108.  
  109.     bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 i)
  110.     {
  111.         pPlayer->PlayerTalkClass->ClearMenus(); // clear the menu
  112.  
  113.         if (CharTitlesEntry const* Title = sCharTitlesStore.LookupEntry(Titles[i].titleID)) // Get title
  114.         {
  115.             if(pPlayer->HasTitle(Title)) // If has title
  116.                 pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_HASTITLE);
  117.             else if(Titles[i].HK > pPlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)) // If doesnt have enough honored kills
  118.                 pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_CASH);
  119.             else
  120.             {
  121.                 pPlayer->SetTitle(Title);
  122.                 pPlayer->SaveToDB();
  123.             }
  124.             OnGossipHello(pPlayer, pCreature);
  125.         }
  126.         return true;
  127.     }
  128. };
  129.  
  130. void AddSC_Title_gossip_codebox()
  131. {
  132.     new Title_gossip_codebox();
  133. }
Advertisement
Add Comment
Please, Sign In to add comment