How to script a npc in c++ menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to script a npc in c++

    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:
    Code:
    void AIUpdate()
    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

    How to script a npc in c++
  2. #2
    2dgreengiant's Avatar ★ Elder ★


    Reputation
    1190
    Join Date
    Feb 2007
    Posts
    7,129
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great guide +11
    If you need me you have my skype, if you don't have my skype then you don't need me.

  3. #3
    [pwn]age's Avatar Member
    Reputation
    56
    Join Date
    Jul 2008
    Posts
    102
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice job slade. +rep

  4. #4
    y2kss66's Avatar Member
    Reputation
    104
    Join Date
    Jan 2008
    Posts
    778
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    fantastic guide slade. +RepX2

  5. #5
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks allot guys

  6. #6
    Glorianglorre's Avatar Active Member
    Reputation
    40
    Join Date
    Feb 2009
    Posts
    340
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man +Rep

  7. #7
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your welcome

  8. #8
    alj03's Avatar Contributor
    Reputation
    91
    Join Date
    Feb 2008
    Posts
    1,103
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Only one step. :P

    Anyway +Repzorz.
    Death to all but Metal.

  9. #9
    Sounddead's Avatar Contributor
    Reputation
    160
    Join Date
    Sep 2007
    Posts
    1,126
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realy don't understand why people use the pre-processor like that. Why would you define something like a spell like that?

    Instead of #define BLAH 123219

    Why not just make a new constant variable that holds that number..? Using the pre-processor like that is not good coding practice.

    I live in a shoe

  10. #10
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats how i learned lol so thats how i do it xD

  11. #11
    svedin's Avatar Contributor
    Reputation
    124
    Join Date
    Jun 2008
    Posts
    557
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice guide maybe i will try to script one in C++ ^^

    Oh snap forgot, +rep x2

  12. #12
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks glad you liked it

  13. #13
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    +Rep x3 Even though i prefer normal CreatureAI =D its a good guide

    glad to see some people still use arc as well
    Lunar Gaming - Reaching For The Stars

  14. #14
    Cripto's Avatar Active Member
    Reputation
    33
    Join Date
    Jul 2008
    Posts
    104
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice +Rep this is a good guide

    Aka Milation

  15. #15
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks allot

Page 1 of 2 12 LastLast

Similar Threads

  1. How to make a npc talk at a perent hp (scripting)
    By Despara in forum WoW EMU Guides & Tutorials
    Replies: 9
    Last Post: 01-31-2009, 07:46 PM
  2. How to get a NPC's Displayid and Gameobject's Spawn ID (ingame)
    By taryon in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 03-28-2008, 04:15 PM
  3. {PICS}How to make a NPC Have Armor or a Weapon
    By Dragonscale in forum WoW EMU Guides & Tutorials
    Replies: 20
    Last Post: 12-29-2007, 05:34 AM
  4. How to create custom NPC's the easy way!Works for all versions!
    By MissMurder in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 12-05-2007, 08:06 PM
  5. How do I make npcs?
    By noobert in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 09-04-2007, 02:38 PM
All times are GMT -5. The time now is 02:24 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search