Advertisement
EmuDevs

EmuDevs: TrinityCore C++ - Struct, for loops & Gossip

Sep 30th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. /*
  2.     ~ EmuDevs TC C++ Tutorial ~
  3.         <http://emudevs.com>
  4. */
  5. struct GossipHelper
  6. {
  7.     uint32 icon;
  8.     std::string optText;
  9.     uint32 menuId;
  10.     uint32 honorAmt;
  11. };
  12.  
  13. GossipHelper Helper[18] =
  14. {
  15.     { GOSSIP_ICON_CHAT, "MenuA 1", 1, 1000 },
  16.     { GOSSIP_ICON_DOT, "MenuA 2", 2, 2000 },
  17.     { GOSSIP_ICON_CHAT, "MenuA 3", 3, 3000 },
  18.     { GOSSIP_ICON_CHAT, "MenuA 4", 4, 4000 },
  19.     { GOSSIP_ICON_CHAT, "MenuA 5", 5, 5000 },
  20.     { GOSSIP_ICON_CHAT, "MenuA 6", 6, 6000 },
  21.     { GOSSIP_ICON_CHAT, "MenuA 7", 7, 7000 },
  22.     { GOSSIP_ICON_CHAT, "MenuA 8", 8, 8000 },
  23.  
  24.     { GOSSIP_ICON_CHAT, "MenuH 1", 1, 1000 },
  25.     { GOSSIP_ICON_DOT, "MenuH 2", 2, 2000 },
  26.     { GOSSIP_ICON_CHAT, "MenuH 3", 3, 3000 },
  27.     { GOSSIP_ICON_CHAT, "MenuH 4", 4, 4000 },
  28.     { GOSSIP_ICON_CHAT, "MenuH 5", 5, 5000 },
  29.     { GOSSIP_ICON_CHAT, "MenuH 6", 6, 6000 },
  30.     { GOSSIP_ICON_CHAT, "MenuH 7", 7, 7000 },
  31.     { GOSSIP_ICON_CHAT, "MenuH 8", 8, 8000 },
  32.     { GOSSIP_ICON_CHAT, "Nevermind..", 99 }
  33. };
  34.  
  35. class npc_gossip_helper : public CreatureScript
  36. {
  37. public:
  38.     npc_gossip_helper() : CreatureScript("npc_gossip_helper") { }
  39.  
  40.     bool OnGossipHello(Player* player, Creature* creature)
  41.     {
  42.         if (player->GetTeam() == ALLIANCE)
  43.             for (int i = 0; i < 8; i++)
  44.                 player->ADD_GOSSIP_ITEM(Helper[i].icon, Helper[i].optText, GOSSIP_SENDER_MAIN, Helper[i].menuId);
  45.         else
  46.         for (int i = 8; i < 17; i++)
  47.         player->ADD_GOSSIP_ITEM(Helper[i].icon, Helper[i].optText, GOSSIP_SENDER_MAIN, Helper[i].menuId);
  48.         player->ADD_GOSSIP_ITEM(Helper[18].icon, Helper[18].optText, GOSSIP_SENDER_MAIN, Helper[18].menuId);
  49.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  50.         return true;
  51.     }
  52.  
  53.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
  54.     {
  55.         player->PlayerTalkClass->ClearMenus();
  56.         for (int i = 0; i < sizeof (Helper) / sizeof(uint32); i++)
  57.             if (actions == Helper[i].menuId)
  58.                 player->ModifyHonorPoints(Helper[i].honorAmt);
  59.         player->CLOSE_GOSSIP_MENU();
  60.         return true;
  61.     }
  62. };
  63.  
  64. void AddSC_gossip_helper()
  65. {
  66.     new npc_gossip_helper;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement