Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "GWA˛.au3"
Opt("GUIOnEventMode",1)
Initialize(WinGetProcess("Guild Wars"),True, True)
Global $loopVar = False
Global $questId = 46
Global $moveVar = 7250
Global $startXp = GetExperience()
Global $runsDone,$earnedXp,$xpPerMin
$gui = GUICreate("Pre Lvl Bot v2.1a", 250, 200, 150, 80)
GUISetBkColor(0xFFFFFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_eventHandler")
$startButton = GUICtrlCreateButton("Start", 125,150, 80, 30)
GUICtrlSetOnEvent(-1,"_eventHandler")
$xpl = GUICtrlCreateLabel("Exp:",45,60,70)
GUICtrlSetFont(-1, 10, 800, 0, "@Arial Unicode MS")
$xpLabel = GUICtrlCreateLabel("0000",145,60,100)
GUICtrlSetFont(-1, 10, 800, 0, "@Arial Unicode MS")
$runsDonel = GUICtrlCreateLabel("Runs:",45,100,70)
GUICtrlSetFont(-1, 10, 800, 0, "@Arial Unicode MS")
$runsDoneLabel = GUICtrlCreateLabel("0000",145,100,100)
GUICtrlSetFont(-1, 10, 800, 0, "@Arial Unicode MS")
$Pic1 = GUICtrlCreatePic("", 0, 0, 172, 228, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
While 1
If $loopVar Then _botLoop()
WEnd
Func _eventHandler()
Switch(@GUI_CtrlId)
Case $startButton
$loopVar = Not $loopVar
AdlibRegister("_time",150)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndFunc
Func _botLoop()
AbandonQuest($questId)
MoveTo(5740,10636)
$agent = GetNearestNPCToAgent(-2)
GoToNPC($agent)
AcceptQuest($questId)
sleep(1000)
MoveTo(7118,10695)
MoveTo(7483,10459)
MoveTo(7404,5933)
MoveTo($moveVar,5350)
WaitForLoad()
Do
sleep(500)
$lMe = GetAgentByID(-2)
$x = DllStructGetData($lMe, 'X')
Until $x <> 0
MoveTo(5526,4505)
sleep(5000)
MoveTo(4498,5469)
MoveTo(3297,6157)
MoveTo(2149,6378)
MoveTo(836,6645)
MoveTo(-382,7450)
MoveTo(-1032,7992)
MoveTo(-2125,8739)
sleep(500)
Do
$agent = GetNearestNPCToAgent(-2)
$aX = DllStructGetData($agent, 'X')
$aY = DllStructGetData($agent, 'Y')
MoveTo($aX,$aY)
$nearestEnemy = GetNearestEnemyToAgent()
$distance = GetDistance($nearestEnemy,-2)
sleep(500)
Until $distance < 1800
sleep(250)
Do
$agent = GetNearestNPCToAgent(-2)
$aX = DllStructGetData($agent, 'X')
$aY = DllStructGetData($agent, 'Y')
MoveTo($aX,$aY)
$nearestEnemy = GetNearestEnemyToAgent()
$distance = GetDistance($nearestEnemy,-2)
$living = GetIsLiving(-2)
sleep(250)
Until $distance > 2000 or $living <> True
GoToTown()
sleep(250)
Do
sleep(250)
$lMe = GetAgentByID(-2)
$x = DllStructGetData($lMe, 'X')
Until $x <> 0
sleep(2000)
_updateLabels()
EndFunc
Func _updateLabels()
$currentXp = GetExperience()
$earnedXp = $currentXp - $startXp
$runsDone +=1
GUICtrlSetData($xpLabel,$earnedXp)
GUICtrlSetData($runsDoneLabel,$runsDone)
EndFunc
Func WaitForLoad()
Do
Sleep(200)
$lMe = GetAgentByID(-2)
Until DllStructGetData($lMe, 'X') <> 0 Or DllStructGetData($lMe, 'Y') <> 0
RndSleep(4000)
EndFunc
Func GoToTown()
TravelTo(148)
RndSleep(1000)
EndFunc
With that it seems to run a bit better, thank you for the source. :)
Edit: But it still does some failruns where it teleports back to town without leeching exp.