[C++] Capture The Flag menu

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  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)

    [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

    [C++] Capture The Flag
  2. #2
    Reflection's Avatar Legendary
    Reputation
    783
    Join Date
    Mar 2008
    Posts
    3,377
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that is very awesome. good job!

  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)
    Thanks for the compliments guys
    Lunar Gaming - Reaching For The Stars

  5. #5
    Linkn's Avatar Contributor
    Reputation
    90
    Join Date
    Mar 2009
    Posts
    296
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Member
    Reputation
    1
    Join Date
    Oct 2009
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    awesome script man

  7. #7
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    150/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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 Knight-Lieutenant
    Reputation
    23
    Join Date
    Aug 2008
    Posts
    260
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man +Rep iv been looking for this and recently posted this in request maybe you saw it

  9. #9
    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 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
    161
    Join Date
    Sep 2008
    Posts
    655
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Active Member
    Reputation
    31
    Join Date
    May 2009
    Posts
    149
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very nice as always mager

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

    ----------------------------------------------------------------

  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)
    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 07:37 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