rendered paste body; Return from Rogue Camp WP to Harrogath Start
; v 0.70 by WildRob
#include "Includes.TownMove.au3"
#include "Includes.Init.au3"
#include "Includes.Click.au3"
opt ("PixelCoordMode", 2)
opt ("MouseCoordMode", 2)
opt ("ColorMode", 1)
$ChickenTimeout = 1000 ;Time to wait for sucessful chicken before retrying
$ChickenRetries = 3 ;Times to retry chicken
$CurrentDir = StringSplit(@ScriptDir, "\")
_ArrayPop($CurrentDir)
$BotDir = $CurrentDir[1]
For $Rebuild = 2 to ($CurrentDir[0] - 1)
$BotDir = $BotDir & "\" & $CurrentDir[$Rebuild]
Next
; check if in act 1
$Act_PCS = PixelChecksum(242,132, 246,136)
If $Act_PCS <> 1115492022 Then
LogReport("We are not in Act 1! Act PCS = " & $Act_PCS)
LogReport(" ")
Exit 1
EndIf
$PCS_Act1_Start = PixelChecksum(242,132, 246,136)
LogReport("Barrel PCS = " & $PCS_Act1_Start)
; read variables
$Char_CheckMoveDelay = IniRead($BotDir & "\Config\mm.BOT.ini", "Advanced Settings", "Char_CheckMoveDelay", "")
$D2_SendKeyDownDelay = IniRead($BotDir & "\Config\mm.BOT.ini", "Advanced Settings", "D2_SendKeyDownDelay", "")
$Walk_Delay = IniRead($BotDir & "\Config\mm.BOT.sequences.ini", "Vars", "@Walk_Delay", "")
$KEY_ClearScreen = IniRead($BotDir & "\Config\mm.BOT.ini", "Character", "Char_Key_ClearScreen", "")
$KEY_ClearScreen = "{" & $KEY_ClearScreen & "}"
Dim $Color_Blue_WP_Torch[5]
Dim $pix[2]
Dim $pixel[2]
$Color_Blue_WP_Torch[0] = 16764878
$Color_Blue_WP_Torch[1] = 16250830
$Color_Blue_WP_Torch[2] = 16764845
$Color_Blue_WP_Torch[3] = 15176291
$Color_Blue_WP_Torch[4] = 14573857 ; not in Merc Insight Aura!
; check location of WP
$GreenBlock = 65304
$MidBlock = PixelSearch( 640, 280, 760, 330, $GreenBlock)
If Not @error Then
$WpLoc = "down"
Else
$WpLoc = "up"
EndIf
LogReport("WP location is " & $WPLoc)
; Go near WP
Call("GreenBlockCoordinates")
If $WpLoc = "down" Then
MouseClick("left", 792, 370, 1, 1)
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
Call("GreenBlockCoordinates")
MouseClick("left", 654, 335, 1, 1) ; 654, 305, 1, 1
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
Call("GreenBlockCoordinates")
ElseIf $WpLoc = "up" Then
MouseClick("left", 610, 103, 1, 1) ; 620
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
Call("GreenBlockCoordinates")
EndIf
; Open WP menu
$X_PS = 5
$X_PS_max = 650
For $i = 1 to 5
For $c = 0 To 4
$pixel = PixelSearch($X_PS, 5, $X_PS_max, 457, $Color_Blue_WP_Torch[$c], 0, 1) ; default $Color_Blue_WP_Torch_4
If NOT @error Then
$pix[0] = $pixel[0]
$pix[1] = $pixel[1]
LogReport("PixelSearch for $Color_Blue_WP_Torch[" & $c & "] successful at: " & $pixel[0] & ", " & $pixel[1])
Else
SetError(1)
LogReport("PixelSearch for $Color_Blue_WP_Torch[" & $c & "] failed")
EndIf
Next
If NOT @error Then
MouseClick("left", $pix[0], $pix[1], 1, 1)
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
Sleep(500)
EndIf
If ValidateWP() Then ExitLoop
LogReport("Error opening Act 1 WP menu: Retry !")
Send("{PRINTSCREEN}")
;If IsArray($pixel) Then
; $X_PS = $pixel[0]
; If $X_PS > $X_PS_max Then $X_PS = 5
; LogReport("Left x coordinate for new PixelSearch: $X_PS = " & $X_PS)
;EndIf
Sleep(50)
Next
; Error check
If NOT ValidateWP() Then
LogReport("Error opening Act 1 WP : ABORTING !")
Chicken()
Exit 0
Endif
If NOT UseWP(5, 1, 10000) Then
LogReport("Timeout using WP : ABORTING !")
Chicken()
Exit 0
Endif
;If we got to here assume everything worked.
$PCS_Act5_WP = PixelChecksum(700, 60, 704, 64)
LogReport("Act 5 WP entered. PCS = " & $PCS_Act5_WP)
;A5 WP To Start
Sleep(1000)
MouseClick("left", 479, 189, 1, 1)
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
SetupActContext(5)
If FromBlockClickTo(100, 250, 350, 500, 393, -276, 2, 0) == 0 Then Return 0
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
If FromBlockClickTo(400, 400, 650, 570, -10, -210, 2, 0) == 0 Then Return 0
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
If FromBlockClickTo(300, 450, 550, 570, 147, -390, 2, -1) == 0 Then Return 0
CheckMove($Char_CheckMoveDelay)
Sleep($Walk_Delay)
$PCS_Start_Act5 = PixelChecksum(70, 70, 74, 74)
LogReport("Reached Start position Act 5. PCS = " & $PCS_Start_Act5)
LogReport(" ")
Exit
Func Chicken()
For $Retries = 1 To $ChickenRetries
Send($KEY_ClearScreen)
MouseUp("Right")
MouseUp("Left")
Send("{ESC}")
$Timeout = TimerInit()
While 1
If (PixelGetColor(481, 535) <> 5406092) AND (PixelGetColor(320, 537) <> 6521492) Then
ExitLoop
ElseIf TimerDiff($Timeout) > 500 Then
LogReport("Failed to open the main menu, will retry... Retry # " & $Retries)
ContinueLoop 2
EndIf
Sleep(100)
WEnd
MouseClick("Left", 400, 280, 1, 0)
$Timeout = TimerInit()
While TimerDiff($Timeout) < $ChickenTimeout
If (PixelGetColor(600, 575) <> 6512995) AND (PixelGetColor(5, 575) <> 2697257) Then ExitLoop 2
Sleep(100)
WEnd
If $Retries >= $ChickenRetries Then
LogReport("Max Retries exceeded, Will terminate the Game.exe process")
LogReport(" ")
ProcessClose("Game.exe")
Else
LogReport("Failed to chicken, Will retry the chicken...")
EndIf
Next
LogReport("Chicken was a success!")
LogReport(" ")
EndFunc ;==>Chicken
Func LogReport($String)
$LogFile = FileOpen($BotDir & "\Logs\Act1_Town.txt", 1)
FileWriteLine($LogFile, @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " [P]> " & $String)
FileClose($LogFile)
EndFunc
Func GreenBlockCoordinates()
$XYBlock = PixelSearch (5, 5, 795, 530, 65304, 0, 15)
If Not @error Then
$XBS = $XYBlock[0]
$YBS = $XYBlock[1]
Do
$XBS = $XBS + 4
$ApixBS = PixelGetColor ($XBS, $YBS)
Until $ApixBS <> 65304
Do
$YBS = $YBS - 4
$ApixBS = PixelGetColor ($XBS, $YBS)
Until $ApixBS <> 65304
$XBF = $XBS
$YBF = $YBS
LogReport("Green Block found at $XBF = " & $XBF & ", $YBF = " & $YBF)
Else
LogReport("Green Block not found")
EndIf
EndFunc