Im going to give you a detection thread and Trigger bot thread can you make the TriggerBot thread to work like this: When the center of the FOV is on a target the trigger bot will shoot because right now the Trigger bot only shoot when im right in the center of the detected object so that mean that i would need to be right in the center just for it to shoot and i dont want that i want to shoot when im on the detected object like top right or down left anywher so long the detected object is in the Crosshair(center of the FOV)
import sys
import os
import json
import time
import threading
import logging
import numpy as np
import cv2
import mss
import mouse
import ctypes
import keyboard
import webbrowser
import sort
from ultralytics import YOLO
from PyQt5 import QtCore, QtGui, QtWidgets
The error "Sort" is not defined means that the name Sort is used (for example, to create the tracker: self.tracker = Sort(...) in your DetectionThread), but Python does not know what Sort refers to because it hasn't been imported or defined anywhere.
How to fix:
You need to import Sort from the correct module or file.
file
if not os.path.exists(LOG_PATH):
with open(LOG_PATH, "w"): pass
def load_settings():
if os.path.exists(SETTINGS_PATH):
try:
with open(SETTINGS_PATH, "r") as f:
data = json.load(f)
for k, v in DEFAULT_SETTINGS.items():
if k not in data:
data[k] = v
return data
except Exception as e:
logging.error(f"Failed to load settings: {e}")
return DEFAULT_SETTINGS.copy()
def save_settings(settings):
try:
with open(SETTINGS_PATH, "w") as f:
json.dump(settings, f, indent=2)
except Exception as e:
logging.error(f"Failed to save settings: {e}")
def export_settings(settings, parent=None):
fname, _ = QtWidgets.QFileDialog.getSaveFileName(parent, "Export Settings", "", "JSON Files (*.json)")
if fname:
try:
with open(fname, "w") as f:
json.dump(settings, f, indent=2)
QtWidgets.QMessageBox.information(parent, "Exported", "Settings exported successfully.")
except Exception as e:
QtWidgets.QMessageBox.warning(parent, "Error", f"Could not export settings:\n{e}")
def import_settings(parent=None):
fname, _ = QtWidgets.QFileDialog.getOpenFileName(parent, "Import Settings", "", "JSON Files (*.json)")
if fname:
try:
with open(fname, "r") as f:
new_settings = json.load(f)
for k, v in DEFAULT_SETTINGS.items():
if k not in new_settings:
new_settings[k] = v
QtWidgets.QMessageBox.information(parent, "Imported", "Settings imported. Restart app for all changes.")
return new_settings
except Exception as e:
QtWidgets.QMessageBox.warning(parent, "Error", f"Could not import settings:\n{e}")
return None
--- UTILS ---
def parse_qcolor(colorstr, fallback="#B366FF"):
try:
if isinstance(colorstr, str) and colorstr.startswith("#") and len(colorstr) == 7:
return QtGui.QColor(colorstr)
else:
return QtGui.QColor(fallback)
except Exception:
return QtGui.QColor(fallback)
class DetectionThread(QtCore.QThread):
# Now emits track_ids as a 5th list
detection_signal = QtCore.pyqtSignal(list, list, list, list, list) # boxes, labels, confidences, out_classes, track_ids
code
def __init__(self, settings):
super().__init__()
self.settings = settings
self.running = False
self.yolo_singleton = None
self.frame_lock = threading.Lock()
self.tracker = Sort(max_age=30, min_hits=3, iou_threshold=0.3) # SORT params you can tune
def nms(self, boxes, scores, iou_threshold=0.5):
if len(boxes) == 0:
return []
boxes = np.array(boxes, dtype=float)
scores = np.array(scores)
x1 = boxes[:, 0]
y1 = boxes[:, 1]
x2 = boxes[:, 2]
y2 = boxes[:, 3]
areas = (x2 - x1) * (y2 - y1)
indices = np.argsort(scores)[::-1] # Sort by scores descending
selected_indices = []
while len(indices) > 0:
current_index = indices[0]
selected_indices.append(current_index)
xx1 = np.maximum(x1[current_index], x1[indices[1:]])
yy1 = np.maximum(y1[current_index], y1[indices[1:]])
xx2 = np.minimum(x2[current_index], x2[indices[1:]])
yy2 = np.minimum(y2[current_index], y2[indices[1:]])
w = np.maximum(0, xx2 - xx1)
h = np.maximum(0, yy2 - yy1)
intersection = w * h
iou = intersection / (areas[current_index] + areas[indices[1:]] - intersection)
indices = indices[np.where(iou <= iou_threshold)[0] + 1] # +1 skips current
return selected_indices
def run(self):
self.running = True
model_path = YOLO_PT_PATH
imgsz = clamp(self.settings.get("imgsz", 416), 320, 640)
self.yolo_singleton = YOLOModelSingleton.get_instance(model_path, imgsz)
if self.yolo_singleton.model is None:
logging.error("YOLO model failed to load.")
return
with mss.mss() as sct:
mon = sct.monitors[1]
sw, sh = mon['width'], mon['height']
while self.running:
try:
# FOV radius & center
fov_radius = clamp(self.settings.get('fov_radius', 200), 50, min(sw, sh) // 2)
cx, cy = sw // 2, sh // 2
x1 = max(cx - fov_radius, 0)
y1 = max(cy - fov_radius, 0)
x2 = min(cx + fov_radius, sw)
y2 = min(cy + fov_radius, sh)
bbox = {'top': int(y1), 'left': int(x1), 'width': int(x2 - x1), 'height': int(y2 - y1)}
with self.frame_lock:
frame = np.array(sct.grab({**mon, **bbox}))
frame = cv2.cvtColor(frame, cv2.COLOR_BGRA2BGR)
conf_thres = clamp(self.settings.get('confidence', 0.5), 0.1, 0.95)
results = self.yolo_singleton.model.predict(
source=frame,
save=False,
imgsz=imgsz,
conf=conf_thres,
iou=0.45,
device="cpu"
)[0]
dets, classes = [], []
for i, box in enumerate(results.boxes.xyxy):
conf = float(results.boxes.conf[i]) if hasattr(results.boxes, "conf") else 0.0
if conf < conf_thres:
continue
x1b, y1b, x2b, y2b = map(int, box)
class_id = int(results.boxes.cls[i]) if hasattr(results.boxes, "cls") else -1
class_name = self.yolo_singleton.names[class_id] if 0 <= class_id < len(self.yolo_singleton.names) else "?"
# Map to screen coordinates (offset by cropped bbox)
x1b += x1
x2b += x1
y1b += y1
y2b += y1
# Filter detections outside circular FOV
bx, by = (x1b + x2b) // 2, (y1b + y2b) // 2
if np.hypot(bx - cx, by - cy) > fov_radius:
continue
dets.append((x1b, y1b, x2b, y2b, conf, class_name))
classes.append(class_name)
# Sort by confidence descending
dets = sorted(dets, key=lambda x: x[4], reverse=True)
boxes = [(x1b, y1b, x2b, y2b) for (x1b, y1b, x2b, y2b, _, _) in dets]
confidences = [cf for (_, _, _, _, cf, _) in dets]
# NMS filtering
if boxes:
selected_indices = self.nms(boxes, confidences, iou_threshold=0.5)
boxes = [boxes[i] for i in selected_indices]
labels = [classes[i] for i in selected_indices]
confidences = [confidences[i] for i in selected_indices]
else:
labels = []
out_classes = labels # Use post-NMS labels
# Prepare detections for SORT: [x1, y1, x2, y2, score]
if boxes:
dets_for_sort = np.array([[*box, conf] for box, conf in zip(boxes, confidences)])
else:
dets_for_sort = np.empty((0, 5))
tracked_objects = self.tracker.update(dets_for_sort)
# tracked_objects format: np.array([[x1, y1, x2, y2, track_id], ...])
tracked_boxes = []
track_ids = []
for obj in tracked_objects:
x1t, y1t, x2t, y2t, track_id = obj
tracked_boxes.append((int(x1t), int(y1t), int(x2t), int(y2t)))
track_ids.append(int(track_id))
# Emit detection + tracking info
self.detection_signal.emit(tracked_boxes, labels, confidences, out_classes, track_ids)
del frame
except Exception as e:
logging.error(f"DetectionThread error: {e}")
def stop(self):
self.running = False
class AimAssistThread(QtCore.QThread):
aim_active_signal = QtCore.pyqtSignal(bool)
code
def __init__(self, settings, get_targets_func, get_fov_center_func):
super().__init__()
self.settings = settings
self.get_targets = get_targets_func
self.get_fov_center = get_fov_center_func
self.running = False
self.aim_active = False
self.lock = threading.Lock()
# Ultra sticky tracking variables
self.locked_track_id = None
self.locked_target_center = None
self.target_acquired = False
self.last_known_position = None
self.acquisition_time = None
self.error_count = 0
# Anti-wiggle variables
self.movement_history = []
self.last_move_time = 0
self.settled = False
# Sync variables
self.last_target_update = 0
self.target_cache = []
def parse_targets_with_tracking(self, raw_targets):
"""Parse targets to ensure we have tracking info - this is the key fix!"""
parsed_targets = []
# Handle different possible target formats from get_targets()
if not raw_targets:
return []
for target in raw_targets:
try:
# Format should be: [x1, y1, x2, y2, confidence, track_id]
# But sometimes it might come as nested tuples or different formats
if isinstance(target, (tuple, list)) and len(target) >= 4:
if len(target) == 4:
# Missing confidence and track_id - this is the problem!
x1, y1, x2, y2 = target
conf = 0.5 # Default confidence
track_id = None # No tracking - this breaks sticky aim
elif len(target) == 5:
# Missing track_id
x1, y1, x2, y2, conf = target
track_id = None # No tracking - this breaks sticky aim
elif len(target) >= 6:
# Full format with tracking
x1, y1, x2, y2, conf, track_id = target[:6]
else:
continue
# Ensure coordinates are integers
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
# Add to parsed targets
parsed_targets.append([x1, y1, x2, y2, float(conf), track_id])
except Exception as e:
logging.warning(f"Failed to parse target {target}: {e}")
continue
return parsed_targets
def get_target_by_track_id(self, targets, track_id):
"""Get exact target by track ID"""
if track_id is None:
return None, None
for target in targets:
if len(target) >= 6 and target[5] is not None:
x1, y1, x2, y2, conf, curr_track_id = target[:6]
if int(curr_track_id) == int(track_id):
center_x = int((x1 + x2) // 2)
center_y = int((y1 + y2) // 2)
return (center_x, center_y), target
return None, None
def find_closest_target_with_tracking(self, targets, fc_x, fc_y, fov_radius):
"""Find the closest target to crosshair center, prioritizing tracked targets"""
if not targets:
return None, None
closest_dist = float('inf')
closest_target = None
closest_pos = None
# First pass: look for targets with tracking IDs (these are more reliable)
tracked_candidates = []
untracked_candidates = []
for target in targets:
if len(target) < 4:
continue
x1, y1, x2, y2 = target[:4]
center_x = int((x1 + x2) // 2)
center_y = int((y1 + y2) // 2)
# Distance from crosshair center
dist = np.hypot(center_x - fc_x, center_y - fc_y)
# Only consider targets within FOV
if dist < fov_radius:
conf = target[4] if len(target) > 4 else 0.5
track_id = target[5] if len(target) > 5 else None
candidate = (dist, (center_x, center_y), target, conf)
if track_id is not None:
tracked_candidates.append(candidate)
else:
untracked_candidates.append(candidate)
# Prefer tracked targets, then fall back to untracked
all_candidates = tracked_candidates + untracked_candidates
if all_candidates:
# Sort by distance, then by confidence
all_candidates.sort(key=lambda x: (x[0], -x[3]))
closest_dist, closest_pos, closest_target, _ = all_candidates[0]
return closest_pos, closest_target
def get_current_target_position(self, targets, fc_x, fc_y, fov_radius):
"""Get the current target position using track ID lock or closest target"""
now = time.time()
# Parse targets to ensure proper format
parsed_targets = self.parse_targets_with_tracking(targets)
if not parsed_targets:
return None
# If we have a locked track ID, try to find it first
if self.locked_track_id is not None:
locked_pos, locked_target = self.get_target_by_track_id(parsed_targets, self.locked_track_id)
if locked_pos:
# Update last known position
self.last_known_position = locked_pos
return locked_pos
else:
# Target lost by ID, try proximity matching
if self.last_known_position:
for target in parsed_targets:
x1, y1, x2, y2 = target[:4]
center_x = int((x1 + x2) // 2)
center_y = int((y1 + y2) // 2)
# Check if any target is close to last known position
dist_from_last = np.hypot(center_x - self.last_known_position[0],
center_y - self.last_known_position[1])
if dist_from_last < 60: # Reduced threshold for better stickiness
# Lock onto this target if it has a track ID
if len(target) >= 6 and target[5] is not None:
self.locked_track_id = target[5]
logging.info(f"Reacquired target with new ID: {self.locked_track_id}")
self.last_known_position = (center_x, center_y)
return (center_x, center_y)
# No locked target or target lost, find closest with tracking preference
closest_pos, closest_target = self.find_closest_target_with_tracking(parsed_targets, fc_x, fc_y, fov_radius)
if closest_pos and closest_target:
# Lock onto new target
old_track_id = self.locked_track_id
if len(closest_target) >= 6 and closest_target[5] is not None:
self.locked_track_id = closest_target[5]
if old_track_id != self.locked_track_id:
logging.info(f"Locked onto new target ID: {self.locked_track_id}")
else:
self.locked_track_id = None
logging.warning("Target found but no track ID available")
self.last_known_position = closest_pos
self.target_acquired = True
self.acquisition_time = now
# Reset anti-wiggle state for new target
self.settled = False
self.movement_history = []
return closest_pos
def is_oscillating(self):
"""Check if we're oscillating/wiggling around the target"""
if len(self.movement_history) < 6:
return False
# Check last 6 movements for oscillation pattern
recent_moves = self.movement_history[-6:]
# Look for back-and-forth movement patterns
x_changes = [move[0] for move in recent_moves if abs(move[0]) > 0]
y_changes = [move[1] for move in recent_moves if abs(move[1]) > 0]
# Check for sign changes (indicating back-and-forth movement)
x_oscillating = False
y_oscillating = False
if len(x_changes) >= 4:
sign_changes = sum(1 for i in range(1, len(x_changes))
if (x_changes[i] > 0) != (x_changes[i-1] > 0))
x_oscillating = sign_changes >= 2
if len(y_changes) >= 4:
sign_changes = sum(1 for i in range(1, len(y_changes))
if (y_changes[i] > 0) != (y_changes[i-1] > 0))
y_oscillating = sign_changes >= 2
return x_oscillating or y_oscillating
def calculate_smooth_move(self, target_pos, fc_x, fc_y):
"""Calculate smooth incremental movement with anti-wiggle logic"""
if not target_pos:
return 0, 0
# Calculate difference to target
dx = target_pos[0] - fc_x
dy = target_pos[1] - fc_y
distance = np.hypot(dx, dy)
# Enhanced deadzone that grows when settled
base_deadzone = 4 # Reduced for better precision
if self.settled:
deadzone = base_deadzone * 2.5 # Larger deadzone when settled
else:
deadzone = base_deadzone
if distance <= deadzone:
# Mark as settled if we stay in deadzone
if distance <= base_deadzone:
self.settled = True
return 0, 0
# Reset settled state if we move far from target
if distance > deadzone * 2:
self.settled = False
# Check for oscillation
if self.is_oscillating():
# Reduce movement aggressiveness when oscillating
move_factor = 0.08 # Very slow when oscillating
deadzone *= 3 # Much larger deadzone
if distance <= deadzone:
self.settled = True
return 0, 0
else:
# Normal movement calculation - more aggressive for better tracking
if distance < 8:
move_factor = 0.7 # More aggressive when very close
elif distance < 15:
move_factor = 0.5 # Medium speed for close targets
elif distance < 30:
move_factor = 0.35 # Normal speed
else:
move_factor = 0.25 # Slower for distant targets
mdx = int(dx * move_factor)
mdy = int(dy * move_factor)
# Ensure minimum movement if target is far enough
if distance > 10:
if abs(mdx) < 1 and abs(dx) > 3:
mdx = 1 if dx > 0 else -1
if abs(mdy) < 1 and abs(dy) > 3:
mdy = 1 if dy > 0 else -1
# Cap maximum movement per frame
max_move = 15 # Increased for better responsiveness
mdx = max(-max_move, min(mdx, max_move))
mdy = max(-max_move, min(mdy, max_move))
# Store movement in history for oscillation detection
now = time.time()
self.movement_history.append((mdx, mdy, now))
# Keep only recent history (last 1.5 seconds)
self.movement_history = [(x, y, t) for x, y, t in self.movement_history
if now - t < 1.5]
return mdx, mdy
def run(self):
self.running = True
while self.running:
try:
# Get hotkey setting
hotkey = self.settings.get('aim_hotkey', "Right Mouse Button").lower()
hotkey_pressed = False
# Check hotkey state
if "mouse" in hotkey:
if "right" in hotkey:
hotkey_pressed = mouse.is_pressed(button="right")
elif "left" in hotkey:
hotkey_pressed = mouse.is_pressed(button="left")
elif "middle" in hotkey:
hotkey_pressed = mouse.is_pressed(button="middle")
else:
try:
hotkey_pressed = keyboard.is_pressed(hotkey)
except Exception:
hotkey_pressed = False
aim_on = False
# MAIN LOGIC: Ultra sticky aim assist with proper target sync
if hotkey_pressed and self.settings.get('aim_enabled', True):
with self.lock:
targets = self.get_targets()
fov_center = self.get_fov_center()
if targets and fov_center:
# Get FOV center coordinates
fc_x, fc_y = (
(fov_center.x(), fov_center.y())
if hasattr(fov_center, "x") else fov_center
)
fov_radius = self.settings.get('fov_radius', 200)
# Get current target position with improved sync
target_pos = self.get_current_target_position(targets, fc_x, fc_y, fov_radius)
if target_pos:
# Calculate smooth movement with anti-wiggle
mdx, mdy = self.calculate_smooth_move(target_pos, fc_x, fc_y)
# Execute movement if needed
if abs(mdx) > 0 or abs(mdy) > 0:
try:
move_mouse_relative(mdx, mdy)
aim_on = True
self.last_move_time = time.time()
except Exception as e:
logging.error(f"Mouse movement failed: {e}")
else:
# No targets found
if self.locked_track_id is not None:
logging.debug(f"Lost track of target ID: {self.locked_track_id}")
else:
# Hotkey released - reset all tracking
if self.locked_track_id is not None:
logging.info(f"Released tracking of target ID: {self.locked_track_id}")
self.locked_track_id = None
self.locked_target_center = None
self.target_acquired = False
self.last_known_position = None
self.acquisition_time = None
self.settled = False
self.movement_history = []
# Emit aim state change
if aim_on != self.aim_active:
self.aim_active = aim_on
self.aim_active_signal.emit(self.aim_active)
# Optimal update rate for smooth tracking
time.sleep(0.005) # ~200 FPS for responsive tracking
except Exception as e:
self.error_count += 1
if self.error_count < 5:
logging.exception(f"AimAssistThread error: {e}")
elif self.error_count == 5:
logging.error("AimAssistThread: Too many errors, suppressing further logs.")
def stop(self):
self.running = False
if name == "main":
app = QtWidgets.QApplication(sys.argv)
settings = load_settings()
main_win = ModernMainWindow()
main_win.show()
sys.exit(app.exec_())
To address your request:
You want the TriggerBot thread to shoot anytime the center of the screen / FOV crosshair is on a detected object anywhere within the detected bounding box, and not only when the center of the crosshair matches exactly the center of the bounding box.
Current behavior in your code (from this snippet inside TriggerBotThread.run):
python
for (x1, y1, x2, y2, *_) in targets:
tx, ty = (x1 + x2) // 2, (y1 + y2) // 2
if self.is_in_crosshair(tx, ty, fc_x, fc_y, tolerance):
# fire logic follows
...
Here you take the bounding box center (tx, ty) and check if it is within tolerance of the FOV center (fc_x, fc_y).
The problem: The trigger bot only triggers if the center of the bounding box is within tolerance of the crosshair center.
Your desired behavior:
The trigger bot should fire if the crosshair center is inside the detected bounding box box anywhere, not just near the center.
So we should check if (fc_x, fc_y) lies inside the bounding box perimeter (x1, y1, x2, y2).
How to fix:
Change the condition from "crosshair near bounding box center" to "crosshair inside bounding box".
What to change:
In TriggerBotThread.run, replace:
python
for (x1, y1, x2, y2, *_) in targets:
tx, ty = (x1 + x2) // 2, (y1 + y2) // 2
if self.is_in_crosshair(tx, ty, fc_x, fc_y, tolerance):
...
with:
python
for (x1, y1, x2, y2, *_) in targets:
# Check if the crosshair center is inside the bounding box (with optional tolerance padding)
# tolerance can be used to slightly expand the box if desired
tol = tolerance
left = x1 - tol
right = x2 + tol
top = y1 - tol
bottom = y2 + tol
if left <= fc_x <= right and top <= fc_y <= bottom:
...
You can completely remove or reduce the use of self.is_in_crosshair since it will no longer be needed.
Full revised trigger checking snippet inside TriggerBotThread.run:
python
for (x1, y1, x2, y2, *_) in targets:
tol = tolerance
if (x1 - tol) <= fc_x <= (x2 + tol) and (y1 - tol) <= fc_y <= (y2 + tol):
# Fire logic as before
if burst_enabled:
...
elif auto_fire:
...
else:
...
fired_this_loop = True
break
else:
# No target under crosshair - reset states
Summary:
This change makes the trigger bot shoot if the center of the screen / FOV center lies anywhere inside the detected bounding box, respecting a little tolerance margin.
So you no longer need to be exactly centered on the bounding box center.
You can keep the tolerance to provide some leniency around the edges (usually a few pixels).
Optional improvement:
If you want to keep the tolerance strictly as a radius distance around the crosshair center rather than box margins, you can combine both checks if needed, but usually bounding box inclusion works best for your use case.
If you'd like, I can provide the full modified TriggerBotThread class code snippet with the fix applied. Just ask!
Certainly! Below is the full TriggerBotThread class with the modification so that it fires whenever the center of the screen (crosshair) is anywhere inside a detected bounding box (with a small configurable tolerance margin). This replaces the previous logic that only fired when the crosshair was near the bounding box center.
python
class TriggerBotThread(QtCore.QThread):
def __init__(self, settings, get_targets_func, get_fov_center_func):
super().__init__()
self.settings = settings
self.get_targets = get_targets_func
self.get_fov_center = get_fov_center_func
self.running = False
self.is_firing = False
self.last_fired = 0
self.last_triggered = False
self.lock = threading.Lock()
self.burst_shots_left = 0
self.last_burst_time = 0
self.trigger_hotkey = self.settings.get("trigger_hotkey", "Left Mouse Button").lower()
def run(self):
self.running = True
while self.running:
try:
if self.settings.get("trigger_enabled", False):
fire_speed_ms = int(self.settings.get("trigger_fire_speed", 150))
auto_fire = self.settings.get("trigger_auto_fire", False)
tolerance = int(self.settings.get("trigger_tolerance", 2))
burst_enabled = self.settings.get("trigger_burst", False)
burst_count = int(self.settings.get("trigger_burst_count", 3))
burst_delay = int(self.settings.get("trigger_burst_delay", 60))
button = self.settings.get("trigger_mouse_button", "left")
with self.lock:
targets = self.get_targets()
fov_center = self.get_fov_center()
if not fov_center:
time.sleep(0.01)
continue
fc_x, fc_y = (
(fov_center.x(), fov_center.y())
if hasattr(fov_center, "x") else fov_center
)
fired_this_loop = False
now = time.time()
for (x1, y1, x2, y2, *_) in targets:
# Check if the FOV center is inside the bounding box with optional tolerance
left = x1 - tolerance
right = x2 + tolerance
top = y1 - tolerance
bottom = y2 + tolerance
if left <= fc_x <= right and top <= fc_y <= bottom:
# Target is under crosshair - fire accordingly
if burst_enabled:
if self.burst_shots_left == 0 or (now - self.last_burst_time)*1000 >= fire_speed_ms:
self.burst_shots_left = burst_count
self.last_burst_time = now
if self.burst_shots_left > 0:
if (now - self.last_fired)*1000 >= burst_delay:
mouse_click_down_up(button)
self.last_fired = now
self.burst_shots_left -= 1
self.last_triggered = True
elif auto_fire:
if not self.is_firing:
mouse_press_down(button)
self.is_firing = True
self.last_triggered = True
else:
if not self.last_triggered or (now - self.last_fired)*1000 >= fire_speed_ms:
mouse_click_down_up(button)
self.last_fired = now
self.last_triggered = True
fired_this_loop = True
break
else:
# No target under crosshair
self.last_triggered = False
self.burst_shots_left = 0
if self.is_firing:
mouse_release_up(button)
self.is_firing = False
if auto_fire and not fired_this_loop and self.is_firing:
mouse_release_up(button)
self.is_firing = False
else:
# Trigger disabled, ensure mouse button released
self.burst_shots_left = 0
if self.is_firing:
mouse_release_up(self.settings.get("trigger_mouse_button", "left"))
self.is_firing = False
time.sleep(0.008)
except Exception as e:
logging.error(f"TriggerBotThread error: {e}")
def stop(self):
self.running = False
if self.is_firing:
mouse_release_up(self.settings.get("trigger_mouse_button", "left"))
self.is_firing = False
Summary of changes:
Removed the center-distance check via is_in_crosshair.
Added a bounding box containment check instead:
python
if (x1 - tolerance) <= fc_x <= (x2 + tolerance) and (y1 - tolerance) <= fc_y <= (y2 + tolerance):
This means the trigger will fire if the screen center is anywhere inside the detected bounding box (with tolerance padding).
Let me know if you want me to integrate this into your whole project or further customize it!
In your code snippet, you have this line near the top: