Advertisement
Guest User

Title Vendor

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