Advertisement
julienanid

[Trinity] Title NPC Bug/Add gossip?

Nov 16th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.56 KB | None | 0 0
  1. /*
  2.     AYE
  3.    
  4.     Tommy
  5. */
  6.  
  7. struct HonorGossip
  8. {
  9.     uint32 menu_id;
  10.     uint8 icon;
  11.     std::string name;
  12.     uint32 HK, titleID;
  13. };
  14.  
  15. // {icon, "title name", honored_kills, titleID}
  16. HonorGossip Titles [] =
  17. {
  18.     {1, 9, "Private", 1, 1 },
  19.     {2, 9, "Corporal", 100, 2 },
  20.     {3, 9, "Sergeant", 250, 3 },
  21.     {4, 9, "Master Sergeant", 500, 4 },
  22.     {5, 9, "Sergeant Major", 750, 5 },
  23.     {6, 9, "Knight", 1000, 6 },
  24.     {7, 9, "Knight-Lieutenant", 1500, 7 },
  25.     {8, 9, "Knight-Captain", 2000, 8 },
  26.     {9, 9, "Knight-Champion", 2500, 9 },
  27.     {10, 9, "Lieutenant Commander", 3000, 10 },
  28.     {11, 9, "Commander", 3500, 11 },
  29.     {12, 9, "Marshal", 4000, 12 },
  30.     {13, 9, "Field Marshal", 4500, 13 },
  31.     {14, 9, "Grand Marshal", 5000, 14 },
  32.  
  33.     {15, 9, "Scout", 1, 15 },
  34.     {16, 9, "Grunt", 100, 16 },
  35.     {17, 9, "Sergeant", 250, 17 },
  36.     {18, 9, "Senior Sergeant", 500, 18 },
  37.     {19, 9, "First Sergeant", 750, 19 },
  38.     {20, 9, "Stone Guard", 1000, 20 },
  39.     {21, 9, "Blood Guard", 1500, 21 },
  40.     {22, 9, "Legionnaire", 2000, 22 },
  41.     {23, 9, "Centurion", 2500, 23 },
  42.     {24, 9, "Champion", 3000, 24 },
  43.     {25, 9, "Lieutenant General", 3500, 25 },
  44.     {26, 9, "General", 4000, 26 },
  45.     {27, 9, "Warlord", 4500, 27 },
  46.     {28, 9, "High Warlord", 5000, 28 },
  47. };
  48.  
  49. class npc_honor_gossip : public CreatureScript
  50. {
  51. public:
  52.     npc_honor_gossip() : CreatureScript("npc_honor_gossip") { }
  53.  
  54.     bool OnGossipHello(Player* player, Creature* creature)
  55.     {
  56.         player->ADD_GOSSIP_ITEM(0, "|TInterface\\icons\\INV_Misc_QuestionMark:30|tHow does this npc work?|r", GOSSIP_SENDER_MAIN, 100);
  57.         player->ADD_GOSSIP_ITEM(4, "|TInterface\\icons\\Achievement_PVP_H_15:30|tHonorable Kills Titles|r", GOSSIP_SENDER_MAIN, 101);
  58.         player->ADD_GOSSIP_ITEM(7, "|TInterface\\icons\\Ability_Spy:30|tNevermind|r", GOSSIP_SENDER_MAIN, 102);
  59.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  60.         return true;
  61.     }
  62.  
  63.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
  64.     {
  65.         player->PlayerTalkClass->ClearMenus();
  66.         if (actions == 100)
  67.             ChatHandler(player->GetSession()).SendSysMessage("|cffff6060[Information]:|r This npc show you 2 different options,Honorable Kills Titles costed on LifeTime Kills,Devium WoW Titles show you our own titles |cffff0000[Patch Required]|r,and costed on [Devium Title Token].");
  68.         return false;
  69.     }
  70.         else if(actions == 101)
  71.         {
  72.             if (player->GetTeam() == ALLIANCE)
  73.                 for (int i = 0; i < 14; i++)
  74.                     player->ADD_GOSSIP_ITEM(Titles[i].icon, Titles[i].name.c_str(), GOSSIP_SENDER_MAIN, Titles[i].menu_id);
  75.             else
  76.                 for (int i = 14; i < 28; i++)
  77.                     player->ADD_GOSSIP_ITEM(Titles[i].icon, Titles[i].name.c_str(), GOSSIP_SENDER_MAIN, Titles[i].menu_id);
  78.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "<- Back", GOSSIP_SENDER_MAIN, 999);
  79.                         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  80.         }
  81.         else if (actions == 102)
  82.             player->CLOSE_GOSSIP_MENU();
  83.  
  84.         else if (actions == 999)
  85.         {
  86.         player->ADD_GOSSIP_ITEM(0, "|TInterface\\icons\\INV_Misc_QuestionMark:30|tHow does this npc work?|r", GOSSIP_SENDER_MAIN, 100);
  87.         player->ADD_GOSSIP_ITEM(4, "|TInterface\\icons\\Achievement_PVP_H_15:30|tHonorable Kills Titles|r", GOSSIP_SENDER_MAIN, 101);
  88.         player->ADD_GOSSIP_ITEM(7, "|TInterface\\icons\\Ability_Spy:30|tNevermind|r", GOSSIP_SENDER_MAIN, 102);
  89.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  90.         }
  91.  
  92.         for (int i = 0; i < sizeof(Titles) / sizeof(uint32); i++)
  93.         {
  94.             if (actions == Titles[i].menu_id)
  95.             {
  96.                 if (player->HasTitle(Titles[i].titleID))
  97.                 {
  98.                     player->GetSession()->SendNotification("You already have this title!");
  99.                     return false;
  100.                 }
  101.                
  102.                 if (player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS) < Titles[i].HK)
  103.                 {
  104.                     player->GetSession()->SendNotification("You don't have enough kills!");
  105.                     return false;
  106.                 }
  107.                
  108.                 if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(Titles[i].titleID))
  109.                 {
  110.                     player->SetTitle(titleEntry);
  111.                     player->CLOSE_GOSSIP_MENU();
  112.                 }
  113.             }
  114.         }
  115.         return true;
  116.     }
  117. };
  118.  
  119. void AddSC_honor_gossip()
  120. {
  121.     new npc_honor_gossip;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement