
The problem is that all the time the bot is busy executing a cycle, responsible for the logic of the character's actions and the object's event handlers and autohotpy do not start listening to events until the cycle ends. The basic logic is ready, so now it looks like in action:Īll work with the cursor and keyboard is done through an autohotpy object, which can be stopped at any time by pressing the ESC button. Now the bot understands how much HP the victim has and if she still lives. The desired window is determined by the title - “Lineage 2”.ĭef get_window_info () : # set window info window_info = # cv2.rectangle(img, pt, (pt + w, pt + h), (255, 255, 255), 2) if not target_widget_coordinates: return -1 pil_image_hp = get_screen( self.window_info + target_widget_coordinates + 15, self.window_info + target_widget_coordinates + 31, self.window_info + target_widget_coordinates + 164, self.window_info + target_widget_coordinates + 62 ) pixels = pil_image_hp.tolist() for pixel in pixels: if pixel = hp_color: filled_red_pixels += 1 percent = 100 * filled_red_pixels / 150 return percent We work with the window using the win32gui module. To do this, we define the coordinates of the window. We will work with screenshots from the game window. Especially for game developers to help them better deal with bots. Those clickers that I found did not work for various reasons, or they were unstable.Īttention: all the information here is for educational purposes only. The second option is more interesting, given that it can be applied with some modifications to any other game, and the implementation will be more interesting. The first is a hard cheat, in terms of games, using them is too unsportsmanlike. They are divided into 2 main groups: those that are embedded in the work of the client and clickers. In general, the creation of a bot for L2 is not new and there are quite a lot of them ready. For control, emulated mouse clicks and keystrokes of the keyboard will be used, and for orientation in space - computer vision, programming language - Python. In the game, you can unite into clans, groups, make friends and fight with rivals, but in general the game is filled with monotonous actions: completing quests and farming (collecting resources, gaining experience ).Īs a result, I decided that the bot should solve one problem: farm.

Once in school, he was fascinated by one of the most popular MMORPGs - Lineage 2. How can you have fun in the New Year holidays? Play computer games? Not! It is better to write a bot that it will do for you, and go yourself to sculpt a snowman and drink mulled wine.
