Register for your free account! | Forgot your password?

You last visited: Today at 12:29

  • 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   #2
 
elite*gold: 0
Join Date: Nov 2009
Posts: 785
Received Thanks: 403
Hmm,not bad.


F i n c h i is offline  
Old   #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   #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



« Previous Thread | Next Thread »

Similar Threads
Help me IN HellMouth Source
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
10 Replies - CO2 PServer - Discussions / Questions
Xampp-HellMouth-Help-please
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...
1 Replies - CO2 PServer - Discussions / Questions
Hellmouth question
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...
3 Replies - CO2 PServer - Discussions / Questions
[Help] Hellmouth Mob Spawn
Alright,I added the following code in Database.cs Database.cs public static void GetSpawns() { //I've changed mob spawn...
31 Replies - CO2 PServer - Discussions / Questions
HellMouth Client
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...
17 Replies - CO2 Weapon, Armor, Effects & Interface edits



All times are GMT +1. The time now is 12:29.


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

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