Perl, packets, packing and unpacking. I'm a Perl newbie

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Message
Author
James1987
Noob
Noob
Posts: 5
Joined: 17 Jan 2013, 08:28
Noob?: No

Perl, packets, packing and unpacking. I'm a Perl newbie

#1 Post by James1987 »

Thank you, in advance, to anyone who can be bothered helping me with this.

Alright, I will try not to waste your precious time so if you want to just buzz ahead to what I need assistance with then please scroll down to the (2) section. Background story under (1).

***** 1) I am a hobbyist programmer and I have some basic knowledge of C/C++/Java.

I play on a private server and I bumped into an issue (obviously, as I am posting here). The closest serverType to the server's client is kRO_RagexeRE_2010_11_24a but the client itself was built on 2010-dec-10th or such. Anyway. There is a packet mismatch happening. I am not sure if it's because of the different built dates or if it's some customisation the private server did to discourage botters.

I have found that the culprit is packet 0858. What's happening is, when an actor "moves" into my screen (packet 0856) everything works well and the bot does not choke up. However when the packet is 0858 (stationary actor coming into view range), the bot cannot extract the coordinates properly, it also does not register the first two characters of the name (if player name is "ILoveStuff" then it registers as "oveStuff"). I understand how the function "makeCoordsDir" extracts the info from this packet. I know that the offset of the "coords" for the packet 0858 from kRO_RagexeRE_2010_11_24a.pm is wrong for my server so I want to move it two bytes to the left and I am having trouble understanding how perl unpack works.

I have attached a packet I captured here:

Code: Select all

67 bytes

   0>  58 08 43 00 00 XX XX 24    00 96 00 00 00 00 00 00    X.C..  $........
  16>  00 00 00 00 00 01 00 DB    04 00 00 00 00 00 00 00    ................
  32>  00 8E 12 8E 12 00 00 00    00 00 00 00 00 00 00 00    ................
  48>  00 00 00 00 00 36 09 30    05 05 2A 00 00 00 XX XX    .....6.0..*...  
  64>  XX XX XX                                                 
(Sorry I replaced the sensitive information with XX's) But anyway - this packet should say that my location is 216, 147 but the bot registered it as 192, 80. I understand the basics of "makeCoordsDir" so I figured that instead of using "36 09 30" as args->coords it used "30 05 05", am I correct with this analysis? This means that the packet unpack format is incorrect for the server I am playing on. So, now I am trying to understand Perl Pack and Unpack to fix this issue myself.

***** 2) Please don't tell me to go read "http://perldoc.perl.org/functions/pack.html" as I have already done this a number of times and I am still confused as hell.

What confuses me the most is that from kRO_RagexeRE_2010_11_24a.pm (look at packet 0858). The unpack format is stated as this > "v C a4 v3 V v11 a4 a2 v V C2 a3 C2 v2 Z*" and the variables to extract from the packet are listed as this > "len object_type ID walk_speed opt1 opt2 option type hair_style weapon shield lowhead tophead midhead hair_color clothes_color head_dir costume guildID emblemID manner opt3 stance sex coords xSize ySize lv font name"

How does this match up? There are about 30 variables expected, but the format has only 15 identifiers. I am so confused by this. I will be very very grateful if someone can help this noob out with understanding perl unpack a bit better. Specifically how it handles strings (a, A formats in unpack).

If you could spare some time to break down the above 0858 packet unpack format and variables for me then I would be very grateful. If you read (1) and you understand what to fix in the packet definition then please tell me that, I would be over the moon if you did that for me. Thanks.

James1987
Noob
Noob
Posts: 5
Joined: 17 Jan 2013, 08:28
Noob?: No

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#2 Post by James1987 »

No one got back to me, doesn't matter though. I figured out how to fix my packet issue. Everything works perfectly now.

Just for completion sake: "Each letter is optionally followed by a repeat count (for numeric values) or a length (for strings). A '*' on an integer format tells pack to use this format for the rest of the values. A '*' on a string format tells pack to use the length of the string." (http://www.perlmonks.org/?node_id=224666)

This is what helped me figure it out. Previously I was completely confused about what a3 a2 C2 v2 etc meant. After that I simply spliced up the packet to what openkore was expecting. Realising that 05 05 must have been xSize and ySize, I adjusted the format string before "a3" to move the coords and such 2 bytes to the left, and boom. Everything works. Botting away on the private server now ;)

Farming items, healing and storing all with the help of the Macro Plugin.

Awesome work by all the geniuses who put Openkore and the Macro plugin together!

Kaspy
Halfway to Eternity
Halfway to Eternity
Posts: 398
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#3 Post by Kaspy »

Could make a diff how was your changes?
Who knows, it can be sent to the SVN?
This is an interesting bug fix, if it works in other private servers.
James1987 wrote:No one got back to me, doesn't matter though. I figured out how to fix my packet issue. Everything works perfectly now.
I had read all your post, but translated by Google, which made her incomprehensible, so I could not help you.
My English is very poor.
Image

James1987
Noob
Noob
Posts: 5
Joined: 17 Jan 2013, 08:28
Noob?: No

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#4 Post by James1987 »

Problem is this was a fix for ONLY the server I am playing on. I've also botted on other servers. (Clients newer than this one) And those servers use those packets fine. So I believe this was an attempt at hindering "bots" on this specific server. I really don't know.

Kaspy
Halfway to Eternity
Halfway to Eternity
Posts: 398
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#5 Post by Kaspy »

I think not. The Network\Receive\kRO and Network\Send\kRO are really outdated.
It may just be that the administrator of private server is using a EXE longer updated, so that the OpenKore can not bear.

In RagexeRE_2010_11_24a so that:

Code: Select all

'0858' => ['actor_moved', 'v C a4 v3 V v11 a4 a2 v V C2 a3 C2 v2 Z*', [qw(len object_type ID walk_speed opt1 opt2 option type hair_style weapon shield lowhead tophead midhead hair_color clothes_color head_dir costume guildID emblemID manner opt3 stance sex coords xSize ySize lv font name)]], # -1
Gives?
If you can be sure which is the date of the client of private server, will help.
Image

pacifist
Noob
Noob
Posts: 1
Joined: 31 Mar 2013, 20:47
Noob?: No

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#6 Post by pacifist »

I actually have the same problem as this guy. At first, the issue that I was having was with detecting the entities around the clients, missing npcs and such. I got around that by changing a value at actor_connected (which was suggested by some poster) and it worked, npcs were being detected properly.

The next issue was this, if a player/monster moves, the coordinates get updated, I'm seeing them just fine with their own respective coordinates. But whenever I enter/move to place where a player/monster is currently present and not moving, actor _exists comes in and the coordinates are incorrect, sometimes out of bounds, thus getting the error removing actor off map due to overlapping coordinates with the given map. When a monster that gets bounced off attacks, it becomes tagged as NPC.

I tried changing some values only only to make it as far as lessening the out of bounds issues with entities, unless the monsters/players move, their coordinates are incorrect.

If I may, what changes did you make under actor under 0858 to get it working properly?

steelbreeze
Noob
Noob
Posts: 1
Joined: 05 Aug 2013, 06:23
Noob?: Yes

Re: Perl, packets, packing and unpacking. I'm a Perl newbie

#7 Post by steelbreeze »

@pacifist @james1987
I am facing a similar situation on an Indian private server here. They did some changes recently on the server and my openkore is flooding with 'Removed actor with off map coordinates' error everytime a immovable monster like pupa, etc. shows up in the screen. I read the previous posts about making changes to actor_exists part of the .pm file. Can you please tell me what exact changes need to be made to fix this?

Locked