|
You last visited: Today at 11:29
Advertisement
[Release] Extremely basic (but working/bugless) C# Source
Discussion on [Release] Extremely basic (but working/bugless) C# Source within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
02/08/2009, 17:02
|
#46
|
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,001
|
GemSocketPacket :
In the Packets folder create a new file called GemSocket Packet.cs and replace the code there with below :
Code:
using System;
namespace ConquerServer_Basic
{
class GemSocketPacket : IClassPacket
{
private byte[] Packet;
public const byte AddSocket = 0,
RemoveSocket = 1;
/// <summary>
/// No idea what this is for, has no use.
/// </summary>
public uint PlayerID
{
get { return BitConverter.ToUInt32(Packet, 4); }
}
public uint ItemUID
{
get { return BitConverter.ToUInt32(Packet, 8); }
}
public uint GemID
{
get { return BitConverter.ToUInt32(Packet, 12); }
}
public byte Socket
{
get { return Packet[16]; }
}
public byte Mode
{
get { return Packet[18]; }
}
public void Deserialize(byte[] Data)
{
Packet = Data;
}
public byte[] Serialize()
{
throw new NotImplementedException();
}
}
}
And in the PacketProcessor.cs add following :
Code:
case 1027:
{
GemSocketPacket cPacket = new GemSocketPacket();
cPacket.Deserialize(Packet);
IConquerItem Item = Client.GetInventoryItem(cPacket.ItemUID);
if (Item != null)
{
if (cPacket.Mode == GemSocketPacket.AddSocket)
{
IConquerItem Gem = Client.GetInventoryItem(cPacket.GemID);
if (Gem != null)
{
byte GemID = (byte)(Gem.ID % 10000);
bool Remove = false;
if (cPacket.Socket == 1 && Item.SocketOne == 255)
{
Item.SocketOne = GemID;
Remove = true;
}
else if (cPacket.Socket == 2 && Item.SocketTwo == 255)
{
Item.SocketTwo = GemID;
Remove = true;
}
if (Remove)
{
Client.RemoveInventory(cPacket.GemID);
ItemDataPacket IPacket = (Item as ItemDataPacket);
IPacket.Mode = ItemMode.UpdateItem;
Client.Send(IPacket);
}
}
}
else if(cPacket.Mode == GemSocketPacket.RemoveSocket)
{
if (cPacket.Socket == 1 && Item.SocketOne != 255)
Item.SocketOne = 255;
else if (cPacket.Socket == 2 && Item.SocketTwo != 255)
Item.SocketTwo = 255;
ItemDataPacket IPacket = (Item as ItemDataPacket);
IPacket.Mode = ItemMode.UpdateItem;
Client.Send(IPacket);
}
}
break;
}
And then add this:
in ItemPacket.cs and under the ItemMode class so it looks like this:
Code:
public const ushort
Default = 0x01,
Trade = 0x02,
UpdateItem = 0x03,
View = 0x04;
|
|
|
02/08/2009, 17:44
|
#47
|
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
|
Quote:
Originally Posted by tanelipe
Oh btw anyone who knows, what is there a packet to update the item stats? Or do I really have to do like I did in this example and first remove it and then add it with new stats? >_>
|
Resend the item packet with mode = 3
|
|
|
02/14/2009, 00:54
|
#48
|
elite*gold: 20
Join Date: Jun 2006
Posts: 1,759
Received Thanks: 827
|
Quote:
Originally Posted by punkmak2
I've added in selling to all the NPCs' Shops now.
-Selling items works
-Correct Sell price for all Items (Based on Item's Price, Item's Current Durability and Item's Max durability)(TQ Style).
-NPC range check added
Same goes with Repairing items.
Although one problem. Does anyone have the item update packet or know what it is. I know I'm having a blonde moment and it's 11:24pm lol.....
|
i could be wrong but i had a look in the source and found this
UpdateItem = 0x03
Item Packet.cs line 29
|
|
|
02/14/2009, 01:58
|
#49
|
elite*gold: 0
Join Date: Feb 2008
Posts: 277
Received Thanks: 52
|
i thought it was 5 or in hex 0x5 isn't 0x3 remove item?
|
|
|
02/14/2009, 02:18
|
#50
|
elite*gold: 20
Join Date: Jun 2006
Posts: 1,759
Received Thanks: 827
|
could be  i just copyed what i read in the source
Code:
public class ItemMode
{
public const ushort
Default = 0x01,
Trade = 0x02,
UpdateItem = 0x03,
View = 0x04;
}
|
|
|
02/14/2009, 06:46
|
#51
|
elite*gold: 0
Join Date: Jun 2005
Posts: 27
Received Thanks: 49
|
Yeah [UpdateItem = 0x03] is the Item Update packet thanks
Btw,
-DragonBall quality upgrading is now implemented.
-Item Usage is now implemented
-Item's Durability is implemented (Save/Loads from Database)
-Buying Items from NPCs is now implemented
-Selling Items to NPCs is now implemented
-Repairing Items at NPCs is now implemented
Although I need help with the chance of upgrading:
Normal -> Refined ?%
Refined -> Unique ?%
Unique -> Elite ?%
Elite -> Super ?%
What I'm thinking is that ill just upload my source or give it to Infamous (to implement in Rev4) because there is too much to add in. lol
Infamous can decide.
|
|
|
02/14/2009, 15:35
|
#52
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by punkmak2
Although I need help with the chance of upgrading:
Normal -> Refined ?%
Refined -> Unique ?%
Unique -> Elite ?%
Elite -> Super ?%
|
According to the EO source, it's based on both level and quality, so you should take a look in there.
|
|
|
02/14/2009, 18:11
|
#53
|
elite*gold: 0
Join Date: Feb 2008
Posts: 277
Received Thanks: 52
|
Quote:
Originally Posted by hio77
could be  i just copyed what i read in the source
Code:
public class ItemMode
{
public const ushort
Default = 0x01,
Trade = 0x02,
UpdateItem = 0x03,
View = 0x04;
}
|
o **** you just helped me x.x. Thanks xD
|
|
|
02/15/2009, 01:49
|
#54
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by punkmak2
I was using the EO source as my basis  . But doesn't seem to apply to conquer. I could be wrong
|
I used these functions when I ported it to C#:
They seemed right to me.
Code:
CUser::ChkUpEqQuality
CUser::ChkUpEqLevel
CUser::GetUpEpQualityInfo
CUser::GetUpEpLevelInfo
CUser::GetChanceUpEpQuality
CUser::GetChanceUpEpLevel
CUser::UpEquipmentQuality
CUser::UpEquipmentQuality
CUser::UpEquipmentLevel
CUser::UpEquipmentLevel
|
|
|
02/16/2009, 17:52
|
#55
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
|
@ sparkie:
I originally wanted to write my server in C++, but I was working with Ultimation at the time and I had already made him learn a basic understanding of C#; And Delphi was out of the question so we went with C#.
A lot of my source however relies on functions and methods that'd be commonly used in C++ such as memcpy, and pointer logic.
:P
@tarouka:
I stayed away for pointers cause I know pointers in C#, isn't really for most people, the vast majority of people should really just stay away from them. I didn't use them because I didn't want to confuse people, have people wind up with access violations, etc.
|
|
|
02/26/2009, 03:57
|
#56
|
elite*gold: 20
Join Date: May 2007
Posts: 1,125
Received Thanks: 332
|
This isn't a 'Grade A' release, but this will allow you to edit the Auth Port, Game Port and Server IP through a Config.ini file instead of through the entire project and then having to re-build it. =d
So here we go.
Step 1: Insert into "Program.cs" the following code under public class Program (underneath the brackets):
Code:
public static IniFile Config;
public static UInt16 AuthPort, GamePort;
public static string IPAddress;
Step 2: Add this under Main():
Code:
Config = new IniFile(Environment.CurrentDirectory + "\\Config.ini");
AuthPort = Config.ReadUInt16("Sockets", "AuthPort", 0);
GamePort = Config.ReadUInt16("Sockets", "GamePort", 0);
IPAddress = Config.ReadString("Sockets", "IPAddress", "0");
Step 3: Edit the following line: Sender.Send(PacketBuilder.AuthResponse("127.0.0.1" , Client.Identifier, 255, 5816)); to:
Code:
Sender.Send(PacketBuilder.AuthResponse(IPAddress, Client.Identifier, 255, GamePort));
Step 4: Adding CONFIG.INI -> Right click in the Debug/Release folder, and click New -> Text Document. Call it Config.ini Add the following into the file:
Code:
[Sockets]
IPAddress=YOUR-IP-ADDRESS
AuthPort=9958
GamePort=5816
Step 4.1: Then click on Save As... and name it Config.ini; IF you have Hide Common Shortcuts enabled, underneath FILE NAME, there should be FILE TYPE. Hit the scroll down bar and select All File Types. Hit Save and complete.
(If you don't have "Text Document", go to Start -> Notepad -> insert in the above -> then save as (in your Debug/Relese folder) -> "Config.ini" -> If needed, look at Step 4.1)
Step 5: Still in Main, replace authSocket.Port = 9958; to
Code:
authSocket.Port = AuthPort;
and change gameSocket.Port = 5816; to
Code:
gameSocket.Port = GamePort;
**Unneeded Step** : If you want to display the AuthPort/GamePort/Server IP within your Console window, all you add into Main() is:
Code:
Console.WriteLine("Server IP Address: " + IPAddress + "\nAuth Port: " + AuthPort + "\nGame Port: " + GamePort);
Hope this helps...even if it's just a little D:
Edit: Removed a String...added it to this by accident =x.
|
|
|
04/05/2009, 23:02
|
#57
|
elite*gold: 0
Join Date: Dec 2007
Posts: 618
Received Thanks: 213
|
Oke...so after some addings in this source (no bugs yet ^^) , i wanted to add some npc dialogs and confronted some troubles with the OptionIDs that were sended.
Idk if its bug or it was coded to be this way but...anyway i found a way out
In NpcProcessor.cs you may find
Code:
else if (parse_dlg.StartsWith("OPTION"))
{
string str_op_num = parse_dlg.Substring(6, parse_dlg.IndexOf(' ') - 6);
string str_op_text = parse_dlg.Substring(6 + str_op_num.Length + 1, parse_dlg.Length - 6 - str_op_num.Length - 1);
Reply.Reset();
Reply.InteractType = NpcReplyPacket.Option;
Reply.OptionID = (byte)short.Parse(str_op_num);
Reply.Text = str_op_text;
Client.Send(Reply);
}
While i want to send the optionid with this thing, lets choose OptionID = 1, it will send 255 ;
but using this one
Code:
else if (parse_dlg.StartsWith("OPTION"))
{
string str_op_num = parse_dlg.Substring(6, parse_dlg.IndexOf(' ') - 6);
string str_op_text = parse_dlg.Substring(6 + str_op_num.Length + 1, parse_dlg.Length - 6 - str_op_num.Length - 1);
Reply.Reset();
Reply.InteractType = NpcReplyPacket.Option;
Reply.OptionID = (byte)-(short.Parse(str_op_num));
Reply.Text = str_op_text;
Client.Send(Reply);
}
If you send OptionID = 1, you`ll get 1;
|
|
|
04/16/2009, 16:48
|
#58
|
elite*gold: 0
Join Date: Feb 2008
Posts: 277
Received Thanks: 52
|
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)NPCType.Dialog;
Send();
}
public void Link(string Text, byte Number)
{
NPC.Reset();
NPC.Text = Text;
NPC.OptionID = Number;
NPC.InteractType = (byte)NPCType.Option;
Send();
}
public void Input(byte Number, ushort MaxLength)
{
NPC.Reset();
NPC.OptionID = Number;
NPC.InteractType = (byte)NPCType.Input;
Send();
}
public void Face(byte Number)
{
NPC.Reset();
NPC.wParam = Number;
NPC.InteractType = (byte)NPCType.Avatar;
Send();
}
public void Complete()
{
NPC.Reset();
NPC.InteractType = (byte)NPCType.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 HandleNPCRequest(GameClient Client, NPCRequestPacket Packet)
{
NPCDialog Dialog = new NPCDialog(Client, Packet.NpcID, Packet.OptionID, Packet.Input);
}
|
|
|
04/16/2009, 16:56
|
#59
|
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
|
Quote:
Originally Posted by Ultimatum
Code:
#region NPCTalk
public unsafe struct NPCTalk
{
public byte DialogNumber, Face;
public string Text;
public NPCType ChatType;
public EnabledNPC Enabled;
public bool SetFace;
public bool Finish;
public static byte[] Packet;
#region Implicit Operator
public static implicit operator byte[](NPCTalk Speak)
{
if (Speak.SetFace)
{
Packet = new byte[24];
}
else if (!Speak.SetFace)
{
Packet = new byte[24 + Speak.Text.Length];
}
fixed (byte* Ptr = Packet)
{
*((ushort*)Ptr) = (ushort)(Packet.Length - 8);
*((ushort*)(Ptr + 2)) = 2032;
if (Speak.SetFace)
{
*(Ptr + 4) = 10;
*(Ptr + 6) = 10;
*((ushort*)(Ptr + 8)) = (ushort)Speak.Face;
*(Ptr + 10) = 0xFF;
*(Ptr + 11) = (byte)Speak.ChatType;
}
else if (!Speak.SetFace)
{
if (Speak.Finish)
{
*(Ptr + 10) = 0xFF;
*(Ptr + 11) = (byte)Speak.ChatType;
}
else if (!Speak.Finish)
{
*(Ptr + 10) = Speak.DialogNumber;
*(Ptr + 11) = (byte)Speak.ChatType;
}
*(Ptr + 12) = (byte)Speak.Enabled;
*(Ptr + 13) = (byte)Speak.Text.Length;
for (int i = 0; i < Speak.Text.Length; i++)
{
*(Ptr + 14 + i) = Convert.ToByte(Speak.Text[i]);
}
}
}
return Packet;
}
#endregion
}
|
|
|
|
04/16/2009, 17:00
|
#60
|
elite*gold: 0
Join Date: Dec 2007
Posts: 618
Received Thanks: 213
|
Quote:
Originally Posted by Ultimatum
Code:
#region NPCTalk
public unsafe struct NPCTalk
{
public byte DialogNumber, Face;
public string Text;
public NPCType ChatType;
public EnabledNPC Enabled;
public bool SetFace;
public bool Finish;
public static byte[] Packet;
#region Implicit Operator
public static implicit operator byte[](NPCTalk Speak)
{
if (Speak.SetFace)
{
Packet = new byte[24];
}
else if (!Speak.SetFace)
{
Packet = new byte[24 + Speak.Text.Length];
}
fixed (byte* Ptr = Packet)
{
*((ushort*)Ptr) = (ushort)(Packet.Length - 8);
*((ushort*)(Ptr + 2)) = 2032;
if (Speak.SetFace)
{
*(Ptr + 4) = 10;
*(Ptr + 6) = 10;
*((ushort*)(Ptr + 8)) = (ushort)Speak.Face;
*(Ptr + 10) = 0xFF;
*(Ptr + 11) = (byte)Speak.ChatType;
}
else if (!Speak.SetFace)
{
if (Speak.Finish)
{
*(Ptr + 10) = 0xFF;
*(Ptr + 11) = (byte)Speak.ChatType;
}
else if (!Speak.Finish)
{
*(Ptr + 10) = Speak.DialogNumber;
*(Ptr + 11) = (byte)Speak.ChatType;
}
*(Ptr + 12) = (byte)Speak.Enabled;
*(Ptr + 13) = (byte)Speak.Text.Length;
for (int i = 0; i < Speak.Text.Length; i++)
{
*(Ptr + 14 + i) = Convert.ToByte(Speak.Text[i]);
}
}
}
return Packet;
}
#endregion
}
|
NO POINTERS IN THIS SOURCE MEH!
Code:
#region NPCTalk
public unsafe struct NPCTalk
{
public byte DialogNumber, Face;
public string Text;
public NPCType ChatType;
public EnabledNPC Enabled;
public bool SetFace;
public bool Finish;
public static byte[] Packet;
#region Implicit Operator
public static implicit operator byte[](NPCTalk Speak)
{
if (Speak.SetFace)
{
Packet = new byte[24];
}
else if (!Speak.SetFace)
{
Packet = new byte[24 + Speak.Text.Length];
}
PacketBuilder.WriteUInt16((ushort)(Packet.Length - 8), Packet, 0);
PacketBuilder.WriteUInt16(2032, Packet, 2);
if (Speak.SetFace)
{
Packet[4] = 10;
Packet[6] = 10;
PacketBuilder.WriteUInt16((ushort)Speak.Face, Packet, 8);
Packet[10] = 0xFF;
Packet[11] = (byte)Speak.ChatType;
}
else if (!Speak.SetFace)
{
if (Speak.Finish)
{
Packet[10] = 0xFF;
Packet[11] = (byte)Speak.ChatType;
}
else if (!Speak.Finish)
{
Packet[10] = Speak.DialogNumber;
Packet[11] = (byte)Speak.ChatType;
}
Packet[12] = (byte)Speak.Enabled;
Packet[13] = (byte)Speak.Text.Length;
for (int i = 0; i < Speak.Text.Length; i++)
{
Packet[14 + i] = Convert.ToByte(Speak.Text[i]);
}
}
return Packet;
}
#endregion
}
#endregion
}
and u probably mean
Code:
case 2031:
case 2032:
{
NPCRequestPacket cPacket = new NPCRequestPacket();
cPacket.Deserialize(Buffer);
if (cPacket.OptionID != NPCRequestPacket.BreakOnCase)
{
HandleNPCRequest(Client, cPacket);
}
break;
}
|
|
|
 |
|
Similar Threads
|
[Huge-Release] All-In-One Basic NPC Scripts For The 5165 Source!
02/19/2010 - CO2 PServer Guides & Releases - 30 Replies
Well I'm sorry that I spammed the whole forum full of my posts So pro4never and .Ryu gave me the idea of making this All-In-One thread about all my NPC's! THESE ARE UPDATED DAILY!
NOTE: TO PEOPLE... SOME OF THE CODES ARE NOT MADE BY ME! I USUALLY JUST FIXED/UPDATED THE BASIC ONES! SORRY I'M LEARNING ON HOW TO CODE!
1. Birth-Island-NPC's(The NPC text is not from "REAL CONQUER" SORRY!...)
#region BirthOldGeneralYang
case 425:
{
|
[FINAL RELEASE]HuB- Source (BASIC) (Original LOTF easier workable)
11/14/2009 - CO2 PServer Guides & Releases - 25 Replies
#REMOVED
|
[RELEASE] Basic LOTF Source
09/03/2009 - CO2 PServer Guides & Releases - 17 Replies
hey this is a basic lotf source edited based off shadowco, if you dont like it then dont post here... flames will be told on!!! :D i will tell on you to the mods if you flame
What it has...
- LuckyTime
- Guard
- 24/7 GW
|
All times are GMT +1. The time now is 11:30.
|
|