[C++] Capture The Flag menu

These ads disappear when you log in.

Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    mager1794's Avatar Lieutenant Commander
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)

    [C++] Capture The Flag

    Alright guys while checking in the Requests section I've found that alot of people are looking for a Capture the flag script.

    Well, I'm pretty sure this isn't exactly what your looking for but Its a pretty good start. If anyone knows the spell id for the Alliance warsong gulch spells that are casted on you when you get the flag please tell me

    Well anyway here is the current script

    #begin - begins the event, only usable by GM's

    implemented a score system, once a faction gets 3 the score resets and the event is over til a GM begins it
    added spell visual to the person who has the flag

    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    #define ITEMID 38234//The object that is in your bag when you have the flag
    #define FLAG_ID 28342//The Object to be clicked to take the flag
    #define ALLYTURNINPOINT 26242//Alliance flag turn in object
    #define HORDTURNINPOINT 26242//Horde flag turn in object
    
    //Don't edit this
    #define SPELL 23335
    
    static bool IsHeld = false;
    static int allyscore = 0;
    static int hordescore = 0;
    static bool isactive = false;
    
    GameObject * flag;
    
    static string begin = "#begin";
    
    void PlayerChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
       if(Message == begin)
       {
           if(pPlayer->GetSession()->HasGMPermissions())
           {
                isactive = true;
                allyscore = 0;
                hordescore = 0;
    
           }
       }
    }
    
    
    class FlagToCapture : public GameObjectAIScript
    {
    public:
        FlagToCapture(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new FlagToCapture(GO);
        }
    
        void OnSpawn()
        {
            flag = _gameobject;
            _gameobject->invisible = false;
        }
    
        void OnActivate(Player * pPlayer)
        {
            if(isactive)
            {
                _gameobject->invisible = false;
            if(IsHeld == false)
            {
            Item * item = objmgr.CreateItem(ITEMID,pPlayer);
            pPlayer->GetItemInterface()->AddItemToFreeSlot(item);
            IsHeld = true;
            _gameobject->invisible = true;
            pPlayer->AddAuraVisual(SPELL,1,true);
            }
            else
            {
                pPlayer->BroadcastMessage("The flag has already been picked up");
            }
            }
            else
            {
                _gameobject->invisible = true;
            }
        }
    };
    
    class HordeObject : public GameObjectAIScript
    {
    public:
        HordeObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new HordeObject(GO);
        }
    
        void OnSpawn()
        {
            RegisterAIUpdateEvent(1);
        }
    
        void AIUpdate()
        {
            Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
            if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
            {
                if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 0)
                {
                    plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID) && isactive);
                    IsHeld = false;
                    flag->invisible = false;
                    hordescore++;
                    if(hordescore == 3)
                    {
                        sWorld.SendWorldWideScreenText("The horde have won capture the flag");
                        sWorld.SendWorldText("score resetting");
                        allyscore = 0;
                        hordescore = 0;
                        isactive = false;
                    }
                    else
                    {
                    char * message;
                    sprintf(message,"%s has captured the flag for the horde",plr->GetName());
                    sWorld.SendWorldWideScreenText(message);
                    plr->RemoveAuraVisual(SPELL,1);
                    }
                }
            }
        }
    };
    
    class AllyObject : public GameObjectAIScript
    {
    public:
        AllyObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new AllyObject(GO);
        }
    
        void OnSpawn()
        {
            RegisterAIUpdateEvent(1);
        }
    
        void AIUpdate()
        {
            Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
            if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
            {
                if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 1 && isactive)
                {
                    plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID));
                    IsHeld = false;
                    flag->invisible = false;
                    allyscore++;
                    if(allyscore == 3)
                    {
                        sWorld.SendWorldWideScreenText("The alliance have won capture the flag");
                        sWorld.SendWorldText("score resetting");
                        allyscore = 0;
                        hordescore = 0;
                        isactive = false;
    
                    }
                    else
                    {
                    char * message;
                    sprintf(message,"%s has captured the flag for the alliance",plr->GetName());
                    sWorld.SendWorldWideScreenText(message);
                            plr->RemoveAuraVisual(SPELL,1);
                    }
                }
            }
        }
    };
    
    
    void SetupCaptureTheFlag(ScriptMgr * mgr)
    {
        mgr->register_gameobject_script(FLAG_ID, &FlagToCapture::Create);
        mgr->register_gameobject_script(ALLYTURNINPOINT, &AllyObject::Create);
        mgr->register_gameobject_script(HORDTURNINPOINT, &HordeObject::Create);
        mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &PlayerChat);
    }
    Without Spells -- Some errors in version with them
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    #define ITEMID 38234//The object that is in your bag when you have the flag
    #define FLAG_ID 28342//The Object to be clicked to take the flag
    #define ALLYTURNINPOINT 26242//Alliance flag turn in object
    #define HORDTURNINPOINT 26242//Horde flag turn in object
    
    //Don't edit this
    #define SPELL 23335
    
    static bool IsHeld = false;
    static int allyscore = 0;
    static int hordescore = 0;
    static bool isactive = false;
    
    GameObject * flag;
    
    static string begin = "#begin";
    
    void PlayerChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
       if(Message == begin)
       {
           if(pPlayer->GetSession()->HasGMPermissions())
           {
                isactive = true;
                allyscore = 0;
                hordescore = 0;
           }
       }
    }
    
    
    class FlagToCapture : public GameObjectAIScript
    {
    public:
        FlagToCapture(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new FlagToCapture(GO);
        }
    
        void OnSpawn()
        {
            flag = _gameobject;
            _gameobject->invisible = false;
        }
    
        void OnActivate(Player * pPlayer)
        {
            if(isactive)
            {
                _gameobject->invisible = false;
            if(IsHeld == false)
            {
            Item * item = objmgr.CreateItem(ITEMID,pPlayer);
            pPlayer->GetItemInterface()->AddItemToFreeSlot(item);
            IsHeld = true;
            _gameobject->invisible = true;
            }
            else
            {
                pPlayer->BroadcastMessage("The flag has already been picked up");
            }
            }
            else
            {
                _gameobject->invisible = true;
            }
        }
    };
    
    class HordeObject : public GameObjectAIScript
    {
    public:
        HordeObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new HordeObject(GO);
        }
    
        void OnSpawn()
        {
            RegisterAIUpdateEvent(1);
        }
    
        void AIUpdate()
        {
            Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
            if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
            {
                if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 0)
                {
                    plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID) && isactive);
                    IsHeld = false;
                    flag->invisible = false;
                    hordescore++;
                    if(hordescore == 3)
                    {
                        sWorld.SendWorldWideScreenText("The horde have won capture the flag");
                        sWorld.SendWorldText("score resetting");
                        allyscore = 0;
                        hordescore = 0;
                        isactive = false;
                    }
                    else
                    {
                    char * message;
                    sprintf(message,"%s has captured the flag for the horde",plr->GetName());
                    sWorld.SendWorldWideScreenText(message);
                    }
                }
            }
        }
    };
    
    class AllyObject : public GameObjectAIScript
    {
    public:
        AllyObject(GameObject* goinstance) : GameObjectAIScript( goinstance ) {}
        static GameObjectAIScript *Create(GameObject * GO)
        {
            return new AllyObject(GO);
        }
    
        void OnSpawn()
        {
            RegisterAIUpdateEvent(1);
        }
    
        void AIUpdate()
        {
            Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());
            if(_gameobject->CalcDistance( _gameobject, plr ) <= 2.0f) // You need to standing 2 meters from the actual center of the pink ring
            {
                if(plr->GetItemInterface()->GetItemCount(ITEMID) >= 1 && plr->GetTeam() == 1 && isactive)
                {
                    plr->GetItemInterface()->RemoveItemAmt(ITEMID,plr->GetItemInterface()->GetItemCount(ITEMID));
                    IsHeld = false;
                    flag->invisible = false;
                    allyscore++;
                    if(allyscore == 3)
                    {
                        sWorld.SendWorldWideScreenText("The alliance have won capture the flag");
                        sWorld.SendWorldText("score resetting");
                        allyscore = 0;
                        hordescore = 0;
                        isactive = false;
    
                    }
                    else
                    {
                    char * message;
                    sprintf(message,"%s has captured the flag for the alliance",plr->GetName());
                    sWorld.SendWorldWideScreenText(message);
                    }
                }
            }
        }
    };
    
    
    void SetupCaptureTheFlag(ScriptMgr * mgr)
    {
        mgr->register_gameobject_script(FLAG_ID, &FlagToCapture::Create);
        mgr->register_gameobject_script(ALLYTURNINPOINT, &AllyObject::Create);
        mgr->register_gameobject_script(HORDTURNINPOINT, &HordeObject::Create);
        mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &PlayerChat);
    }
    Just modify the definitions to what you want
    and create your game objects (sorry that i don't have them, i don't have an updated DB will +Rep anyone to make them)
    Last edited by mager1794; 12-21-2009 at 07:10 PM.
    Lunar Gaming - Reaching For The Stars

    These ads disappear when you log in.

  2. #2
    Reflection's Avatar Legendary CoreCoins User
    Reputation
    781
    Join Date
    Mar 2008
    Posts
    3,377
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Once again, an awesome script. Sweet work!

    Freelance Digital Artist
    https://reflectionartwork.deviantart.com
    You did not desert me
    My brothers in arms


  3. #3
    MEC's Avatar Banned
    Reputation
    5
    Join Date
    Sep 2007
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    that is very awesome. good job!

  4. #4
    mager1794's Avatar Lieutenant Commander
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Thanks for the compliments guys
    Lunar Gaming - Reaching For The Stars

  5. #5
    Linkn's Avatar Contributor CoreCoins User
    Reputation
    90
    Join Date
    Mar 2009
    Posts
    296
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Awesome job, as usual. I wanted to do something along the lines of this and didn't know where to start.

  6. #6
    hugocub's Avatar Corporal
    Reputation
    1
    Join Date
    Oct 2009
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    awesome script man

  7. #7
    stoneharry's Avatar Moderator Harry

    CoreCoins User Authenticator enabled
    Reputation
    1519
    Join Date
    Sep 2007
    Posts
    4,385
    Thanks G/R
    104/96
    Trade Feedback
    0 (0%)
    I've been wondering if this is possible, due to the flag being a aura and gameobjects being able to give aura's then despawn. I'm glad you've gone and done it to save me having to go and look into it. I'm going to be using part of this, so +Rep and nominated as nobody has done it before effectively.

    Edit: Got to spread

  8. #8
    Agent Orange's Avatar Active Member
    Reputation
    23
    Join Date
    Aug 2008
    Posts
    260
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Thanks man +Rep iv been looking for this and recently posted this in request maybe you saw it

  9. #9
    mager1794's Avatar Lieutenant Commander
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Thanks man +Rep iv been looking for this and recently posted this in request maybe you saw it
    Thats exactly where i got the idea +Rep for it
    Lunar Gaming - Reaching For The Stars

  10. #10
    sasoritail's Avatar Contributor
    Reputation
    160
    Join Date
    Sep 2008
    Posts
    655
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    awesome!
    ur scripting is like the finest art!
    It's been a while

  11. #11
    runiker's Avatar Contributor
    Reputation
    105
    Join Date
    Nov 2007
    Posts
    501
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Sweet its a remake of my lua script "http://www.mmowned.com/forums/emulator-server-discussion/132695-release-battle-ground-flag-lua-sql-files.html" but its in c+= now lol. Actualy if I feel nice I might release it as a lua again but upadted given the information.

  12. #12
    Warriar's Avatar Sergeant Major
    Reputation
    31
    Join Date
    May 2009
    Posts
    149
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Great Release, Keep goin mager

  13. #13
    namelessgnome's Avatar Contributor
    Reputation
    108
    Join Date
    May 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Very nice as always mager

  14. #14
    Mitron's Avatar Field Marshal
    Reputation
    127
    Join Date
    Jun 2008
    Posts
    1,328
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Nice script you got there :P pretty fast too imo +rep and nominated !

  15. #15
    mager1794's Avatar Lieutenant Commander
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Thanks for all the wonderful feedback guys
    Lunar Gaming - Reaching For The Stars

Page 1 of 3 123 LastLast

Similar Threads

  1. Capture the flag battleground program
    By cruciform in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 01-21-2011, 04:03 AM
  2. [Request] Capture the Flag or Search and Destroy Script
    By Agent Orange in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 12-08-2009, 05:42 PM
  3. [C++ Request] Capture the Flag
    By umandez in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 06-23-2009, 11:59 AM
  4. Capture the Flag Script
    By umandez in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 06-22-2009, 09:23 PM
  5. [CTF] Capture The Flag Event!
    By ~SaiLyn~ in forum World of Warcraft Emulator Servers
    Replies: 17
    Last Post: 03-21-2008, 05:29 PM
All times are GMT -5. The time now is 11:19 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved. Digital Point modules: Sphinx-based search