├── requirements.txt ├── Valorant-Lineup-Script ├── overlays │ ├── red_dot.png │ └── violet_x.png ├── settings.json └── Valorant-Lineup-Tool.py ├── LICENSE └── README.md /requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow 2 | pynput 3 | PyAutoGUI 4 | -------------------------------------------------------------------------------- /Valorant-Lineup-Script/overlays/red_dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simonrye/valorant-lineup-tool/HEAD/Valorant-Lineup-Script/overlays/red_dot.png -------------------------------------------------------------------------------- /Valorant-Lineup-Script/overlays/violet_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simonrye/valorant-lineup-tool/HEAD/Valorant-Lineup-Script/overlays/violet_x.png -------------------------------------------------------------------------------- /Valorant-Lineup-Script/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "valorant_sensitivity": 0.4, 3 | // Adjust this value to match your in-game sensitivity. 4 | 5 | "player_coords": [206, 227], 6 | // These are the coordinates of the center of the minimap or your point of view (POV). 7 | 8 | "map_distance_multiplier": 1, 9 | // Modify this value if necessary to account for variations. 10 | // Increase if projectiles consistently fall short, decrease if they overshoot. 11 | // Test adjustments on even ground for accuracy. 12 | // Note: Uneven terrain may affect distances and require in-game adjustments. 13 | 14 | 15 | "ascent_multiplier": 1.07, 16 | "bind_multiplier": 1.2625, 17 | "breeze_multiplier": 1.03, 18 | "fracture_multiplier": 0.96, 19 | "haven_multiplier": 1.00, 20 | "icebox_multiplier": 1.03, 21 | "lotus_multiplier": 1.035, 22 | "pearl_multiplier": 0.96, 23 | "split_multiplier": 0.958, 24 | "sunset_multiplier": 0.964, 25 | // Only adjust map multipliers if you are familiar with their impact. 26 | 27 | 28 | "unplanted_spike_rgb": [219, 230, 3], 29 | // RGB color code for the unplanted spike. Adjust if needed for screen variations. 30 | 31 | "planted_spike_rgb": [248, 188, 0], 32 | // RGB color code for the planted spike. Modify as necessary. 33 | 34 | "tolerance": 12, 35 | // The tolerance level for RGB color matching. Generally, this should not need to change. 36 | 37 | "x_file": "overlays/violet_x.png", 38 | "dot_file": "overlays/red_dot.png" 39 | // File paths for the overlay images used. 40 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Valorant Lineup Tool

2 |

3 | 4 |

5 | 6 |
7 | This tool is designed to assist players in creating on-the-spot lineups for specific agents. Stand nearly anywhere within range, and you'll receive an overlay to guide the lineup. The tool analyzes the minimap to determine the exact distance and direction of the spike, then places a convenient overlay on your Valorant game screen. With this tool, anyone can quickly and easily create precise lineups from anywhere on the map. Importantly, this script does not interact with the game files, ensuring it remains entirely external. For a better understanding of how the script works, expand the videos below. 8 |
9 | This project was created for the purpose of quickly setting up memorable lineups in custom games for later use. 10 |
11 |

Agents

12 |
Brimstone: Incendiary
13 |
14 | Brimstone Video Demos 15 | 16 | 17 | https://github.com/Simonrye/valorant-lineup-tool/assets/85827801/9ecd9daa-3f87-45ee-9955-d2d85240361a 18 | 19 | 20 | https://github.com/Simonrye/valorant-lineup-tool/assets/85827801/c73c23aa-9fe3-4a6d-93ea-c22e8610841f 21 |
22 | When you're far enough, you'll see two indicators: an 'X' for a bounce landing and a dot for a direct hit. 23 |
24 | Direct hits may be needed when a backboard is present and the terrain in front of the spike prevents a predictable bounce. 25 |
26 | 27 | *Some computers may have trouble rendering the second indicator, which may distrupt the script.* 28 |
Viper: Snake Bite
29 |
30 | Viper Video Demo 31 | 32 | 33 | https://github.com/Simonrye/valorant-lineup-tool/assets/85827801/21f364b9-a7ca-4731-921b-dee09b4fcabd 34 |
35 | The extreme range of a Snake Bite, paired with the direct impact when landing makes Viper the best agent for this tool. 36 |
37 | The trajectory is less affected by elevation differences. 38 |
KAY/O: FRAG/ment
39 |
40 | KAY/O Video Demo 41 | 42 | 43 | https://github.com/Simonrye/valorant-lineup-tool/assets/85827801/b660febe-5c62-4af2-8754-83a3f9a531a6 44 |
45 | This projectile is limited by it's shorter reach, but still works close range. 46 |
47 | This projectile is underdeveloped, and still may present issues. 48 |

Setup

49 | 50 | 1. **Dependencies:** Be sure to have installed the nessessary Python libraries. 51 | * `pip install Pillow` 52 | * `pip install pynput` 53 | * `pip install PyAutoGUI` 54 | 55 | 3. **Configure Your Settings:** *Compatible settings are crucial for the script to function!* 56 | * Disable mouse acceleration if it's enabled. (It's often enabled by default on Windows) 57 | * Open `settings.json` and adjust the valorant sensitivity value to match your own. 58 | * Launch Valorant and ensure the mini-map settings are set as: 59 | * Rotate: `Rotate` 60 | * Keep Player Centered: `On` 61 | * Minimap Size: `1` 62 | * Minimap Zoom: `1` 63 | 64 |

Usage

65 | 66 | 1. **Running the Script:** 67 | * Download the entire "Valorant-Lineup-Tool" folder found in this repo. Inside lies the Python script. 68 | * If you are trying the script for the first time, choosing Viper, Breeze, and an unplanted spike is recommended. 69 | * Start a custom Valorant game with cheats enabled and run the Python file. 70 | * Select the same agent and map of choice for both Valorant and the script. 71 | * Select whether you want to aim at a planted or unplanted spike in the script. 72 | 73 | 2. **Create lineup:** 74 | * Drop or plant the bomb (depending on selected choice earlier) at a point of your choosing. 75 | * Move to your location of choice for the lineup. 76 | * Somewhat face the direction of the spike. *As long as the spike is not "behind" you on the minimap it's okay.* 77 | * Look straight down, and let go of your mouse. 78 | * Hit the right arrow key. *It is good practice to hit the left arrow once before this to prevent any past lineup confliction.* 79 | * Slowly look up and find the X that marks the spot to shoot the projectile. Do not open the map, or any other UI such as Brimstone's smokes or ultimate (E- Sky Smokes, X- Orbital Strike) during this time until projectile is fired. 80 | * Once fired, hit the left arrow to reset the X. Repeat. 81 | 82 |

Troubleshooting

83 | 84 | 1. **Change spike RGB values:** Issues may arise if you had applied any color enhancements to your computer. 85 | * Start a custom game with cheats enabled. 86 | * Drop the spike and take a screenshot of it on the minimap. 87 | * Open the screenshot with a tool such as Paint 3D to extract the required RGB from the spike. 88 | * Ensure that you select a pixel color that accurately represents the majority of the spike. 89 | * Open `settings.json` and edit the respective value. 90 | * Repeat this process for a planted spike. 91 | 92 | 2. **Adjust Map Multiplier** If you find that the projectile consistently falls short or goes too far, follow these steps: 93 | * Enter a custom game, preferly on the Icebox map. 94 | * Launch the script while selecting the same map. 95 | * Choose a corner that allows for maximum distance, positioning yourself as far away as possible while maintaining a clear view of the spike. 96 | * Ping the spike to get the distance (in meters). Then press the right arrow, then the left arrow. 97 | * Compare the in-game distance with the distance displayed in the console. 98 | * Make the necessary adjustments in the `settings.json` file; you'll find more detailed instructions there. 99 | 100 |

How Does It Work?

101 | 102 |
103 | Watch the Explanation Video 104 | 105 | 106 | https://github.com/Simonrye/valorant-lineup-tool/assets/85827801/6042b287-4205-487a-8283-f4470051d60c 107 |
108 | 109 | The script operates by utilizing the centered minimap and the spike's RGB information to determine the player's fixed position and the relative position of the spike. This data is used to calculate the distance and direction to the spike. Subsequently, the script places an "X" overlay onto the screen, intended to guide the player precisely where to aim in-game. To initiate the lineup, the player must look straight down to align the "X" with the correct y-position. 110 | 111 | When you switch away from the Valorant window while keeping the minimap in view, the script will continue to function as expected. See the video above. 112 | 113 | As Valorant directly uses raw input from the mouse itself, the script attempts to accurately track the in-game mouse movements through the cursor's position. However, there may be slight discrepancies between raw mouse movement and cursor position, which is why extreme mouse movement will cause desync. Additionally, mouse cursors are confined within the monitor boundaries, while raw mouse movement is not. This explains why the mouse DPI is intentionally reduced to prevent any cursor collisions with the top of the screen when aiming upward in-game during a lineup. 114 | 115 | The calculations for converting distance (in meters) to a y-offset were determined through a trial-and-error process, resulting in reasonably accurate functions. This method is far from flawless. 116 | 117 | Each map in Valorant has a distinct pixel-to-distance (in meters) ratio, which is why map-specific multipliers were included in the `settings.json` file. These multipliers are rough estimations and are not precise. 118 | 119 |

IMPORTANT NOTICE

120 |

121 | Please read this section carefully before using this tool. 122 |

123 |

124 | 125 | **Disclaimer:** The tool is **NOT** affiliated with Valorant. Exercise caution when using it in custom games. I have not and will not test this script during live games as a precaution. The script **DOES NOT** interact with any game files. Any responsibility for using this script will solely rest upon the user who chooses to use it. 126 |

127 |

128 | 129 | **The most intrusive actions taken by this script include:** 130 | 131 | * Reading your screen to locate the bomb 132 | * Displaying a small overlay (X) above all your windows 133 | * Tracking the mouse cursor position to move the overlay accordingly 134 | * Placing the mouse cursor at the bottom of your screen at the start of ever lineup 135 | * Changing mouse DPI during the lineup 136 |

137 |

138 | 139 | **Important:** This tool temperarily changes your DPI during a lineup. If you notice your mouse moving unusually slowly outside of Valorant, click the left arrow to reset the DPI. If the script is closed, you can run the script again to reset the DPI. To prevent this, always remember to click the left arrow after completing a lineup, and avoid closing the script in the middle of a lineup. 140 |

141 | -------------------------------------------------------------------------------- /Valorant-Lineup-Script/Valorant-Lineup-Tool.py: -------------------------------------------------------------------------------- 1 | # Valorant Lineup Script 2 | # Version 1.0 3 | # Author: Simonrye 4 | # GitHub: https://github.com/Simonrye/valorant-lineup-tool/ 5 | # License: Creative Commons Zero v1.0 Universal 6 | 7 | # Please read the entire README.md file for instructions and usage guidelines. 8 | # Use this script responsibly and only in custom games. 9 | # Respect the game's terms of service and fair play rules. 10 | # Remember that third-party scripts are not officially endorsed by Valorant. 11 | 12 | from pynput import keyboard, mouse 13 | from pynput.mouse import Button, Controller 14 | from tkinter import * 15 | from PIL import Image, ImageTk 16 | import pyautogui 17 | import math 18 | import ctypes 19 | import json 20 | 21 | def change_speed(speed=10): 22 | set_mouse_speed = 113 23 | ctypes.windll.user32.SystemParametersInfoA(set_mouse_speed, 0, speed, 0) 24 | 25 | settings_file = 'settings.json' 26 | def remove_comments(json_text): 27 | lines = json_text.split('\n') 28 | cleaned_lines = [line for line in lines if not line.lstrip().startswith('//')] 29 | return '\n'.join(cleaned_lines) 30 | 31 | change_speed(speed=10) 32 | with open(settings_file, 'r') as file: 33 | try: 34 | json_text = remove_comments(file.read()) 35 | data = json.loads(json_text) 36 | val_sensitivity = data['valorant_sensitivity'] 37 | player_x, player_y = data['player_coords'] 38 | 39 | personal_multi = data['map_distance_multiplier'] 40 | 41 | ascent_multi = data['ascent_multiplier'] 42 | bind_multi = data['bind_multiplier'] 43 | breeze_multi = data['breeze_multiplier'] 44 | fracture_multi = data['fracture_multiplier'] 45 | haven_multi = data['haven_multiplier'] 46 | icebox_multi = data['icebox_multiplier'] 47 | lotus_multi = data['lotus_multiplier'] 48 | pearl_multi = data['pearl_multiplier'] 49 | split_multi = data['split_multiplier'] 50 | sunset_multi = data['sunset_multiplier'] 51 | 52 | 53 | unplanted_rgb = data['unplanted_spike_rgb'] 54 | planted_rgb = data['planted_spike_rgb'] 55 | tolerance = data['tolerance'] 56 | XFILE = data['x_file'] 57 | DOTFILE = data['dot_file'] 58 | 59 | except Exception as e: 60 | val_sensitivity = 0.4 61 | player_x, player_y = 206, 227 62 | personal_multi = 1 63 | 64 | ascent_multi = 1.07 65 | bind_multi = 1.27 66 | breeze_multi = 1.03 67 | fracture_multi = 0.96 68 | haven_multi = 1 69 | icebox_multi = 1.03 70 | lotus_multi = 1.035 71 | pearl_multi = 0.96 72 | split_multi = 0.958 73 | sunset_multi = 0.964 74 | 75 | unplanted_rgb = [219, 230, 3] 76 | planted_rgb = [248, 188, 0] 77 | tolerance = 12 78 | XFILE = 'overlays/violet_x.png' 79 | DOTFILE = 'overlays/red_dot.png' 80 | 81 | print(f'WARNING! Unable to load {settings_file}!\nUsing default values that may be inaccurate.') 82 | print(f'Error message:\n{e}\n') 83 | 84 | print('''Valorant Lineup Script 85 | Version 1.0 86 | Author: Simonrye 87 | GitHub: https://github.com/Simonrye/valorant-lineup-tool/ 88 | License: Creative Commons Zero v1.0 Universal 89 | 90 | Please read the entire README.md file for instructions and usage guidelines. 91 | Use this script responsibly and only in custom games. 92 | Respect the game's terms of service and fair play rules. 93 | Remember that third-party scripts are not officially endorsed by Valorant. 94 | ''') 95 | 96 | 97 | while True: 98 | choice = input('''Select agent: 99 | 1. Brimstone 100 | 2. Viper 101 | 3. KAY/O 102 | ''').strip() 103 | if choice in ('1', '2', '3'): 104 | agent = { 105 | '1': 'Brimstone', 106 | '2': 'Viper', 107 | '3': 'KAY/O', 108 | }[choice] 109 | break 110 | 111 | while True: 112 | choice = input(''' 113 | Select map: 114 | 1. Ascent 115 | 2. Bind 116 | 3. Breeze 117 | 4. Fracture 118 | 5. Haven 119 | 6. Icebox 120 | 7. Lotus 121 | 8. Pearl 122 | 9. Split 123 | 10. Sunset 124 | ''').strip() 125 | if choice in (str(x) for x in range(1,11)): 126 | map_multi = { 127 | '1': ascent_multi, 128 | '2': bind_multi, 129 | '3': breeze_multi, 130 | '4': fracture_multi, 131 | '5': haven_multi, 132 | '6': icebox_multi, 133 | '7': lotus_multi, 134 | '8': pearl_multi, 135 | '9': split_multi, 136 | '10': sunset_multi 137 | }[choice] * personal_multi 138 | break 139 | 140 | while True: 141 | choice = input(''' 142 | Select mode: 143 | 1. Unplanted spike 144 | 2. Planted spike 145 | ''').strip() 146 | if choice in ('1', '2'): 147 | target_color = { 148 | '1': unplanted_rgb, 149 | '2': planted_rgb 150 | }[choice] 151 | break 152 | 153 | print('\nSELECTED AGENT:', agent) 154 | 155 | SENSE_MULTI = val_sensitivity/.4 #Do not change. Edit sensitivity in settings.json file. 156 | 157 | print('Script initiated.') 158 | def find_all_pixels_with_tolerance(target_color, tolerance, region_top_left, region_bottom_right): 159 | screen = pyautogui.screenshot(region=(region_top_left[0], region_top_left[1], region_bottom_right[0] - region_top_left[0], region_bottom_right[1] - region_top_left[1])) 160 | matches = [] 161 | for x in range(screen.width): 162 | for y in range(screen.height): 163 | pixel_color = screen.getpixel((x, y)) 164 | if all(abs(pixel_color[i] - target_color[i]) <= tolerance for i in range(3)): 165 | matches.append((x + region_top_left[0], y + region_top_left[1])) 166 | return matches 167 | 168 | 169 | def calculate_average_coordinates(matches): 170 | if not matches: 171 | return None, None 172 | avg_x = sum(x for x, y in matches) // len(matches) 173 | avg_y = sum(y for x, y in matches) // len(matches) 174 | return avg_x, avg_y 175 | 176 | 177 | def calculation(target_x, target_y): 178 | delta_x = target_x - player_x 179 | delta_y = target_y - player_y 180 | turn_angle = math.degrees(math.atan2(delta_y, delta_x)) 181 | distance_m = math.sqrt(delta_x ** 2 + delta_y ** 2) 182 | return distance_m, turn_angle 183 | 184 | 185 | def find_spike(): 186 | global target_color, tolerance 187 | 188 | region_top_left = (20, 30) 189 | region_bottom_right = (400, 230) 190 | matches = find_all_pixels_with_tolerance(target_color, tolerance, region_top_left, region_bottom_right) 191 | if matches: 192 | avg_x, avg_y = calculate_average_coordinates(matches) 193 | distance_m, turn_angle = calculation(avg_x, avg_y) 194 | return distance_m * 0.351 * map_multi, turn_angle + 90 195 | else: 196 | print(f'Spike not found! No pixels with color {target_color} found in the specified region') 197 | return None, None 198 | 199 | 200 | START_X = 960 201 | START_Y = -1650 202 | 203 | win = Tk() 204 | win.wm_attributes('-transparentcolor', win['bg']) 205 | win.geometry('1920x1000') 206 | 207 | canvas = Canvas(win, width=1920, height=1080) 208 | canvas.pack() 209 | 210 | image = ImageTk.PhotoImage(Image.open(XFILE)) 211 | image2 = ImageTk.PhotoImage(Image.open(DOTFILE)) 212 | img = canvas.create_image(START_X, START_Y, anchor='center', image=image, state='hidden') 213 | img2 = canvas.create_image(START_X, START_Y, anchor='center', image=image2, state='hidden') 214 | 215 | label = Label() 216 | label.master.overrideredirect(True) 217 | label.master.lift() 218 | label.master.wm_attributes('-topmost', True) 219 | 220 | online = False 221 | dropable = False 222 | lastx, lasty = 960, 540 223 | mouse_moved = False 224 | 225 | def on_move(x, y): 226 | global listener, lastx, lasty, mouse_moved, dropable 227 | if not mouse_moved: 228 | mouse_moved = True 229 | canvas.itemconfig(img, state='normal') 230 | if dropable: 231 | canvas.itemconfig(img2, state='normal') 232 | canvas.move(img, (lastx - x) * 2.5 * SENSE_MULTI, (lasty - y) * 6 * SENSE_MULTI) 233 | canvas.move(img2, (lastx - x) * 2.5 * SENSE_MULTI, (lasty - y) * 6 * SENSE_MULTI) 234 | lastx, lasty = x, y 235 | #canvas.move(img, (lastx - x)*2.5 * SENSE_MULTI, -(y - lasty )*12/2 * SENSE_MULTI) 236 | 237 | def ExitESC(key): 238 | global listener, listenerExit, online, win 239 | stop_keys = [keyboard.Key.left, keyboard.Key.esc, keyboard.Key.caps_lock] 240 | if key in stop_keys and online: 241 | listener.stop() 242 | listenerExit.stop() 243 | canvas.itemconfig(img, state='hidden') 244 | canvas.itemconfig(img2, state='hidden') 245 | change_speed(speed=10) 246 | online = False 247 | 248 | def BeginMouse(): 249 | global listenerExit, lastx, lasty, mouse_moved 250 | lastx, lasty = 960, 1080 251 | Controller().position = (1920//2 , 1080) 252 | mouse_moved = False 253 | global listener 254 | listener = mouse.Listener(on_move=on_move) 255 | listener.start() 256 | listenerExit = keyboard.Listener(on_press=ExitESC) 257 | listenerExit.start() 258 | 259 | 260 | def on_press1(key): 261 | global listener, online, win 262 | try: 263 | if key == keyboard.Key.right and not online: 264 | distance_m, turn_angle = find_spike() 265 | if distance_m is None or turn_angle is None: 266 | return 267 | canvas.coords(img, START_X, START_Y) 268 | canvas.coords(img2, START_X, START_Y) 269 | canvas.move(img, turn_angle * 5.6, 0) 270 | canvas.move(img2, turn_angle * 5.6, 0) 271 | 272 | if agent == 'Brimstone': 273 | change_main, change_drop = calculate_change_brim(distance_m) 274 | elif agent == 'Viper': 275 | change_main, change_drop = calculate_change_viper(distance_m) 276 | elif agent == 'KAY/O': 277 | change_main, change_drop = calculate_change_kayo(distance_m) 278 | else: 279 | print('Agent selection error.') 280 | return 281 | print('Distance:', distance_m) 282 | 283 | canvas.move(img, 0, change_main) 284 | if change_drop is not None: 285 | canvas.move(img2, 0, change_drop) 286 | BeginMouse() 287 | change_speed(speed=2) 288 | online = True 289 | except Exception as e: 290 | print(e) 291 | 292 | 293 | def calculate_change_brim(M_bounce): 294 | global dropable 295 | change_main = M_bounce * 5.7 - 240 296 | if M_bounce <= 16: 297 | dropable = False 298 | return change_main, None 299 | dropable = True 300 | change_drop = M_bounce * 6.6 - 240 301 | return change_main, change_drop 302 | 303 | 304 | def calculate_change_viper(M_bounce): 305 | global dropable 306 | dropable = False 307 | if M_bounce <= 44: 308 | change_main = M_bounce * 6.1 - 230 309 | elif M_bounce <= 46: 310 | change_main = M_bounce * 8 - 300 311 | else: 312 | change_main = M_bounce * 10 - 410 313 | return change_main, None 314 | 315 | 316 | def calculate_change_kayo(M_bounce): 317 | global dropable 318 | dropable = False 319 | if M_bounce <= 26: 320 | change_main = M_bounce * 10 - 220 321 | elif M_bounce <= 37: 322 | change_main = M_bounce * 20 - 540 323 | else: 324 | change_main = M_bounce * 100 - 3900 325 | return change_main, None 326 | 327 | 328 | listener1 = keyboard.Listener( 329 | on_press=on_press1) 330 | listener1.start() 331 | win.mainloop() 332 | --------------------------------------------------------------------------------