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

05/10/2010 00:02 Basser#241
Once you've updated the game server's cryptographer, and updated the packet structures, it will be easy to finish.
Monsters are easy since there's enough servers with examples, skills and that kinda stuff is a piece of shit if you ask me.
05/10/2010 20:55 MonstersAbroad#242
Ok so I got NPC's implanted just wondering if this would work no errors so.... I am hoping this would work
Code:
                #region Welcome NPC
                case 10010:
                    {
                        switch(PageNumber)
                        {
                            case 0:
                                Text("Hi and welcome to the server, having fun?");
                                Link("Yes", 1);
                                break;

                            case 1:
                                Face(30);
                                Text("Thats glad to know ...");
                                Link("Cya", 255);
                                break;
                        }
                        Face(30);
                        Complete();
                        break;
                    }
                #endregion
any help ???

also I said no errors

Quote:
Originally Posted by Ultimatum
Figured the npc system needed a little tlc.

Right i made this as the 'ProcessNPC.cs'
UPDATED
Code:
  public class NPCStructure
    {
        public NpcReplyPacket NPC = new NpcReplyPacket();
        public GameClient Client;

        public void Text(string Text)
        {
            NPC.Reset();
            NPC.Text = Text;
            NPC.InteractType = (byte)[COLOR="Red"][B]NPCType[/B][/COLOR].Dialog;
            Send();
        }
        public void Link(string Text, byte Number)
        {
            NPC.Reset();
            NPC.Text = Text;
            NPC.OptionID = Number;
            NPC.InteractType = (byte)[COLOR="Red"][B]NPCType[/B][/COLOR].Option;
            Send();
        }
        public void Input(byte Number, ushort MaxLength)
        {
            NPC.Reset();
            NPC.OptionID = Number;
            NPC.InteractType = (byte)[COLOR="Red"][B]NPCType[/B][/COLOR].Input;
            Send();
        }
        public void Face(byte Number)
        {
            NPC.Reset();
            NPC.wParam = Number;
            NPC.InteractType = (byte)[COLOR="Red"][B]NPCType[/B][/COLOR].Avatar;
            Send();
        }
        public void Complete()
        {
            NPC.Reset();
            NPC.InteractType = (byte)[COLOR="Red"][B]NPCType[/B][/COLOR].Finish;
            NPC.OptionID = 255;
            NPC.DontDisplay = true;
            Send();
        }
        public void Send()
        {
            Client.Send(NPC.Serialize());
        }
    }
Uses the Interaction Packet found in the source


Code:
 public class NPCDialog : NPCStructure
    {
        public uint PageNumber;
        public uint NPCID;
        public string InputBoxString;

        public NPCDialog(GameClient m_Client, uint m_UID, uint m_Number, string Input)
        {
            NPCID = m_UID;
            InputBoxString = Input;
            PageNumber = m_Number;
            Client = m_Client;
            ManageChat();
        }

        void ManageChat()
        {
            if (NPCID == 0)
                NPCID = Client.ActiveNpcID;
            switch (NPCID)
            {
                case 10010:
                    {
                        if (PageNumber == 0)
                        {
                            Face(30);
                            Text("Hi and welcome to the server, having fun?");
                            Link("Yes", 1);
                            Complete();
                        }
                        else if (PageNumber == 1)
                        {
                            Face(30);
                            Text("Thats glad to know ...");
                            Link("Cya", 255);
                            Complete();
                        }
                        break;
                    }
                default:
                    {
                        Face(30);
                        Text("Hi am not implemented yet");
                        Link("Ok", 255);
                        Complete();
                        break;
                    }
            }
        }
    }
Added npc 10010 just so you know how to work with npc pages.

Now as for the packethandler, i know this source as a npc dialog in so.

Code:
public static void [B][COLOR="Red"]HandleNPCRequest[/COLOR][/B](GameClient Client, [COLOR="Red"][B]NPCRequestPacket[/B][/COLOR] Packet)
        {
            NPCDialog[COLOR="Red"] Dialog[/COLOR] = new NPCDialog(Client, Packet.NpcID, Packet.OptionID, Packet.Input);
        }
The code in RED are the errors

Errors are as follow:

Here's a picture becuase I am lazy to type all the errors out:
[Only registered and activated users can see links. Click Here To Register...]
if you cannot see the picture [Only registered and activated users can see links. Click Here To Register...]
05/18/2010 09:32 scottdavey#243
Anyone still working on this?
05/18/2010 09:46 Arcо#244
I am on a side project.
05/18/2010 10:50 Arcо#245
And you have the database loaded right?
05/18/2010 11:36 ~Yuki~#246
#Requested ban for .Arco

Reason:
Quote:
I am on a side project.
oh and for double post hhhhhhhh

(kidding)
05/19/2010 02:05 ranny2#247
I'm still working on it :). It's the best server to build off by far. Updated it from 5017-5257. A test server should be out soon
05/19/2010 02:28 BlueFlame11#248
Quote:
Originally Posted by ranny2 View Post
I'm still working on it :). It's the best server to build off by far. Updated it from 5017-5257. A test server should be out soon
Woah ranny that's pretty cool hope it all goes well
I started using this source today ha ^^ but i ain't good enough to up it to 5257
05/19/2010 03:55 scottdavey#249
Quote:
Originally Posted by ranny2 View Post
I'm still working on it :). It's the best server to build off by far. Updated it from 5017-5257. A test server should be out soon
Nice, would love to test it.

PM me if you need a tester.
05/19/2010 18:19 xScott#250
Quote:
Originally Posted by ranny2 View Post
I'm still working on it :). It's the best server to build off by far. Updated it from 5017-5257. A test server should be out soon
i wouldn't mind testing it aswell,
08/15/2010 21:52 theloz#251
Rev3: Freeze can't login.
08/15/2010 22:00 ImFlamedCOD#252
There is nothing wrong with Rev 3 , works fine. Did you change the ip in program.cs under auth receive?
08/16/2010 11:30 Fish*#253
Quote:
Originally Posted by theloz View Post
Rev3: Freeze can't login.
use nullable's loader v3
09/20/2010 13:33 Fish*#254
Im working with it.
U got msn?
PM me it :D
10/24/2010 20:31 HolyMage#255
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);