Advertisement
Easelm

Untitled

May 28th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. class gossip_layout : public CreatureScript
  4. {
  5.    public:
  6.        gossip_layout() : CreatureScript("gossip_layout") { }
  7.  
  8.        bool OnGossipHello(Player * player, Creature * creature) // This menu will show before the 'OnGossipSelect'
  9.        {
  10.            if(player->isInCombat())
  11.                return false; // If player is in combat, we don't allow it to continue
  12.  
  13.            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Action 1", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  14.            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  15.            player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID()); // Showing the menu to the player
  16.            return true; // Returning true telling us to continue
  17.        }
  18.  
  19.        bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 actions)
  20.        {
  21.            player->PlayerTalkClass->ClearMenus(); // Clearing duplicate menus
  22.            if(sender != GOSSIP_SENDER_MAIN)
  23.                return false;
  24.  
  25.            switch(actions) // Switching actions, allowing us to use cases
  26.            {
  27.                case GOSSIP_ACTION_INFO_DEF+1: // "Action 1"
  28.                    // Do actions here :/
  29.                    creature->CastSpell(player, 1); // Replace 1 with a correct SpellId
  30.                    creature->setFaction(16); // Faction 16 is an enemy
  31.                    creature->AI()->AttackStart(player); // Attacking the player
  32.                    break; // This allows us to stop, not allowing to go through all of your menus that doesn't have breaks
  33.  
  34.                case GOSSIP_ACTION_INFO_DEF+2: // "Nevermind"
  35.                    player->PlayerTalkClass->SendCloseGossip(); // Closing the gossip menu
  36.                    break;
  37.            }
  38.            return true;
  39.        }
  40. };
  41.  
  42. void AddSC_npc_layout()
  43. {
  44.     new gossip_layout;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement