Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 4 of 4
  1. #1
    Contributor
    Cocain's Avatar
    Join Date
    Mar 2010
    Posts
    208
    Post Thanks / Like
    Rep Power
    16
    Reputation
    92

    [C++] Scripting an Npc/Boss.


    Register to remove this ad
    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,
    Code:
    //
    gives the start of a so called 'comment'. Imo with
    Code:
    /*
    the only diffrence is the // only comments that line, whilst /* comments everything between the second /*. I'll show you.

    Code:
    //AuxProductions first guide.
    Code:
    /*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.

    Code:
    /* 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.

    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.
    Code:
    //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.
    Code:
    //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 :

    Code:
    /*****************************************
    *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 :

    Code:
    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.

    Code:
    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 :

    Code:
    /*****************************************
    *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 :

    Code:
    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.

    Code:
    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 :



    Code:
    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

    Code:
            ParentClass::AIUpdate();
            ParentClass::AIUpdate();
    }
    };
    To the end of the phase part.

    Example :
    Code:
    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 :

    Code:
    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.


    › See More: [C++] Scripting an Npc/Boss.



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Banned

    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    652
    Post Thanks / Like
    Rep Power
    0
    Reputation
    103
    Thanks for the guide, will be sure to test it shortly.

  4. #3
    Beginner

    Join Date
    Jul 2011
    Posts
    1
    Post Thanks / Like
    Rep Power
    14
    Reputation
    1
    Nice guide and is really easy for begginers to become Devs

    The problem is, I have a trinitycore server, fresh installed is not a repack, only question is where i will put my script to test it in game ?
    Last edited by moteofsun; 01-08-11 at 02:37 AM.

  5. #4
    Beginner

    Join Date
    Apr 2009
    Posts
    1
    Post Thanks / Like
    Rep Power
    16
    Reputation
    1

    Register to remove this ad
    there no need to add double call methods, i mean for example
    Code:
    ParentClass::AIUpdate();
    ParentClass::AIUpdate();
    need to put only one

 

 

Visitors found this page by searching for:

wow npc script c

C boss script

wow boss scripts

wow c scriptshow to script wow bossesTrinity Boss Scriptwow c boss scriptcomment scripter un boss wowhow to script bosses in wowtrinity custom bosshow to script a boss in wowtrinity boss scriptingWoW boss script C c wow scriptwow trinity boss scriptinserting boss script trinitywow boss scripten c wow c scriptscript c wowc boss scriptshow to script npc trinitywow boss scripts c trinity npc cast spelltrinity c bossworld of warcraft boss scriptsCustom boss trinitytrinity bossscripts schreibenhow to make a npc to cast spell c script boss trinityc script trinityNPC BOSScustom boss c trinityc script bosses cast spell onc coding npchow to script a bosscomment script un boss wowscript npc trinitymangos boss scriptingc boss trinitycustom boss trinitycoretrinity boss scripts how to script a wow bosswow boss scriptingscripting bosses in wowWoW how to script a bosshow to script boss with c wowscript boss wowHow to Script a Phased Boss With c how to script c npcHow to make a boss script C for Trinity
SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 12:20 AM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org