|
المشاركات 41 |
+التقييم 0.01 |
تاريخ التسجيل Apr 2013 |
الاقامة |
نظام التشغيل |
رقم العضوية 2786 |
ConquerItemTable
using System;
using System.Linq;
using Conquer_Online_Server.Network.GamePackets;
using System.Collections.Generic;
namespace Conquer_Online_Server.Database
{
public class ConquerItemTable
{
#region Blob
#region Main
public Network.GamePackets.ConquerItem ReadItem(System.IO.BinaryReader reader)
{
Network.GamePackets.ConquerItem item = new ConquerItem(true);
item.ID = reader.ReadUInt32();//4
item.UID = reader.ReadUInt32();//8
item.Durability = reader.ReadUInt16();//10
item.MaximDurability = reader.ReadUInt16();//12
item.Position = reader.ReadUInt16();//14
item.SocketProgress = reader.ReadUInt32();//18
item.PlusProgress = reader.ReadUInt32();//22
item.SocketOne = (Game.Enums.Gem)reader.ReadUInt16();//24
item.SocketTwo = (Game.Enums.Gem)reader.ReadUInt16();//26
item.Effect = (Game.Enums.ItemEffect)reader.ReadUInt16();//28
item.Mode = Game.Enums.ItemMode.Default;
item.Plus = reader.ReadByte();//29
item.Bless = reader.ReadByte();//30
item.Bound = reader.ReadBoolean();//31
item.Enchant = reader.ReadByte();//32
item.Lock = reader.ReadByte();//33
item.UnlockEnd = DateTime.FromBinary(reader.ReadInt64());//41
item.Suspicious = reader.ReadBoolean();//42
item.SuspiciousStart = DateTime.FromBinary(reader.ReadInt64());//50
item.Color = (Game.Enums.Color)reader.ReadUInt32();//54
if ((byte)item.Color > 9 || (byte)item.Color < 2)
item.Color = (Game.Enums.Color)Kernel.Random.Next(2, 8);
item.Warehouse = reader.ReadUInt16();//56
item.StackSize = reader.ReadUInt16();//58
if (item.Lock == 2)
if (DateTime.Now >= item.UnlockEnd)
item.Lock = 0;
return item;
}
#endregion
#region other
public void WriteItem(System.IO.BinaryWriter writer, Network.GamePackets.ConquerItem item)
{
writer.Write(item.ID); //= reader.ReadUInt32();
writer.Write(item.UID);
writer.Write(item.Durability);
writer.Write(item.MaximDurability);
writer.Write(item.Position);
writer.Write(item.SocketProgress);
writer.Write(item.PlusProgress);
writer.Write((ushort)item.SocketOne);
writer.Write((ushort)item.SocketTwo);
writer.Write((ushort)item.Effect);
writer.Write(item.Plus);
writer.Write(item.Bless);
writer.Write(item.Bound);
writer.Write(item.Enchant);
writer.Write(item.Lock);
writer.Write(item.UnlockEnd.Ticks);
writer.Write(item.Suspicious);
writer.Write(item.SuspiciousStart.Ticks);
writer.Write((uint)item.Color);
writer.Write(item.Warehouse);
writer.Write(item.StackSize);
// writer.Write((uint)(item.NextGreen | (item.NextBlue << 8) | (item.NextRed << 16)));
}
public static byte[] GetItemsAraay(Client.GameData client)
{
uint count = (uint)(client.Inventory.Count + client.Equipment.Count);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write(count);
foreach (var item in client.Inventory.Objects)
new ConquerItemTable().WriteItem(writer, item);
foreach (var item in client.Equipment.GetCollection())
new ConquerItemTable().WriteItem(writer, item);
return stream.ToArray();
}
#endregion
#endregion
public static void LoadItems(Client.GameData client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("EntityID", client.Entity.UID))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
var item = deserialzeItem(reader);
if (!ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
continue;
HandleInscribing(item, client);
ItemAddingTable.GetAddingsForItem(item);
#region WareHouse
if (item.Warehouse == 0)
{
switch (item.Position)
{
case 0: client.Inventory.Add(item, Game.Enums.ItemUse.None); break;
default:
if (item.Position > 29) continue;
if (client.Equipment.Free((byte)item.Position))
client.Equipment.Add(item, Game.Enums.ItemUse.None);
else
{
if (client.Inventory.Count < 40)
{
item.Position = 0;
client.Inventory.Add(item, Game.Enums.ItemUse.None);
if (client.Warehouses[Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market].Count < 20)
client.Warehouses[Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market].Add(item);
UpdatePosition(item);
}
}
break;
}
}
else
{
if (item != null)
{
Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID whID = (Game.ConquerStructures.Warehouse.WarehouseID)item.Warehouse;
if (client.Warehouses.ContainsKey(whID))
{
client.Warehouses[whID].Add(item);
}
else
{
using (var cmdx = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("Uid", (uint)item.Warehouse))
using (var readerx = new MySqlReader(cmdx))
if (readerx.Read())
{
client.Warehouses.Add((Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(client, (Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse));
client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)(uint)whID].Add(item);
}
}
}
}
#endregion WareHouse
if (item.ID == 720828)
{
string str = reader.ReadString("agate");
uint key = 0;
string[] strArray = str.Split(new char[] { '#' });
foreach (string str2 in strArray)
{
if (str2.Length > 6)
{
item.Agate_map.Add(key, str2);
key++;
}
}
}
}
}
}
public static ConquerItem deserialzeItem(MySqlReader reader)
{
ConquerItem item = new Network.GamePackets.ConquerItem(true);
item.ID = reader.ReadUInt32("Id");
item.UID = reader.ReadUInt32("Uid");
item.Durability = reader.ReadUInt16("Durability");
item.MaximDurability = reader.ReadUInt16("MaximDurability");
item.Position = reader.ReadUInt16("Position");
item.Agate = reader.ReadString("Agate");
item.SocketProgress = reader.ReadUInt32("SocketProgress");
item.PlusProgress = reader.ReadUInt32("PlusProgress");
item.SocketOne = (Game.Enums.Gem)reader.ReadUInt16("SocketOne");
item.SocketTwo = (Game.Enums.Gem)reader.ReadUInt16("SocketTwo");
item.Effect = (Game.Enums.ItemEffect)reader.ReadUInt16("Effect");
item.Mode = Game.Enums.ItemMode.Default;
item.Plus = reader.ReadByte("Plus");
item.Bless = reader.ReadByte("Bless");
item.Bound = reader.ReadBoolean("Bound");
item.Enchant = reader.ReadByte("Enchant");
item.Lock = reader.ReadByte("Locked");
item.UnlockEnd = DateTime.FromBinary(reader.ReadInt64("UnlockEnd"));
item.Suspicious = reader.ReadBoolean("Suspicious");
item.SuspiciousStart = DateTime.FromBinary(reader.ReadInt64("SuspiciousStart"));
item.Color = (Game.Enums.Color)reader.ReadUInt32("Color");
item.Warehouse = reader.ReadUInt32("Warehouse");
item.StackSize = reader.ReadUInt16("StackSize");
item.RefineItem = reader.ReadUInt32("RefineryItem");
Int64 rTime = reader.ReadInt64("RefineryTime");
if (item.ID == 300000)
{
uint NextSteedColor = reader.ReadUInt32("NextSteedColor");
item.NextGreen = (byte)(NextSteedColor & 0xFF);
item.NextBlue = (byte)((NextSteedColor >> 8) & 0xFF);
item.NextRed = (byte)((NextSteedColor >> 16) & 0xFF);
}
if (item.RefineItem > 0 && rTime != 0)
{
item.RefineryTime = DateTime.FromBinary(rTime);
if (DateTime.Now > item.RefineryTime)
{
item.RefineryTime = new DateTime(0);
item.RefineItem = 0;
}
}
if (item.Lock == 2)
if (DateTime.Now >= item.UnlockEnd)
item.Lock = 0;
item.DayStamp = DateTime.FromBinary(reader.ReadInt64("DayStamp"));
item.Days = reader.ReadByte("Days");
return item;
}
public static void UpdateDurabilityItem2(ConquerItem Item, uint ItemID)
{
if (Item != null)
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("Durability", (long)Item.Durability).Where("UID", (long)Item.UID).And("ID", (long)ItemID).Execute();
}
}
public static void SetDurabilityItem0(ConquerItem Item)
{
using (MySql.Data.MySqlClient.MySqlConnection connection = DataHolder.MySqlConnection)
{
connection.Open();
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("Durability", (long)0L).Where("UID", (long)Item.UID).Execute(connection);
connection.Close();
}
}
public static void HandleInscribing(ConquerItem item, Client.GameData client, bool detained = false)
{
if (client.Entity.GuildID != 0)
{
if (client.Guild != null)
{
int itemPosition = Network.PacketHandler.ArsenalPosition(item.ID);
if (itemPosition != -1)
{
var arsenal = client.Guild.Arsenals[itemPosition];
if (arsenal.Unlocked)
{
if (arsenal.ItemDictionary.ContainsKey(item.UID))
{
var arsenalItem = arsenal.ItemDictionary[item.UID];
arsenalItem.Update(item, client);
item.Inscribed = true;
client.ArsenalDonations[itemPosition] += arsenalItem.DonationWorth;
}
}
}
}
}
}
public static ConquerItem LoadItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("UID", UID))
using (var reader = new MySqlReader(cmd))
if (reader.Read())
return deserialzeItem(reader);
return new ConquerItem(true);
}
public static void AddItem(ref ConquerItem Item, Client.GameData client)
{
try
{
using (var cmd = new MySqlCommand(MySqlCommandType.INSERT).Insert("items"))
cmd.Insert("ID", Item.ID).Insert("UID", Item.UID)
.Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
.Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
.Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
.Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
.Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
.Insert("Bound", Item.Bound).Insert("DayStamp", Item.DayStamp.ToString()).Insert("Days", Item.Days).Insert("Locked", Item.Lock).Insert("UnlockEnd", Item.UnlockEnd.Ticks)
.Insert("Suspicious", Item.Suspicious).Insert("SuspiciousStart", Item.SuspiciousStart.Ticks)
.Insert("Color", (ushort)Item.Color).Insert("Position", Item.Position).Insert("StackSize", Item.StackSize)
.Insert("RefineryItem", Item.RefineItem).Insert("RefineryTime", Item.RefineryTime.Ticks).Insert("EntityID", client.Entity.UID)
.Execute();
}
catch (Exception e)
{
Console.WriteLine(e);
DeleteItem(Item.UID);
AddItem(ref Item, client);
}
}
private static void UpdateData(ConquerItem Item, string column, object value)
{
UpdateData(Item.UID, column, value);
}
private static void UpdateData(uint UID, string column, object value)
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set(column, value.ToString())
.Where("UID", UID).Execute();
}
public static void UpdateBless(ConquerItem Item)
{
UpdateData(Item, "Bless", Item.Bless);
}
public static void UpdateRefineryItem(ConquerItem Item)
{
UpdateData(Item, "RefineryItem", Item.RefineItem);
}
public static void UpdateRefineryTime(ConquerItem Item)
{
UpdateData(Item, "RefineryTime", Item.RefineryTime.Ticks);
}
public static void UpdateItemAgate(ConquerItem Item)
{
string agate = "";
if (Item.ID == 720828)
{
foreach (string coord in Item.Agate_map.Values)
{
agate += coord + "#";
UpdateData(Item, "agate", agate);
}
}
}
public static void UpdateColor(ConquerItem Item)
{
UpdateData(Item, "Color", (uint)Item.Color);
}
public static void UpdateStack(ConquerItem Item)
{
UpdateData(Item, "StackSize", Item.StackSize);
}
public static void UpdateEnchant(ConquerItem Item)
{
UpdateData(Item, "Enchant", Item.Enchant);
}
public static void UpdateLock(ConquerItem Item)
{
UpdateData(Item, "Locked", Item.Lock);
UpdateData(Item, "UnlockEnd", Item.UnlockEnd.ToBinary());
}
public static void UpdateSockets(ConquerItem Item)
{
UpdateData(Item, "SocketOne", (byte)Item.SocketOne);
UpdateData(Item, "SocketTwo", (byte)Item.SocketTwo);
}
public static void UpdateSocketProgress(ConquerItem Item)
{
UpdateData(Item, "SocketProgress", Item.SocketProgress);
}
public static void UpdateNextSteedColor(ConquerItem Item)
{
UpdateData(Item, "NextSteedColor", Item.NextGreen | (Item.NextBlue << 8) | (Item.NextRed << 16));
}
public static void UpdateDurabilityItem(ConquerItem Item)
{
}
public static void UpdateLocation(ConquerItem Item, Client.GameData client)
{
if (IsThere(Item.UID))
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("EntityID", client.Entity.UID)
.Set("Position", Item.Position).Set("Warehouse", (uint)Item.Warehouse)
.Where("UID", Item.UID).Execute();
}
else
{
using (var cmd = new MySqlCommand(MySqlCommandType.INSERT).Insert("items"))
cmd.Insert("ID", Item.ID).Insert("UID", Item.UID)
.Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
.Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
.Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
.Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
.Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
.Insert("Bound", Item.Bound).Insert("DayStamp", Item.DayStamp.ToString()).Insert("Days", Item.Days).Insert("Locked", Item.Lock).Insert("UnlockEnd", Item.UnlockEnd.Ticks)
.Insert("Suspicious", Item.Suspicious).Insert("SuspiciousStart", Item.SuspiciousStart.Ticks)
.Insert("Color", (ushort)Item.Color).Insert("Position", Item.Position).Insert("StackSize", Item.StackSize)
.Insert("RefineryItem", Item.RefineItem).Insert("RefineryTime", Item.RefineryTime.Ticks).Insert("EntityID", client.Entity.UID)
.Execute();
}
}
public static void UpdatePosition(ConquerItem Item)
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("Position", Item.Position).Set("Warehouse", Item.Warehouse)
.Where("UID", Item.UID).Execute();
}
public static void UpdatePlus(ConquerItem Item)
{
UpdateData(Item, "Plus", Item.Plus);
}
public static void UpdateBound(ConquerItem Item)
{
UpdateData(Item, "Bound", 0);
}
public static void UpdatePlusProgress(ConquerItem Item)
{
UpdateData(Item, "PlusProgress", Item.PlusProgress);
}
public static void UpdateItemID(ConquerItem Item, Client.GameData client)
{
UpdateData(Item, "ID", Item.ID);
}
public static void RemoveItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("EntityID", 0)
.Set("Position", 0).Where("UID", UID).Execute();
}
public static void DeleteItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.DELETE))
cmd.Delete("items", "UID", UID).Execute();
}
public static void ClearPosition(uint EntityID, byte position)
{
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
cmd.Update("items").Set("EntityID", 0).Set("Position", 0)
.Where("EntityID", EntityID).And("Position", position).Execute();
}
public static void RefineryUpdate(ConquerItem Item, Client.GameData client)
{
}
public static void ClearNulledItems()
{
Dictionary<uint, int> dict = new Dictionary<uint, int>();
using (var c = new MySqlCommand(MySqlCommandType.SELECT).Select("detaineditems"))
using (var r = c.CreateReader())
while (r.Read())
dict[r.ReadUInt32("ItemUID")] = 0;
//cmd.Where("UID", r.ReadUInt32("ItemUID"));
using (var c = new MySqlCommand(MySqlCommandType.SELECT).Select("claimitems"))
using (var r = c.CreateReader())
while (r.Read())
dict[r.ReadUInt32("ItemUID")] = 0;
//cmd.Where("UID", r.ReadUInt32("ItemUID"));
var array = dict.Keys.ToArray();
foreach (var item in array)
using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("items")
.Set("entityid", 1).Where("entityid", 0).And("uid", item))
cmd.Execute();
using (var cmd = new MySqlCommand(MySqlCommandType.DELETE).Delete("items", "entityid", 0))
cmd.Execute();
Console.WriteLine("Cleared items with EntityID = 0");
}
public static bool IsThere(uint uid)
{
MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
command.Select("items").Where("UID", (long)uid);
MySqlReader reader = new MySqlReader(command);
if (reader.Read())
{
// Reader.Close();
//// Reader.Dispose();
return true;
}
// Reader.Close();
//// Reader.Dispose();
return false;
}
public static void Update_Free(ConquerItem Item, Client.GameData client)
{
MySqlCommand command = new MySqlCommand(MySqlCommandType.UPDATE);
command.Update("items").Set("EntityID", client.Entity.UID).Set("DayStamp", Item.DayStamp.Ticks).Set("Days", Item.Days).Where("UID", Item.UID).Execute();
}
}
}
ConquerItem
using System;
using System.Drawing;
using Conquer_Online_Server.Game;
using System.Collections.Generic;
using System.IO;
namespace Conquer_Online_Server.Network.GamePackets
{
public class ConquerItem : Writer, Interfaces.IPacket
{
public const ushort
Inventory = 0,
Head = 1,
Necklace = 2,
Armor = 3,
RightWeapon = 4,
LeftWeapon = 5,
Ring = 6,
Bottle = 7,
Boots = 8,
Garment = 9,
Fan = 10,
Tower = 11,
Steed = 12,
SteedCrop = 18,
RightWeaponAccessory = 15,
LeftWeaponAccessory = 16,
SteedArmor = 17,
Remove = 255,
Wing = 19,
AlternateHead = 21,
AlternateNecklace = 22,
AlternateArmor = 23,
AlternateRightWeapon = 24,
AlternateLeftWeapon = 25,
AlternateRing = 26,
AlternateBottle = 27,
AlternateBoots = 28,
AlternateGarment = 29;
public const uint GoldPrize = 2100075;
public bool IsWorn = false;
public byte[] Buffer;
public static Counter ItemUID = new Counter(0);
private UInt32 mRefineItem = 0;
private DateTime mRefineryTime;
private ulong suspiciousStart = 0, unlockEnd = 0;
private bool unlocking = false;
private uint warehouse = 0;
public Dictionary<uint, string> Agate_map { get; set; }
public DateTime RefineryStarted { get; set; }
public ConquerItem(bool Create)
{
if (Create)
{
Buffer = new byte[92];
WriteUInt16(84, 0, Buffer);
WriteUInt16(1008, 2, Buffer);
Mode = Conquer_Online_Server.Game.Enums.ItemMode.Default;
this.Agate_map = new Dictionary<uint, string>(10);
StatsLoaded = false;
}
}
public byte Days
{
get;
set;
}
public DateTime DayStamp
{
get;
set;
}
public uint UID
{
get { return BitConverter.ToUInt32(Buffer, 4); }
set { WriteUInt32(value, 4, Buffer); }
}
public uint ID
{
get { return BitConverter.ToUInt32(Buffer, 8); }
set
{
if (value == 0 && ID != 0)
throw new Exception("Invalid ID for an Item. Please check the stack trace to find the cause.");
WriteUInt32(value, 8, Buffer);
}
}
public void SetID(uint ID)
{
WriteUInt32(ID, 8, Buffer);
}
public ushort Durability
{
get { return BitConverter.ToUInt16(Buffer, 12); }
set { WriteUInt16(value, 12, Buffer); }
}
public ushort MaximDurability
{
get { return BitConverter.ToUInt16(Buffer, 14); }
set { WriteUInt16(value, 14, Buffer); }
}
public Enums.ItemMode Mode
{
get { return (Enums.ItemMode)BitConverter.ToUInt16(Buffer, 16); }
set { WriteUInt16((ushort)value, 16, Buffer); }
}
public ushort Position
{
get { return BitConverter.ToUInt16(Buffer, 18); }
set { WriteUInt16(value, 18, Buffer); }
}
public uint Warehouse
{
get { return warehouse; }
set { warehouse = value; }
}
public uint SocketProgress
{
get { return BitConverter.ToUInt32(Buffer, 20); }
set { WriteUInt32(value, 20, Buffer); }
}
public Enums.Gem SocketOne
{
get { return (Enums.Gem)Buffer[24]; }
set { Buffer[24] = (byte)value; }
}
public Enums.Gem SocketTwo
{
get { return (Enums.Gem)Buffer[25]; }
set { Buffer[25] = (byte)value; }
}
public Enums.ItemEffect Effect
{
get { return (Enums.ItemEffect)BitConverter.ToUInt16(Buffer, 28); }
set { WriteUInt16((ushort)value, 28, Buffer); }
}
public byte Plus
{
get { return Buffer[33]; }
set
{
if (value > 12) value = 12;
Buffer[33] = value;
}
}
public byte Bless
{
get { return Buffer[34]; }
set { Buffer[34] = value; }
}
public bool Bound
{
get { return Buffer[35] == 0 ? false : true; }
set { Buffer[35] = (byte)(value ? 1 : 0); }
}
public byte Enchant
{
get { return Buffer[36]; }
set { Buffer[36] = value; }
}
public byte NextRed
{
get { return Buffer[34]; }
set { Buffer[34] = value; }
}
public byte NextBlue
{
get { return Buffer[36]; }
set { Buffer[36] = value; }
}
public byte NextGreen
{
get { return Buffer[40]; }
set { Buffer[40] = value; }
}
public bool Suspicious
{
get { return Buffer[44] == 0 ? false : true; }
set { Buffer[44] = (byte)(value ? 1 : 0); }
}
public byte Lock
{
get { return Buffer[46]; }
set { Buffer[46] = value; }
}
public Enums.Color Color
{
get { return (Enums.Color)BitConverter.ToUInt32(Buffer, 48); }
set { WriteUInt32((uint)value, 48, Buffer); }
}
public uint PlusProgress
{
get { return BitConverter.ToUInt32(Buffer, 52); }
set { WriteUInt32(value, 52, Buffer); }
}
public bool Inscribed
{
get
{
return (BitConverter.ToUInt16(this.Buffer, 56) == 1);
}
set
{
Writer.WriteUInt16(value ? ((byte)1) : ((byte)0), 56, this.Buffer);
}
}
public uint TimeLeftInMinutes
{
get { return BitConverter.ToUInt32(Buffer, 60); }
set { WriteUInt32(value, 60, Buffer); }
}
public ushort StackSize
{
get { return BitConverter.ToUInt16(Buffer, 68); }
set { WriteUInt16(value, 68, Buffer); }
}
public ushort MaxStackSize
{
get;
set;
}
public DateTime SuspiciousStart
{
get { return DateTime.FromBinary((long)suspiciousStart); }
set { suspiciousStart = (ulong)value.Ticks; }
}
public DateTime UnlockEnd
{
get { return DateTime.FromBinary((long)unlockEnd); }
set { unlockEnd = (ulong)value.Ticks; }
}
public bool Unlocking
{
get { return unlocking; }
set { unlocking = value; }
}
public bool MobDropped
{
get;
set;
}
public bool StatsLoaded
{
get;
set;
}
public string Agate
{
get;
set;
}
public byte[] ToArray()
{
return Buffer;
}
public void Deserialize(byte[] buffer)
{
throw new NotImplementedException();
}
public class ItemSocket
{
public const Byte
Phoenix = 0,
Dragon = 1,
Fury = 2,
Rainbow = 3,
Kylin = 4,
Violet = 5,
Moon = 6,
Tortoise = 7,
Thunder = 10,
Glory = 12,
OpenSocket = 255,
NoSocket = 0;
/// <summary>
/// Pass the entire gem's ID, not just the type.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static Double GetGemBonus(Byte value)
{
switch (value)
{
case 71:
return 0.02;
case 72:
return 0.04;
case 1:
case 11:
case 21:
return 0.05;
case 73:
return 0.06;
case 2:
case 12:
case 22:
case 31:
return 0.10;
case 3:
case 23:
case 32:
case 61:
case 13:
return 0.15;
case 33:
return 0.25;
case 51:
case 62:
return 0.30;
case 41:
case 52:
case 63:
return 0.50;
case 42:
case 53:
return 1.00;
case 43:
return 2.00;
case 101:
case 121:
return 100;
case 102:
case 122:
return 300;
case 103:
case 123:
return 500;
default:
return 0;
}
}
}
public Double GemBonus(Byte type)
{
Double bonus = 0;
if (SocketOne != Enums.Gem.NoSocket)
{
if ((Int32)SocketOne / 10 == type)
bonus += ItemSocket.GetGemBonus((Byte)SocketOne);
if (SocketTwo != Enums.Gem.NoSocket)
{
if ((Int32)SocketTwo / 10 == type)
bonus += ItemSocket.GetGemBonus((Byte)SocketTwo);
}
}
return bonus;
}
//public Double GemBonus(Byte type)
//{
// Double bonus = 0;
// if (SocketOne != Enums.Gem.NoSocket)
// {
// if ((Int32)SocketOne / 10 == type)
// bonus += ItemSocket.GetGemBonus((Byte)SocketOne);
// if (SocketTwo != Enums.Gem.NoSocket)
// {
// if ((Int32)SocketTwo / 10 == type)
// bonus += ItemSocket.GetGemBonus((Byte)SocketTwo);
// }
// }
// return bonus;
//}
public override string ToString()
{
return ID.ToString() + "#"
+ Durability.ToString() + "#"
+ MaximDurability.ToString() + "#"
+ Position.ToString() + "#"
+ SocketProgress.ToString() + "#"
+ ((byte)SocketOne).ToString() + "#"
+ ((byte)SocketTwo).ToString() + "#"
+ ((ushort)Effect).ToString() + "#"
+ Plus.ToString() + "#"
+ Bless.ToString() + "#"
+ (Bound ? "1" : "0") + "#"
+ Enchant.ToString() + "#"
+ (Suspicious ? "1" : "0") + "#"
+ Lock.ToString() + "#"
+ (Unlocking ? "1" : "0") + "#"
+ PlusProgress.ToString() + "#"
+ (Inscribed ? "1" : "0") + "#"
+ suspiciousStart.ToString() + "#"
+ Days.ToString() + "#"
+ DayStamp.ToString() + "#"
+ unlockEnd.ToString();
}
public string ToLog()
{
return "UID: " + UID.ToString() + " | "
+ "ID: " + ID.ToString() + " | "
+ "Plus: " + Plus.ToString();
}
public ItemAdding.Purification_ Purification
{
get;
set;
}
public ItemAdding.Refinery_ ExtraEffect
{
get;
set;
}
public UInt32 RefineItem
{
get { return mRefineItem; }
set { mRefineItem = value; }
}
public void SendExtras(Client.GameData client)
{
if (client == null)
return;
if (RefineItem != 0)
{
Refinery.RefineryItem rI = RefineStats;
if (rI != null)
{
client.Send(new Game_ItemSoul()
{
ID = rI.Identifier,
Identifier = UID,
Level = rI.Level,
Mode = Game_ItemSoul.Types.Refine,
Percent = rI.Percent,
Type = 1,
Time = (UInt32)(RefineryTime.Subtract(DateTime.Now).TotalSeconds)
});
}
}
ItemAdding add = new ItemAdding(true);
if (Purification.Available)
add.Append(Purification);
if (ExtraEffect.Available)
add.Append(ExtraEffect);
if (Purification.Available || ExtraEffect.Available)
client.Send(add);
if (Lock == 2)
{
ItemLock itemLock = new ItemLock(true);
itemLock.UID = UID;
itemLock.ID = ItemLock.UnlockDate;
itemLock.dwParam = (uint)(UnlockEnd.Year * 10000 + UnlockEnd.Month * 100 + UnlockEnd.Day);
client.Send(itemLock);
}
}
public void SendAgate(Client.GameData client)
{
byte[] buffer = new byte[(40 + (0x30 * this.Agate_map.Count)) + 0x30];
Writer.WriteUInt16((ushort)(buffer.Length - 8), 0, buffer);
Writer.WriteUInt16(0x83e, 2, buffer);
Writer.WriteUInt32(this.UID, 8, buffer);
Writer.WriteUInt32((byte)this.Agate_map.Count, 12, buffer);
Writer.WriteUInt32((byte)this.Agate_map.Count, 0x10, buffer);
Writer.WriteUInt32(this.Durability, 0x18, buffer);
Writer.WriteUInt32((byte)this.Agate_map.Count, 0x1c, buffer);
if (this.Agate_map.Count > 0)
{
int offset = 0x20;
for (uint i = 0; i < this.Agate_map.Count; i++)
{
Writer.WriteUInt32(i, offset, buffer);
offset += 4;
Writer.WriteUInt16(ushort.Parse(this.Agate_map[i].Split(new char[] { '~' })[0].ToString()), offset, buffer);
offset += 4;
Writer.WriteUInt16(ushort.Parse(this.Agate_map[i].Split(new char[] { '~' })[1].ToString()), offset, buffer);
offset += 4;
Writer.WriteUInt16(ushort.Parse(this.Agate_map[i].Split(new char[] { '~' })[2].ToString()), offset, buffer);
offset += 0x24;
}
}
client.Send(buffer);
}
public void Send(Client.GameData client)
{
if (client == null)
return;
if (ID == 300000)
{
uint G = SocketProgress & 0xFF;
uint B = (SocketProgress >> 8) & 0xFF;
uint R = (SocketProgress >> 16) & 0xFF;
if (NextRed == 0 && NextBlue == 0 && NextGreen == 0)
{
NextRed = (byte)R;
NextBlue = (byte)B;
NextGreen = (byte)G;
Database.ConquerItemTable.UpdateNextSteedColor(this);
}
}
if (Days > 0)
{
if (DateTime.Now >= this.DayStamp.AddDays(Days))
{
Database.ConquerItemTable.DeleteItem(this.UID);
Database.ConquerItemTable.RemoveItem(this.UID);
client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Your Item Has Expired", System.Drawing.Color.Red, Message.TopLeft));
}
TimeSpan Remain = DayStamp.AddDays(Days) - DateTime.Now;
TimeLeftInMinutes = (uint)Remain.TotalSeconds;
}
client.Send(Buffer);
ItemAdding add = new ItemAdding(true);
if (Purification.Available)
add.Append(Purification);
if (ExtraEffect.Available)
add.Append(ExtraEffect);
if (Purification.Available || ExtraEffect.Available)
client.Send(add);
if (Lock == 2 && (Mode == Enums.ItemMode.Default || Mode == Enums.ItemMode.Update))
{
ItemLock itemLock = new ItemLock(true);
itemLock.UID = UID;
itemLock.ID = ItemLock.UnlockDate;
itemLock.dwParam = (uint)(UnlockEnd.Year * 10000 + UnlockEnd.Month * 100 + UnlockEnd.Day);
client.Send(itemLock);
}
Mode = Enums.ItemMode.Default;
// client.Send(Buffer);
}
public static Boolean isRune(UInt32 itemid)
{
if (itemid >= 729960 && itemid <= 729970)
return true;
return false;
}
public ushort Vigor
{
get;
set;
}
public short BattlePower
{
get
{
short potBase = 0;
byte Quality = (byte)(ID % 10);
if (Quality >= 5)
potBase += (byte)(Quality - 5);
potBase += Plus;
if (SocketOne != Enums.Gem.NoSocket) potBase++;
if (SocketTwo != Enums.Gem.NoSocket) potBase++;
if (((byte)SocketOne) % 10 == 3) potBase++;
if (((byte)SocketTwo) % 10 == 3) potBase++;
if (ID / 1000 == 421 || PacketHandler.IsTwoHand(ID))
potBase *= 2;
return potBase;
}
}
public override int GetHashCode()
{
return (int)this.UID;
}
public override bool Equals(object obj)
{
return (obj as ConquerItem).UID == GetHashCode();
}
public Refinery.RefineryItem RefineStats
{
get
{
Refinery.RefineryItem i = null;
Kernel.DatabaseRefinery.TryGetValue(RefineItem, out i);
return i;
}
}
public DateTime RefineryTime
{
get { return mRefineryTime; }
set { mRefineryTime = value; }
}
public bool IsTwoHander()
{
ItemTypes item_type = (ItemTypes)GetItemType();
bool check = ((UInt16)item_type >= 500 && (UInt16)item_type <= 580);
if (check)
{
check = (item_type != ItemTypes.ShieldID);
if (check)
{
check = (item_type != ItemTypes.NinjaSwordID);
if (check)
{
check = (item_type != ItemTypes.MonkBeadsID);
}
}
}
return check;
}
public ItemTypes GetItemType()
{
return (ItemTypes)(this.ID / 1000);
}
public static void CheckItemExtra(ConquerItem i, Client.GameData c)
{
if (i.RefineryTime.Ticks != 0)
{
if (DateTime.Now > i.RefineryTime)
{
i.RefineItem = 0;
i.RefineryTime = new DateTime(0);
Game_ItemSoul expire = new Game_ItemSoul()
{
Identifier = i.UID
};
expire.Expired(c);
i.Send(c);
c.Send(PacketHandler.WindowStats(c));
Database.ConquerItemTable.UpdateRefineryItem(i);
Database.ConquerItemTable.UpdateRefineryTime(i);
if (!c.Equipment.Free(i.Position))
{
//c.UnloadItemStats(i, true);
c.LoadItemStats();
}
}
}
}
public enum ItemTypes : ushort
{
BowID = 500,
ArrowID = 1050,
ShieldID = 900,
BackswordID = 421,
BladeID = 410,
SwordID = 420,
NinjaSwordID = 601,
MonkBeadsID = 610,
FanID = 201,
TowerID = 202,
CropID = 203,
GarmentID_1 = 181,
GarmentID_2 = 182,
BottleID = 2100,
GemID = 700,
PickaxeID = 562,
RingID = 150,
BootID = 160,
SteedArmorID = 200,
NecklaceID = 120,
BraceletID = 152,
BagID = 121,
RightAccessory1 = 350,
RightAccessory2 = 360,
RightAccessory3 = 370,
LeftAccessory = 380
}
public uint OriginalUID { get; set; }
}
}
ConquerItemInformation
http://up.top4top.net/downloadf-top4top_1ce67d35c91-rar.html
http://up.top4top.net/downloadf-top4top_cf2d090bac1-rar.html
pJg laJ;gm hghsJjt fdojJtd h, fdjgyf' ugd fuqJ,
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
انواع عرض الموضوع |
العرض العادي |
الانتقال إلى العرض المتطور |
الانتقال إلى العرض الشجري |
|