anyone know why this code is not working in game /u/Overall_Barnacle7851 Python Education

import pydirectinput import threading import keyboard import time # Define the recoil pattern for the AK-47 ak_recoil_pattern = [ [1.390706, -2.003941], [1.176434, -3.844176], [3.387171, -5.516686], [5.087049, -7.017456], [5.094189, -8.342467], [4.426013, -9.487704], [3.250455, -10.44915], [1.73545, -11.22279], [0.04893398, -11.8046], [-1.641158, -12.19056], [-3.166891, -12.58713], [-4.360331, -13.32077], [-5.053545, -14.32128], [-5.090651, -15.51103], [-4.489915, -16.81242], [-3.382552, -18.14783], [-1.899585, -19.43966], [-0.1720295, -20.61031], [1.669086, -21.58213], [3.492748, -22.27755], [5.16793, -22.61893], [6.563614, -22.81778], [7.548776, -23.37389], [7.992399, -24.21139], [7.512226, -25.23734], [6.063792, -26.35886], [4.117367, -27.48302], [2.143932, -28.51692], [0.6144824, -29.36766] ] # Game settings (user-specified) sensitivity = 0.5 fov = 90.0 # Calculate the multiplier based on sensitivity and FOV multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'Multiplier calculated: {multiplier}') # Debug statement def convert_recoil_to_pixels(recoil_pattern, multiplier): """ Convert the recoil pattern to pixel movements. """ pixel_movements = [] last_shot = [0, 0] for index, shot in enumerate(recoil_pattern): dx = (shot[0] - last_shot[0]) / multiplier dy = (shot[1] - last_shot[1]) / multiplier pixel_movements.append([dx, dy]) last_shot = shot print(f'Shot {index + 1}: dx={dx}, dy={dy}') # Debug statement return pixel_movements def apply_recoil(pixel_movements, repeat_delay): """ Apply the recoil pattern using pixel movements. """ for index, (dx, dy) in enumerate(pixel_movements): print(f'Applying recoil step {index + 1}: Moving by dx={int(dx)}, dy={int(dy)}') # Debug statement pydirectinput.moveRel(int(dx), int(dy)) time.sleep(repeat_delay / 1000.0) # Convert milliseconds to seconds def on_click(): """ Handle mouse click event to start applying the recoil pattern. """ repeat_delay = 1000.0 / (600 / 60.0) # Assuming AK-47 has 600 RPM print(f'Repeat delay calculated: {repeat_delay} ms') # Debug statement pixel_movements = convert_recoil_to_pixels(ak_recoil_pattern, multiplier) print("Starting recoil pattern application...") # Debug statement apply_recoil(pixel_movements, repeat_delay) def monitor_mouse(): """ Monitor the left mouse button and trigger recoil pattern on click. """ while True: if keyboard.is_pressed('left'): print("Left mouse button detected. Applying recoil...") # Debug statement on_click() time.sleep(0.1) # Start the monitoring thread to handle mouse clicks print("Starting mouse monitoring thread...") # Debug statement thread = threading.Thread(target=monitor_mouse) thread.start() def adjust_sensitivity(new_sensitivity): """ Adjust the mouse sensitivity and recalculate the multiplier. """ global sensitivity, multiplier sensitivity = new_sensitivity multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'Sensitivity adjusted: {sensitivity}, New Multiplier: {multiplier}') # Debug statement def adjust_fov(new_fov): """ Adjust the field of view (FOV) and recalculate the multiplier. """ global fov, multiplier fov = new_fov multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'FOV adjusted: {fov}, New Multiplier: {multiplier}') # Debug statement # Confirm current settings print(f'Current Settings: Sensitivity={sensitivity}, FOV={fov}, Multiplier={multiplier}') # Debug statement 

submitted by /u/Overall_Barnacle7851
[link] [comments]

​r/learnpython import pydirectinput import threading import keyboard import time # Define the recoil pattern for the AK-47 ak_recoil_pattern = [ [1.390706, -2.003941], [1.176434, -3.844176], [3.387171, -5.516686], [5.087049, -7.017456], [5.094189, -8.342467], [4.426013, -9.487704], [3.250455, -10.44915], [1.73545, -11.22279], [0.04893398, -11.8046], [-1.641158, -12.19056], [-3.166891, -12.58713], [-4.360331, -13.32077], [-5.053545, -14.32128], [-5.090651, -15.51103], [-4.489915, -16.81242], [-3.382552, -18.14783], [-1.899585, -19.43966], [-0.1720295, -20.61031], [1.669086, -21.58213], [3.492748, -22.27755], [5.16793, -22.61893], [6.563614, -22.81778], [7.548776, -23.37389], [7.992399, -24.21139], [7.512226, -25.23734], [6.063792, -26.35886], [4.117367, -27.48302], [2.143932, -28.51692], [0.6144824, -29.36766] ] # Game settings (user-specified) sensitivity = 0.5 fov = 90.0 # Calculate the multiplier based on sensitivity and FOV multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f’Multiplier calculated: {multiplier}’) # Debug statement def convert_recoil_to_pixels(recoil_pattern, multiplier): “”” Convert the recoil pattern to pixel movements. “”” pixel_movements = [] last_shot = [0, 0] for index, shot in enumerate(recoil_pattern): dx = (shot[0] – last_shot[0]) / multiplier dy = (shot[1] – last_shot[1]) / multiplier pixel_movements.append([dx, dy]) last_shot = shot print(f’Shot {index + 1}: dx={dx}, dy={dy}’) # Debug statement return pixel_movements def apply_recoil(pixel_movements, repeat_delay): “”” Apply the recoil pattern using pixel movements. “”” for index, (dx, dy) in enumerate(pixel_movements): print(f’Applying recoil step {index + 1}: Moving by dx={int(dx)}, dy={int(dy)}’) # Debug statement pydirectinput.moveRel(int(dx), int(dy)) time.sleep(repeat_delay / 1000.0) # Convert milliseconds to seconds def on_click(): “”” Handle mouse click event to start applying the recoil pattern. “”” repeat_delay = 1000.0 / (600 / 60.0) # Assuming AK-47 has 600 RPM print(f’Repeat delay calculated: {repeat_delay} ms’) # Debug statement pixel_movements = convert_recoil_to_pixels(ak_recoil_pattern, multiplier) print(“Starting recoil pattern application…”) # Debug statement apply_recoil(pixel_movements, repeat_delay) def monitor_mouse(): “”” Monitor the left mouse button and trigger recoil pattern on click. “”” while True: if keyboard.is_pressed(‘left’): print(“Left mouse button detected. Applying recoil…”) # Debug statement on_click() time.sleep(0.1) # Start the monitoring thread to handle mouse clicks print(“Starting mouse monitoring thread…”) # Debug statement thread = threading.Thread(target=monitor_mouse) thread.start() def adjust_sensitivity(new_sensitivity): “”” Adjust the mouse sensitivity and recalculate the multiplier. “”” global sensitivity, multiplier sensitivity = new_sensitivity multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f’Sensitivity adjusted: {sensitivity}, New Multiplier: {multiplier}’) # Debug statement def adjust_fov(new_fov): “”” Adjust the field of view (FOV) and recalculate the multiplier. “”” global fov, multiplier fov = new_fov multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f’FOV adjusted: {fov}, New Multiplier: {multiplier}’) # Debug statement # Confirm current settings print(f’Current Settings: Sensitivity={sensitivity}, FOV={fov}, Multiplier={multiplier}’) # Debug statement submitted by /u/Overall_Barnacle7851 [link] [comments] 

import pydirectinput import threading import keyboard import time # Define the recoil pattern for the AK-47 ak_recoil_pattern = [ [1.390706, -2.003941], [1.176434, -3.844176], [3.387171, -5.516686], [5.087049, -7.017456], [5.094189, -8.342467], [4.426013, -9.487704], [3.250455, -10.44915], [1.73545, -11.22279], [0.04893398, -11.8046], [-1.641158, -12.19056], [-3.166891, -12.58713], [-4.360331, -13.32077], [-5.053545, -14.32128], [-5.090651, -15.51103], [-4.489915, -16.81242], [-3.382552, -18.14783], [-1.899585, -19.43966], [-0.1720295, -20.61031], [1.669086, -21.58213], [3.492748, -22.27755], [5.16793, -22.61893], [6.563614, -22.81778], [7.548776, -23.37389], [7.992399, -24.21139], [7.512226, -25.23734], [6.063792, -26.35886], [4.117367, -27.48302], [2.143932, -28.51692], [0.6144824, -29.36766] ] # Game settings (user-specified) sensitivity = 0.5 fov = 90.0 # Calculate the multiplier based on sensitivity and FOV multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'Multiplier calculated: {multiplier}') # Debug statement def convert_recoil_to_pixels(recoil_pattern, multiplier): """ Convert the recoil pattern to pixel movements. """ pixel_movements = [] last_shot = [0, 0] for index, shot in enumerate(recoil_pattern): dx = (shot[0] - last_shot[0]) / multiplier dy = (shot[1] - last_shot[1]) / multiplier pixel_movements.append([dx, dy]) last_shot = shot print(f'Shot {index + 1}: dx={dx}, dy={dy}') # Debug statement return pixel_movements def apply_recoil(pixel_movements, repeat_delay): """ Apply the recoil pattern using pixel movements. """ for index, (dx, dy) in enumerate(pixel_movements): print(f'Applying recoil step {index + 1}: Moving by dx={int(dx)}, dy={int(dy)}') # Debug statement pydirectinput.moveRel(int(dx), int(dy)) time.sleep(repeat_delay / 1000.0) # Convert milliseconds to seconds def on_click(): """ Handle mouse click event to start applying the recoil pattern. """ repeat_delay = 1000.0 / (600 / 60.0) # Assuming AK-47 has 600 RPM print(f'Repeat delay calculated: {repeat_delay} ms') # Debug statement pixel_movements = convert_recoil_to_pixels(ak_recoil_pattern, multiplier) print("Starting recoil pattern application...") # Debug statement apply_recoil(pixel_movements, repeat_delay) def monitor_mouse(): """ Monitor the left mouse button and trigger recoil pattern on click. """ while True: if keyboard.is_pressed('left'): print("Left mouse button detected. Applying recoil...") # Debug statement on_click() time.sleep(0.1) # Start the monitoring thread to handle mouse clicks print("Starting mouse monitoring thread...") # Debug statement thread = threading.Thread(target=monitor_mouse) thread.start() def adjust_sensitivity(new_sensitivity): """ Adjust the mouse sensitivity and recalculate the multiplier. """ global sensitivity, multiplier sensitivity = new_sensitivity multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'Sensitivity adjusted: {sensitivity}, New Multiplier: {multiplier}') # Debug statement def adjust_fov(new_fov): """ Adjust the field of view (FOV) and recalculate the multiplier. """ global fov, multiplier fov = new_fov multiplier = -0.03 * (sensitivity * 3.0) * (fov / 100.0) print(f'FOV adjusted: {fov}, New Multiplier: {multiplier}') # Debug statement # Confirm current settings print(f'Current Settings: Sensitivity={sensitivity}, FOV={fov}, Multiplier={multiplier}') # Debug statement 

submitted by /u/Overall_Barnacle7851
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *