Advertisement
Guest User

With Badges

a guest
May 26th, 2013
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.54 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. //  {icon, "title name", honored_kills, titleID}
  11. Rochet2 Titles [] =
  12. {
  13.     {9,     "|TInterface/PvPRankBadges/PvPRank01:20:20|t Private",                  50,         1   },
  14.     {9,     "|TInterface/PvPRankBadges/PvPRank02:20:20|t Corporal",                 100,        2   },
  15.     {9,     "|TInterface/PvPRankBadges/PvPRank03:20:20|t Sergeant",                 250,        3   },
  16.     {9,     "|TInterface/PvPRankBadges/PvPRank04:20:20|t Master Sergeant",          500,        4   },
  17.     {9,     "|TInterface/PvPRankBadges/PvPRank05:20:20|t Sergeant Major",           750,        5   },
  18.     {9,     "|TInterface/PvPRankBadges/PvPRank06:20:20|t Knight",                   1000,       6   },
  19.     {9,     "|TInterface/PvPRankBadges/PvPRank07:20:20|t Knight-Lieutenant",        1500,       7   },
  20.     {9,     "|TInterface/PvPRankBadges/PvPRank08:20:20|t Knight-Captain",           2000,       8   },
  21.     {9,     "|TInterface/PvPRankBadges/PvPRank09:20:20|t Knight-Champion",          2500,       9   },
  22.     {9,     "|TInterface/PvPRankBadges/PvPRank10:20:20|t Lieutenant Commander",     3000,       10  },
  23.     {9,     "|TInterface/PvPRankBadges/PvPRank11:20:20|t Commander",                3500,       11  },
  24.     {9,     "|TInterface/PvPRankBadges/PvPRank12:20:20|t Marshal",                  4000,       12  },
  25.     {9,     "|TInterface/PvPRankBadges/PvPRank13:20:20|t Field Marshal",            4500,       13  },
  26.     {9,     "|TInterface/PvPRankBadges/PvPRank14:20:20|t Grand Marshal",            5000,       14  },
  27.  
  28.     {9,     "|TInterface/PvPRankBadges/PvPRank01:20:20|t Scout",                    50,         15  },
  29.     {9,     "|TInterface/PvPRankBadges/PvPRank02:20:20|t Grunt",                    100,        16  },
  30.     {9,     "|TInterface/PvPRankBadges/PvPRank03:20:20|t Sergeant",                 250,        17  },
  31.     {9,     "|TInterface/PvPRankBadges/PvPRank04:20:20|t Senior Sergeant",          500,        18  },
  32.     {9,     "|TInterface/PvPRankBadges/PvPRank05:20:20|t First Sergeant",           750,        19  },
  33.     {9,     "|TInterface/PvPRankBadges/PvPRank06:20:20|t Stone Guard",              1000,       20  },
  34.     {9,     "|TInterface/PvPRankBadges/PvPRank07:20:20|t Blood Guard",              1500,       21  },
  35.     {9,     "|TInterface/PvPRankBadges/PvPRank08:20:20|t Legionnaire",              2000,       22  },
  36.     {9,     "|TInterface/PvPRankBadges/PvPRank09:20:20|t Centurion",                2500,       23  },
  37.     {9,     "|TInterface/PvPRankBadges/PvPRank10:20:20|t Champion",                 3000,       24  },
  38.     {9,     "|TInterface/PvPRankBadges/PvPRank11:20:20|t Lieutenant General",       3500,       25  },
  39.     {9,     "|TInterface/PvPRankBadges/PvPRank12:20:20|t General",                  4000,       26  },
  40.     {9,     "|TInterface/PvPRankBadges/PvPRank13:20:20|t Warlord",                  4500,       27  },
  41.     {9,     "|TInterface/PvPRankBadges/PvPRank14:20:20|t High Warlord",             5000,       28  },
  42. };
  43.  
  44. enum eEnums
  45. {
  46.     Amount  =   sizeof Titles/sizeof(*Titles),
  47.  
  48.     // npc_text ID
  49.     Greetings_A =   1,
  50.     Greetings_H =   2,
  51. };
  52.  
  53. #define ERROR_HASTITLE  "|cffff0000You already have this title|r" // Error message that shows up when a player already has the title
  54. #define ERROR_CASH "|cffff0000You don't have enough honorable kills|r"
  55.  
  56.  
  57. class Title_gossip_codebox : public CreatureScript
  58. {
  59.     public:
  60.     Title_gossip_codebox()
  61.     : CreatureScript("Title_gossip_codebox")
  62.     {
  63.     }
  64.  
  65.     bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  66.     {
  67.         uint32 txt  = Greetings_A;
  68.         uint32 i    = 0;
  69.         uint32 m    = Amount/2;
  70.         if(pPlayer->GetTeam() == HORDE)
  71.         {
  72.             txt = Greetings_H;
  73.             i = Amount/2;
  74.             m = Amount;
  75.         }
  76.         for (i; i<m; i++)
  77.         {
  78.             std::ostringstream ss;
  79.             ss << Titles[i].name << " - " << Titles[i].HK << " Honorable Kills";
  80.             std::string showcoolshit = ss.str();
  81.             ss.clear();
  82.             ss << "Are you black?\nYou will be granted the title: " << Titles[i].name;
  83.             std::string showcoolshit2 = ss.str();
  84.             // ADD_GOSSIP_ITEM_EXTENDED Parameters: (icon, label, GOSSIP_SENDER_MAIN (Sender), Title ID ? (action), popup, coppercost, code (false))
  85.             pPlayer->ADD_GOSSIP_ITEM_EXTENDED(Titles[i].icon, showcoolshit.c_str(), GOSSIP_SENDER_MAIN, i, showcoolshit2, 0, false);
  86.         }
  87.         pPlayer->PlayerTalkClass->SendGossipMenu(txt, pCreature->GetGUID());
  88.         return true;
  89.     }
  90.  
  91.     bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 i)
  92.     {
  93.         pPlayer->PlayerTalkClass->ClearMenus(); // clear the menu
  94.  
  95.         if (CharTitlesEntry const* Title = sCharTitlesStore.LookupEntry(Titles[i].titleID)) // Get title
  96.         {
  97.             if(pPlayer->HasTitle(Title)) // If has title
  98.                 pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_HASTITLE);
  99.             else if(Titles[i].HK > pPlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)) // If doesnt have enough honored kills
  100.                 pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_CASH);
  101.             else
  102.             {
  103.                 pPlayer->SetTitle(Title);
  104.                 pPlayer->SaveToDB();
  105.             }
  106.             OnGossipHello(pPlayer, pCreature);
  107.         }
  108.         return true;
  109.     }
  110. };
  111.  
  112. void AddSC_Title_gossip_codebox()
  113. {
  114.     new Title_gossip_codebox();
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement