Discussion on [Release] Extremely basic (but working/bugless) C# Source within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
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 **** if you ask me.
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:
if you cannot see the picture
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++;
}
}
}
[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:
{
[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