Advertisement
EmuDevs

CreatureScript ScriptedAI Template

Mar 30th, 2016
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. /*
  2.     EmuDevs - (http://emudevs.com)
  3.     Use this as your template. Make sure to point credits towards ED.
  4. */
  5.  
  6. class npc_tut_ai : public CreatureScript // npc_tut_ai - Class constructor, name this anything that doesn't conflict with another name
  7. {
  8. public:
  9.     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
  10.  
  11.     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
  12.     {
  13.         npc_tutAI(Creature* creature) : ScriptedAI(creature) { } // Setting up
  14.  
  15.         void Reset() override // This will be called once the npc resets. (OnSpawn, OnCombatLeave, etc)
  16.         {
  17.         }
  18.  
  19.         void UpdateAI(uint32 diff) override // This function updates every 100 or 1000 (I believe) and is used for the timers, etc
  20.         {
  21.         }
  22.  
  23.         void EnterCombat(Unit* /*target*/) override // This calls when the npc enters combat
  24.         {
  25.         }
  26.  
  27.         void JustDied(Unit* /*killer*/) override // This calls when the npc dies
  28.         {
  29.         }
  30.  
  31.         void KilledUnit(Unit* /*victim*/) override // This calls when the npc kills a unit
  32.         {
  33.         }
  34.     };
  35.  
  36.     CreatureAI* GetAI(Creature* creature) const override // We then return new 'npc_tutAI' so the script will load and work ingame
  37.     {
  38.         return new npc_tutAI(creature);
  39.     }
  40. };
  41.  
  42. void AddSC_ai_tutorial() // This is your ScriptLoader.cpp setup function
  43. {
  44.     new npc_tut_ai; // Call any new classes here as 'new classname;'
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement