Creating a Game Bot using PyAutoGUI, OpenCV, and Pytesseract — Part 2

April–June 2024

After finishing my fishing bot, I wanted to automate something more complicated.

I discovered that more dungeons had been added to the game. A dungeon is like a mission or quest consisting of several tasks, usually ending with defeating a dungeon boss. The tasks were generally simple and repetitive—great candidates for automation.

I ran a few dungeons manually first. I wanted to understand how they worked overall: did tasks appear in the same order? Did monsters always spawn in the same places? I needed to evaluate their automation potential. After several runs, I settled on a hell-themed dungeon as my target.

I began coding. I took screenshots of the monster names (I discovered that the font color was unique for each category: bosses, monsters, or metin stones). I used these screenshots with PyAutoGUI to locate them on screen. I also set up automated clicks for using potions. After some effort, I got my bot loop running.

At the start, I watched the bot closely—observing how my character behaved, checking whether it looked suspicious or “bot-like.” After a while, I noticed some variation in monster and stone spawn positions. After a few hours, my character started clicking in the wrong places because the stones sometimes spawned farther or closer than expected.

To address this, I added a function that clicked a second time on the stone. If the character was already attacking, nothing happened. But if it wasn’t attacking, that second click would correct its position.

That was essentially it—the same core logic as the fishing bot (locate images, automate mouse and keyboard input), but the dungeon bot was more advanced.

I ran the bot for a while and then noticed two important issues.

First, running dungeons wasn’t very profitable for me. Most players used around six characters to farm six dungeons simultaneously. I had only one character, and my bot could only handle one dungeon at a time. I couldn’t scale easily for two reasons: I didn’t have a powerful computer (just a Lenovo ThinkPad T460 with an Intel i5-6600U that could run maybe two or three instances of the game), and even if I upgraded my hardware, my approach wasn’t scalable. I’d need to set up virtual machines for each instance.

Second, because dungeons were so repetitive, many players had started using bots—and admins knew this. They manually checked players by sending private messages, asking casual questions or questions about in-game events. I didn’t know this at first. Eventually, I got checked, didn’t respond in time, and got banned.