Register for your free account! | Forgot your password?

You last visited: Today at 07:34

  • Please register to post and access all features, it's quick, easy and FREE!


QuestClass - Hellmouth

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2011
Posts: 73
Received Thanks: 12
QuestClass - Hellmouth

Enums:
Code:
    public enum Quest_State
    {
        NotAvailable = 0,
        NotStarted = 1,
        Begun = 2,
        Finished = 3
    }
    public enum Quest_Types
    {
        SingleQuest = 0,//Can be done one time.
        SpecialQuest = 1,//Having a time range.
        NormalQuest = 2,//Can be done multiple times.
        Dungeon = 3//Quests in dungeons.
    }
QuestClient:
Code:
    public class QuestClient
    {
        public Quest[] Quests;
        public int QuestsFinished
        {
            get
            {
                int count = 0;
                foreach (Quest quests in Quests)
                {
                    if (quests.State == Quest_State.Finished)
                        count++;
                }
                return count;
            }
        }
        public int QuestsStarted
        {
            get
            {
                int count = 0;
                foreach (Quest quests in Quests)
                {
                    if (quests.State == Quest_State.Begun)
                        count++;
                }
                return count;
            }
        }
    }
Quest Requirements:
Code:
    public class QuestRequirements
    {
        public byte Level;
        public ushort[] Stats;
        public byte[] JobRange;
        public byte Reborns;
    }
Quest
Code:
public class Quest
    {
        public Quest(string Name, Struct.ItemInfo[] Reward_Items, uint[] RewardMoney,
            Quest_Types Type, Client[] Clients, int[] TimeRange,
            Map[] QuestMaps, string[] HelpInfo, QuestRequirements Requirements)
        {
            this.Name = Name;
            this.Reward_Items = Reward_Items;
            this.RewardCPs = RewardMoney[0];
            this.RewardSilvers = RewardMoney[1];
            this.Type = Type;
            this.Clients = Clients;
            this.TimeRange = TimeRange;
            this.QuestMaps = QuestMaps;
            this.HelpInfo = HelpInfo;
            this.Requirements = Requirements;
        }

        public string Name;
        public Struct.ItemInfo[] Reward_Items;
        public uint RewardCPs;
        public uint RewardSilvers;
        public string[] HelpInfo;
        public Quest_State State;
        public Quest_Types Type;
        public Client[] Clients;
        public int[] TimeRange;
        public Map[] QuestMaps;
        public QuestRequirements Requirements;

        public void ShowHelp(Client Client, int Index)
        {
            Client.Send(Packets.Chat(HelpInfo[Index], "[Quest]", Client.Name, Struct.ChatType.Talk));
        }
        public void Reward()
        {
            Random r = new Random();
            for (int i = 0; i < Clients.Length; i++)
            {
                Clients[i].CP = RewardCPs;
                Clients[i].Money = RewardSilvers;
                int len = Reward_Items.Length;
                Struct.ItemInfo I = Reward_Items[r.Next(0, len)];
                Database.ItemCount++;
                I.UID = Database.ItemCount;
                Database.AddItem(I, Clients[i]);
                Packets.Send(Packets.ItemInfo(I, 1), Clients[i]);
                if (!Clients[i].Inventory.ContainsKey(I.UID))
                    Clients[i].Inventory.Add(I.UID, I);
            }
        }
        public bool CanJoin()
        {
            if (Clients[Clients.Length] == null)
                return true;

            return false;
        }
        public void Begin(Client Client)
        {
            if (State == Quest_State.Begun || State == Quest_State.Finished)
                return;

            Checking =  -1;
            bool Requirements = true;
            for (int i = 0; i < 7; i++)
            {
                if (Requirements)
                    Requirements = HaveRequirements(Client);
            }

            if (Client.Level == this.Requirements.Level ||
                Requirements ||
                DateTime.Now.Hour >= TimeRange[0] &&
                DateTime.Now.Minute >= TimeRange[1] &&
                DateTime.Now.Hour <= TimeRange[3] &&
                DateTime.Now.Minute <= TimeRange[4])
            {
                State = Quest_State.Begun;
                return;
            }

            State = Quest_State.NotAvailable;
        }
        int Checking = -1;
        bool HaveRequirements(Client Client)
        {
            Checking++;
            if (this.Requirements.JobRange != null && Checking == 1)
                if (Client.Job >= this.Requirements.JobRange[0] && Client.Job <= this.Requirements.JobRange[1])
                    return true;
                else
                    return false;
            Checking++;
            if (this.Requirements.Level > 0 && Checking == 2)
                if (Client.Level >= this.Requirements.Level)
                    return true;
                else
                    return false;
            Checking++;
            if (this.Requirements.Reborns >0 && Checking == 3)
                if (Client.Reborn >= this.Requirements.Reborns)
                    return true;
                else
                    return false;
            Checking++;
            if (this.Requirements.Stats != null && Checking == 4)
            {
                if (Client.Str >= this.Requirements.Stats[0] &&
                    Client.Agi >= this.Requirements.Stats[1] &&
                    Client.Vit >= this.Requirements.Stats[2] &&
                    Client.Spi >= this.Requirements.Stats[3])
                    return true;
                else
                    return false;
            }

            return true;
        }
    }
Then in Client.cs put this:
Code:
        public QuestClient QuestClient;
Example:
Code:
            Struct.ItemInfo RewardItem = new Struct.ItemInfo();
            RewardItem.ID = 410339;
            RewardItem.Locked = false;
            RewardItem.Suspicious = false;
            RewardItem.Plus = 0;
            RewardItem.Enchant = 0;
            RewardItem.Soc1 = 0;
            RewardItem.Soc2 = 0;
            RewardItem.Color = 0;
            RewardItem.Composition = 0;
            RewardItem.Amount = 0;
            RewardItem.Bless = 0;
            RewardItem.Free = false;
            if (Dictionary.ItemData.ContainsKey(RewardItem.ID))
            {
                RewardItem.Dura = Dictionary.ItemData[RewardItem.ID].MaxDura;
                RewardItem.MaxDura = Dictionary.ItemData[RewardItem.ID].MaxDura;
            }
            else
            {
                RewardItem.Dura = 20000;
                RewardItem.MaxDura = 20000;
            }
            QuestRequirements req = new QuestRequirements();
            req.Level = 120;
            req.Reborns = 2;
            Quest example = new Quest("The blue montain",
                new Struct.ItemInfo[] { RewardItem },
                new uint[] { 10000, 500000 },
                Quest_Types.SingleQuest,
                new Client[] { client },
                new int[] { 0, 0, 0, 0 },
                null,
                new string[] { "Walk to TwinCity.", "Walk to BirdIsland." },
                req);
You need to make a load/save system for quests by your self. This is just a base.
This is useful, when you're creating quests, because it gives a good strucutre over your quests and you can easy manage them. It will also make your source look less messy.
It should be pretty easy to grab and use.

Goodluck



Secured is offline  
Old 04/27/2011, 14:47   #2
 
elite*gold: 0
Join Date: Nov 2009
Posts: 785
Received Thanks: 405
Hmm,not bad.


F i n c h i is offline  
Old 04/27/2011, 18:03   #3
 
elite*gold: 0
Join Date: Apr 2009
Posts: 749
Received Thanks: 432
yeah not bad... but if you do just used two counters for the quests (one for started quests and one for finished quests) would be better i guess... yo would get less of memory usage
12tails is offline  
Old 04/27/2011, 21:17   #4
 
elite*gold: 0
Join Date: Nov 2010
Posts: 237
Received Thanks: 99
Quote:
Originally Posted by 12tails View Post
yeah not bad... but if you do just used two counters for the quests (one for started quests and one for finished quests) would be better i guess... yo would get less of memory usage
I agree on that but its nicely coded
|NeoX is offline  
Reply



« [Release]enter/exit TG | [Small-Release] A few nice commands for LOTF »

Similar Threads
Help me IN HellMouth Source
07/21/2011 - CO2 PServer - Discussions / Questions - 10 Replies
i did every thing changed ip like hamachi ip but and open hellmouth to open my server but i got one problem and it's YouTube - Rec#04
Xampp-HellMouth-Help-please
04/23/2011 - CO2 PServer - Discussions / Questions - 1 Replies
Guyz i Need Help :mofo: I took ABout 1 day now trying to do that server and no 1 helps me .. even the videos Doesnot contains the first importans part about the mysql .. i downloaded app and it didnot work ... now i downloaded Xampp .. aND still GOt proplems ... so Guyz i gOt an idea .. .why not some one help me to steup that source? ? ? please :( .... :D Here is My e-mail to Contact [email protected]
Hellmouth question
04/13/2011 - CO2 PServer - Discussions / Questions - 3 Replies
I am currently fixing all the bugs/glitches in arena and the one im presently trying to fix is the character not showing up to the opponent until they jump. My question is the code that makes everything disapear exept you and your opponent
[Help] Hellmouth Mob Spawn
04/12/2011 - CO2 PServer - Discussions / Questions - 31 Replies
Alright,I added the following code in Database.cs Database.cs public static void GetSpawns() { //I've changed mob spawn code like 5 times.. this should still work though so w/e. MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("MobSpawns"); uint Count = 0; MySqlReader r = new MySqlReader(cmd);
HellMouth Client
02/18/2011 - CO2 Weapon, Armor, Effects & Interface edits - 17 Replies
Basically I've done the client for HellMouth and would like some feedback and some input to what can be done to improve it. The logo is already going to be removed since its blurry. Thanks. http://i47.tinypic.com/2i1h0km.png ## Updated -Removed Logo -Added new background to top and bottom I'm happy with what it has turned out as.



All times are GMT +1. The time now is 07:34.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.