Hey there i decided to make this tutorial on scripting npcs in c++ becuase c++ has a lot more function that lua does not, but this is just a basic guide on how to just do things like percentages and spells and make him yell stuff so here it goes.
Step 1
First we need to make a new .cpp file in visualc++ like so:
and
now the code part, first thought the basics to right notes to yourself or anything like that you want to go // so for example:
Code:
//########################
// Made by ##
//slade1000 of ac web ##
// ##
// ##
//########################
each line of comments your write has be first followed by // just remember that.
Now for are includes, you have to add these because what they are scripts made by arc emu with all the commands that you can use without these your script is basically useless so add this to the begging of your script:
Code:
#include "StdAfx.h"
#include "Setup.h"
#include "Base.h"
Now below that we can start are defines. The defines are when you define what you are going to use in your script this includes spells and the npc that your are scripting this script for.
So first thing is to define your boss like this
Code:
//Boss
#define Slayer 34253
#define tells the script that you are defining something that you will use later Slayer is the name of my npc and 34253 is the id of the npc itself. I like to put the //boss over the define to remind myself what it is.
Now for the spells this is sort of a tricky part there are a few key things that you want to make sure you do and there is also different ways you can do this but i will be teaching you the easiest way.
so you want to start out like this
Code:
// Spells
#define Cleave 37476
You can add as many spells as you like i just added cleave as an example makesure that when you have a spell like this:
Code:
#define Dragons Breath 42949
you want to make sure that the dragons breath is together like so:
Code:
#define DragonsBreath 42949
or the the script will not compile right.
ok when you are done adding all the spells you want you can also define phases for example:
Code:
//Phase 1
#define SeedofCorruption 47836
this will be used for a later point in the script now the central part of the script.
you start with this
Code:
class yourcreaturenamehereAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(yourcreaturenamehereAI, ArcScriptBossAI);
yourcreaturenamehereAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
then when you have that you start scripting the npc like so:
Code:
{
AddSpell(BlastWave, Target_Current, 15, 0, 40);
you only have to add the { once at teh very beggining of your adding spells and once at the very end.
the 15 is the chance it has to hit and the 40 is the the cool down so 4 seconds(correct me if im wrong here not totally sure about that).
so mine would go somthing like this
Code:
AddSpell(BlastWave, Target_Current, 15, 0, 40);
AddSpell(Blizzard, Target_RandomPlayer, 15, 1.5, 20);
AddSpell(BlastWave, Target_RandomPlayer, 15, 0, 20);
AddSpell(DragonsBreath, Target_ClosestPlayer, 20, 0, 16, 0, 0, false, "haha getting warm isnt it", Text_Yell, 10290);
AddSpell(Cleave, Target_Current, 10, 0, 2);
you can also add text after he casts a spell by adding a
Code:
0, 0, false, "yourtexthere", Text_Yell, 10290);
Now we add are emotes
Code:
AddEmote(Event_OnCombatStart, "I will kill you then the peasents", Text_Yell, 10289);
AddEmote(Event_OnTargetDied, "One down", Text_Yell, 11250);
AddEmote(Event_OnTargetDied, "Another one bites the dust", Text_Yell, 11252);
AddEmote(Event_OnDied, "What? How did this........Gahh", Text_Yell, 10291);
}
thats what mine looked like. It looks sort of like lua doesnt it and make sure to add the closing } that tells the script that you are done with that section now we go into the phases part of the script: so we have to start with a:
and then we have somthing like this:
Code:
{
if(GetHealthPercent()<=60)//phase 1
{
AddSpell(SeedofCorruption, Target_SecondMostHated, 90, 0, 20);
}
the script reconizes that the bosses health is at 60% and activates seed of corruption on the second most hated of the group make sure you add your opening and closing brackets. you can add as many phases as you wish.
now make sure after you are done with your phases you add this
Code:
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
this will update the interface and tell the script that it is done with its phases.
and then at the last part of your script you want to add this
Code:
void SetupWorldBoss(ScriptMgr* pScriptMgr)
{
pScriptMgr->register_creature_script(Slayer, &yournpcnamehereAI::Create);
}
and thats it you made your first c++ script here is an example of how mine turned out
Code:
//########################
// Made by ##
//slade1000 of ac web ##
// ##
// ##
//########################
#include "StdAfx.h"
#include "../Setup.h"
#include "../Base.h"
//Boss
#define Slayer 34253
// Spells
#define Cleave 37476
#define Blast Wave 42945
#define Dragons Breath 42949
#define Blizzard 42940
//Phase 1
#define Seed of Corruption 47836
class SlayerAI : public ArcScriptBossAI
{
ARCSCRIPT_FACTORY_FUNCTION(SlayerAI, ArcScriptBossAI);
SlayerAI(Creature* pCreature) : ArcScriptBossAI(pCreature)
{
AddSpell(Blast Wave, Target_Current, 15, 0, 40);
AddSpell(Blizzard, Target_RandomPlayer, 15, 1.5, 20);
AddSpell(Blast Wave, Target_RandomPlayer, 15, 0, 20);
AddSpell(Dragons Breath, Target_ClosestPlayer, 20, 0, 16, 0, 0, false, "haha getting warm isnt it", Text_Yell, 10290);
AddSpell(Cleave, Target_Current, 10, 0, 2);
AddEmote(Event_OnCombatStart, "I will kill you then the peasents", Text_Yell, 10289);
AddEmote(Event_OnTargetDied, "One down", Text_Yell, 11250);
AddEmote(Event_OnTargetDied, "Another one bites the dust", Text_Yell, 11252);
AddEmote(Event_OnDied, "What? How did this........Gahh", Text_Yell, 10291);
}
void AIUpdate()
{
if(GetHealthPercent()<=60)//phase 1
{
AddSpell(Seed of Corruption, Target_SecondMostHated, 90, 0, 20);
}
if(GetHealthPercent()<=20) // Phase 2
{
AddSpell(Seed of Corruption, Target_RandomPlayer, 90, 0, 20);
}
ParentClass::AIUpdate();
ParentClass::AIUpdate();
}
};
void SetupWorldBoss(ScriptMgr* pScriptMgr)
{
pScriptMgr->register_creature_script(Slayer, &SlayerAI::Create);
}
thanks for reading this tutorial i hope you enjoyed it if there is anything i forgot please tell me and i will add it to the tutorial
here is the link to tell you how your compile this script by qq:[TuT- With Pics]: How to compile custom Boss/Npc C++ files. - AC Web
any questions? post here and i will try and answer then for you