Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "Player.h"
- #include "Creature.h"
- #include "ScriptedCreature.h"
- class TestGossip : public CreatureScript
- {
- public:
- TestGossip() : CreatureScript("TestGossip") { }
- static bool OnGossipHello(Player* player, Creature* creature)
- {
- AddGossipItemFor(player, 0, "Test item", 0, 1);
- SendGossipMenuFor(player, 1, creature);
- return true;
- }
- static bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- if(action == 0)
- {
- CloseGossipMenuFor(player);
- player->DealDamage(pPlayer, MaxHealth);
- }
- // code
- return true;
- }
- static bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
- {
- player->PlayerTalkClass->ClearMenus();
- // code
- return true;
- }
- struct MyAI : public ScriptedAI
- {
- MyAI(Creature* creature) : ScriptedAI(creature) { }
- bool GossipHello(Player* player) override
- {
- return OnGossipHello(player, me);
- }
- bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
- {
- uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
- uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
- return OnGossipSelect(player, me, sender, action);
- }
- bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override
- {
- uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
- uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
- return OnGossipSelectCode(player, me, sender, action, code);
- }
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new MyAI(creature);
- }
- };
- void AddSC_TestGossip()
- {
- new TestGossip;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement