Advertisement
EmuDevs

EmuDevs: TrinityCore: Make a trigger give a player something

Aug 7th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. /*
  2.     EmuDevs NPC Tutorial
  3.     http://emudevs.com
  4.     TrinityCore Tutorial
  5. */
  6.  
  7. class npc_tutorial : public CreatureScript
  8. {
  9. public:
  10.     npc_tutorial() : CreatureScript("npc_tutorial") { }
  11.  
  12.     struct npc_tutorialAI : public ScriptedAI
  13.     {
  14.         npc_tutorialAI(Creature* creature) : ScriptedAI(creature) { }
  15.  
  16.         uint32 tickTimer;
  17.  
  18.         void Reset()
  19.         {
  20.             tickTimer = 1000;
  21.         }
  22.  
  23.         void UpdateAI(uint32 diff)
  24.         {
  25.             if (tickTimer <= diff)
  26.             {
  27.                 if (Player* player = me->SelectNearestPlayer(10.0f))
  28.                 {
  29.                     if (player->HasAtLoginFlag(AT_LOGIN_FIRST))
  30.                         player->learnSpell(30000, true);
  31.                 }
  32.             }
  33.             else
  34.                 tickTimer -= diff;
  35.     }
  36.     };
  37.  
  38.     CreatureAI* GetAI(Creature* creature) const
  39.     {
  40.         return new npc_tutorialAI(creature);
  41.     }
  42. };
  43.  
  44. void AddSC_Tutorial()
  45. {
  46.     new npc_tutorial;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement