ok here is spawning NPC's, it found it Qonquers Botting tool.
Packetbuilder.cs
Code:
public static byte[] SPAWNnpc(int id, int x, int y, int type, int dir, int flag)
{
byte[] b = new byte[20];
b[0] = 20;
b[2] = (byte)(int)0xee;
b[3] = 7;
b[4] = (byte)(id & 0xff);
b[5] = (byte)((id & 0xff00) >> 8);
b[6] = (byte)((id & 0xff0000) >> 16);
b[7] = (byte)((id & 0xff000000) >> 24);
b[8] = (byte)(x & 0xff);
b[9] = (byte)((x & 0xff00) >> 8);
b[10] = (byte)(y & 0xff);
b[11] = (byte)((y & 0xff00) >> 8);
b[12] = (byte)(type & 0xff);
b[13] = (byte)((type & 0xff00) >> 8);
b[14] = (byte)(dir & 0xff);
b[15] = (byte)((dir & 0xff00) >> 8);
b[16] = (byte)(flag & 0xff);
b[17] = (byte)((flag & 0xff00) >> 8);
b[18] = (byte)((flag & 0xff0000) >> 16);
b[19] = (byte)((flag & 0xff000000) >> 24);
return b;
}
World.cs
Code:
if (Splitter[0] == "/spawnnpc" || Splitter[0] == "/Spawnnpc")
{
int NPC_id = Convert.ToInt32(Splitter[1]);
int NPC_x = Convert.ToInt32(Splitter[2]);
int NPC_y = Convert.ToInt32(Splitter[3]);
int NPC_type = Convert.ToInt32(Splitter[4]);
int NPC_dir = Convert.ToInt32(Splitter[5]);
int NPC_flag = Convert.ToInt32(Splitter[6]);
Client.SendData(PacketBuilder.Message(Client.MessageID, "[GM]", Client.Char.Name, "NPC Spawned.", ChatType.Top));
Client.SendData(PacketBuilder.SPAWNnpc(NPC_id, NPC_x, NPC_y, NPC_type, NPC_dir, NPC_flag));
}
This tool is so that you can spawn an a talkable npc which checks via the NPC's ID for a talk dialog.
CoClient.cs
Code:
else if (Incoming.Length == 0x10 && Incoming[0x02] == 0xEF) //NPC Talk
{
string npc_id = Convert.ToString(Incoming[0x04]);
World.LoadNPCsay(this, npc_id);
}
World.cs
(make sure u put it somewhere at the top with the "public static void's")
Code:
public static void LoadNPCsay(COClient Client, string npc_id)
{
Character Char = Client.Char;
Client.SendData(PacketBuilder.Message(Client.MessageID, "[GM]", Client.Char.Name, "NPC ID:" + npc_id + ".", ChatType.Center));
int npc_id_2 = Convert.ToInt32(npc_id);
if (npc_id_2 == 150) { Client.SendData(PacketBuilder.NPCtalk("Hey I'm the Retarded NPC hahaha.", "I~see.")); }
}
Now we need to make them spawn with all players, but make it so that it doesnt spam the packet everytime u walk, its quite hard todo and this needs alot of work.
Atm this is only works for Jumping and seems to have a few bugs.
World.cs
Code:
public static void GetSurroundingsNPCs(COClient Client, byte[] Packet)
{
int PrevX = (Packet[0x0d] << 8) + Packet[0x0c];
int PrevY = (Packet[0x0f] << 8) + Packet[0x0e];
int NewX = (Packet[0x15] << 8) + Packet[0x14];
int NewY = (Packet[0x17] << 8) + Packet[0x016];
Character Char = Client.Char;
ArrayList[,] Target = GetTarget(Client.Char.Map);
int x_min = Char.CurrentLoc.X - VIEWTHRESHOLD;
int y_min = Char.CurrentLoc.Y - VIEWTHRESHOLD;
int x_max = Char.CurrentLoc.X + VIEWTHRESHOLD;
int y_max = Char.CurrentLoc.Y + VIEWTHRESHOLD;
int x_min2 = PrevX - VIEWTHRESHOLD;
int y_min2 = PrevY - VIEWTHRESHOLD;
int x_max2 = PrevX + VIEWTHRESHOLD;
int y_max2 = PrevY + VIEWTHRESHOLD;
int[][] arr = new int[100][];
//TC
arr[0] = new int[7] {1 , 413 , 351, 10, 1, 1, 1002};
arr[1] = new int[7] { 2, 418, 351, 50, 6, 1, 1002 };
//MA
arr[2] = new int[7] { 3, 194, 195, 1600, 3, 1, 1036 };
for (int i = 0; i < arr.Length; i++)
{
uint testss = Convert.ToUInt32(Client.Char.Map);
if (testss == arr[i][6])
{
if (x_min <= (arr[i][1] + 4) && x_max >= (arr[i][1] - 6) && y_min <= (arr[i][2] + 4) && y_max >= (arr[i][2] - 6))
{
if (x_min2 <= (arr[i][1] + 3) && x_max2 >= (arr[i][1] - 5) && y_min2 <= (arr[i][2] + 3) && y_max2 >= (arr[i][2] - 5)) { break; }
else
{
Client.SendData(PacketBuilder.Message(Client.MessageID, "Alert", Client.Char.Name, "You are in Range of NPC. ID:" + arr[i][0] + " (" + PrevX + "," + PrevY + "). in " + Client.Char.Map, ChatType.Top));
int NPC_ID_I = Convert.ToInt32(arr[i][0]);
int NPC_x_I = Convert.ToInt32(arr[i][1]);
int NPC_y_I = Convert.ToInt32(arr[i][2]);
int NPC_type_I = Convert.ToInt32(arr[i][3]);
int NPC_dir_I = Convert.ToInt32(arr[i][4]);
int NPC_flag_I = Convert.ToInt32(arr[i][5]);
//Client.SendData(PacketBuilder.SpawnGuard(Guard_ID_I, Guard_Model_I, Guard_x_I, Guard_y_I));
Client.SendData(PacketBuilder.SPAWNnpc(arr[i][0], arr[i][1], arr[i][2], arr[i][3], arr[i][4], arr[i][5]));
}
}
}
}
}
World.cs
Fix the InitWorld() so that it supports Market.
so search InitWorld() and replace it with the following code:
Code:
public static void InitWorld()
{
for (int x = 0; x < 1000; x++)
{
for (int y = 0; y < 1000; y++)
{
TCLocHash[x,y] = new ArrayList(2);
MFLocHash[x, y] = new ArrayList(2);
MALocHash[x, y] = new ArrayList(2);
}
}
}
Adding the update when jumping
replace the existing code of "else if (Incoming[0x18] == 0x8e) //Jump packet"with the following code;
CoClient.cs
Code:
else if (Incoming[0x18] == 0x8e) //Jump packet
{
if (Status == Mode.World)
{
try
{
World.Jump(this, Incoming);
//World.WalkNPC(this, Incoming);
World.GetSurroundingsNPCs(this, Incoming);
}
catch
{
throw;
}
}
}