Advertisement
EmuDevs

EmuDevs: TrinityCore - Get nearest creature position

Sep 4th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *            http://emudevs.com
  7. */
  8.  
  9. class npc_tutorial_gossip : public CreatureScript
  10. {
  11. public:
  12.     npc_tutorial_gossip() : CreatureScript("npc_tutorial_gossip") { }
  13.  
  14.     bool OnGossipHello(Player* player, Creature* creature)
  15.     {
  16.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Do Action", GOSSIP_SENDER_MAIN, 1);
  17.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  18.         return true;
  19.     }
  20.  
  21.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
  22.     {
  23.         player->PlayerTalkClass->ClearMenus();
  24.         if (actions == 1)
  25.         {
  26.             float x, y, z;
  27.             if (Creature* target = creature->FindNearestCreature(30000, 30.0f, true))
  28.             {
  29.                 target->GetPosition(x, y, z);
  30.                 target->GetMotionMaster()->MovePoint(1, x + rand() % 5, y - rand() % 10, z);
  31.                 target->SetHealth(300000);
  32.             }
  33.         }
  34.         return true;
  35.     }
  36. };
  37.  
  38. void AddSC_gossip_tut()
  39. {
  40.     new npc_tutorial_gossip;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement