Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptMgr.h"
  2. #include "Player.h"
  3. #include "Creature.h"
  4. #include "ScriptedCreature.h"
  5.  
  6. class TestGossip : public CreatureScript
  7. {
  8. public:
  9.     TestGossip() : CreatureScript("TestGossip") { }
  10.  
  11.     static bool OnGossipHello(Player* player, Creature* creature)
  12.     {
  13.         AddGossipItemFor(player, 0, "Test item", 0, 1);
  14.         SendGossipMenuFor(player, 1, creature);
  15.         return true;
  16.     }
  17.  
  18.     static bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  19.     {
  20.         player->PlayerTalkClass->ClearMenus();
  21.         if(action == 0)
  22.         {
  23.              CloseGossipMenuFor(player);
  24.              player->DealDamage(pPlayer, MaxHealth);
  25.         }
  26.         // code
  27.         return true;
  28.     }
  29.  
  30.     static bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
  31.     {
  32.         player->PlayerTalkClass->ClearMenus();
  33.         // code
  34.         return true;
  35.     }
  36.  
  37.     struct MyAI : public ScriptedAI
  38.     {
  39.         MyAI(Creature* creature) : ScriptedAI(creature) { }
  40.         bool GossipHello(Player* player) override
  41.         {
  42.             return OnGossipHello(player, me);
  43.         }
  44.         bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
  45.         {
  46.             uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
  47.             uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
  48.             return OnGossipSelect(player, me, sender, action);
  49.         }
  50.         bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override
  51.         {
  52.             uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
  53.             uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
  54.             return OnGossipSelectCode(player, me, sender, action, code);
  55.         }
  56.     };
  57.  
  58.     CreatureAI* GetAI(Creature* creature) const override
  59.     {
  60.         return new MyAI(creature);
  61.     }
  62. };
  63.  
  64. void AddSC_TestGossip()
  65. {
  66.     new TestGossip;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement