Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- class gossip_layout : public CreatureScript
- {
- public:
- gossip_layout() : CreatureScript("gossip_layout") { }
- bool OnGossipHello(Player * player, Creature * creature) // This menu will show before the 'OnGossipSelect'
- {
- if(player->isInCombat())
- return false; // If player is in combat, we don't allow it to continue
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Action 1", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID()); // Showing the menu to the player
- return true; // Returning true telling us to continue
- }
- bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 actions)
- {
- player->PlayerTalkClass->ClearMenus(); // Clearing duplicate menus
- if(sender != GOSSIP_SENDER_MAIN)
- return false;
- switch(actions) // Switching actions, allowing us to use cases
- {
- case GOSSIP_ACTION_INFO_DEF+1: // "Action 1"
- // Do actions here :/
- creature->CastSpell(player, 1); // Replace 1 with a correct SpellId
- creature->setFaction(16); // Faction 16 is an enemy
- creature->AI()->AttackStart(player); // Attacking the player
- break; // This allows us to stop, not allowing to go through all of your menus that doesn't have breaks
- case GOSSIP_ACTION_INFO_DEF+2: // "Nevermind"
- player->PlayerTalkClass->SendCloseGossip(); // Closing the gossip menu
- break;
- }
- return true;
- }
- };
- void AddSC_npc_layout()
- {
- new gossip_layout;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement