[C++] Guild Wars v0.5 menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  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++] Guild Wars v0.5

    Guild Wars v0.5

    I have finally finished my script for Guild Wars. Unfortunately its in v0.5 Beta, now together as a community were gonna work out the kinks. In order to report a bug go here and post about the issue in the forums. I will try to work on the fixes and be updating this thread as often as possible.
    Through this script if you haven't noticed i am kicking off my new Project Transcendant Scripting. Now on to what we all came here for

    GuildWars.cpp
    Code:
    //===============
    // Guild Wars
    //  by Mager1794
    // Transcendent Scripting
    //===============
    #include "StdAfx.h"
    #include "Setup.h"
    
    class SCRIPT_DECL GuildWar : 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;
        }
    };
    
    bool ChecksPassed(Player * pPlayer, uint32 guilda, uint32 guildb, bool war)
    {
        if(!pPlayer)
        {
            return false;
        }
        else if(pPlayer->GetGuild()->GetGuildLeader() == pPlayer->GetGUID())
        {
            pPlayer->BroadcastMessage("You must be the guild leader in order to use this function");
            return false;
        }
        else if(!guilda)
        {
            pPlayer->BroadcastMessage("You are not in a guild");
            return false;
        }
        else if(!guildb)
        {
            pPlayer->BroadcastMessage("You did not specify a guild");
            return false;
        }
        else if(guilda == guildb)
        {
            pPlayer->BroadcastMessage("You cannot declare war on your own guild");
            return false;
        }
        else
        {
            const char * guildA = objmgr.GetGuild(guilda)->GetGuildName();
            const char * guildB = objmgr.GetGuild(guildb)->GetGuildName();
            char * message;
            if(war)
            {
                sprintf(message, "[Guild Wars] %s has declared war on %s", guildA,guildB);
            }
            else
            {
                sprintf(message, "[Guild Wars] %s has declared peace with %s", guildA,guildB);
            }
            sWorld.SendWorldWideScreenText(message);
            return true;
        }
    };
    
    void GuildWar::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
    {
        GossipMenu *Menu;
        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
        Menu->AddItem(1, "Propose A Guild War", 1, 1);
        Menu->AddItem(1, "Propose A Guild Peace", 1, 2);
        Menu->AddItem(1, "Exit Menu", 1, 3);
        
        if(AutoSend)
            Menu->SendTo(Plr);
    }
    
    void GuildWar::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
    {
        switch(IntId)
        {
            case 0:
            {
                GossipHello(pObject, Plr, true);
            }break;
            case 1:
                {
                    if(!Code)
                    {
                        Plr->BroadcastMessage("You must enter a guild a name");
                    }
                    uint32 enemy = objmgr.GetGuildByGuildName(Code)->GetGuildId();
                    uint32 friendly = Plr->GetGuildId();
                    if(ChecksPassed(Plr, friendly, enemy, true))
                    {
                    WorldDatabase.Query("INSERT INTO `guild_wars` VALUES('%s','%s');",friendly,enemy);
                    WorldDatabase.Query("INSERT INTO `guild_wars` VALUES('%s','%s');",enemy,friendly);
                    }
                }break;
            case 2:
                {
                    if(!Code)
                    {
                        Plr->BroadcastMessage("You must enter a guild a name");
                    }
                    uint32 enemy = objmgr.GetGuildByGuildName(Code)->GetGuildId();
                    uint32 friendly = Plr->GetGuildId();
                    if(ChecksPassed(Plr, friendly, enemy, false))
                    {
                    WorldDatabase.Query("DELETE FROM `guild_wars` WHERE `aguild ='%s' AND `bguild`='%s');",friendly,enemy);
                    WorldDatabase.Query("DELETE FROM `guild_wars` WHERE `aguild ='%s' AND `bguild`='%s';",enemy,friendly);
                    }
                }break;
            case 3:
                {
                    GossipEnd(pObject, Plr);
                }break;
        }
    };
    
    void GuildWar::GossipEnd(Object * pObject, Player* Plr)
    {
        GossipScript::GossipEnd(pObject, Plr);
    }
    
    bool IsGuildAtWar(uint32 aguild, uint32 vguild)
    {
        if(aguild = vguild)
            return false;
        QueryResult * res = WorldDatabase.Query("SELECT * FROM `guild_wars` WHERE `aguild` ='%s' AND `bguild` ='%s';", aguild, vguild);
        if(res == NULL)
            return false;
        Field * guilds = res->Fetch();
        if(guilds == NULL)
            return false;
        else
            return true;
    }
    
    void AddGold(uint32 gold, Player * Plr)
    {
        uint32 gamm = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
        uint32 goldammount = gamm + gold;
        Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, gamm);
    }
    
    void TakeGold(uint32 gold, Player * Plr)
    {
        int32 gamm = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
        int32 goldammount;
        goldammount = gamm - gold;
        Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, goldammount);
    }
    
    void GuildWarScript(Player* attacker, Player* victim)
    {
        uint32 aguild = attacker->GetGuildId();
        uint32 vguild = victim->GetGuildId();
        if(IsGuildAtWar(aguild, vguild))
        {
            AddGold(10000, attacker);
            TakeGold(5000, victim);
        }
    }
    
    
    void SetupGuildWars(ScriptMgr * mgr)
    {
        GossipScript * gs = (GossipScript*) new GuildWar();
        mgr->register_item_gossip_script(61000, gs);
        mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, (void*)GuildWarScript);
    }
    SQL
    Code:
    CREATE DATABASE "guildwars";
    
    USE "guildwars";
    
    
    CREATE TABLE "guild_wars" (
      "aguild" text,
      "bguild" text
    );
    
    LOCK TABLES "guild_wars" WRITE;
    UNLOCK TABLES;
    I Hope to see you guys on forums soon

    SVN Link (Updated Versions of Script)

    Last edited by mager1794; 06-23-2009 at 09:24 PM.
    Lunar Gaming - Reaching For The Stars

    [C++] Guild Wars v0.5
  2. #2
    Choices's Avatar Member
    Reputation
    94
    Join Date
    Apr 2008
    Posts
    231
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very nice Mager. + REP

  3. #3
    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 =D
    Lunar Gaming - Reaching For The Stars

  4. #4
    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)
    Nice job yet again mager. +Rep (If i can)

    You must spread some Reputation around before giving it to mager1794 again.

  5. #5
    Claiver's Avatar Member
    Reputation
    138
    Join Date
    Mar 2009
    Posts
    217
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, very nifty! Already a +Rep for you, but all this will do is set two guilds 'hated' to eachother, no actual fight or whatever, right? I am not a C++ scripter, so I wouldn't know!
    Edit: Cooldown :/

  6. #6
    The-Eradicator's Avatar Contributor

    Reputation
    149
    Join Date
    May 2007
    Posts
    829
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Claiver View Post
    all this will do is set two guilds 'hated' to eachother, no actual fight or whatever, right?
    Correct.

    @OP: +Repx3

  7. #7
    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)
    epic! finally someone with major skill has done it!

    +RepX2
    wish I could give more

    cooldown. dang! and I wanted to +Rep you oh well I will be back....
    Last edited by y2kss66; 06-23-2009 at 08:11 AM.

  8. #8
    MegaBigBoss's Avatar Member
    Reputation
    18
    Join Date
    Aug 2008
    Posts
    17
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, you should add something to make a player enemy with another player that has an Enemy guild.

  9. #9
    Fyesan's Avatar Member
    Reputation
    5
    Join Date
    Jun 2009
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just epic o.O
    nice work +Rep

  10. #10
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Looks good, +Rep x4 just because your releasing so much at the moment.

  11. #11
    Fyesan's Avatar Member
    Reputation
    5
    Join Date
    Jun 2009
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it possible to exclude guilds from this script?
    like gm guild? so there is a variable or so?

    EDIT: maybe like an additional collum in db with 1 for "no war guild" and 0 for "war guild"
    Last edited by Fyesan; 06-23-2009 at 12:51 PM.

  12. #12
    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)
    I know this is unfinished, right now it only supports kills in Arenas and BG's thats why i said beta i'm hoping to attract players to my forums and stuff to start posting bugs they find etc. stuff like that
    Lunar Gaming - Reaching For The Stars

  13. #13
    Fyesan's Avatar Member
    Reputation
    5
    Join Date
    Jun 2009
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    +1 registration xD
    Last edited by Fyesan; 06-23-2009 at 01:16 PM.

  14. #14
    Vindicated's Avatar Contributor
    Reputation
    226
    Join Date
    Aug 2008
    Posts
    1,067
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice release mate. +Rep (if I can). Good to see that at least ONE person is releasing their C++ scripts and content instead of being completely greedy.


  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)
    Updated the script a bit, Added the system of checks please post bugs on the forums.

    Still working on a way to make the guilds hostile to each other
    Lunar Gaming - Reaching For The Stars

Page 1 of 2 12 LastLast

Similar Threads

  1. Guild Wars account (+11 rep)
    By Alkhara Majere in forum Gaming Chat
    Replies: 14
    Last Post: 05-26-2007, 09:32 AM
  2. WTT Guild Wars account, lol.
    By raamoz in forum Members Only Accounts And CD Keys Buy Sell
    Replies: 0
    Last Post: 03-17-2007, 11:11 PM
  3. Guild Wars Bot
    By Mexdude in forum Gaming Chat
    Replies: 1
    Last Post: 12-17-2006, 03:18 PM
  4. Guild Wars
    By Haunted126 in forum Gaming Chat
    Replies: 6
    Last Post: 09-30-2006, 01:54 AM
  5. Guild Wars CD-Key Changer?
    By MANT1S in forum Gaming Chat
    Replies: 2
    Last Post: 07-31-2006, 09:16 AM
All times are GMT -5. The time now is 11:24 PM. 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