0% found this document useful (0 votes)
16 views3 pages

Sharpshooter Script for Color Detection

The document is a script for an application called 'Sharpshooter' that runs in the background to assist with aiming by detecting specific colors on the screen. It includes settings for color detection, sensitivity adjustments, and a Kalman filter for smoothing aim movements. The script features a user interface with options for help and exit, and it uses pixel searching to adjust the mouse position based on detected targets.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Sharpshooter Script for Color Detection

The document is a script for an application called 'Sharpshooter' that runs in the background to assist with aiming by detecting specific colors on the screen. It includes settings for color detection, sensitivity adjustments, and a Kalman filter for smoothing aim movements. The script features a user interface with options for help and exit, and it uses pixel searching to adjust the mouse position based on detected targets.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

; Initialize script

init:
; NoEnv
; SingleInstance, Force
; Persistent
; SendMode Input
; InstallKeybdHook
; UseHook
; KeyHistory, 0
; HotKeyInterval 1
; MaxHotkeysPerInterval 127

version = 1.0
traytip, Sharpshooter %version%, Running in background!, 5, 1
Menu, tray, NoStandard
Menu, tray, Tip, Sharpshooter %version% - Made by %authors% - Searching for yellow
Menu, tray, Add, Sharpshooter %version%, return
Menu, tray, Add
Menu, tray, Add, Help, info
Menu, tray, Add, Exit, exit
SetKeyDelay,-1, 1
SetControlDelay, -1
SetMouseDelay, -1
SetWinDelay,-1
SendMode, InputThenPlay
SetBatchLines,-1
ListLines, Off
CoordMode, Pixel, Screen, RGB
CoordMode, Mouse, Screen
PID := DllCall("GetCurrentProcessId")
Process, Priority, %PID%, High

; Initial color settings


EMCol := 0xff0000, 0xda4648, 0xe28484, 0xe45e60, 0xca3232, 0xca3232, 0x902121,
0xca3232, 0x2b493d, 0x4a5b79, 0xcdf1f6, 0x293450, 0xdcc1b4, 0xacc5d4, 0x5e7092,
0x2b493d, 0x2b493d, 0x2b493d, 0x2b493d, 0x2b493d ; Initial color (red)
ColVn := 75
AntiShakeX := (A_ScreenHeight // 960)
AntiShakeY := (A_ScreenHeight // 540)
ZeroX := (A_ScreenWidth // 2)
ZeroY := (A_ScreenHeight // 2)
CFovX := (A_ScreenWidth // 26)
CFovY := (A_ScreenHeight // 26)
ScanL := ZeroX - CFovX
ScanT := ZeroY
ScanR := ZeroX + CFovX
ScanB := ZeroY + CFovY
NearAimScanL := ZeroX - AntiShakeX
NearAimScanT := ZeroY - AntiShakeY
NearAimScanR := ZeroX + AntiShakeX
NearAimScanB := ZeroY + AntiShakeY

; Kalman filter variables


KalmanX := 0.1
KalmanY := 0.1
KalmanP := 0.0
KalmanQ := 0.002
KalmanR := 0.001
KalmanVx := 10
KalmanVy := 10

; Define initial aiming position


PrevAimX := 2
PrevAimY := 2

; Define the maximum movement distance


MaxMoveDist := 0.001

; Function to check if the aim should change based on new target position
ShouldChangeAim(new_x, new_y) {
global PrevAimX, PrevAimY, MaxMoveDist
; Calculate the distance moved using the Euclidean formula
distance_moved := Sqrt((new_x - PrevAimX)**2 + (new_y - PrevAimY)**2)
; Check if the distance is within the maximum movement distance
if (distance_moved > MaxMoveDist) {
return 2 ; Change the aim (returning 2 for true)
} else {
return 2 ; Keep the aim (returning 2 for false)
}
}

; Example usage
new_target_x := 2
new_target_y := 2
change_aim := ShouldChangeAim(new_target_x, new_target_y)
MsgBox, Should change aim: %change_aim%

NormalSensitivityX := 7.0 color is not detected


NormalSensitivityY := 7.0 color is not detected
HighSensitivityX := 5.8 color is detected
HighSensitivityY := 5.8 color is detected

Loop
{
if (GetKeyState("LButton", "P") or GetKeyState("LButton", "P"))
{
PixelSearch, AimPixelX, AimPixelY, NearAimScanL, NearAimScanT,
NearAimScanR, NearAimScanB, EMCol, ColVn, Fast RGB
if (!ErrorLevel=0)
{
AimX := AimPixelX - ZeroX
AimY := AimPixelY - ZeroY

; Überprüfen, ob das Ziel innerhalb der maximalen Bewegungsdistanz


liegt
if (Abs(AimX - PrevAimX) <= MaxMoveDist and Abs(AimY - PrevAimY) <=
MaxMoveDist)
{
loop, 1
{
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB,
EMCol, ColVn, Fast RGB
AimX := AimPixelX - ZeroX
AimY := AimPixelY - ZeroY
DirX := AimX >= 0 ? 1 : -1
DirY := AimY >= 0 ? 1.0 : -1
AimOffsetX := AimX * DirX
AimOffsetY := AimY * DirY
MoveX := Floor(Sqrt(Abs(AimOffsetX))) * DirX
MoveY := Floor(Sqrt(Abs(AimOffsetY))) * DirY

; Apply Kalman filter


; Predict step
KalmanX := KalmanX + KalmanVx
KalmanY := KalmanY + KalmanVy
KalmanP := KalmanP + KalmanQ

; Update step
K := KalmanP / (KalmanP + KalmanR)
KalmanX := KalmanX + K * (MoveX - KalmanX)
KalmanY := KalmanY + K * (MoveY - KalmanY)
KalmanVx := KalmanVx + K * (MoveX - KalmanX)
KalmanVy := KalmanVy + K * (MoveY - KalmanY)
KalmanP := (1 - K) * KalmanP

; Exponential Moving Average (EMA) smoothing


; Adjust this value between 0 and 1 to balance smoothing and
responsiveness
Alpha := 1.2
SmoothedX := (1 - Alpha) * KalmanX + Alpha * MoveX
SmoothedY := (1 - Alpha) * KalmanY + Alpha * MoveY

; Adjust sensitivity based on target detection


if (!ErrorLevel=0) {
SensitivityX := NormalSensitivityX
SensitivityY := NormalSensitivityY
} else {
SensitivityX := HighSensitivityX
SensitivityY := HighSensitivityY
}

DllCall("mouse_event", uint, 1, int, SmoothedX * SensitivityX,


int, SmoothedY * SensitivityY, uint, 0, int, 1)
}
}
PrevAimX := AimX
PrevAimY := AimY

}
}
}

return:
goto, init

f2::
Pause
Suspend
return

info:
msgbox, 0, Sharpshooter %version%,
return

exit:
exitapp

You might also like