jfd02 / TFT-OCR-BOT

A bot that plays Teamfight Tactics using OCR. Keeps track of bench, board, items, and plays the user defined team comp.
GNU General Public License v3.0
329 stars 91 forks source link

The Future of TFT OCR BOT #325

Open anthony5301 opened 2 months ago

anthony5301 commented 2 months ago

Hello jfd02,

With the launch of Vanguard, the Win32 API on Windows (used for pydirectinput) has become unavailable. I believe this repository could take one of three directions:

  1. Transition to macOS platform without Vanguard. However, I don't have an Apple computer, so I may not be able to continue developing the bot.
  2. Transition to an Android emulator, still running on Windows. This would require modify many things to control the emulator.
  3. Archive this repository.

Please tell me if you have any thoughts.

Sizzzles commented 2 months ago

Using pynput is possible but the concern would be Vanguard in general. Here is code using pynput. I'm sure delays will need to be fine tuned mk_functions.txt

anthony5301 commented 2 months ago

Using pynput is possible but the concern would be Vanguard in general.

no way they didnt block pynput on LOL vanguard? cuz I know those lib and win32 are blocked on valorant's vanguard long time ago....

Sizzzles commented 2 months ago

Spaghetti code is too strong I guess. I assume pyautogui wouldn't work should probably just try everything at this point

anthony5301 commented 2 months ago

On the contrary, I don't want to continue taking risks on Windows. You never know when this powerful backdoor program Vanguard might get you banned for using those input control lib.

Sizzzles commented 2 months ago

True... Feel like emulators might end up to laggy if ran for long periods of time since this bot is used for farming passes or maybe I've just chosen bad emulators in the past. But might be the only good option since a fair few people won't have macOS

anthony5301 commented 2 months ago

The current issue is that it takes 0.5-0.8 seconds each time to capture a screenshot from the emulator using adb shell. We need to find a way to share one screenshot among multiple functions as much as possible. Otherwise, just waiting for adb to return the screenshot would consume all the game round time.

This is the most ideal approach because it's entirely controlled through adb, it will still running even if the emulator is at background. However, if performance issues cannot be resolved, I will choose to fix the screen size of the emulator to 1920x1080 and control it using the original method.

Sizzzles commented 2 months ago

Yes adb is ideal but it is slow as you mentioned. Just from using the Alune bot that uses adb it doesn't buy champions until halfway through the round or later. It's using images for actions which I don't think is ideal but I honestly have no idea if custom comps would be possible like what OCR BOT was doing. I also wouldn't know where to start to help out since I struggled enough with the auto comps version of OCR BOT due to not knowing much coding

anthony5301 commented 2 months ago

I'm almost done with the fully adb-based version of TFT-OCR-BOT. I've removed the UI display feature, and there are no issues with other functionalities. The main modification involves replacing some inputs with swipe, queue without riot api, coords. However, due to the delay caused by adb, it's practically unusable. I'll be shifting towards "full-screen emulator" direction, and adb will only be used to check if TFT is installed and to open it.

Sizzzles commented 2 months ago

Interested to see how it turns out. You could also use adb to set resolution of the emulators (if aren't just using on one emulator) assuming they aren't set to 1920x1080 by default... Honestly any settings that needs to be changed from the default that adb has the ability to change would be a good idea makes it more user friendly

jfd02 commented 1 month ago

Sorry for the late reply. I primarily use macOS now and don't play much League anymore, so it's hard for me to provide input on the best future direction for this repo. I believe any functional solution is preferable to archiving it, but ultimately, the decision is up to you (or any other contributors)

When I first started building the bot, I used BlueStacks, expecting this version to be detected early on, and relied on screen capture. However, the placement of UI elements made things more complicated. Since I wrote most of the original code while learning to program, there's a lot that could be done better. Moving to ADB seems like a significant refactor, so I'm open to the idea of archiving this repo. You could create your own repo, and we can link to it in the README of this one if you prefer that.

Thanks for maintaining it throughout all the updates! @anthony5301

rayhahn commented 1 month ago

Using pynput is possible but the concern would be Vanguard in general. Here is code using pynput. I'm sure delays will need to be fine tuned mk_functions.txt

On my subcomputer, this bot puts items in champs, but on my main computer, it doesn't put items in champs. The difference between the two computers is that main computer is Windows 10 and the subcomputer is Windows 11. I tried shutting it down just in case the Corsair keyboard program was a problem, but it didn't work. The two computers differ only in the Windows version under exactly the same conditions. I hope this problem is solved.

anthony5301 commented 1 month ago

However, the placement of UI elements made things more complicated.

Yes, the unique UI design on the mobile version requires the bot to spend time carefully recognizing the current screen. Just toggling the shop took me several days of off-work time. Sometimes when fixing bugs, I feel like just buying a M2 Mac mini for bot is the best choice xd, just not sure how much RAM is needed. If I buy a Mac, I may convert this repository into a Mac version, and then create a new repository for the emulator version.

Although I did use adb, it was minimal, such as setting the emulator's screen size and dpi, checking if TFT was installed and opening it. For other parts, I used the same method to control the emulator window because using adb for input and take screenshot are extremely slow.

kizxlove commented 1 month ago

This morning I heard that vanguard just started to ban all account that using LoL API without their permission from 22 May. It mean that tft bot will be risks from now on.

anthony5301 commented 1 month ago

This morning I heard that vanguard just started to ban all account that using LoL API without their permission from 22 May. It mean that tft bot will be risks from now on.

On the day Vanguard arrived in LoL, the bot was already a risk because Vanguard can block and monitor all Win32API actions that control the keyboard and mouse.

jfd02 commented 1 month ago

https://www.reddit.com/r/leagueoflegends/comments/1cwne6a/comment/l4xxy7a/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

is using auto hot key an option?

anthony5301 commented 1 month ago

and we have other methods to remove those bots for now.

He said this, and I believe they can identify which key is being pressed by AHK, only remap some key to other key are acceptable. Although our bot only requires simple mouse clicks, similar to remapping a button. I wouldn't want to take any risks while vanguard is running.

kizxlove commented 1 month ago

it's been month since the day vanomegalulguard released. Is there any guys got trouble yet?