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
323 stars 91 forks source link

Buying champ then selling it directly #15

Open AmineMessabhia opened 2 years ago

AmineMessabhia commented 2 years ago

Hello man, First, I'd like to thank you for this tremendous work, gg wp!!

After using it for some time, I notice that sometimes, the bot buys Illaoi or Tristana for example, then they don't get a name in the overlay, and right after the buying phase, he sells them, and the log says: Selling unknown champion.

Is there any way this can be fixed? because it makes the comp aways on a 1-star champs.

Oh, one more question, is there any way to make it work with 1366x768 monitors? I tried it on a laptop, and it is stuck at "Loading screen found! Waiting for round 1-1"

Thanks again!!

AmineMessabhia commented 2 years ago

I've just watched the bot play, and I was able to take screenshots of the problem:

Round 3-6 r3-6

Round 3-7 r3-7

Round 4-5 r4-5

Notice how the champs are bought, then not added in the overlay, then treated as unknown and sold.

ffb7c5 commented 2 years ago

Is it trying to place items after already in PVP in the last screen shot? Also I assume you modified the "level": 2 in the comps.py file?

AmineMessabhia commented 2 years ago

Here's my comp file: image

It's not about items, the items are working perfectly, the problem is that it buys a champ, then it doesn't show in the overlay, then it sells it directly.

MrDumox commented 2 years ago

I'm also getting this problem and script tries to put items during PVP

AmineMessabhia commented 2 years ago

In the comp.py file, the Level, is it the level of the champ? (1 star, 2 stars, 3stars?) or the level of the Tactician?

AmineMessabhia commented 2 years ago

I'm also getting this problem and script tries to put items during PVP

Sometimes, and especially after the PVE fight (against raptors and others), the script takes a lot of time to gather the items, to the point that when it is done, and it goes into the buying champ phase it does buy, then in the log it shows "Placing CHAMP on board" but the PVP fight has already started, and the champ is still benched.

This sometimes leads to a random champ taking a random hex, but the overlay still shows the CHAMP (that has been bought) is placed.

AmineMessabhia commented 2 years ago

@jfd02 Any idea about this behavior?

ffb7c5 commented 2 years ago

@AmineMessabhia

Sorry for the delay, was taking a break. How are your PC specs? The only time this has happened to me is when I run the game on a PC with old hardware. On the code side the only thing that can be done is either make the bot not perform any actions on item pickup rounds or come up with a way to pick up items efficiently.

To be honest, I'm not sure how to implement the solution I have in mind and would need someone to contribute to this.

My idea is to calculate the location of the orbs on the board using using the RGB codes of the orb (I can do this part), once you have these positions I assume you would need to find the position on the screen to click which can't be on the board because it may be on top of a champion. So you take your position and the target position, find the slope of the line and calculate the first position where x is farther right then the board and click there. Then you would need to recalculate for the next orb on the board. The only problem I see with this is orbs can overlap each other and the color changes slightly.

Picture for better example:

Board

BrandTime commented 2 years ago

Is it possible to read game memory? Just like the project of Lmeme. It is easy to get items object world position, you can filter it by object name, then use worldToScreen and click it. Meanwhile, it make everything becoming easy. It can never fail when check bench hero. (I never get 3 star hero, because it will sell all bench hero when it will be successful. )

ffb7c5 commented 2 years ago

Is it possible to read game memory? Just like the project of Lmeme. It is easy to get items object world position, you can filter it by object name, then use worldToScreen and click it. Meanwhile, it make everything becoming easy. It can never fail when check bench hero. (I never get 3 star hero, because it will sell all bench hero when it will be successful. )

Yeah its possible

AmineMessabhia commented 2 years ago

How are your PC specs?

ASU GL553VD:

esbe1175 commented 2 years ago

You should probably try resetting league of legends' internal brightness/vibrance/contrast sliders to default values.

i boldly assume it uses some sort of image recognition to detect each champion, which any deviance from how the software knows a champion is supposed to look (like changing it's color levels) would make it harder for it or in some cases impossible to detect.

Reason i'm saying this is your screenshot looks abnormally bright compared to what it should look like at default values.

Feel like it's a good guess, but i didn't have a look under the hood nor the expertise to make sense of most any of it.

These are the ones im talking about, by the way: image

jfd02 commented 2 years ago

There is no image recognition in the bot, only OCR and checking pixel colors. So it may be possible the color settings do mess with the health bar color which is a way the bot checks if a slot is occupied which may mess things up. I'm not confident the logic isn't at fault either though as there is a lot of edge cases such as picking up an orb causing a champion on the board to change tiers, removing the champions on the bench.

esbe1175 commented 2 years ago

Ah, I see. Worth mentioning anyway.

I think specifically the UI is unaffected by those values actually.