Advertisement
Rochet2

Example gossip TC 3.3.5

Nov 28th, 2017
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include "Creature.h"
  2. #include "Player.h"
  3. #include "ScriptMgr.h"
  4. #include "ScriptedGossip.h"
  5. #include "ScriptedCreature.h"
  6. #include "Define.h"
  7.  
  8. class example : public CreatureScript
  9. {
  10. public:
  11.     example() : CreatureScript("example") { }
  12.  
  13.     struct example_AI : public ScriptedAI
  14.     {
  15.         example_AI(Creature* creature) : ScriptedAI(creature) { }
  16.  
  17.         bool GossipHello(Player* player) override
  18.         {
  19.             if (me->IsQuestGiver())
  20.                 player->PrepareQuestMenu(me->GetGUID());
  21.             AddGossipItemFor(player, 0, "Example 1 - Show main menu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  22.             AddGossipItemFor(player, 0, "Example 2 - Exit", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
  23.             SendGossipMenuFor(player, GOSSIP_MENU_I_HAVE_LONG_KNOWN, me->GetGUID());
  24.             return true;
  25.         }
  26.  
  27.         bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
  28.         {
  29.             uint32 const sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
  30.             uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
  31.             ClearGossipMenuFor(player);
  32.            
  33.             if (sender == GOSSIP_SENDER_MAIN)
  34.             {
  35.                 if (action == GOSSIP_ACTION_INFO_DEF + 1)
  36.                 {
  37.                     GossipHello(player);
  38.                 }
  39.                 if (action == GOSSIP_ACTION_INFO_DEF + 2)
  40.                 {
  41.                     CloseGossipMenuFor(player);
  42.                 }
  43.             }
  44.             return true;
  45.         }
  46.     };
  47.  
  48.     CreatureAI* GetAI(Creature* creature) const override
  49.     {
  50.         return new example_AI(creature);
  51.     }
  52. };
  53.  
  54. void AddSC_example()
  55. {
  56.     new example();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement