Achraf-Louiza / dofus-job-bot

This is a customizable bot for the game Dofus that automates tasks such as harvesting, combat, and fishing, and provides map awareness using techniques such as image recognition and window activation.
1 stars 0 forks source link

Question About RECOLTABLE_IDS and API Documentation for Similar Project #1

Open NizarKarroud opened 2 months ago

NizarKarroud commented 2 months ago

Hello, I hope this message finds you well.

I am currently working on a project similar to this repository and I came across the following dictionary:

RECOLTABLE_IDS = {
    'wheat': 289,
    'chanvre': 425,
    'seigle': 532,
    'lin': 423,
    'malt': 405,
    'orge': 400,
    'avoine': 533,
    'houblon': 401,
    'riz': 7018
}

I have a couple of questions regarding this:

Could you please provide information on the source of these values? Is there any documentation available for the API that you could share?

This information would be incredibly helpful for my project. Thank you for your time and assistance.

Achraf-Louiza commented 2 months ago

Hey Nizar,

This has been a good project I have worked on. I have managed to make it work with multi dofus windows working simultaneously.

I judges that the project wouldn't be able to generate enough money with kamas.

Anyway, the API you are asking about is simply reverse engineering on this website: [image: image.png]

They have an internal, non-documented, API that managed to understand through network inspection while doing the actions of clicking on a product in the MAP page. The give you map positions of where the products are in the game.

It would be a pleasure to discuss your work and how we can combine ours to make sth out of this project.

Le dim. 23 juin 2024 à 20:06, Karroud Nizar @.***> a écrit :

Hello, I hope this message finds you well.

I am currently working on a project similar to this repository and I came across the following dictionary:

RECOLTABLE_IDS = { 'wheat': 289, 'chanvre': 425, 'seigle': 532, 'lin': 423, 'malt': 405, 'orge': 400, 'avoine': 533, 'houblon': 401, 'riz': 7018 }

I have a couple of questions regarding this:

Could you please provide information on the source of these values? Is there any documentation available for the API that you could share?

This information would be incredibly helpful for my project. Thank you for your time and assistance.

— Reply to this email directly, view it on GitHub https://github.com/Achraf-Louiza/dofus-job-bot/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJ43G2XJEWU3UFJLD7VLG3ZI4FB3AVCNFSM6AAAAABJYSGEPKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DQOBRGIZDENQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

NizarKarroud commented 2 months ago

Hi Achraf,

I did check the network tab in the developer tools to see the API calls, and the JSON returned the map coordinates and resources but not the actual x,y coordinates of the resource. I also checked their Discord for documentation, but it barely had any. I thought of other APIs, but there aren't any functional ones, so I guess I just have to manually create a CSV file of the x,y positions of the resources.

For your project, you managed to make it work with multiple Dofus windows by focusing every window. I thought of an alternative using win32ui, win32con, win32api, and win32gui so that I can keep the window in the background. I tested it so far on one window by sending clicks to the window. I noticed that the window has a different resolution than my monitor even when it's fullscreen, so I had to adjust the x,y coordinates of the clicks relative to the window resolution.

Regarding the map and pathfinding, most maps in Dofus can be represented as a grid, where cells not in the map have a value of *, and cells that make up the Dofus map have a value of 0 ( not all maps are squares or rectangles so you have to remove some cells ) . I used the DFS algorithm to traverse the grid and create the path. While I'm not sure if it's the most efficient way, as I'm not very strong in data structures and algorithms, it's what I have implemented so far.

I'd love to discuss further and see how we can combine our efforts.

Best regards, Nizar

Achraf-Louiza commented 2 months ago

Hello Nizar,

You did pretty good on every aspect. I found about win32ui later on and was gonna make the changes so that it could run in background. It would be way more efficient that way and enables scaling efficiently. Btw, It is true that the API only gives MAP coordinates and not the pixels of each block of the resource on each map coordinate.

To solve the pixel coordinate issue, at each map coordinate, if it is the first time you go to it, I have a program that moves the mouse in a grid applied on the screen and gets a screenshot around the cursor position then uses an OCR (tesseract, but now paddleOCR can be way more efficient) to get the text. if It detects either one of the resources It saves its pixel coordinates. This way, I can launch the bot and automatically extract all pixel coordinates in one swoop.

Now, on the subject of finding the shortest path, since in dofus you can only go (up, down, left or right), you do not need a graph optimal path algorithm such as DFS. Whatever the path you take to get to the resource, you will do the same number of movements as long as you go in the direction of the object. So at each step, you go to the map coordinate in the direction where the coordinate difference (between you and the resource is the farthest.

The biggest issue in this situation is the obstacles (map coordinates where you cannot go in a specific direction). I used a random direction when stuck and since the next direction is decided on the spot at each iteration, he can manage to get back on track but it is not perfect.

We can have a meeting and discuss the project in more details. You can share with me your availability and I'll reserve a meeting.

Have a good day !

Le lun. 24 juin 2024 à 23:41, Karroud Nizar @.***> a écrit :

Hi Achraf,

I did check the network tab in the developer tools to see the API calls, and the JSON returned the map coordinates and resources but not the actual x,y coordinates of the resource. I also checked their Discord for documentation, but it barely had any. I thought of other APIs, but there aren't any functional ones, so I guess I just have to manually create a CSV file of the x,y positions of the resources.

For your project, you managed to make it work with multiple Dofus windows by focusing every window. I thought of an alternative using win32ui, win32con, win32api, and win32gui so that I can keep the window in the background. I tested it so far on one window by sending clicks to the window. I noticed that the window has a different resolution than my monitor even when it's fullscreen, so I had to adjust the x,y coordinates of the clicks relative to the window resolution.

Regarding the map and pathfinding, most maps in Dofus can be represented as a grid, where cells not in the map have a value of *, and cells that make up the Dofus map have a value of 0 ( not all maps are squares or rectangles so you have to remove some cells ) . I used the DFS algorithm to traverse the grid and create the path. While I'm not sure if it's the most efficient way, as I'm not very strong in data structures and algorithms, it's what I have implemented so far.

I'd love to discuss further and see how we can combine our efforts.

Best regards, Nizar

— Reply to this email directly, view it on GitHub https://github.com/Achraf-Louiza/dofus-job-bot/issues/1#issuecomment-2187456775, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJ43G6KTVRA54GAXMM4USTZJCG7BAVCNFSM6AAAAABJYSGEPKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBXGQ2TMNZXGU . You are receiving this because you commented.Message ID: @.***>

NizarKarroud commented 2 months ago

Hello,

Regarding the pathfinding, it's true that simple math will do the trick. All you need to do is get the coordinates of the character, sort the map coordinates (to get the closest map), and simply get the (x,y) difference. For the map coordinates where you cannot go in a specific direction, I thought of using OCR to check if the character is still in the same map after the move action. If it is, you take the second most optimal route to the map. For example, if you can't move to the left, you should test if you can move up or down. If yes, you repeat the same process until you get to the map. I also haven't considered the time it takes for a resource to respawn.

Due to my current internship commitments, my availability is limited to weekends and weeknights.