Advertisement
EmuDevs

EmuDevs - CreatureScript ScriptedAI Template

May 31st, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *       EmuDevs - (http://emudevs.com)
  7. */
  8.  
  9. class npc_tut_ai : public CreatureScript // npc_tut_ai - Class constructor, name this anything that doesn't conflict with another name
  10. {
  11. public:
  12.     npc_tut_ai() : CreatureScript("npc_tut_ai") { } // npc_tut_ai, should be the same as class npc_tut_ai -- CreatureScript("npc_tut_ai") - This is your 'ScriptName' that you will assign in your database
  13.  
  14.     struct npc_tutAI : public ScriptedAI // npc_tutAI - Structure name. This can be anything that doesn't conflict with your class constructor. 'public ScriptedAI', We're using ScriptedAI, so we call it
  15.     {
  16.         npc_tutAI(Creature* creature) : ScriptedAI(creature) { } // Setting up
  17.  
  18.         void Reset() // This will be called once the npc resets. (OnSpawn, OnCombatLeave, etc)
  19.         {
  20.         }
  21.  
  22.         void UpdateAI(uint32 diff) // This function updates every 100 or 1000 (I believe) and is used for the timers, etc
  23.         {
  24.         }
  25.  
  26.         void EnterCombat(Unit* /*target*/) // This calls when the npc enters combat
  27.         {
  28.         }
  29.  
  30.         void JustDied(Unit* /*killer*/) // This calls when the npc dies
  31.         {
  32.         }
  33.  
  34.         void KilledUnit(Unit* /*victim*/) // This calls when the npc kills a unit
  35.         {
  36.         }
  37.     };
  38.  
  39.     CreatureAI* GetAI(Creature* creature) const // We then return new 'npc_tutAI' so the script will load and work ingame
  40.     {
  41.         return new npc_tutAI(creature);
  42.     }
  43. };
  44.  
  45. void AddSC_ai_tutorial() // This is your ScriptLoader.cpp setup function
  46. {
  47.     new npc_tut_ai(); // Call any new classes here as 'new classname();'
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement