I have been working on this source for a few months and learn a lot from it:) Just wanted to release something I made if anyone has a better way to make this just let me know:).
This is so when you equip and unequip Items the other player sees them:)
Frist in Entity.cs Search For
Code:
public string Name
{
get
{
return Encoding.ASCII.GetString(this.SpawnPacket, 82, 16).Trim(new char[] { (char)0x0000 });
}
set
{
if (value.Length > 15)
{
value = value.Substring(0, 15);
}
this.SpawnPacket[80] = 255;
this.SpawnPacket[81] = (byte)value.Length;
PacketBuilder.WriteString(value, this.SpawnPacket, 82);
}
}
Add this Under it
Code:
public uint HeadGear
{
get
{
return BitConverter.ToUInt32(this.SpawnPacket, 28);
}
set
{
PacketBuilder.WriteUInt32(value, this.SpawnPacket, 28);
}
}
public uint Armoer
{
get
{
return BitConverter.ToUInt32(this.SpawnPacket, 32);
}
set
{
PacketBuilder.WriteUInt32(value, this.SpawnPacket, 32);
}
}
public uint RightArm
{
get
{
return BitConverter.ToUInt32(this.SpawnPacket, 36);
}
set
{
PacketBuilder.WriteUInt32(value, this.SpawnPacket, 36);
}
}
public uint LeftArm
{
get
{
return BitConverter.ToUInt32(this.SpawnPacket, 40);
}
set
{
PacketBuilder.WriteUInt32(value, this.SpawnPacket, 40);
}
}
Than Search for EquipGear(GameClient Client, ItemUsagePacket Packet)
Replace with
Code:
public static void EquipGear(GameClient Client, ItemUsagePacket Packet)
{
IConquerItem EquipItem = Client.GetInventoryItem(Packet.UID);
if (EquipItem != null)
{
Client.RemoveInventory(EquipItem.UID);
ushort EquipSlot = (ushort)Packet.dwParam;
if (Client.Equipment.ContainsKey(EquipSlot))
{
if (!Client.Unequip(EquipSlot))
throw new Exception("PacketProcessor::EquipGear() -> Failed to call Client.Unequip()");
}
if (!Client.Equip(EquipItem, EquipSlot))
throw new Exception("PacketProcessor::EquipGear() -> Failed to call Client.Equip()");
if (EquipSlot == 9)
{
if (EquipItem.ID > 0)
{
Client.Entity.Armoer = EquipItem.ID;
}
}
if (EquipSlot == 0)
{
if (EquipItem.ID > 0)
{
Client.Entity.HeadGear = EquipItem.ID;
}
}
if (EquipSlot == 2)
{
if (Client.Entity.Armoer == 0)
{
Client.Entity.Armoer = EquipItem.ID;
}
}
if (EquipSlot == 4)
{
if (EquipItem.ID > 0)
{
Client.Entity.LeftArm = EquipItem.ID;
}
}
if (EquipSlot == 5)
{
if (EquipItem.ID > 0)
{
Client.Entity.RightArm = EquipItem.ID;
}
}
Client.CalculateStatBonus();
Client.CalculateHPBonus();
Client.CalculateDamageBoost();
Client.SendStatMessage();
Client.SendScreen(Client.Entity.SpawnPacket, true);
Client.Screen.Reload(true, null);
}
}
And Than Search for public static void UnequipGear(GameClient Client, ItemUsagePacket Packet)
and replace with
Code:
public static void UnequipGear(GameClient Client, ItemUsagePacket Packet)
{
ushort EquipSlot = (ushort)Packet.dwParam;
if (Client.Equipment.ContainsKey(EquipSlot))
{
if (!Client.Unequip(EquipSlot))
throw new Exception("PacketProcessor::UnequipGear() -> Failed to call Client.Unequip()");
if (EquipSlot == 9)
{
for (int ID = 1; ID < Client.Equipment.Count; ID++)
{
if (Client.Equipment.ContainsKey((ushort)ID))
{
if (Client.Equipment[(ushort)ID].ID >= 130203 && Client.Equipment[(ushort)ID].ID <= 139999)
{
Client.Entity.Armoer = Client.Equipment[(ushort)ID].ID;
}
}
}
}
if (EquipSlot == 3)
{
for (int ID = 1; ID < Client.Equipment.Count; ID++)
{
if (Client.Equipment.ContainsKey((ushort)ID))
{
if (Client.Equipment[(ushort)ID].ID <= 137300 && Client.Equipment[(ushort)ID].ID >= 137970)
{
Client.Entity.Armoer = Client.Equipment[(ushort)ID].ID;
}
}
}
}
if (EquipSlot == 5)
{
{
Client.Entity.RightArm = 0;
}
}
if (EquipSlot == 4)
{
{
Client.Entity.LeftArm = 0;
}
}
if (EquipSlot == 0)
{
{
Client.Entity.HeadGear = 0;
}
}
Client.SendScreen(Packet, true);
Client.CalculateStatBonus();
Client.CalculateHPBonus();
Client.CalculateDamageBoost();
Client.SendStatMessage();
Client.SendScreen(Client.Entity.SpawnPacket, true);
Client.Screen.Reload(true, null);
}
}
and also to Load and Save Equips in Database.cs Add
Code:
public static void LoadEquips(GameClient Client)
{
IniFile rdr = new IniFile(DatabasePath + @"\Equips\" + Client.Username + ".ini");
for (sbyte i = 0; i < 9; i++)
{
string[] Item = (rdr.ReadString("Equips", "Item[" + i.ToString() + "]", String.Empty)).Split(' ');
if (Item.Length < 2) continue;
ItemDataPacket LoadedItem = new ItemDataPacket(true);
LoadedItem.ID = uint.Parse(Item[0]);
LoadedItem.Plus = byte.Parse(Item[1]);
LoadedItem.Enchant = byte.Parse(Item[2]);
LoadedItem.Bless = byte.Parse(Item[3]);
LoadedItem.SocketOne = byte.Parse(Item[4]);
LoadedItem.SocketTwo = byte.Parse(Item[5]);
LoadedItem.UID = ItemDataPacket.NextItemUID;
Client.Equip(LoadedItem, (ushort)(i + 1));
if (i == 8)
{
if (LoadedItem.ID > 0)
{
Client.Entity.Armoer = LoadedItem.ID;
}
}
if (i == 0)
{
if (LoadedItem.ID > 0)
{
Client.Entity.HeadGear = LoadedItem.ID;
}
}
if (i == 0)
{
if (LoadedItem.ID > 0)
{
Client.Entity.HeadGear = LoadedItem.ID;
}
}
if (i == 3)
{
if (LoadedItem.ID > 0)
{
Client.Entity.LeftArm = LoadedItem.ID;
}
}
if (i == 4)
{
if (LoadedItem.ID > 0)
{
Client.Entity.RightArm = LoadedItem.ID;
}
}
}
}
public static void SaveEquips(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Equips\" + Client.Username + ".ini");
lock (Client.Equipment)
{
sbyte i = 0;
foreach (KeyValuePair<ushort, IConquerItem> DE in Client.Equipment)
{
wrtr.Write("Equips", "Item[" + (DE.Key - 1).ToString() + "]", DE.Value.ToString());
i++;
}
}
}
And in Save add
Code:
SaveEquips(Client);
Also add LoadCharcter
Code:
LoadEquips(Client);