Importing Libraries: The script uses several libraries:
- cv2 (OpenCV) for image processing tasks.
- numpy for handling arrays.
- pyautogui and pydirectinput for simulating keyboard and mouse inputs.
- time for managing time-related functions like delays.
- keyboard for detecting and sending keyboard events.
- win32api, win32con, win32gui, and win32ui for interacting with Windows APIs, especially for mouse events and screen capture.
Function Definitions:
- click(x, y): Moves the cursor to the specified position (x, y) on the screen and performs a right-click. This function uses Windows API functions to set the cursor position and simulate mouse events.
- target_enemy(): Captures the current screen, converts it to grayscale, and searches for a predefined image (template) using OpenCV's matchTemplate method. If the image is found, the script simulates a mouse click at a specified location relative to the found image.
- find_target_image(): Similar to target_enemy, but it checks if a target image exists on the screen by taking a screenshot, converting it to grayscale, and using template matching. It returns True if the target is found, False otherwise.
SkillTracker Class:
- This class is designed to manage the usage of skills based on cooldowns. It stores the key associated with a skill, the cooldown interval, and the last time the skill was used. The use_skill method checks if the skill can be used (if the cooldown has passed) and, if so, triggers the skill and updates the last used time.
Main Execution Loop:
- The script continuously checks for the presence of a target image. If no target is found, it attempts to locate and target an enemy using the target_enemy() function. If a target is subsequently found, it simulates pressing specific keys for attacking.
- The loop also continuously manages the use of various skills through instances of the SkillTracker class, ensuring each skill is used only after its cooldown period has elapsed.
- Delays are integrated into the loop to prevent rapid, unrealistic inputs that could either not register properly or might flag abnormal behavior in game systems.
Step-by-Step Tutorial: Setting Up Your Gaming Automation Script
This tutorial will guide you through the setup process for a Python script that automates certain actions in a video game by recognizing images on the screen. The script is designed to handle intensive tasks, such as defeating a large number of monsters continuously. It has been tested to successfully handle around 50,000 monsters in two days without issues. Before you start, ensure you have Python installed and the required libraries (cv2, numpy, pyautogui, pydirectinput, keyboard, win32api, win32con) are installed.
Step 1: Prepare Image Files
- Capture a screenshot of the monster you want to target in the game. Ensure this screenshot captures only the monster and minimal background to improve recognition accuracy. This image should be saved as 'Monster.png'. You can find an example of such an image in your script's folder, labeled as '1'.
- Next, capture a screenshot of the target bar when a monster is targeted. This will be used to verify if the correct target is selected during the game. Save this image as 'TargetBar.png'. An example of this image can also be found in your script's folder, labeled as '2'.
Step 2: Update the Script
- Open your Python script.
- Modify the 'target_enemy()' function to use the 'Monster.png' file by updating the line that reads the image file: template = cv2.imread('Monster.png', 0).
- Update the 'find_target_image()' function to use the 'TargetBar.png' file similarly.
Final Step: Execute the Automation Script
- In the last cell of your Jupyter Notebook, start the main execution loop of your script by calling the main function or just running the loop directly if your script is written procedurally.
- Monitor the script's output in the Jupyter Notebook to ensure it is performing as expected. Adjustments may be needed based on the game's responses and the script's performance.
Note: Although the script was quickly written and isn't fully polished, it has been highly effective in testing, managing to kill approximately 50,000 monsters continuously over two days without any problems. Additionally, the raw code included at the end of the script is designed to read memory for tasks such as loading hacks. In my case, I've only used it to create a MapHack that allows for teleporting using the Juno card.
Additional Features and Customization Options
If there is further interest in enhancing the functionality of this script, there are several potential upgrades and customizations that could be implemented:
- User Interface (UI): A graphical user interface (UI) could be developed to make the script easier to use and more accessible. The UI could provide controls for starting and stopping the script, adjusting settings, and displaying real-time feedback about the script’s activity and performance.
- Hidden Clicks: Currently, the script simulates mouse clicks within the game window without using your actual mouse cursor. This means it can perform actions in the background while you use your computer for other tasks. This feature could be expanded or refined based on specific needs or feedback.
- Monster Clombo: Hack Feature such as Teleporting in Monster Combo which makes it possible to get more then 8 Players in Monster Combo, and even get more coins
Custom Development: While this project was initially a small undertaking, I am open to further developing and enhancing the script based on specific orders or requests. Customizations such as adding a UI or refining the hidden click functionality can be discussed and implemented as per your requirements.






