Register for your free account! | Forgot your password?

You last visited: Today at 08:17

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

Advertisement



[Release] Memory Agate

Discussion on [Release] Memory Agate within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
[Release] Memory Agate

The structure that I have in Kibou:
Code:
namespace Kibou.World
{
    using System;
    using System.Collections.Generic;

    public unsafe class MemoryAgate
    {
        public List<string[]> Locations = new List<string[]>();
        public uint Identity = 0;
        public Connections.Packets.MemoryAgate Packet;
        public ushort Durability;

        public MemoryAgate(uint identity)
        {
            Identity = identity;
        }
        public void UpdateDurability(ushort value)
        {
            new Database.MySqlCmd("UPDATE `player_agates` SET `Durability` = " + value + " WHERE `Identity` = " + Identity);
            Packet.Durability = value;
        }
    }
}
The packet:

Code:
namespace Kibou.Connections.Packets
{
    using System.Runtime.InteropServices;
    using System.Runtime.Serialization.Formatters.Binary;

    [StructLayout(LayoutKind.Explicit)]
    public struct MemoryAgate
    {
        [FieldOffset(0)]
        private ushort _length;
        [FieldOffset(2)]
        private ushort _id;
        [FieldOffset(8)]
        public uint ItemIdentity;
        [FieldOffset(24)]
        public uint Durability;
        [FieldOffset(28)]
        public uint Amount;

        [FieldOffset(32)]
        public uint Location0;
        [FieldOffset(36)]
        public uint Map0;
        [FieldOffset(40)]
        public uint X0;
        [FieldOffset(44)]
        public uint Y0;

        [FieldOffset(80)]
        public uint Location1;
        [FieldOffset(84)]
        public uint Map1;
        [FieldOffset(88)]
        public uint X1;
        [FieldOffset(92)]
        public uint Y1;

        [FieldOffset(128)]
        public uint Location2;
        [FieldOffset(132)]
        public uint Map2;
        [FieldOffset(136)]
        public uint X2;
        [FieldOffset(140)]
        public uint Y2;

        [FieldOffset(176)]
        public uint Location3;
        [FieldOffset(180)]
        public uint Map3;
        [FieldOffset(184)]
        public uint X3;
        [FieldOffset(188)]
        public uint Y3;

        [FieldOffset(224)]
        public uint Location4;
        [FieldOffset(228)]
        public uint Map4;
        [FieldOffset(232)]
        public uint X4;
        [FieldOffset(236)]
        public uint Y4;

        [FieldOffset(272)]
        public uint Location5;
        [FieldOffset(276)]
        public uint Map5;
        [FieldOffset(280)]
        public uint X5;
        [FieldOffset(284)]
        public uint Y5;

        [FieldOffset(320)]
        public uint Location6;
        [FieldOffset(324)]
        public uint Map6;
        [FieldOffset(328)]
        public uint X6;
        [FieldOffset(332)]
        public uint Y6;

        [FieldOffset(368)]
        public uint Location7;
        [FieldOffset(372)]
        public uint Map7;
        [FieldOffset(376)]
        public uint X7;
        [FieldOffset(380)]
        public uint Y7;

        [FieldOffset(416)]
        public uint Location8;
        [FieldOffset(420)]
        public uint Map8;
        [FieldOffset(424)]
        public uint X8;
        [FieldOffset(428)]
        public uint Y8;

        [FieldOffset(464)]
        public uint Location9;
        [FieldOffset(468)]
        public uint Map9;
        [FieldOffset(472)]
        public uint X9;
        [FieldOffset(476)]
        public uint Y9;

        public MemoryAgate(uint itemIdentity, byte dura, byte amount)
        {
            _length = (ushort)(32 + (48 * amount));
            _id = 2110;
            ItemIdentity = itemIdentity;
            Durability = dura;
            Amount = amount;
            Location0 = 0;
            Map0 = 0;
            X0 = 0;
            Y0 = 0;
            Location1 = 1;
            Map1 = 0;
            X1 = 0;
            Y1 = 0;
            Location2 = 2;
            Map2 = 0;
            X2 = 0;
            Y2 = 0;
            Location3 = 3;
            Map3 = 0;
            X3 = 0;
            Y3 = 0;
            Location4 = 4;
            Map4 = 0;
            X4 = 0;
            Y4 = 0;
            Location5 = 5;
            Map5 = 0;
            X5 = 0;
            Y5 = 0;
            Location6 = 6;
            Map6 = 0;
            X6 = 0;
            Y6 = 0;
            Location7 = 7;
            Map7 = 0;
            X7 = 0;
            Y7 = 0;
            Location8 = 8;
            Map8 = 0;
            X8 = 0;
            Y8 = 0;
            Location9 = 9;
            Map9 = 0;
            X9 = 0;
            Y9 = 0;
        }
        public void Record(byte position, uint map, ushort x, ushort y)
        {
            switch (position)
            {
                case 0:
                    Map0 = map;
                    X0 = x;
                    Y0 = y;
                    break;
                case 1:
                    Map1 = map;
                    X1 = x;
                    Y1 = y;
                    break;
                case 2:
                    Map2 = map;
                    X2 = x;
                    Y2 = y;
                    break;
                case 3:
                    Map3 = map;
                    X3 = x;
                    Y3 = y;
                    break;
                case 4:
                    Map4 = map;
                    X4 = x;
                    Y4 = y;
                    break;
                case 5:
                    Map5 = map;
                    X5 = x;
                    Y5 = y;
                    break;
                case 6:
                    Map6 = map;
                    X6 = x;
                    Y6 = y;
                    break;
                case 7:
                    Map7 = map;
                    X7 = x;
                    Y7 = y;
                    break;
                case 8:
                    Map8 = map;
                    X8 = x;
                    Y8 = y;
                    break;
                case 9:
                    Map9 = map;
                    X9 = x;
                    Y9 = y;
                    break;
            }
        }
        public unsafe byte[] ToArray()
        {
            byte[] buffer = new byte[40 + (Amount * 48)];
            _length = (ushort)(32 + (48 * Amount));
            fixed (byte* ptr = buffer)
                *(MemoryAgate*)ptr = this;
            return buffer;
        }
    }
}
Packet Handler:
Code:
#region 2110 - Memory Agate
                    case 2110:
                        byte position = buffer[12];
                        uint identity = BitConverter.ToUInt32(buffer, 8);
                        switch (buffer[4])
                        {
                            #region [1] Record
                            case 1: MemoryAgateHandler.Record(client, identity, position); break;
                            #endregion
                            #region [3] Recall
                            case 3: MemoryAgateHandler.Recall(client, identity, position); break;
                            #endregion
                            #region [4] Repair
                            case 4: MemoryAgateHandler.Repair(client, identity); break;
                            #endregion

                            default: Report("2110 [Memory Agate]", buffer[4]); break;
                        }
                        break;
                    #endregion
Handlers:
Code:
namespace Kibou.Connections.Handlers
{
    using System;
    using System.Collections.Generic;

    public static class MemoryAgateHandler
    {
        public static void Open(World.Client client, World.Item item)
        {
            if (!client.MemoryAgates.ContainsKey(item.Identity))
            {
                Database.Agates.Insert(client.Identity, item.Identity);
                World.MemoryAgate newagate = new World.MemoryAgate(item.Identity);
                client.MemoryAgates.TryAdd(item.Identity, newagate);
            }
            World.MemoryAgate temp = null;
            client.MemoryAgates.TryGetValue(item.Identity, out temp);
            if (temp.Packet.ItemIdentity < 1)
            {
                temp.Packet = new Packets.MemoryAgate(item.Identity, (byte)item.Packet.Durability, 0);
                client.Send(temp.Packet.ToArray());
            }
            else
                client.Send(temp.Packet.ToArray());
        }
        public static void Record(World.Client client, uint identity, byte position)
        {
            if (!Database.Maps.RejectAgate.Contains(client.Character.MapId) && !client.Map.Dynamic)
            {
                if (client.Inventory.InventoryBase.ContainsKey(identity))
                {
                    World.MemoryAgate temp = client.MemoryAgates[identity];
                    Database.Agates.Update(temp.Identity, "Location " + position, client.Character.MapId
                        + "," + client.Character.X + "," + client.Character.Y);
                    temp.Packet.Record(position, client.Character.MapId, client.Character.X, client.Character.Y);
                    temp.Locations.Add(new string[4] { client.Character.MapId.ToString(), client.Character.X.ToString(), client.Character.Y.ToString(), position.ToString() });
                    if (temp.Packet.Amount < position + 1)
                        temp.Packet.Amount++;
                    client.Send(temp.Packet.ToArray());
                }
            }
            else
            {
                client.Send(new Packets.Message(0, "You can't record this map!", client.Character.Name, "SYSTEM", 
                    System.Drawing.Color.FromArgb(0, 255, 255), Packets.Message.Agate).ToArray());
            }
        }
        public static void Recall(World.Client client, uint identity, byte position)
        {
            if (client.Inventory.InventoryBase.ContainsKey(identity))
            {
                World.Item item = client.Inventory.InventoryBase[identity];
                if (item.Packet.Durability > 0)
                {
                    item.Durability--;
                    client.Inventory.Remove(identity);
                    client.Inventory.Add(item);
                    World.MemoryAgate temp = client.MemoryAgates[item.Identity];
                    temp.UpdateDurability(item.Durability);
                    client.Character.Teleport(uint.Parse(temp.Locations[position][0]), ushort.Parse(temp.Locations[position][1]), ushort.Parse(temp.Locations[position][2]));
                    client.Send(temp.Packet.ToArray());
                }
            }
        }
        public static void Repair(World.Client client, uint identity)
        {
            if (client.Inventory.InventoryBase.ContainsKey(identity))
            {
                World.Item item = client.Inventory.InventoryBase[identity];
                uint cost = (uint)Math.Round(((decimal)item.Packet.MaxDurability - (decimal)item.Durability) / 2);
                if (cost < 1)
                    cost = 1;
                if (item.Packet.Durability < item.Packet.MaxDurability)
                    if (client.Character.Cps >= cost)
                    {
                        client.Character.Cps -= cost;
                        World.MemoryAgate temp = client.MemoryAgates[item.Identity];
                        temp.UpdateDurability(item.Packet.MaxDurability);
                        item.Durability = item.Packet.MaxDurability;
                        client.Inventory.Remove(identity);
                        client.Inventory.Add(item);
                        client.Send(temp.Packet.ToArray());
                    }
            }
        }
    }
}
Ask me how to install any of this.
I dare you. ._. *shot gun ready*

Sincerely,
Fang

PS: None of this will work in any source known to this community
unless you code it for your own source.
Spirited is offline  
Thanks
7 Users
Old 08/10/2011, 09:46   #2
 
elite*gold: 0
Join Date: Jul 2011
Posts: 39
Received Thanks: 2
the table "Player_agates" contains only "Durability " and "identity" ?
bodayo69 is offline  
Old 08/10/2011, 09:53   #3
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by bodayo69 View Post
the table "Player_agates" contains only "Durability " and "identity" ?
It also contains Common Sense.
You can read about it on Google if you're confused.
Spirited is offline  
Old 08/10/2011, 17:58   #4
 
elite*gold: 0
Join Date: Feb 2011
Posts: 31
Received Thanks: 0
where this packet

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Conquer_Online_Server.Database
{
class Agates
{
}
}
moidy1 is offline  
Old 08/10/2011, 18:07   #5
 
bryce16's Avatar
 
elite*gold: 0
Join Date: Oct 2010
Posts: 47
Received Thanks: 3
Funny how your releases on here; you make it challenging for us(which ofcourse isn't bad) however on "other" forums you specify your releases a 'bit" more.

Good luck for who ever tries to toy around with this & if you need help just leave me a msg. (:
bryce16 is offline  
Old 08/10/2011, 20:01   #6
 
elite*gold: 0
Join Date: Jan 2011
Posts: 15
Received Thanks: 0
Fang Please Explaine where We Put It
The~Lord! is offline  
Old 08/10/2011, 20:06   #7
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by The~Lord! View Post
Fang Please Explaine where We Put It
Up your ***.
Don't ask again.
Spirited is offline  
Thanks
1 User
Old 08/10/2011, 23:00   #8
 
S/W's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 159
Received Thanks: 39
Quote:
Originally Posted by The~Lord! View Post
Fang Please Explaine where We Put It
If you don't know where put it stop In P Sever dev its not for you,You need read learn read understand and read learn,and one more time read learn understand,after you can make server.
S/W is offline  
Old 08/11/2011, 12:41   #9
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
Lol... making this work in the source (ANY) is a peace of cake... lol
12tails is offline  
Thanks
1 User
Old 08/11/2011, 14:13   #10
 
JobvdH's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 371
Received Thanks: 120
Nice work
JobvdH is offline  
Reply




All times are GMT +1. The time now is 08:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.