little help with packet structure and inspiration

09/10/2012 10:07 go for it#1
edit : okay now forget what i've said been hrs looking for this stuff but still at some point so damn confused

now i got a working proxy , i got packet structure for entity spawn and for attacking packet and i can simply do something like ummm here
while(hunting)
get monsters x,y from packet 10014
send 1022 packet to the server with action kill the monster , right ? and incase i want to update the client i send the server reply to the client , right ?

is that right ? i don't think so , cuz i get the 10014 packet way faster than ill reply for it
for example : servers send me 50 monsters and i reply that i've killed 1 , so server won't send more till i move , right ?
should i save them in a list then with foreach loop ?

i duno im completely lost , will keep trying but still need little help to save time , thanks and any help is appreciated
09/10/2012 18:51 { Angelius }#2
Quote:
Originally Posted by go for it View Post
edit : okay now forget what i've said been hrs looking for this stuff but still at some point so damn confused

now i got a working proxy , i got packet structure for entity spawn and for attacking packet and i can simply do something like ummm here
while(hunting)
get monsters x,y from packet 10014
send 1022 packet to the server with action kill the monster , right ? and incase i want to update the client i send the server reply to the client , right ?

is that right ? i don't think so , cuz i get the 10014 packet way faster than ill reply for it
for example : servers send me 50 monsters and i reply that i've killed 1 , so server won't send more till i move , right ?
should i save them in a list then with foreach loop ?

i duno im completely lost , will keep trying but still need little help to save time , thanks and any help is appreciated
That's where dictionary's/Lists come in handy...

You need to store the spawned monsters in a dictionary/list based on monster type/level which is totally up to you and create a thread to loop through that list content... find the closest monster and attack it

Attached is a C# Example.. check it out it might be useful to you
09/10/2012 18:59 go for it#3
fine i know about that , list and then attack them , but i was talking about better view , like hit nearest monster (which i think it's kinda useless) or like jump when there is no more monsters
anyway i've done that so far , using collection to sort monsters on sight and haven't made it to attack them yet as i'm not done with 1022 , also so damn confused at 10017 as im trying to make it auto use fs once it come , all i got is 10017 1022 1105 and trying to understand them correctly
so far have done 10010 1004 10014 1101 1009 but still need help or atleast couple of days to fully understand the rest of packets , it's kinda fun but sometimes boring when u can't figure out anything about something or how it works
anyway thanks , if u don't mind i would want to know what packet recived/sent for xp skills , pm or post ^^ thanks bro

EDIT : HAHAHAHAHAHAHHAHAHAHAHAHA I DID IT FUCKKKKKKKKKKKKKK XD
finally after an hr i figured it out :D :D :D

Code:
case 10017:
                            Console.WriteLine("packed of 10017 had came to life with value at offset 16 = " + BitConverter.ToInt16(data, 16));
                            if (BitConverter.ToInt16(data, 16) == 16)
                            {
                                Console.WriteLine("xp skill is there , test code");
                                byte[] data2; // this should send superman to server and server will tell client if it works and activate it
                                data2 = new byte[48];
                                ReadWrite.WriteUInt16(0x0028, 0, data2);
                                ReadWrite.WriteUInt16(0x03FE,2,data2);
                                ReadWrite.WriteUInt32(0x000F50C0, 8, data2);
                                ReadWrite.WriteUInt32(0x9DE0A56B, 12, data2);
                                ReadWrite.WriteUInt16(role.X, 16, data2);
                                ReadWrite.WriteUInt16(role.Y, 18, data2);
                                ReadWrite.WriteUInt32(0x00000018, 20, data2);
                                ReadWrite.WriteUInt32(0xCC2161CA, 24, data2);
                                Console.WriteLine("trying to send this packet to activate fs" + data2.ToString()); //should be convert.tostring(data2) ^^
                                role.SendToServer(data2);
                            }
                            break;
it's damn fun to figure stuff on your own , yes was packet 10017 offset 16 with value 0x10 (16b)
ill struct it now for the rest of xp skills :D i was doing it on wrong offset

and thank you for the class example , ill check it out now :D
for any mod , close this thread , i was damn wrong to give up and post this , doing it on my own sounds more fun XD
09/10/2012 22:47 pro4never#4
Here's a VERY basic example of how I have coded it in the past.



Step 1: Learn about your surroundings.

In your packet handler you handle the entity spawn packet. If the UID matches the range for monsters (300k-500k iirc) then add it to a monsters list by storing the X/Y/UID + any other information you feel you want for your purposes.

Step 2: Updating the map

On kill subtype (server>Client interaction packet with subtype kill) then you remove the UID from your map collection.

On moving (jump/walk Client>Server) you check all stored monsters to see if they are off screen and now you remove from your map collection

On Entity remove subtype of general data packet (very rare but may as well handle it) remove from the map collection


Grats! You can now move around the map and have an always up to date list of monsters which are currently on your screen.

Now you need to create a logic thread. This will look something like...


//Only abort the logic loop when you disconnect and should be clearing your resources at this point
while(user.Connected)
{
//use whatever time system you want. Personally I've used Environment.TickCount, SystemTime and DateTime. They all work just fine
if(user.LastAttack + user.AttackSpeed > CurrentTime)
{
Monster mob = GetClosestMonster();//Just cycle through the monsters collection and pull closest to your location!

if(mob == null)
{
//Pick a location to move to and jump/walk there! (pathfinding or random movement checked vs dmaps.

}
else if(Distance(user, mob) < 3)//In melee Range
{
user.SendToServer(new InteractionPacket(AttackType.Melee, user.UID, mob.UID));
user.LastAttack = CurrentTime;
}
else
{
Point moveTo = GetPathPoint(user, mob);//Simple function to find a point to move to closer to monsters
user.SendToServer(new GeneralDataPacket(ActionType.Jump, user UID, moveTo.X, moveTo.Y));
user.SendToClient(new GeneralDataPacket(ActionType.NinjaStep, user.UID, moveTo.X, moveTo.Y));

//This is debatable. Ideally I'd only update my position from the Server>Client Jump responses but this is a simple example so whatever.
user.X = moveTo.X;
user.Y = moveTo.Y;
}
}
}


Done! Very basic hunt bot with simple logic.
09/11/2012 00:08 go for it#5
Code:
case 10014 :
                            if(GUI.__ishunting)
                            {
                                Dictionary<uint, Point> Monsters = new Dictionary<uint, Point>();
                                ushort X = BitConverter.ToUInt16(data, 86);//get the X value from the packet 
                                ushort Y = BitConverter.ToUInt16(data, 88);//get the Y value from the packet 
                                uint UID = BitConverter.ToUInt32(data, 8);
                                Monsters.Add(UID, new Point (X,Y) , true);
                                if (Monsters.Keys.Count != 0)
                                {
                                    foreach (KeyValuePair<uint, Point> monster in Monsters)
                                    {
                                        if ((role.X - BitConverter.ToInt16(data, 16) < 18) && (role.Y - BitConverter.ToInt16(data, 18) < 18))
                                        {
                                            try
                                            {
                                                Console.WriteLine("hunting started");
                                                byte[] data3; // this should send superman to server and server will tell client if it works and activate it
                                                data3 = new byte[40];
                                                ReadWrite.WriteUInt16(0x0028, 0, data3);
                                                ReadWrite.WriteUInt16(0x03FE, 2, data3);
                                                ReadWrite.WriteUInt32(0x000F50C0, 8, data3);
                                                ReadWrite.WriteUInt32(monster.Key, 12, data3);
                                                ReadWrite.WriteUInt16((Convert.ToUInt16(monster.Value.X)), 16, data3);
                                                ReadWrite.WriteUInt16((Convert.ToUInt16(monster.Value.Y)), 18, data3);
                                                ReadWrite.WriteUInt32(0x00000002, 20, data3);
                                                Console.WriteLine("trying to send this packet to hunt");
                                                role.SendToServer(data3);
                                            }
                                            finally
                                            {
                                                //          Point newpoint = new Point(((Convert.ToUInt16(monster.Value.X)),(Convert.ToUInt16(monster.Value.Y))));
                                                Monsters.Remove(monster.Key);
                                            }
                                        }
                                    }
that's what i was doing , basically trying to kill every monster i get on packet 10014 , if failed or passed it remove it from the directory , it's really shitty and giving me error that the directory had been modified (duno how to solve it) , anyway ill read now what u posted and will rewrite it all over again , duno how to separate the hunting/looting from packets aka can't create events and stuff cuz im asshole in c# and my packet structures ain't good , but ill work on it , thanks and ill rewrite it once more
09/11/2012 00:52 pro4never#6
Quote:
Originally Posted by go for it View Post
Code:
case 10014 :
                            if(GUI.__ishunting)
                            {
                                Dictionary<uint, Point> Monsters = new Dictionary<uint, Point>();
                                ushort X = BitConverter.ToUInt16(data, 86);//get the X value from the packet 
                                ushort Y = BitConverter.ToUInt16(data, 88);//get the Y value from the packet 
                                uint UID = BitConverter.ToUInt32(data, 8);
                                Monsters.Add(UID, new Point (X,Y) , true);
                                if (Monsters.Keys.Count != 0)
                                {
                                    foreach (KeyValuePair<uint, Point> monster in Monsters)
                                    {
                                        if ((role.X - BitConverter.ToInt16(data, 16) < 18) && (role.Y - BitConverter.ToInt16(data, 18) < 18))
                                        {
                                            try
                                            {
                                                Console.WriteLine("hunting started");
                                                byte[] data3; // this should send superman to server and server will tell client if it works and activate it
                                                data3 = new byte[40];
                                                ReadWrite.WriteUInt16(0x0028, 0, data3);
                                                ReadWrite.WriteUInt16(0x03FE, 2, data3);
                                                ReadWrite.WriteUInt32(0x000F50C0, 8, data3);
                                                ReadWrite.WriteUInt32(monster.Key, 12, data3);
                                                ReadWrite.WriteUInt16((Convert.ToUInt16(monster.Value.X)), 16, data3);
                                                ReadWrite.WriteUInt16((Convert.ToUInt16(monster.Value.Y)), 18, data3);
                                                ReadWrite.WriteUInt32(0x00000002, 20, data3);
                                                Console.WriteLine("trying to send this packet to hunt");
                                                role.SendToServer(data3);
                                            }
                                            finally
                                            {
                                                //          Point newpoint = new Point(((Convert.ToUInt16(monster.Value.X)),(Convert.ToUInt16(monster.Value.Y))));
                                                Monsters.Remove(monster.Key);
                                            }
                                        }
                                    }
that's what i was doing , basically trying to kill every monster i get on packet 10014 , if failed or passed it remove it from the directory , it's really shitty and giving me error that the directory had been modified (duno how to solve it) , anyway ill read now what u posted and will rewrite it all over again , duno how to separate the hunting/looting from packets aka can't create events and stuff cuz im asshole in c# and my packet structures ain't good , but ill work on it , thanks and ill rewrite it once more
#1: If you send attack packet with coords > 6 from where you are then you get booted.

#2: if you attack too quickly you can get booted.


You need to be sure to handle things in a timely fashion that makes sense with how the game plays and interacts with the server (EG: Cannot just say "yah, i attacked that monster that's across the map from me cause I can!" the server simply won't allow it and will either ignore, boot or botjail you)
09/11/2012 03:43 Silent-Death#7
nice thread, i actually hope the lad keeps us posted on his progress..
over at chrome the spawn is analysed as the account is attacking it so you get the best out of the xp skill.

Keep us posted mate, and good luck.
09/11/2012 08:07 go for it#8
fuck it , ill help myself no matter how long it take, thanks everyone
09/11/2012 12:56 { Angelius }#9
Quote:
Originally Posted by go for it View Post
fuck it , ill help myself no matter how long it took , thanks everyone
I saw your post before you edit it and it sounds like you have problems handling things in the correct order :P

You need only 1 thread to do the job for you and you don't restart the thread every time a new monster is spawned...

Check the attached project...
09/11/2012 13:40 go for it#10
Quote:
Originally Posted by { Angelius } View Post
I saw your post before you edit it and it sounds like you have problems handling things in the correct order :P

You need only 1 thread to do the job for you and you don't restart the thread every time a new monster is spawned...

Check the attached project...
im really thankful , im learning how to handle it from your codes