Stepping Into C++ menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    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)

    Stepping Into C++

    Stepping into C++ by Mager1794

    Table of Contents

    1. Introduction to C++ or Introduction to Suicide
    2. Writing Gossip Scripts
    3. Game Object AI...
    4. Artificial Intelligence <not as detailed but will update>
    5. Playing with Hooks... Is it dangerous?
    6. C++ Command info
    7. Credits

    1. Introduction to C++ or Introduction to Suicide

    In this guide im gonna help you learn C++. C++ is an easy language just
    everyone needs there stepping stone into it. So here is where i come in
    im teaching everything that i learned on my own to step into C++ and makin
    it easier for you.
    Follow this tutorial to make a project http://www.mmowned.com/forums/emulator-server-guides/133969-how-compile-dll-video.html
    dont do the DLL compiling part just get your self a project file fully set up with the Setup.h and Setup.cpp

    2. Writing Gossip Scripts

    Now C++ Gossip Scripts is kinda like LUA Gossip scripts only im good at the C++
    ones lol
    well lets start with a basic Gossip Script a simple WarpNPC
    Ok well every Gossip Script must begin like this

    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    #ifdef WIN32
    #pragma warning(disable:4305)
    #endif
     
    class SCRIPT_DECL GlobalNPC : public GossipScript
    {
    public:
     void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
     void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
     void GossipEnd(Object * pObject, Player* Plr);
    void Destroy()
    {
    delete this;
    }
    };
    notice "class SCRIPT_DECL GlobalNPC : public" creates a new class if your
    using a C++ editor programm you can probably click a"-" button that hides it
    every gossip script requires this code above but note the "GlobalNPC" thats the
    name of it you can change that to what ever you wish as long as you change the
    setup at the bottom which we will get to later
    now lets add this to our script
    Code:
    void GlobalNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
     {
         GossipMenu *Menu;
         objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
     
    if(AutoSend)
               Menu->SendTo(Plr);
     }
    now i know thats practically completely empty this si the part where we get to
    add choices to our script lets make it look like this
    Code:
    void GlobalNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
     {
         GossipMenu *Menu;
         objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
    Menu->AddItem(5, "Shattrath", 1);
    if(AutoSend)
             Menu->SendTo(Plr);
     }
    Note how that looks think do you think you understand it good..im telling you
    what it means anyway
    Menu->AddItem([Put a random number between 1 and 10 this doesn't matter], "[Name of the Selection], [What case it activates when click])
    Dont edit anything until we finish this section
    Code:
    void GlobalNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
     {
    Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
    if(pCreature==NULL)
    return;
         GossipMenu * Menu;
         switch(IntId)
         {
         case 0:
    GossipHello(pObject, Plr, true);
         break;
    }
    }
    ok lets make it look like this
    Code:
     
    void GlobalNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
     {
    Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
    if(pCreature==NULL)
    return;
         GossipMenu * Menu;
         switch(IntId)
         {
         case 0:
    GossipHello(pObject, Plr, true);
         break;
    case 1: // Add some random comment after a //
    Plr->
    break;
    }
    }
    the Plr is basically saying "Person who clicked it"
    now Add this after it [no spaces] EventTeleport(mapid, x, y, z);
    now change out the (mapid, x, y, z,); with what ever you wish
    or to make it shattrath do this (530, -1887.510010, 5359.379883, -12.427300);
    Great now were only learning so write now what i want you to do is go out and write your own script for a warp NPC
    close the NPC Script off like this
    Code:
    void GlobalNPC::GossipEnd(Object * pObject, Player* Plr)
    {
     GossipScript::GossipEnd(pObject, Plr);
    }
    void SetupGlobalNPC(ScriptMgr * mgr)
    {
    GossipScript * gs = (GossipScript*) new GlobalNPC();
     mgr->register_gossip_script([NPCID], gs);
    }
    look at "void SetupGlobalNPC(ScriptMgr * mgr)" you should have those setup files made for this to work if not in setup.cpp
    make it like this
    void SetupGlobalNPC(ScriptMgr * mgr)
    and setup.h like this
    SetupGlobalNPC(mgr)
    that ends our gossip NPC scripts chapter remember theres so much more you can
    do with gossip scripts just play around with it

    3. Game Object AI...

    Game Object AI isn't quite as long as Gossip Script and well truly not much
    more advanced
    im gonna give you a full gameobject script and i want you to study it and then
    i will show you how to make them
    Code:
    class TutorialPortal : public GameObjectAIScript
    {
    public:
           TutorialPortal(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
           void OnActivate(Player * Plr)
           {
                 Plr->SafeTeleport(1, 0, 4627.442383, -3831.523438, 943.386353, 1.220509);
           }
           static GameObjectAIScript *Create(GameObject * GO) { return new TutorialPortal(GO); }
    };
    GameObjectAIScript * create_go[GOID](GameObject * GO) { return new TutorialPortal(GO); }
    void SetupPortalHandler(ScriptMgr * mgr)
    {
       mgr->register_gameobject_script([GOID], &TutorialPortal::Create);
    }
    now you see where pPlayer->SafeTeleport(1, 0, 4627.442383, -3831.523438, 943.386353, 1.220509); is
    simply edit that to the (1, 0, 4627.442383, -3831.523438, 943.386353, 1.220509); to your custom portals
    (map, zone, x, y, z, o)
    now say you want to limit things to certain people like maybe make guild house compile
    you can easily make if functions like this

    Code:
    if(Plr->GetGUID() == 1)
    {
    after the "{"
    simple start writing code like Plr->SafeTeleport
    and stuff
    lets look at the registering
    Code:
    void SetupPortalHandler(ScriptMgr * mgr)
    {
       mgr->register_gameobject_script([GOID], &TutorialPortal::Create);
    }
    its a gameobject script this time so its not gossip scripts like the last one
    as long as you do the setups right and the base of the script right then the chances of errors will be highly slim
    in setup.h add this under the one in there already
    SetupGlobalNPC(mgr)
    do the same with setup.cpp
    void SetupGlobalNPC(ScriptMgr * mgr)
    and whala your done with a gameobject script

    4. Artificial Intelligence

    ok this section is AI i absolutely suck at this but when i get better i will fil this in with info or if someone
    would like to fill it in for me just contact me on MSN at [email protected] ill put your credits and everything
    ill even give a link to give you +Rep

    5. Playing with Hooks... Is it dangerous?

    ok well server hooks are where most people get all there cool stuff like insta 70 and gold on startup and more so
    im gonna give you a server hook script taht i wrote and give you every server hook there is for you to look at
    [in the C++ Commands chapter]
    ok lets begin
    Code:
    void OnLoginForFirstTime(Player* plr)
    {
    now that name trully has no effect whatso ever other than thats what i wil register it as
    what really matters is the server hook it gets registered as lets continue make it like this
    Code:
    void OnLoginForFirstTime(Player* plr)
    {
    plr->BroadcastMessage(" Welcome to [Server name] %s", plr->GetName()
    }
    high chance you understand that except maybe the %s. what the %s does is uses that function i added to the end
    of function and gets the players name its fairly simple
    now lets do the setup
    Code:
    void SetupFirstLogon(ScriptMgr * mgr)
    {
    mgr->register_hook(SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD, (void*)OnLoginForFirstTime);
    }
    in setup.h add this under the one in there already
    SetupFirstLogon(mgr)
    do the same with setup.cpp
    void SetupFirstLogon(ScriptMgr * mgr)
    and whala your done with a gameobject script

    6. C++ Command info

    SERVER HOOKS:
    SERVER_HOOK_EVENT_ON_NEW_CHARACTER
    SERVER_HOOK_EVENT_ON_KILL_PLAYER
    SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD
    SERVER_HOOK_EVENT_ON_ENTER_WORLD
    SERVER_HOOK_EVENT_ON_GUILD_JOIN
    SERVER_HOOK_EVENT_ON_DEATH
    SERVER_HOOK_EVENT_ON_REPOP
    SERVER_HOOK_EVENT_ON_EMOTE
    SERVER_HOOK_EVENT_ON_ENTER_COMBAT
    SERVER_HOOK_EVENT_ON_CAST_SPELL
    SERVER_HOOK_EVENT_ON_TICK
    SERVER_HOOK_EVENT_ON_LOGOUT_REQUEST
    SERVER_HOOK_EVENT_ON_LOGOUT
    SERVER_HOOK_EVENT_ON_QUEST_ACCEPT
    SERVER_HOOK_EVENT_ON_ZONE
    SERVER_HOOK_EVENT_ON_CHAT
    SERVER_HOOK_EVENT_ON_LOOT
    SERVER_HOOK_EVENT_ON_GUILD_CREATE
    SERVER_HOOK_EVENT_ON_ENTER_WORLD_2
    SERVER_HOOK_EVENT_ON_CHARACTER_CREATE
    SERVER_HOOK_EVENT_ON_QUEST_CANCELLED
    SERVER_HOOK_EVENT_ON_QUEST_FINISHED
    SERVER_HOOK_EVENT_ON_HONORABLE_KILL
    SERVER_HOOK_EVENT_ON_ARENA_FINISH
    SERVER_HOOK_EVENT_ON_OBJECTLOOT
    SERVER_HOOK_EVENT_ON_AREATRIGGER
    SERVER_HOOK_EVENT_ON_POST_LEVELUP
    SERVER_HOOK_EVENT_ON_PRE_DIE - general unit die, not only based on players
    SERVER_HOOK_EVENT_ON_ADVANCE_SKILLLINE

    You get the C++ info by user Plr->
    most the time it brings up a box and lets you choose a command comes in handy alot

    7. Final Tips

    Get the SVN for Sun++ and AspireDev and study there scripts all have great quality and use alot of functions

    Guide is Fully Written by me - Mager1794
    Last edited by mager1794; 07-28-2008 at 09:35 PM.
    Lunar Gaming - Reaching For The Stars

    Stepping Into C++
  2. #2
    BrantX's Avatar Contributor
    Reputation
    205
    Join Date
    Jul 2007
    Posts
    899
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll be looking into this guide for a while and will be learning it. Thanks for the release. i will now stare into the screen for 3-4 hours.



  3. #3
    Strupantwn's Avatar Contributor
    Reputation
    115
    Join Date
    Apr 2007
    Posts
    1,045
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great guide, too bad can't rep you, repped you already yesterday

  4. #4
    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)
    ^^Bumped i think this is a great guide why arn't people posting /cry
    Lunar Gaming - Reaching For The Stars

  5. #5
    Power of Illuminati's Avatar Contributor
    Reputation
    179
    Join Date
    May 2008
    Posts
    1,410
    Thanks G/R
    6/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just forgot to post and rep when I read it! >.< Was in a hurry.

  6. #6
    Koksy's Avatar Member
    Reputation
    14
    Join Date
    May 2007
    Posts
    171
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    really nice guide thanks a lot!

  7. #7
    runiker's Avatar Contributor
    Reputation
    105
    Join Date
    Nov 2007
    Posts
    501
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet guide

  8. #8
    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)
    thanks for all of the comments guys : )
    Lunar Gaming - Reaching For The Stars

  9. #9
    Rian22's Avatar Member
    Reputation
    6
    Join Date
    Jul 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Nice!!!

    Great guide, I am completly new to C++ (well not really, but don't know how to do ANYTHING in it) and I have already learned a lot. +Rep, thanks for the help!!

  10. #10
    TheSpidey's Avatar Elite User
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,200
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're showing great potential, keep it up

  11. #11
    Cursed's Avatar Contributor
    Reputation
    270
    Join Date
    Jun 2007
    Posts
    1,380
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very good guide for Beginners +Rep 2x

  12. #12
    RaZZal's Avatar Site Donator
    Reputation
    16
    Join Date
    Mar 2008
    Posts
    70
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good guide, i'll +Rep when I can =]

  13. #13
    syrtan's Avatar Member
    Reputation
    11
    Join Date
    May 2007
    Posts
    93
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice guide

  14. #14
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent guide majer! Now we have a nice thread to link noobs to if they have script problems. + rep
    Life Puzzler WoW - Website | Forums

  15. #15
    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)
    man i cant believe i actaully let this post get to page four after all the time i spent on it
    Lunar Gaming - Reaching For The Stars

Page 1 of 2 12 LastLast

Similar Threads

  1. #1 Step Into The Arena /w Shenmue (Warrior) & Haste (Boomy)
    By DatGuyShenmue in forum World of Warcraft General
    Replies: 2
    Last Post: 06-30-2013, 06:05 PM
  2. Replies: 4
    Last Post: 10-11-2012, 03:19 PM
  3. Stepping Into C++ [Updated]
    By mager1794 in forum WoW EMU Guides & Tutorials
    Replies: 16
    Last Post: 05-08-2009, 03:09 PM
  4. How to chain 2+ spells into a macro
    By Matt in forum World of Warcraft Exploits
    Replies: 22
    Last Post: 07-03-2007, 12:33 AM
  5. Getting into BG with that pesky deserters buff!
    By janzi9 in forum World of Warcraft Exploits
    Replies: 0
    Last Post: 03-06-2006, 11:35 PM
All times are GMT -5. The time now is 03:14 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search