Advertisement
Rochet2

Item&Player gossip scripts

Dec 21st, 2013
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.75 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. #define MENU_ID 123 // Our menuID used to match the sent menu to select hook (playerscript)
  4.  
  5. class example_PlayerGossip : public PlayerScript
  6. {
  7. public:
  8.     example_PlayerGossip() : PlayerScript("example_PlayerGossip") {}
  9.  
  10.     void OnPlayerLeaveCombat(Player* player)                                // Any hook here
  11.     {
  12.         player->PlayerTalkClass->ClearMenus();                              // Clears old options
  13.         player->ADD_GOSSIP_ITEM(0, "Morph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  14.         player->ADD_GOSSIP_ITEM(0, "Demorph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  15.                                                                             // SetMenuId must be after clear menu and before send menu!!
  16.         player->PlayerTalkClass->GetGossipMenu().SetMenuId(MENU_ID);        // Sets menu ID so we can identify our menu in Select hook. Needs unique number for the menu
  17.         player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID());
  18.         return false;
  19.     }
  20.  
  21.     void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
  22.     {
  23.         if (menu_id != MENU_ID) // Not the menu coded here? stop.
  24.             return;
  25.         player->PlayerTalkClass->ClearMenus();
  26.  
  27.         switch(action)
  28.         {
  29.         case GOSSIP_ACTION_INFO_DEF+1:
  30.             player->SetDisplayId(999);
  31.             break;
  32.         case GOSSIP_ACTION_INFO_DEF+2:
  33.             player->DeMorph();
  34.             break;
  35.         }
  36.         player->CLOSE_GOSSIP_MENU();
  37.     }
  38. };
  39.  
  40. void AddSC_example_PlayerGossip() // Add to scriptloader normally
  41. {
  42.     new example_PlayerGossip();
  43. }
  44.  
  45.  
  46. class example_ItemGossip : public ItemScript
  47. {
  48. public:
  49.     example_ItemGossip() : ItemScript("example_ItemGossip") {}
  50.  
  51.     bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) // Any hook here
  52.     {
  53.         player->PlayerTalkClass->ClearMenus();                              // Clears old options
  54.         player->ADD_GOSSIP_ITEM(0, "Morph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  55.         player->ADD_GOSSIP_ITEM(0, "Demorph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  56.         player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
  57.     }
  58.  
  59.     void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
  60.     {
  61.         player->PlayerTalkClass->ClearMenus();
  62.  
  63.         switch(action)
  64.         {
  65.         case GOSSIP_ACTION_INFO_DEF+1:
  66.             player->SetDisplayId(999);
  67.             break;
  68.         case GOSSIP_ACTION_INFO_DEF+2:
  69.             player->DeMorph();
  70.             break;
  71.         }
  72.         player->CLOSE_GOSSIP_MENU();
  73.     }
  74. };
  75.  
  76. void AddSC_example_ItemGossip() // Add to scriptloader normally
  77. {
  78.     new example_ItemGossip();
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement