Code:
;-----------------------------------------------------------------------------
;+++ LAZYPAD 0.99 by SCORPS1 +++
;A lazy Guild Wars 2 auto-attack & loot script that is used with a gamepad
;Original code and ideas came from Tomatoes99 afk bot 1.0.6 script
;Combat mode or "xmode" ideas came from Combat Mode 1.1 by pvpproject
;Feel free to beg, borrow, or steal from this but please share and give credit
;Hopefully you learn something from this like i did from these guys
;-----------------------------------------------------------------------------
;Notes:
;Since this is a "lazy" script, please do not ask me to "generalize" it
;This script is made for my elementalist toon, may not work well with others
;This script is tailored for my window settings (windowed 1680x1010), so if
; you change the $xres and $yres, you will need to recheck all Pixelsearches
;The "crosshair" is currently assuming a 7x7 white .bmp file in script dir
;Do not ask me any gamepad questions please,
; for gamepad help please go to: http://wiki.guildwars2.com/wiki/User:Mighty
;-----------------------------------------------------------------------------
;In-game settings required:
;Autotargeting = on
;Promote skill target = off
;Fast-cast ground targeting = on
;Unbind TAB and make sure nothing is bound to 'next enemy' or 'nearest enemy'
;You will need to rebind Targetlock to 'L' in game
;-----------------------------------------------------------------------------
;Hotkeys (i map these plus many others to my gamepad):
;CAPSLOCK to "pause" script (starts in paused mode)
;TAB to toggle combat mode (xmode)
;F8/F9 switches my skills array up how i like it
;x to toggle target lockon/lockoff, so you dont have to hold the key down
;-----------------------------------------------------------------------------
;Settings and variables
;#RequireAdmin ;not really required unless you are having problems getting the script to work
#include <WindowsConstants.au3> ;needed for GUI $WS_%%% commands
Opt("SendCapslockMode", 0) ;1=store and restore, 0=don't (this is needed for CAPSLOCK toggle to work in my Windows installation)
Global $skills[8]=["2", "3", "4", "5", "7", "8", "9", "0"] ;keys your skills are bound to (DON'T CHANGE THE NUMBER OF SKILLS UNLESS YOU KNOW WHAT YOU ARE DOING!)
Global $Paused, $weapon=1, $xstate=0, $s=2, $xres=1680, $yres=1010, $rtime=110
;Hotkey settings
Send("{CAPSLOCK off}") ;set capslock off before HotKeySet
HotKeySet("{CAPSLOCK}", "TogglePause") ;set capslock as the toggle
HotKeySet("{TAB}", "xmode")
HotKeySet("{F8}", "scepter")
HotKeySet("{F9}", "staff")
HotKeySet("x", "targetlockon")
;;;; Body of program ;;;;
Sleep(200)
WinWait("Guild Wars 2") ;wait for gw2 window
Sleep(700)
checkwindow() ;size the window the way i like it
Sleep(100)
GUICreate("xhair", 7, 7, ($xres/2)-3, ($yres/2-85)-3, $WS_POPUP, $WS_EX_TOPMOST );+ $WS_EX_LAYERED) ;ex_layered makes the background transparent but impacts frame-rate so turned off right now
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\crosshair1.bmp", 0, 0, 0, 0) ;right now the .bmp file is a white 7x7 square; easy to create yourself; did i mention this was a lazy script?
TogglePause() ;start paused
While 1
If WinActive("Guild Wars 2") Then
Send("1") ;start attack sequence
randsleep($rtime)
For $i = 0 To 7 Step 1 ;spam 8 random skills
randskill()
Next
PixelSearch(840, 908, 842, 910, 0xB51905, 15) ;check health and if below ~75% heal me
If @error Then
Send("6")
EndIf
randsleep($rtime)
PixelSearch(1105, 706, 1107, 708, 0x5A3802, 15) ;check for loot indicator at 1106,707
If Not @error Then
For $j = 0 to 2 Step 1
Send("f")
randsleep(60)
Next
EndIf
EndIf
WEnd
;;;;;;;;
Func checkwindow() ;check window size and fix if necessary
Local $size = WinGetPos("Guild Wars 2")
If $size[0]=0 and $size[1]=0 and $size[2]=$xres and $size[3]=$yres Then
Return
Else
WinMove("Guild Wars 2","",0,0,$xres,$yres)
EndIf
EndFunc ; >checkwindow
Func TogglePause() ;umm this is TogglePause :)
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
If $weapon=1 Then
ToolTip("Scepter", 110, 0)
ElseIf $weapon=2 Then
ToolTip("Staff", 110, 0)
Else
ToolTip("")
EndIf
EndFunc ; >TogglePause
Func RandSkill() ;choose random skill from $skills
$s=$skills[Random(0,7,1)]
Send($s)
randsleep($rtime)
EndFunc ; >RandSkill
Func RandSleep($ms) ;Sleeps + or - 20% of amount
Sleep($ms*Random(.80,1.2))
EndFunc ; >RandSleep
Func scepter() ;skills array with scepter-dagger
$skills[2]="4"
$weapon=1
ToolTip("Scepter", 110, 0)
EndFunc ; >scepter
Func staff() ;skills array for staff
$skills[2]="2"
$weapon=2
ToolTip("Staff", 110, 0)
EndFunc ; >staff
Func targetlockon() ;targetlock on
sleep(20)
send("{l down}")
sleep(100)
HotKeySet("x", "targetlockoff")
EndFunc ; >targetlock on
Func targetlockoff() ;targetlock off
sleep(20)
send("{l up}")
sleep(100)
HotKeySet("x", "targetlockon")
EndFunc ; >targetlock off
Func xmode() ;sometimes i find it that it doesn't work 100% on the 1st try; any suggestions will help me here
If $xstate=0 Then
$xstate=1
;~ BlockInput(1) ;don't think this command is working and probably is not even necessary
MouseMove($xres/2-10, $yres/2-85, 1) ;move mouse near crosshair position
MouseDown("right")
sleep(20)
MouseMove($xres/2, $yres/2-85, 1) ;need to move mouse after mousedown event so that camera look will kick in
;~ BlockInput(0) ;don't think this command is working and probably is not even necessary
sleep(20)
GUISetState(@SW_SHOW)
WinActivate("Guild Wars 2")
Sleep(100)
Else
$xstate=0
MouseUp("right")
GUISetState(@SW_HIDE)
EndIf
EndFunc ; >xmode