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;
}
}
}
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;
}
}
}
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
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());
}
}
}
}
}
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.






