DorskFR / LeaguePyBot

A Python computer vision bot for League Of Legends
MIT License
65 stars 19 forks source link

Bot hovers mouse on minions/champions but does not attack or move to them #11

Closed JeffersonDawg closed 3 years ago

JeffersonDawg commented 3 years ago

Hi, i finally managed to make the bot work and start game, but it just goes to the tower and stands there. i see the mouse trying to go to minions and attack champions but doesnt actually click, only hovers them, any idea?

JeffersonDawg commented 3 years ago

Oh and does not use any abilities what so ever (Garen)

DorskFR commented 3 years ago

Check if you have an "attackmove" hotkey defined Should be 'a' by default I believe? I quick hacked this yesterday but maybe missed something.

JeffersonDawg commented 3 years ago

Yes, Player Attack Move is set to A

JeffersonDawg commented 3 years ago

Also, i can see in the console that it is trying to recall, but never does. Also i get a message saying "clear" is not a valid command. But that is probably cuz im on Windows.

JeffersonDawg commented 3 years ago

should i be running a specific resolution?

DorskFR commented 3 years ago

resolution: classic 1920x1080 clear: ah yes right, will fix this.

I supposed there is a problem with the keybinds, I have not tested on Windows. Setting up a box now to run some tests.

JeffersonDawg commented 3 years ago

Thank you. Sorry to bother you with all of this.

DorskFR commented 3 years ago

git pull origin main for the latest version.

Actually had to do quite a few things.

Because League on Windows uses DirectX and probably some cheat prevention, they are not allowing simulated keypresses to go through.

So the keyboard library I use (pynput) does not work for league on Windows. I added a different keyboard provider (pydirectinput) for Windows.

However this keyboard provider does not support unicode (actually Windows cmd.exe does not either by default, so it probably prints garbage in the console if your game locale is in a non alphabet language).

So switched to english for items in the shop which works most of the time but fails for some stuff (eg: ward).

Now it still does not work properly on Windows, at least on my virtual machine, because it does not detect objects on screen properly. This being due to OpenCV and the threshold defined in vision.py file.

Lowering the thresholds will lower the fidelity and increase the number of result with a lot of false positives simultaneously.

tl;dr: it's still broken on windows because of game object detection. not sure when I will have the time to fix it. feel free to tinker.

JeffersonDawg commented 3 years ago

It is now clicking. Thanks!

Just as a note> It seems like its considering a US Layout Keyboard. I quickly added it to my Windows because I use a Portuguese Layout, and it was using "º" instead of " ´ " when searching for items in the shop, so it couldnt find, for example "doran´s blade". It was writing "doranºs blade". Not a big deal with pretty ez fix. Just something to keep in mind for anyone having this issue.

DorskFR commented 3 years ago

So this issue does not exist with pynput on macos and linux but it does exist with pydirectinput in windows sadly.

I was usying pydirectinput in v1 and It was one of the reason why I wanted to switch to another library for simulated keypresses as the limitations induced by this library are significant in my opinion too:

While this issue does not exist on linux and macos, I am yet to find a library that can at the same time bypass game protections by being low level enough when simulating keypresses and handle high level charsets but I am open to any recommendation.

On a side note: the instance you run is now correctly detecting units (printing amount of minions, champions, buildings in the console) and clicking on them? Because when I tried it on a windows virtual machine I had issues with OpenCV and could not actually detect the units on screen properly.