Bot development

01/28/2021 00:37 turbomann123#1
Hey guys,
I wanted to start a Nostale bot project in Python. I already developed a dll injector to use the packet logger by BladeTiger12. I also started to build my own UI which at this point can only send packets via the tcp feature of the packet logger.


Now im a bit stuck. I don't get how i can make my character attack monsters (experimented a bit with the ncif packet but didn't get any result). Neither i have any idea how to implement a map to click on (to set waypoints to walk to) as seen in other Nostale bots for example the clientless bot by Pumba and many more. Anoter question i have is: how do i get the characters hp to know when to use a healing potion. I would appreciate any help or tips for my project.
Thanks in advance for any answers :)
01/28/2021 03:40 Apourtartt#2
ncif packet is the "target" packet.
When you send it, you receive a st packet with target hp/mp and list of buffs, if i remember correctly
the packet you want to send is u_s or u_as if the skill is a skillshot, then there are some arguments.
Take a look at
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
for the arguments

About your character hp, just read the stat packet
(arguments here : [Only registered and activated users can see links. Click Here To Register...] there is also another argument, it's used for the settings such as family blocked, you don't care about it)


And for the map, Pumba used a widget on Qt and tracked the mouse click position in order to use it for a walk packet : [Only registered and activated users can see links. Click Here To Register...])
01/30/2021 21:41 turbomann123#3
Thank you very much for your reply. It helped me a lot. I can now save waypoints, walk along them, attack monster in my area...
My biggest problem right now is the handeling of the packets from the packet logger. I get them via TCP. I tryed to split the received packets at each blank space to analyse them. The problem is that i get a really long list and have to itarate over it to search for "mv" or "stat" to get the values. It would be way better if i only get 1 packet to analyse at a time.

Code to connect to packet logger and recv packets
Code:
def receiveData():
    return str(s.recv(1024), "cp1252")


HOST, PORT = "127.0.0.1", get_nostale_packet_logger_ports()[0]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

Thread which always gets the new packets.
Code:
def packetListenThread():
    global packet
    while True:
        receivedPacket = PacketSender.receiveData()
        packet = receivedPacket.split()
01/30/2021 22:04 Apourtartt#4
This is really strange to have multiple threads for a bot, why do you have two ?
I don't know much about python, neither about the format of packets sent by bladetigger's packetlogger, but try maybe to split by newline ("\n") ?
01/30/2021 22:22 turbomann123#5
Thread topic:
my approach was to make multiple threads for different tasks. One is for checking the health of the player, one for walking... they are all basically while loops which run parrallel.

The biggest problem is, that i cant get the packets one by one. But i think you cant help me with this.

I cant try the newline approach right now but i will try it later

The packet splittet at each space bar:
[Only registered and activated users can see links. Click Here To Register...]
01/30/2021 23:01 FI0w#6
Quote:
Originally Posted by turbomann123 View Post
Thread topic:
my approach was to make multiple threads for different tasks. One is for checking the health of the player, one for walking... they are all basically while loops which run parrallel.

The biggest problem is, that i cant get the packets one by one. But i think you cant help me with this.

I cant try the newline approach right now but i will try it later

The packet splittet at each space bar:
[Only registered and activated users can see links. Click Here To Register...]
Maybe you can use some Game Functions to get HP/Walk etc would be easier
01/30/2021 23:09 Hatz~#7
It seems like the first packet on your output is displaying correctly but the others are not. Are you cleaning up the variable in which you store the received data? The packetlogger should be sending the packets 1 by 1. In c++ you can use this function to clean the data from your buffer: [Only registered and activated users can see links. Click Here To Register...]

In c++ you should call it like this:
01/31/2021 00:12 Limoo#8
I split them with vbCr
[Only registered and activated users can see links. Click Here To Register...]
01/31/2021 04:35 turbomann123#9
Quote:
Originally Posted by FI0w View Post
Maybe you can use some Game Functions to get HP/Walk etc would be easier
I got no idea how to do that. The packet sending strategy see,s quiet promising.


Quote:
Originally Posted by Hatz~ View Post
It seems like the first packet on your output is displaying correctly but the others are not. Are you cleaning up the variable in which you store the received data? The packetlogger should be sending the packets 1 by 1. In c++ you can use this function to clean the data from your buffer: [Only registered and activated users can see links. Click Here To Register...]

In c++ you should call it like this:
Thank you for the idea. I rethought my tcp recieve function and with the comment of Limoo i got the solution.

with s.recv(1024) i took 1024 bytes from the packet logger which explains why i got such long lists after i splitted it. Now i take one Byte at a time and if a newline appears i save the packet and reset the variable.

Code:
def receiveData():
    global fullpacket
    packet = ""
    while True:
        part = s.recv(1).decode('utf-8')
        if part == "\r":
            fullpacket = packet.split()
            packet = ""
            print(fullpacket)
        packet += part
this is giving me a nice list whith only one packet in it.
[Only registered and activated users can see links. Click Here To Register...]

I got a new question. What is the best way to track the current player position?