[RSPS] PixelBot Combat Trainer

 
Dec 20, 2016
24
4
0

This is V2.
Does not support eating.
Does not support item pick-up.
It can be integrated, I have created the available sections to improve the script itself.

Supports all servers, including Runescape. (Although I wouldn't suggest using it on Runescape).

Below is the .au3 script. you must download AutoIt to use the Raw Script

Make sure you edit your client coordinates to properly integrate it for use in the server you'd like.

Code:
; === Combat Trainer with Color-Based Targeting ===
#include <ScreenCapture.au3>
#include <File.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $attacking = False, $start = False, $kills = 0, $lastMove = TimerInit()

Global $color = 0xD2AE85
Global $hpColor = 0x00FF00
Global $trackXP = False, $xpLastColor = 0, $xpStartTime = 0, $xpChanges = 0
Global $lootEnabled = False, $lootColors[2] = [0xFFFF00, 0xC0C0C0]
Global $configPath = @ScriptDir & "\CombatTrainerConfig.ini"
Global $logPath = @ScriptDir & "\CombatTrainerLog.txt"
Global $botActive = True

HotKeySet("{F1}", "SetColor")
HotKeySet("{F2}", "ToggleBot")
HotKeySet("{ESC}", "Terminate")

MsgBox(64, "Combat Trainer", "F1 = Set Color, F2 = Start/Pause, ESC = Exit")

Global $gui = GUICreate("Combat Trainer", 300, 120)
Global $lblStatus = GUICtrlCreateLabel("Status: Paused", 10, 10, 280, 20)
Global $lblRuntime = GUICtrlCreateLabel("Runtime: 00:00:00", 10, 35, 280, 20)
GUISetState(@SW_SHOW, $gui)
Global $startTime = TimerInit()

While $botActive
    Local $elapsed = TimerDiff($startTime) / 1000
    Local $h = Floor($elapsed / 3600), $m = Floor(Mod($elapsed, 3600) / 60), $s = Mod($elapsed, 60)
    GUICtrlSetData($lblStatus, "Status: " & ($start ? "Running" : "Paused"))
    GUICtrlSetData($lblRuntime, "Runtime: " & StringFormat("%02i:%02i:%02i", $h, $m, $s))
    Sleep(500)
WEnd

Func SetColor()
    Local $pos = MouseGetPos()
    $color = PixelGetColor($pos[0], $pos[1])
    MsgBox(64, "Color Set", "New NPC Color: 0x" & Hex($color, 6))
EndFunc

Func ToggleBot()
    $start = Not $start
    GUICtrlSetData($lblStatus, "Status: " & ($start ? "Running" : "Paused"))
    If $start Then
        RunBot()
    Else
        While Not $start
            Sleep(1000)
        WEnd
    EndIf
EndFunc

Func RunBot()
    While $start And $botActive
        AntiIdle()
        WinActivate("[CLASS:SunAwtFrame]")

        If $lootEnabled Then LootItems()

        Local $pix = PixelSearch(0, 0, 771, 572, $color, 5)
        If IsArray($pix) Then
            MouseClick("left", $pix[0] + Random(-3, 3, 1), $pix[1] + Random(-3, 3, 1), 1, 1)
            Sleep(Random(100, 200, 1))

            Local $waitStart = TimerInit()
            While True
                AntiIdle()
                Local $isAttacking = PixelSearch(0, 0, 771, 572, $hpColor, 5)
                If @error Or TimerDiff($waitStart) > 10000 Then ExitLoop
                Sleep(100)
            WEnd
            $kills += 1
            LogKill()
            TakeScreenshot($kills)
            If $trackXP Then TrackXP()
            Sleep(Random(800, 1200, 1))
        EndIf
        Sleep(Random(200, 400, 1))
    WEnd
EndFunc

Func LootItems()
    Local $i, $loot
    For $i = 0 To UBound($lootColors) - 1
        $loot = PixelSearch(0, 0, 771, 572, $lootColors[$i], 5)
        If IsArray($loot) Then
            MouseClick("left", $loot[0] + Random(-2, 2, 1), $loot[1] + Random(-2, 2, 1), 1, 1)
            Sleep(Random(300, 600, 1))
        EndIf
    Next
EndFunc

Func TrackXP()
    Local $xpColor = PixelGetColor(650, 490)
    If $xpColor <> $xpLastColor Then
        $xpChanges += 1
        $xpLastColor = $xpColor
    EndIf
EndFunc

Func LogKill()
    Local $timestamp = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
    FileWrite($logPath, $timestamp & " - Kill #" & $kills & @CRLF)
EndFunc

Func TakeScreenshot($killNum)
    Local $path = @ScriptDir & "\screenshots"
    DirCreate($path)
    _ScreenCapture_Capture($path & "\kill_" & $killNum & ".bmp", 0, 0, 771, 572)
EndFunc

Func AntiIdle()
    If TimerDiff($lastMove) > 120000 Then
        Local $pos = MouseGetPos()
        MouseMove($pos[0] + Random(-5, 5, 1), $pos[1] + Random(-5, 5, 1), 5)
        $lastMove = TimerInit()
    EndIf
EndFunc

Func Terminate()
    $start = False
    $botActive = False
    MsgBox(0, "Combat Trainer", "Script stopped.")
    Exit
EndFunc

This is updated with proper GUI, and has failsafe. Enjoy.
 

Users who are viewing this thread (total: 1, members: 0, guests: 1)