[Release] Extremely basic (but working/bugless) C# Source

04/19/2009 20:18 alexbigfoot#61
Well...that a very easy thing...
Code:
    public class Proficiency
    {
        private byte[] Packet;
        public Proficiency()
        {
                Packet = new byte[16];
                PacketBuilder.WriteUInt16(16, Packet, 0);
                PacketBuilder.WriteUInt16(0x401, Packet, 2);
        }
        public uint WeaponID
        {
            get { return BitConverter.ToUInt32(Packet, 4); }
            set { PacketBuilder.WriteUInt32(value, Packet, 4); }
        }
        public uint Level
        {
            get { return BitConverter.ToUInt32(Packet, 8); }
            set { PacketBuilder.WriteUInt32(value, Packet, 8); }
        }
        public uint Exp
        {
            get { return BitConverter.ToUInt32(Packet, 12); }
            set { PacketBuilder.WriteUInt32(value, Packet, 12); }
        }
        public byte[] Serialize()
        {
            return Packet;
        }
    }
Usage: Proficiency prof = new Proficiency(); prof.WeaponID = 480; prof.Level = 19; prof.Exp = 192321; Client.Send(prof.Serialize());

The database save & load its ur job.
04/19/2009 21:35 tao4229#62
You'll have to add the database part, but this is all I've got lol.
04/22/2009 18:04 LordSesshomaru#63
Ok here is a code that i have been working on for + item restriction (as seen on AcidCO) I figured since i am using Hybrid's source that i should post it here and hopes that more people will take interest in this growing source.

Code:
string[] Info = Item.Split('-');
ItemData.ID = uint.Parse(Info[0]);
ItemData.Plus = Math.Min(byte.Parse(Info[1]), 9);
ItemData.Bless = byte.Parse(Info[2]);
ItemData.Enchant = byte.Parse(Info[3]);
ItemData.SocketOne = byte.Parse(Info[4]);
ItemData.SocketTwo = byte.Parse(Info[5]);
ItemData.UID = NextItemUID;
return true;
Big Thanks to Tao for the one who helped me figure out a better way than how i tired it.

@Anyone
Anyone know a good decompiler , i want to decompile the SocketNetwork.dll so i can study what Hybrid did with it. Thanks
04/22/2009 19:02 kinshi88#64
Quote:
Originally Posted by LordSesshomaru View Post
@Anyone
Anyone know a good decompiler , i want to decompile the SocketNetwork.dll so i can study what Hybrid did with it. Thanks
.Net Reflector
04/23/2009 03:56 kinshi88#65
Code:
        private static void LoadInventory(GameClient Client)
        {
            IniFile rdr = new IniFile(DatabasePath + @"\Inventory\" + Client.Username + ".ini");
            sbyte count = rdr.ReadSByte("Inventory", "Count", 0);
            for (sbyte i = 0; i < count; i++)
            {
                string[] Item = (rdr.ReadString("Inventory", "Item[" + i.ToString() + "]", String.Empty)).Split(' ');
                ItemDataPacket LoadedItem = new ItemDataPacket(true);
                LoadedItem.ID = uint.Parse(Item[0]);
                LoadedItem.Plus = byte.Parse(Item[1]);
                LoadedItem.Enchant = byte.Parse(Item[2]);
                LoadedItem.SocketOne = byte.Parse(Item[3]);
                LoadedItem.SocketTwo = byte.Parse(Item[4]);
                LoadedItem.UID = ItemDataPacket.NextItemUID;
                Client.AddInventory(LoadedItem);
            }
        }
That's whats in my source, seems to work just fine =P
04/23/2009 22:15 LordSesshomaru#66
Code:
        private static void LoadEquips(GameClient Client)
        {
            IniFile rdr = new IniFile(DatabasePath + @"\Equips\" + Client.Username + ".ini");
            for (sbyte i = 0; i < Client.Equipment.Count; i++)
            {
                ItemDataPacket LoadedEquip;
                if (ItemDataPacket.Parse(rdr.ReadString("Equips", "Item[" + i.ToString() + "]", String.Empty), out LoadedEquip))
                {
                    Client.Equip(LoadedEquip, (ushort)(i + 1));
                }
            }
        }
Ok this is the code i have been working on for loading gears this code "does not work" I been working on this since yesterday anyone have any idea what is wrong? Ive rewrote it 3 times and either way i write it it still don't load. When it saves it looks like this
Code:
[Equips]
Item[2]=137310 0 0 0 0 0
Ill keep taking cracks at it. Good luck to anyone else working with this soure
04/23/2009 22:47 LordSesshomaru#67
Code:
        private static void LoadInventory(GameClient Client)
        {
            IniFile rdr = new IniFile(DatabasePath + @"\Inventory\" + Client.Username + ".ini");
            sbyte count = rdr.ReadSByte("Inventory", "Count", 0);
            for (sbyte i = 0; i < count; i++)
            {
                string[] Item = (rdr.ReadString("Inventory", "Item[" + i.ToString() + "]", String.Empty)).Split(' ');
                ItemDataPacket LoadedItem = new ItemDataPacket(true);
                LoadedItem.ID = uint.Parse(Item[0]);
                LoadedItem.Plus = byte.Parse(Item[1]);
                LoadedItem.Enchant = byte.Parse(Item[2]);
                LoadedItem.SocketOne = byte.Parse(Item[3]);
                LoadedItem.SocketTwo = byte.Parse(Item[4]);
                LoadedItem.UID = ItemDataPacket.NextItemUID;
                Client.AddInventory(LoadedItem);
            }
        }
here you go This one does work
04/24/2009 16:20 LordSesshomaru#68
@Djago
here is my save inventory ( Make sure u have a folder called Inventory in your database?)
Quote:
private static void SaveInventory(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Inventory\" + Client.Username + ".ini");

sbyte i = 0;
foreach (IConquerItem Item in Client.Inventory)
{
wrtr.Write("Inventory", "Item[" + i.ToString() + "]", Item.ToString());
i++;

}
wrtr.Write("Inventory", "Count", i.ToString());
}
And don't give up yet please add me to msn and ill help you there to get your problem solved faster k man [Only registered and activated users can see links. Click Here To Register...]

Also at the end of public static void SaveCharacter(GameClient Client)

make sure it looks like this man
Quote:
wrtr.Write("Character", "Y", Client.Entity.Y);
wrtr.Write("Character", "RebornCount", Client.Entity.Reborn);

SaveInventory(Client);
04/24/2009 19:54 LordSesshomaru#69
Need some help here been working on this since yesterday with talking npc's just using the code that was there and i think i got it figured out just need someone to confirm my theory?

Quote:
case 900100:
{
dialog(Client, new string[] {
"AVATAR 30",
"TEXT Hello i am a testing NPC!",
"OPTION-1 Ok Good Bye!",

});
break;
}
All i did was add that before the default. But i got a couple of questions i am not sure about with the code that is already in the source is that good enough npc code? If it is how can i add another "page of talking? thanks ill keep taking a crack at it to figure it if i can.

Can a mod merge my my 2 posts forgot that i just replied to Djago sorry
04/24/2009 22:27 alexbigfoot#70
To add more "pages" you should use this:
Code:
                case 900100:
                    {
                        if(OptionID == 0)
                        dialog(Client, new string[] {
                            "AVATAR 30",
                            "TEXT Hello i am a testing NPC!",
                            "OPTION-1 Ok Good Bye!",
                            });
                        else if(OptionID == 1)
                            dialog(Client, new string[] {
                            "AVATAR 30",
                            "TEXT Hello this is the second page i`ve been working on for ages!",
                            "OPTION-255 Ok Good Bye!",
                            });

                        break;
                    }
When you click on a npc... the OptionID will be automaticaly 0, the first "page" you`ll get.

Also, there is a kinda bug while adding the optionid which will be sent and i posted the way to fix some weeks ago(i think).
Here`s the link: [Only registered and activated users can see links. Click Here To Register...]
04/25/2009 16:25 alexbigfoot#71
Code:
if(OptionID == 0)
{
dialog(Client, new string[] {
"AVATAR 30",
"TEXT Howdy! Would you like some money?",
"OPTION-1 Ohh, yea I need some."
"OPTION-255 No, thank you."
}); 
}
else if (OptionID == 1)
{
dialog(Client, new string[] {
"AVATAR 30",
"TEXT Here it is!",
"OPTION-255 Okay. Thanks."
}); 
Client.Money += 1000;
SyncPacket Package = new SyncPacket(1);
Package.UID = Client.Identifier;
Package[0] = SyncPacket.Data.Create(SyncPacket.Money, Client.Money);
Client.Send(Package.Serialize());
}
04/25/2009 19:27 KraHen#72
@Alexbigfoot : Make the syncpacket out of that NPC code, you don`t want to create it every time, only send it.
04/26/2009 01:17 kinshi88#73
Quote:
Originally Posted by alexbigfoot View Post
Code:
if(OptionID == 0)
{
dialog(Client, new string[] {
"AVATAR 30",
"TEXT Howdy! Would you like some money?",
"OPTION-1 Ohh, yea I need some."
"OPTION-255 No, thank you."
}); 
}
else if (OptionID == 1)
{
dialog(Client, new string[] {
"AVATAR 30",
"TEXT Here it is!",
"OPTION-255 Okay. Thanks."
}); 
Client.Money += 1000;
SyncPacket Package = new SyncPacket(1);
Package.UID = Client.Identifier;
Package[0] = SyncPacket.Data.Create(SyncPacket.Money, Client.Money);
Client.Send(Package.Serialize());
}
Use switches for Npc Dialog.
04/26/2009 12:36 alexbigfoot#74
why would I? I mean its not a big difference. It works the same...
anyway as you wish
Code:
switch(OptionID)
{
case 0:{dialog(Client, new string[] {
"AVATAR 30",
"TEXT Howdy! Would you like some money?",
"OPTION-1 Ohh, yea I need some."
"OPTION-255 No, thank you."
});}  break;
case 1:{dialog(Client, new string[] {
"AVATAR 30",
"TEXT Here it is!",
"OPTION-255 Okay. Thanks."
}); 
Client.Money += 1000;
SyncPacket Package = new SyncPacket(1);
Package.UID = Client.Identifier;
Package[0] = SyncPacket.Data.Create(SyncPacket.Money, Client.Money);
Client.Send(Package.Serialize()); }break;
}
04/26/2009 18:03 KraHen#75
Okay, got spawned a mob, mobspawns should be easy now.

Here comes the attack packet (although I`m not even 10% sure that it works since I never really worked with them). If something is missing or isn`t correct, correct me as you wish :P

1.) Create a file with the name Attack Packet.cs

2.) Copy this in it


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

namespace ConquerServer_Basic
{
public class AttackPacket : IClassPacket
{
private byte[] Packet;
public uint UID
{
get { return BitConverter.ToUInt32(Packet, 8); }
set { PacketBuilder.WriteUInt32(value, Packet, 8); }
}
public uint Target
{
get { return BitConverter.ToUInt32(Packet, 12); }
set { PacketBuilder.WriteUInt32(value, Packet, 12); }
}
public ushort TargetX
{
get { return BitConverter.ToUInt16(Packet, 16); }
set { PacketBuilder.WriteUInt32(value, Packet, 16); }
}
public ushort TargetY
{
get { return BitConverter.ToUInt16(Packet, 18); }
set { PacketBuilder.WriteUInt32(value, Packet, 18); }
}
public uint AttackType
{
get { return BitConverter.ToUInt32(Packet, 20); }
set { PacketBuilder.WriteUInt32(value, Packet, 20); }
}
public uint Damage
{
get { return BitConverter.ToUInt32(Packet, 24); }
set { PacketBuilder.WriteUInt32(value, Packet, 24); }
}
public void Deserialize(byte[] Bytes)
{
Packet = Bytes;
}
public byte[] Serialize()
{
return this.Packet;
}
}
}