Cocain
11-03-10, 02:24 PM
As to start of, this is the first Tutorial released from AuxProductions, mind that I rather do not retain flaming.
This guide will contain how to script simple NPC's. (A SIMPLE guide so.)
Let's begin,
As some of you might already know,
// gives the start of a so called 'comment'. Imo with
/* the only diffrence is the // only comments that line, whilst /* comments everything between the second /*. I'll show you.
//AuxProductions first guide.
/*Auxproductions first
guide
made by
Auxilium.*/
I've explained you the use of 'Comment Brackets' because it might come in handy when you're scripting an NPC or any other kind of boss.
Now, let's start the actual script.
We'll instantly use what I've just tought you guys, so.
/* My first script.
Credits to : Myself.
*/
Now, you've made the 'intro' and you've given yourself the credits which you want. Now we can start by scripting the actual boss.
Start Code.
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
Should always be underneath your credits.
Lines beginning with a hash sign (#) are directives for the preprocessor. They are not regular code lines with expressions but indications for the compiler's preprocessor.
^ Hope that explains what it the hashes do. This basicly includes the commands that you'll be using in the future to script the boss, which you're working on.
The red hashes should always be included !
Defining spells & the Npc's id.
As the title says, now we'll be doing basicly the same as the Local = lua function. You'll be defining the spells that the NPC will be able to cast/wont be able to cast. Imo for the ID (Meaning that the NPC his ID will be defined here.)
It's fairly easy, just watch :
Defining the NPC id.
//My First Boss.
#Define Auxilium 123
The 'Auxilium' will have to be replaced by the name of your own boss.
The 123 is the ID of the npc.
Defining the spells that the NPC will be using.
//Auxilium's Spells.
#Define Spellname Spellid.
You can do this as many times as you want.
The 'Spellname' stands for the actual spellname, for example Death Touch.
The Spellid stands for the ID of the spell that the NPC will be casting. (Can be found on wowhead; thotbott, ..)
Your script should now look like this :
/*****************************************
*All Credits go to Auxlium *
* *
* *
*Name Of Boss : X *
******************************************/
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
// X ID
#define Auxilium ID
// Auxilium Spells
#define SPELL SPELLID
The actual script.
When you have defined your spells, you can insert :
class AuxiliumAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(AuxiliumAI, ArcScriptBossAI);
AuxiliumAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
Underneath your spells / Npc id.
As you see, the 'Auxilium' = Name of the boss you recently defined, is inserted here in a AI form. You can just replace 'Auxilium' by the name of your boss.
As soon as you reached this point, you can start adding spells underneath the codeline you have just inserted, for example :
Adding spells.
class ZZZZZAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(ZZZZZZAI, ArcScriptBossAI);
ZZZZZZAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
AddSpell(Lolwoot, Target_Self, 35, 0, 10);
}
}
You can keep adding spell lines which you defined above like that as much as you want.
Your current script should look like this now :
/*****************************************
*All Credits go to Auxlium *
* *
* *
*Name Of Boss : X *
******************************************/
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
// X ID
#define Auxilium ID
// Auxilium Spells
#define SPELL SPELLID
class ZZZZZAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(ZZZZZZAI, ArcScriptBossAI);
ZZZZZZAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
AddSpell(Lolwoot, Target_Self, 35, 0, 15);
AddSpell(Rofl, Target_RandomPlayer, 45, 2, 10);
Let me explain what the AddSpell function did.
The
35 & 45 define the amount of chance it has to hit/proc.
0 & 2 define the Casttime. In seconds.
10 & 15 will define the interval. Meaning that it'll cast spell X each 10 & 15 seconds.
Adding Emotes.
Same as when you're adding spells, you'll be using the Add.. function.
Example :
AddEmote(Event_OnCombatStart, "Auxilium's guide.", Text_Yell, 0);
Again,
The orange part defines when he says it. (This can be variable from OnCombatStart / OnDied / OnTargetDied / OnLeaveCombat)
& The '0' at the end, is reffering to the SoundID that it'll play when your npc announced the emote.
Phases.
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
}
Is the way on how to define correct phases.
You can add phases on similar ways as with this one,
for example :
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
if(GetHealthPercent()<=80) //TestPhase2
{
AddSpell(Y)
When you're done with adding phases, you can just add a
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
To the end of the phase part.
Example :
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
}
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
Now, you've learned on how to add phases, emotes & spells. You're almost done with your script now, just end the script by using :
void SetupAuxilium(ScriptMgr* pScriptMgr)
{
pScriptMgr->register_creature_script(Auxilium, &AuxiliumAI::Create);
}
I hope that you enjoyed my guide, if you have any questions please post them here and I'll reply onto them as soon as possible.
This guide will contain how to script simple NPC's. (A SIMPLE guide so.)
Let's begin,
As some of you might already know,
// gives the start of a so called 'comment'. Imo with
/* the only diffrence is the // only comments that line, whilst /* comments everything between the second /*. I'll show you.
//AuxProductions first guide.
/*Auxproductions first
guide
made by
Auxilium.*/
I've explained you the use of 'Comment Brackets' because it might come in handy when you're scripting an NPC or any other kind of boss.
Now, let's start the actual script.
We'll instantly use what I've just tought you guys, so.
/* My first script.
Credits to : Myself.
*/
Now, you've made the 'intro' and you've given yourself the credits which you want. Now we can start by scripting the actual boss.
Start Code.
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
Should always be underneath your credits.
Lines beginning with a hash sign (#) are directives for the preprocessor. They are not regular code lines with expressions but indications for the compiler's preprocessor.
^ Hope that explains what it the hashes do. This basicly includes the commands that you'll be using in the future to script the boss, which you're working on.
The red hashes should always be included !
Defining spells & the Npc's id.
As the title says, now we'll be doing basicly the same as the Local = lua function. You'll be defining the spells that the NPC will be able to cast/wont be able to cast. Imo for the ID (Meaning that the NPC his ID will be defined here.)
It's fairly easy, just watch :
Defining the NPC id.
//My First Boss.
#Define Auxilium 123
The 'Auxilium' will have to be replaced by the name of your own boss.
The 123 is the ID of the npc.
Defining the spells that the NPC will be using.
//Auxilium's Spells.
#Define Spellname Spellid.
You can do this as many times as you want.
The 'Spellname' stands for the actual spellname, for example Death Touch.
The Spellid stands for the ID of the spell that the NPC will be casting. (Can be found on wowhead; thotbott, ..)
Your script should now look like this :
/*****************************************
*All Credits go to Auxlium *
* *
* *
*Name Of Boss : X *
******************************************/
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
// X ID
#define Auxilium ID
// Auxilium Spells
#define SPELL SPELLID
The actual script.
When you have defined your spells, you can insert :
class AuxiliumAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(AuxiliumAI, ArcScriptBossAI);
AuxiliumAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
Underneath your spells / Npc id.
As you see, the 'Auxilium' = Name of the boss you recently defined, is inserted here in a AI form. You can just replace 'Auxilium' by the name of your boss.
As soon as you reached this point, you can start adding spells underneath the codeline you have just inserted, for example :
Adding spells.
class ZZZZZAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(ZZZZZZAI, ArcScriptBossAI);
ZZZZZZAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
AddSpell(Lolwoot, Target_Self, 35, 0, 10);
}
}
You can keep adding spell lines which you defined above like that as much as you want.
Your current script should look like this now :
/*****************************************
*All Credits go to Auxlium *
* *
* *
*Name Of Boss : X *
******************************************/
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
// X ID
#define Auxilium ID
// Auxilium Spells
#define SPELL SPELLID
class ZZZZZAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(ZZZZZZAI, ArcScriptBossAI);
ZZZZZZAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
AddSpell(Lolwoot, Target_Self, 35, 0, 15);
AddSpell(Rofl, Target_RandomPlayer, 45, 2, 10);
Let me explain what the AddSpell function did.
The
35 & 45 define the amount of chance it has to hit/proc.
0 & 2 define the Casttime. In seconds.
10 & 15 will define the interval. Meaning that it'll cast spell X each 10 & 15 seconds.
Adding Emotes.
Same as when you're adding spells, you'll be using the Add.. function.
Example :
AddEmote(Event_OnCombatStart, "Auxilium's guide.", Text_Yell, 0);
Again,
The orange part defines when he says it. (This can be variable from OnCombatStart / OnDied / OnTargetDied / OnLeaveCombat)
& The '0' at the end, is reffering to the SoundID that it'll play when your npc announced the emote.
Phases.
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
}
Is the way on how to define correct phases.
You can add phases on similar ways as with this one,
for example :
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
if(GetHealthPercent()<=80) //TestPhase2
{
AddSpell(Y)
When you're done with adding phases, you can just add a
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
To the end of the phase part.
Example :
void AIUpdate()
{
if(GetHealthPercent()<=90) //TestPhase
{
AddSpell(X)
}
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
Now, you've learned on how to add phases, emotes & spells. You're almost done with your script now, just end the script by using :
void SetupAuxilium(ScriptMgr* pScriptMgr)
{
pScriptMgr->register_creature_script(Auxilium, &AuxiliumAI::Create);
}
I hope that you enjoyed my guide, if you have any questions please post them here and I'll reply onto them as soon as possible.