amamic1803 / Autofish-Fishing-Planet

A fishing bot for automatically catching fish in Fishing Planet
MIT License
40 stars 26 forks source link

resolution and mouse move wrong pos #8

Open kira-pareser opened 11 months ago

kira-pareser commented 11 months ago

I hope this post is still of interest Hi, I just downloaded and used, the UI detection, throwing and pulling the fishing rod is quite good, but I have a few problems:

  1. When the pop ups appear, it seems that the system still detects the templates, but the mouse move doesn't seem to be in the right position, so disabling these windows is not done. I've made a few changes: instead of clicking the mouse, I'll do a button press on the keyboard keyboard.press_and_release('space') (backspace, and esc) image

    However it still works pretty bad for cases like warp_time, extend_day so hope you can explain me more about mouse.move commands

  2. Maybe the problem is partly due to the resolution, but I can't find the parameters to adjust for the different resolutions, so the positions may be wrong due to different versions. Can you point me to resolution-related arguments that I can adjust myself? (my monitor has a resolution of 1920x1080)

amamic1803 commented 11 months ago

Hi, there are no resolution related arguments. Only supported resolution is 1920x1080 because that is the resolution the templates were taken in. On other resolutions those templates wouldn't work. Location on the screen where mouse click should occur should be the location where a certain template was detected. I have no idea why that doesn't happen for you. Are you sure those templates are getting detected correctly? Do you have the game in english? (templates are in english so if the game is set to another language, they do not match) You can try printing out rel[0], rel[2][0] and rel[2][1] to see more information about location on the screen where template was detected (and if it was detected). rel[2][0] and rel[2][1] should be the coordinates where the template was matched. mouse.move moves the mouse pointer to that location and mouse.click clicks the mouse at that location. I didn't go with keyboard approach because sometimes, at least in the past, game would bug out and keyboard wouldn't work for closing these windows. Note that warp_time isn't working particularly well at all. Regards 😄

kira-pareser commented 11 months ago

Hi, there are no resolution related arguments. Only supported resolution is 1920x1080 because that is the resolution the templates were taken in. On other resolutions those templates wouldn't work. Location on the screen where mouse click should occur should be the location where a certain template was detected. I have no idea why that doesn't happen for you. Are you sure those templates are getting detected correctly? Do you have the game in english? (templates are in english so if the game is set to another language, they do not match) You can try printing out rel[0], rel[2][0] and rel[2][1] to see more information about location on the screen where template was detected (and if it was detected). rel[2][0] and rel[2][1] should be the coordinates where the template was matched. mouse.move moves the mouse pointer to that location and mouse.click clicks the mouse at that location. I didn't go with keyboard approach because sometimes, at least in the past, game would bug out and keyboard wouldn't work for closing these windows. Note that warp_time isn't working particularly well at all. Regards 😄

The pattern detection is pretty good, I've also added new patterns to the data folder, As for the return position of the minMaxLoc() function, I've tried it outside the game and the results are still pretty bad, so I just have to manually calculate it and add and subtract the number of pixels it's different from. Now with the test run it's pretty good for the whole function

however as you said, warp_time is not working, i am looking for the cause to fix it, the detection of fullkeepnet is still working very well, but it seems that the conditional functions are not activated making the mouse move and click to "next morning" seem not to be performed

image

amamic1803 commented 11 months ago

I really don't know why these coordinates have such a big offset for you, very strange. To me they are spot on. Probably has something to do with Pillow ImageGrab not screenshotting the whole screen. I don't know what else might be the cause of it. You can try storing np.array(ImageGrab.grab()) in a separate variable and then calling np.shape to see if the dimensions of the loaded image are really 1920x1080. Another possiblity is that the mouse module is placing the mouse pointer incorrectly, that is the offset appears there. If you do make any improvements in the program, feel free to open pull request. 😄 I can't accept these offsets in a pull request though as these do not appear for others. Regards

kira-pareser commented 11 months ago

ImageGrab

hanks for the help, i will try to test it again with ImageGrab, however for now most of the functions i calculate by myself and use mousemove manually just for compatibility with my environment so it may not work for others

kira-pareser commented 11 months ago

hey @DarkLord76865 , i seem to have been able to solve almost all the problems i had even though it was a bit manual However, there are 2 small but sometimes occurring problems that interrupt the automatic process,

1, sometimes before the cast is redundant, a right click of the mouse causes the cast system to be interrupted and it is almost impossible to get out of that interruption, i tried to put more lines in the Twitching section (because i only use twitching and the error occurs in these cases) but still can't fix it, can you give me some advice that this right click is caused by any line of code? image

  1. every time you do "caught_fish" the camera will be reset to the center of the screen, so sometimes the fish hook will get stuck because the character doesn't look down. I have tried many ways to script mouse.move down but this is not possible for some reason which may be related to the nature of FPS game or game security. I don't know if you have encountered this problem? (I only tried the system on Emerald lake)
amamic1803 commented 11 months ago

Right click only appears in the part of code that is responsible for different types of retrieves. I don't know why there is a redundant right click that you described. Last time I used my app, everything worked fine, there were no redundant right clicks. Could you maybe film a short video of it happening? It is very difficult to see anything in the screenshot that you shared. As for the camera self centering, I don't think that there is anything that can be done about that. The game self centers the camera. You could try to position a character in a way that would make it impossible for a hook to get stuck on the ground.

amamic1803 commented 11 months ago

About that right click, the app should stop doing any retrieve type when the line is 5 meters or less, it should just reel straight from that point, without using the right click. What you described seems to be caused by retrieve type (twitching) not being stopped correctly before the line is reeled out of the water. What may cause that is incorrectly detecting the line length in the lower right of the screen. I don't know why that would be the case because, as I said, it works correctly for me.