Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.3_zeenexx

Jun 26th, 2012
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 61.98 KB | None | 0 0
  1. #include <WindowsConstants.au3>
  2. #include <Misc.au3>
  3. #include <WinAPI.au3>
  4. #include <StaticConstants.au3>
  5. #include <GuiListBox.au3>
  6. #include <ScrollBarConstants.au3>
  7. #include <Array.au3>
  8. #include <GUIConstantsEx.au3>
  9.  
  10. Initialize()
  11.  
  12. #cs
  13.  
  14.    [Gold/Itemfarming] [AutoIt] Sarkoth Act I Dank Cellar [WD] [Stash, Sell, Repair, +++]
  15.                                     by zEEneXx
  16.                                  
  17.                                    Version: 1.3
  18.                                
  19.                                 www.ownedcore.com
  20.                  
  21. #ce
  22.  
  23. ;///////////////////////////////////////--CONFIG--////////////////////////////////////////////////////////////////////////////////////////////
  24. ;                                                                                                                                   //
  25. ;                                       Important                                                                                   //
  26. $ComputerLag            = 0                                         ;Increase this in steps of 100 if you have a slow computer              //
  27. $MoveDelay              = 0                                         ;Increase this in steps of 50 if you have movement issues               //
  28. $LootDelay              = 0                                         ;Increase this in steps of 50 if you have looting issues                //
  29. $SalvageDelay           = 0                                         ;Increase this in steps of 50 if you have salvaging issues              //
  30. $SellDelay              = 0                                         ;Increase this in steps of 50 if you have selling issues                //
  31. $StashDelay             = 0                                         ;Increase this in steps of 50 if you have stashing issues               //
  32. $ImgDir                 = "C:\Program Files (x86)\AutoIt3\pics\"    ;Location of the image folder                                           //
  33. ;                                                                                                                                           //
  34. ;                                       Functions                                                                                   //
  35. $Repair                 = True                                      ;Orders the bot to repair when items are damaged                        //
  36. $Salvage                = True                                      ;Orders the bot to salvage items with item level 60 and above           //
  37. $Sell                   = True                                      ;Orders the bot to sell magic items when bag is full                    //
  38. $KeepHighLevel          = True                                      ;Set this to true if you want to keep items with $KeepLevel and above   //
  39. $KeepLevel              = 62                                        ;60, 61, 62, 63                                                         //
  40. $UseStash               = True                                      ;Orders the bot to use the stash                                        //
  41. $HighGoldRadius         = False                                     ;Set this to true if you have more than +18 gold radius                 //
  42. ;                                                                                                                                           //
  43. ;                                     Miscellaneous                                                                                 //
  44. $Sounds                 = True                                      ;Enable pickup sounds                                                   //
  45. $SoundsDir              = "C:\Program Files (x86)\AutoIt3\sounds\"  ;Location of the sounds folder                                          //
  46. $ShowLootArea           = True                                      ;Shows lootarea                                                         //
  47. $ShowLog                = True                                      ;Shows log overlay                                                      //
  48. $SaveStats              = True                                      ;Saves current statistics to a *.txt file                               //
  49. $SaveLogsPath           = "C:\Program Files (x86)\AutoIt3\logs\"    ;Folder to save the logs and statistics in                              //
  50. ;                                                                                                                                           //
  51. ;                                      Relogging                                                                                    //                                 
  52. $UseRelogging           = False                                     ;Enable Relogging                                                       //
  53. $Password               = "XXXXXXXXXXX"                             ;Your password                                                          //
  54. ;                                                                                                                                           //
  55. ;                                        Looting                                                                                    //
  56. $LootLegendaries        = True                                      ;Loot legendary items                                                   //
  57. $LootSets               = True                                      ;Loot set items                                                         //
  58. $LootRares              = True                                      ;Loot rare items                                                        //
  59. $LootMagics             = True                                      ;Loot magic items (includes tomes)                                      //
  60. $LootTomes              = True                                      ;Loot tomes                                                             //
  61. $LootGems               = True                                      ;Loot gems                                                              //
  62. ;                                                                                                                                           //
  63. ;      <<<Changes below have an significant impact on the needed for looting>>>                                                     //
  64. ;                                                                                                                                   //
  65. $LegendaryLootAmount    = 1                                         ;Amount of legendary items to loot                                      //
  66. $SetLootAmount          = 1                                         ;Amount of set items to loot                                            //
  67. $RareLootAmount         = 1                                         ;Amount of rare items to loot                                           //
  68. $MagicLootAmount        = 3                                         ;Amount of magic items to loot (including tomes)                        //
  69. $TomeLootAmount         = 1                                         ;Amount of tomes to loot                                                //
  70. $GemLootAmount          = 2                                         ;Amount of gems to loot                                                 //
  71. ;                                                                                                                                           //
  72. $LootingArea[0]         = 570                                       ;Left   (lower -> bigger)                                               //
  73. $LootingArea[1]         = 185                                       ;Top    (lower -> bigger)                                               //
  74. $LootingArea[2]         = 1375                                      ;Right  (higher -> bigger)                                              //
  75. $LootingArea[3]         = 720                                       ;Bot    (higher -> bigger)                                              //
  76. ;                                                                                                                                           //
  77. ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78.  
  79. ScriptStarted()  
  80.  
  81. While 1
  82.    While WinActive('Diablo III')
  83.       Randomize()
  84.  
  85.       Switch ResumeGame()
  86.          Case "LeftGame"
  87.             ExitLoop
  88.          Case "Network connection lost"
  89.             ExitLoop
  90.          Case "Relogged"
  91.             ExitLoop
  92.       EndSwitch
  93.      
  94.       MoveToCellar()
  95.      
  96.       Switch EnterCellar()
  97.          Case "LeftGame"
  98.             ExitLoop
  99.          Case "Network connection lost"
  100.             ExitLoop
  101.          Case "Relogged"
  102.             ExitLoop
  103.       EndSwitch
  104.      
  105.       MoveInCellar()
  106.       UseSkills()
  107.       KillSarkoth()
  108.       LootGold()
  109.      
  110.       Switch LootItems()
  111.          Case "LeftGame"
  112.             ExitLoop
  113.          Case "Network connection lost"
  114.             ExitLoop
  115.          Case "Relogged"
  116.             ExitLoop
  117.       EndSwitch
  118.      
  119.       Switch TeleportToTown()
  120.          Case "LeftGame"
  121.             ExitLoop
  122.          Case "Network connection lost"
  123.             ExitLoop
  124.          Case "Relogged"
  125.             ExitLoop  
  126.       EndSwitch
  127.      
  128.       LeaveGame()
  129.    WEnd
  130. WEnd
  131.  
  132. ;Routine
  133. Func ResumeGame()
  134.    If $UseRelogging = True Then
  135.       $Array = StringSplit($ImageFiles[7][4],"|")
  136.       $File = $Array[1]
  137.       $Accuracy = $Array[2]
  138.    
  139.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  140.       If $Target = 1 Then
  141.          Relog()
  142.          Return "Relogged"
  143.       EndIf
  144.    EndIf
  145.      
  146.    Switch InGameLobby()
  147.       Case "InGameLobby"
  148.          ToLog("Resuming game...")
  149.          MouseClick('LEFT', $ResumeButton[0], $ResumeButton[1], 1, 5)
  150.       Case "LeftGame"
  151.          Return "LeftGame"
  152.       Case "Relogged"
  153.          Return "Relogged"
  154.    EndSwitch
  155.    
  156.    Switch InGameplayScreen()
  157.       Case "LeftGame"
  158.          Return "LeftGame"
  159.       Case "InGamePlayScreen"
  160.          Return "InGamePlayScreen"
  161.       Case "Network connection lost"
  162.          Return "Network connection lost"
  163.       Case "Relogged"
  164.          Return "Relogged"
  165.    EndSwitch
  166. EndFunc
  167.  
  168. Func MoveToCellar()
  169.    $Sek = Floor(TimerDiff($RunTimer) / 1000)
  170.    If $Runs > 0 Then
  171.       ToLog("Last run took: " & $Sek & "s")
  172.    EndIf
  173.    
  174.    $RunTimer = TimerInit()
  175.    
  176.    ToLog("Starting run...")
  177.    $Runs+=1
  178.    RefreshStats()
  179.    
  180.    Sleep(375 + $Computerlag)
  181.  
  182.    Send("{4}")
  183.    Sleep(30 + ($Computerlag/2))
  184.    
  185.    ToLog("Moving to cellar - 1")
  186.    Move($MoveToCellar1[0], $MoveToCellar1[1])
  187.    Sleep(1175 + $MoveDelay)
  188.    
  189.    ToLog("Moving to cellar - 2")
  190.    Move($MoveToCellar2[0], $MoveToCellar2[1])
  191.    Sleep(2075 + $MoveDelay)
  192.    
  193.    ToLog("Moving to cellar - 3")
  194.    Move($MoveToCellar3[0], $MoveToCellar3[1])
  195.    Sleep(1550 + $MoveDelay)
  196.    
  197.    Send("{2}")
  198.    Sleep(200 + $Computerlag)
  199. EndFunc
  200.  
  201. Func EnterCellar()
  202.    MouseMove($CellarLocation[0], $CellarLocation[1], 2)
  203.    Sleep(100 + ($Computerlag/2))
  204.    
  205.    for $i = 0 to 2
  206.       $CellarPixel = PixelSearch($CellarSearchArea[0], $CellarSearchArea[1], $CellarSearchArea[2], $CellarSearchArea[3], 0x334FB7, 8)
  207.       If @error Then
  208.          ToLog("Cellar is closed")
  209.          $Closed+=1
  210.          RefreshStats()
  211.          Switch TeleportToTown()
  212.             Case "LeftGame"
  213.                Return "LeftGame"
  214.             Case "Network connection lost"
  215.                Return "Network connection lost"
  216.             Case "Relogged"
  217.                Return "Relogged"     
  218.          EndSwitch
  219.          LeaveGame()
  220.          Return "LeftGame"
  221.       Else
  222.          ToLog("Entering cellar...")
  223.          MouseClick('LEFT', $CellarLocation[0], $CellarLocation[1], 1, 5)
  224.          Switch InCellar()
  225.          Case "InCellar"
  226.             Return "InCellar"
  227.          Case "LeftGame"
  228.             Return "LeftGame"
  229.          Case "Network connection lost"
  230.             Return "Network connection lost"
  231.          Case "Relogged"
  232.             Return "Relogged"
  233.          EndSwitch
  234.       EndIf  
  235.       Sleep(Random(20, 30, 1))
  236.    Next
  237. EndFunc
  238.  
  239. Func MoveInCellar()
  240.    ToLog("Moving in cellar - 1")
  241.    Move($MoveInCellar1[0], $MoveInCellar1[1])
  242.    Sleep(2050 + $MoveDelay)
  243.    
  244.    ToLog("Moving in cellar - 2")
  245.    Move($MoveInCellar2[0], $MoveInCellar2[1])
  246.    Sleep(1050 + $MoveDelay)
  247.    
  248.    MouseMove($MonsterLocation[0],$MonsterLocation[1], 5)
  249.    Sleep(50 + ($Computerlag/2))
  250. EndFunc
  251.    
  252. Func UseSkills()
  253.    ToLog("Using skills...")
  254.    Send("{1}")
  255.    Sleep(400 + $Computerlag)
  256.    
  257.    Send("{3}")
  258.    Sleep(400 + $Computerlag)
  259.    
  260.    MouseClick('RIGHT')
  261.    Sleep(250 + $Computerlag)
  262. EndFunc
  263.    
  264. Func KillSarkoth()
  265.    ToLog("Killing Sarkoth...")
  266.    While 1
  267.       $MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  268.       If @error Then
  269.          Attack($MonsterLocation[0],$MonsterLocation[1])
  270.          Sleep(600)
  271.          
  272.          $MonsterBar =  PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  273.          If @error Then
  274.             ExitLoop
  275.          EndIf
  276.       EndIf
  277.      
  278.       Attack($MonsterBar[0], $MonsterBar[1])
  279.       Sleep(100)
  280.    WEnd
  281.    ToLog("All monsters are dead")
  282.    
  283.    Send("{4}")
  284.    Sleep(30 + ($Computerlag/2))
  285. EndFunc
  286.  
  287. Func LootGold()
  288.    If $ShowLootArea = True Then
  289.       DrawLootArea()   
  290.    EndIf
  291.    
  292.    ToLog("Looting gold...")
  293.    If $HighGoldRadius = False Then
  294.       Move($MoveToGoldLoot1a[0], $MoveToGoldLoot1a[1])
  295.       Sleep(850 + $MoveDelay)
  296.       AttackNearbyMonsters()
  297.      
  298.       Move($MoveToGoldLoot2[0], $MoveToGoldLoot2[1])
  299.       Sleep(550 + $MoveDelay)
  300.       AttackNearbyMonsters()
  301.      
  302.       Move($MoveToGoldLoot3[0], $MoveToGoldLoot3[1])
  303.       Sleep(400 + $MoveDelay)
  304.       AttackNearbyMonsters()
  305.    Else
  306.       Move($MoveToGoldLoot1b[0], $MoveToGoldLoot1b[1])
  307.       Sleep(800 + $MoveDelay)
  308.       AttackNearbyMonsters()
  309.    EndIf
  310.    
  311.    MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  312.    Sleep(50)
  313. EndFunc
  314.  
  315. Func LootItems()
  316.    If $LootSets Then
  317.       Send("{ALT}")
  318.       Switch LootSets()
  319.          Case "LeftGame"
  320.             Return "LeftGame"
  321.          Case "Network connection lost"
  322.             Return "Network connection lost"
  323.          Case "Relogged"
  324.             Return "Relogged"
  325.       EndSwitch
  326.    EndIf
  327.    
  328.    If $LootLegendaries Then
  329.       Send("{ALT}")
  330.       Switch LootLegendaries()
  331.          Case "LeftGame"
  332.             Return "LeftGame"
  333.          Case "Network connection lost"
  334.             Return "Network connection lost"
  335.          Case "Relogged"
  336.             Return "Relogged"
  337.       EndSwitch
  338.    EndIf
  339.    
  340.    If $LootRares Then
  341.       Send("{ALT}")
  342.       Switch LootRares()
  343.          Case "LeftGame"
  344.             Return "LeftGame"
  345.          Case "Network connection lost"
  346.             Return "Network connection lost"
  347.          Case "Relogged"
  348.             Return "Relogged"
  349.       EndSwitch
  350.       $RareLootAttempts = 0
  351.    EndIf
  352.    
  353.    If $LootMagics Then
  354.       Send("{ALT}")
  355.       Switch LootMagics()
  356.          Case "LeftGame"
  357.             Return "LeftGame"
  358.          Case "Network connection lost"
  359.             Return "Network connection lost"
  360.          Case "Relogged"
  361.             Return "Relogged"
  362.       EndSwitch
  363.       $MagicLootAttempts = 0
  364.    Else
  365.       If $LootTomes Then
  366.          Send("{ALT}")
  367.          Switch LootTomes()
  368.          Case "LeftGame"
  369.             Return "LeftGame"
  370.          Case "Network connection lost"
  371.             Return "Network connection lost"
  372.          Case "Relogged"
  373.             Return "Relogged"
  374.          EndSwitch
  375.          $TomeLootAttempts = 0
  376.       EndIf
  377.    EndIf
  378.    
  379.    If $LootGems Then
  380.       Send("{ALT}")
  381.       Switch LootGems()
  382.          Case "LeftGame"
  383.             Return "LeftGame"
  384.          Case "Network connection lost"
  385.             Return "Network connection lost"
  386.          Case "Relogged"
  387.             Return "Relogged"
  388.       EndSwitch
  389.       $GemLootAttempts = 0
  390.    EndIf
  391.    
  392.    If $ShowLootArea = True Then
  393.       GUIDelete($LootAreaGUI)  
  394.    EndIf
  395.    
  396.    Return "Looted"
  397. EndFunc
  398.    
  399. Func TeleportToTown()
  400.    ToLog("Teleporting to town...")
  401.    Sleep(50 + ($Computerlag/2))
  402.    Send("{t}")
  403.    Switch InTown()
  404.       Case "InTown"
  405.          Return "InTown"
  406.       Case "LeftGame"
  407.          Return "LeftGame"
  408.       Case "Network connection lost"
  409.          Return "Network connection lost"
  410.       Case "Relogged"
  411.          Return "Relogged"
  412.    EndSwitch
  413. EndFunc
  414.  
  415.  
  416. ;Loot
  417. Func LootLegendaries()
  418.    While $LegendaryLootAttempts < $LegendaryLootAmount
  419.       ToLog("Searching for legendaries... " & $LegendaryLootAttempts + 1)
  420.       For $gI = 0 to 4
  421.          $Array = StringSplit($ImageFiles[0][$gI],"|")
  422.          $File = $Array[1]
  423.          $Accuracy = $Array[2]
  424.      
  425.          $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  426.          If $Target = 1 Then
  427.             ToLog("Legendary found")
  428.          
  429.             If $Sounds = True Then
  430.                SoundPlay($SoundsDir & $SoundFiles[0], 0)
  431.             EndIf
  432.          
  433.             MouseClick("LEFT", $ISx, $ISy, 1, 4)
  434.             Sleep(550 + $LootDelay)
  435.          
  436.             MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  437.             Sleep(50)
  438.          
  439.             If $Salvage = True Or $Sell = True Or $UseStash = True Then
  440.                Switch CheckBagFull()
  441.                Case "LeftGame"
  442.                   Return "LeftGame"
  443.                Case "Network connection lost"
  444.                   Return "Network connection lost"
  445.                Case "Relogged"
  446.                   Return "Relogged"
  447.             EndSwitch
  448.                If $FullBag = True Then
  449.                   $FullBag = False
  450.                Else
  451.                   $LegendaryLootAttempts+=1
  452.                   $Legendaries+=1
  453.                   RefreshStats()
  454.                EndIf
  455.             EndIf
  456.             ExitLoop
  457.          EndIf
  458.       Next
  459.       If $Target = 0 Then ExitLoop
  460.    WEnd
  461.    Return "Looted"
  462. EndFunc
  463.  
  464. Func LootSets()
  465.    While $SetLootAttempts < $SetLootAmount
  466.       ToLog("Searching for sets... " & $SetLootAttempts + 1)
  467.       For $gI = 0 to 4
  468.          $Array = StringSplit($ImageFiles[1][$gI],"|")
  469.          $File = $Array[1]
  470.          $Accuracy = $Array[2]
  471.      
  472.          $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  473.          If $Target = 1 Then
  474.             ToLog("Set found")
  475.          
  476.             If $Sounds = True Then
  477.                SoundPlay($SoundsDir & $SoundFiles[1], 0)
  478.             EndIf
  479.          
  480.             MouseClick("LEFT", $ISx, $ISy, 1, 4)
  481.             Sleep(550 + $LootDelay)
  482.          
  483.             MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  484.             Sleep(50)
  485.          
  486.             If $Salvage = True Or $Sell = True Or $UseStash = True Then
  487.                CheckBagFull()
  488.                If $FullBag = True Then
  489.                   $FullBag = False
  490.                Else
  491.                   $SetLootAttempts+=1  
  492.                   $Sets+=1
  493.                   RefreshStats()
  494.                EndIf
  495.             EndIf
  496.             ExitLoop
  497.          EndIf
  498.       Next
  499.       If $Target = 0 Then ExitLoop
  500.    WEnd
  501.    Return "Looted"
  502. EndFunc
  503.  
  504. Func LootRares()
  505.    While $RareLootAttempts < $RareLootAmount
  506.       ToLog("Searching for rares... " & $RareLootAttempts + 1)
  507.       For $gI = 0 to 4
  508.          $Array = StringSplit($ImageFiles[2][$gI],"|")
  509.          $File = $Array[1]
  510.          $Accuracy = $Array[2]
  511.      
  512.          $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  513.          If $Target = 1 Then
  514.             ToLog("Rare found")
  515.          
  516.             If $Sounds = True Then
  517.                SoundPlay($SoundsDir & $SoundFiles[2], 0)
  518.             EndIf
  519.          
  520.             MouseClick("LEFT", $ISx, $ISy, 1, 4)
  521.             Sleep(550 + $LootDelay)
  522.          
  523.             MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  524.             Sleep(50)
  525.          
  526.             If $Salvage = True Or $Sell = True Or $UseStash = True Then
  527.                Switch CheckBagFull()
  528.                Case "LeftGame"
  529.                   Return "LeftGame"
  530.                Case "Network connection lost"
  531.                   Return "Network connection lost"
  532.                Case "Relogged"
  533.                   Return "Relogged"
  534.             EndSwitch
  535.                If $FullBag = True Then
  536.                   $FullBag = False
  537.                   $RareLootAttempts-=1
  538.                Else
  539.                   $Rares+=1
  540.                   RefreshStats()
  541.                EndIf
  542.             EndIf
  543.             ExitLoop
  544.          EndIf
  545.       Next
  546.       $RareLootAttempts+=1 
  547.    WEnd
  548.    Return "Looted"
  549. EndFunc
  550.  
  551. Func LootMagics()
  552.    While $MagicLootAttempts < $MagicLootAmount
  553.       ToLog("Searching for magics... " & $MagicLootAttempts + 1)
  554.       For $gI = 0 to 4
  555.          $Array = StringSplit($ImageFiles[3][$gI],"|")
  556.          $File = $Array[1]
  557.          $Accuracy = $Array[2]
  558.      
  559.          $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  560.          If $Target = 1 Then
  561.             ToLog("Magic found")
  562.          
  563.             If $Sounds = True Then
  564.                SoundPlay($SoundsDir & $SoundFiles[3], 0)
  565.             EndIf
  566.          
  567.             MouseClick("LEFT", $ISx, $ISy, 1, 4)
  568.             Sleep(550 + $LootDelay)
  569.          
  570.             MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  571.             Sleep(50)
  572.          
  573.             If $Salvage = True Or $Sell = True Or $UseStash = True Then
  574.                Switch CheckBagFull()
  575.                   Case "LeftGame"
  576.                      Return "LeftGame"
  577.                   Case "Network connection lost"
  578.                      Return "Network connection lost"
  579.                   Case "Relogged"
  580.                      Return "Relogged"
  581.                EndSwitch
  582.                If $FullBag = True Then
  583.                   $FullBag = False
  584.                Else
  585.                   $MagicLootAttempts+=1
  586.                   $Magics+=1
  587.                   RefreshStats()
  588.                EndIf
  589.             EndIf
  590.             ExitLoop
  591.          EndIf
  592.       Next
  593.       If $Target = 0 Then ExitLoop
  594.    WEnd
  595.    Return "Looted"
  596. EndFunc
  597.  
  598. Func LootTomes()
  599.    While $TomeLootAttempts < $TomeLootAmount
  600.       ToLog("Searching for Tomes of Secrets... " & $TomeLootAttempts + 1)
  601.       $Array = StringSplit($ImageFiles[4][0],"|")
  602.       $File = $Array[1]
  603.       $Accuracy = $Array[2]
  604.      
  605.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  606.       If $Target = 1 Then
  607.          ToLog("Tome of Secrets found")
  608.          
  609.          If $Sounds = True Then
  610.             SoundPlay($SoundsDir & $SoundFiles[4], 0)
  611.          EndIf
  612.          
  613.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  614.          Sleep(550 + $LootDelay)
  615.          
  616.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  617.          Sleep(50)
  618.          
  619.          If $Salvage = True Or $Sell = True Or $UseStash = True Then
  620.             Switch CheckBagFull()
  621.                Case "LeftGame"
  622.                   Return "LeftGame"
  623.                Case "Network connection lost"
  624.                   Return "Network connection lost"
  625.                Case "Relogged"
  626.                   Return "Relogged"
  627.             EndSwitch
  628.             If $FullBag = True Then
  629.                $FullBag = False
  630.             Else
  631.                $TomeLootAttempts+=1
  632.                $Tomes+=1
  633.                RefreshStats()
  634.             EndIf
  635.          EndIf
  636.       EndIf
  637.       If $Target = 0 Then ExitLoop
  638.    WEnd
  639.    Return "Looted"
  640. EndFunc
  641.    
  642. Func LootGems()
  643.    While $GemLootAttempts < $GemLootAmount
  644.       ToLog("Searching for Gems... " & $GemLootAttempts + 1)
  645.       $Array = StringSplit($ImageFiles[4][1],"|")
  646.       $File = $Array[1]
  647.       $Accuracy = $Array[2]
  648.      
  649.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  650.       If $Target = 1 Then
  651.          ToLog("Gem found")
  652.          
  653.          If $Sounds = True Then
  654.             SoundPlay($SoundsDir & $SoundFiles[5], 0)
  655.          EndIf
  656.          
  657.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  658.          Sleep(550 + $LootDelay)
  659.          
  660.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  661.          Sleep(50)
  662.          
  663.          If $Salvage = True Or $Sell = True Or $UseStash = True Then
  664.             Switch CheckBagFull()
  665.                Case "LeftGame"
  666.                   Return "LeftGame"
  667.                Case "Network connection lost"
  668.                   Return "Network connection lost"
  669.                Case "Relogged"
  670.                   Return "Relogged"
  671.             EndSwitch
  672.             If $FullBag = True Then
  673.                $FullBag = False
  674.             Else
  675.                $GemLootAttempts+=1 
  676.                $Gems+=1
  677.                RefreshStats()
  678.             EndIf
  679.          EndIf
  680.       EndIf
  681.       If $Target = 0 Then ExitLoop
  682.    WEnd
  683.    Return "Looted"
  684. EndFunc
  685.  
  686.  
  687. ;Salvage, Sell, store and repair
  688. Func CheckBagFull()
  689.    $Array = StringSplit($ImageFiles[6][4],"|")
  690.    $File = $Array[1]
  691.    $Accuracy = $Array[2]
  692.    
  693.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullBagSearchArea[0], $FullBagSearchArea[1], $FullBagSearchArea[2], $FullBagSearchArea[3], $ISx, $ISy, $Accuracy)
  694.    If $Target = 1 Then
  695.       ToLog("Our bag is full")
  696.       $FullBag = True
  697.       Switch SellItems()
  698.          Case "LeftGame"
  699.             Return "LeftGame"
  700.          Case "Network connection lost"
  701.             Return "Network connection lost"
  702.          Case "Relogged"
  703.             Return "Relogged"
  704.       EndSwitch
  705.    EndIf
  706.    Return "BagNotFull"
  707. EndFunc
  708.  
  709. Func SalvageItems()
  710.    ToLog("Salvaging...")
  711.    
  712.    $Count = 0
  713.    
  714.    RandomizeInventory()
  715.    MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  716.    While UBOUND($Stash) > 0
  717.       $r = Random(0, UBOUND($Stash)-1, 1)
  718.      
  719.       $Array = StringSplit($ImageFiles[5][0],"|")
  720.       $File = $Array[1]
  721.       $Accuracy = $Array[2]
  722.      
  723.       $Target = _ImageSearchArea($ImgDir & $File, 1, $Stash[$r][0]-25, $Stash[$r][1]-25, $Stash[$r][0]+25, $Stash[$r][1]+25, 0, 0, $Accuracy)
  724.       If Not $Target = 1 Then
  725.          MouseMove($Stash[$r][0], $Stash[$r][1], 0)
  726.          Sleep(200 + $SalvageDelay)
  727.          $Array = StringSplit($ImageFiles[5][1],"|")
  728.          $File = $Array[1]
  729.          $Accuracy = $Array[2]
  730.      
  731.          $Target = _ImageSearchArea($ImgDir & $File, 0, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
  732.          If $Target = 1 Then
  733.             For $gI = 2 to 6
  734.                $Array = StringSplit($ImageFiles[5][$gI],"|")
  735.                $File = $Array[1]
  736.                $Accuracy = $Array[2]
  737.      
  738.                $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy, $ISx+420, $ISy+75, 0, 0, $Accuracy)
  739.          
  740.                If $Target = 1 Then
  741.                   If $Sell = True Then
  742.                      If $KeepHighLevel = True Then
  743.                         Switch $KeepLevel
  744.                            Case 60
  745.                               ExitLoop
  746.                            Case 61
  747.                               $Array = StringSplit($ImageFiles[4][2],"|")
  748.                               $File = $Array[1]
  749.                               $Accuracy = $Array[2]
  750.      
  751.                               $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  752.          
  753.                               If $Target = 1 Then
  754.                                  MouseClick("LEFT")
  755.                                  MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  756.                                  $Count+=1
  757.                                  Sleep(100)
  758.                                  ExitLoop
  759.                               EndIf
  760.                        
  761.                            Case 62
  762.                               For $gI = 2 to 3
  763.                                  $Array = StringSplit($ImageFiles[4][$gI],"|")
  764.                                  $File = $Array[1]
  765.                                  $Accuracy = $Array[2]
  766.      
  767.                                  $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  768.          
  769.                                  If $Target = 1 Then
  770.                                     MouseClick("LEFT")
  771.                                     MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  772.                                     $Count+=1
  773.                                     Sleep(100)
  774.                                     ExitLoop 2
  775.                                  EndIf
  776.                               Next
  777.                        
  778.                            Case 63
  779.                               For $gI = 2 to 4
  780.                                  $Array = StringSplit($ImageFiles[4][$gI],"|")
  781.                                  $File = $Array[1]
  782.                                  $Accuracy = $Array[2]
  783.      
  784.                                  $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  785.          
  786.                                  If $Target = 1 Then
  787.                                     MouseClick("LEFT")
  788.                                     MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  789.                                     $Count+=1
  790.                                     Sleep(100)
  791.                                     ExitLoop 2
  792.                                  EndIf
  793.                               Next
  794.                         EndSwitch
  795.                         ExitLoop
  796.                      Else
  797.                         For $gI = 2 to 5
  798.                            $Array = StringSplit($ImageFiles[4][$gI],"|")
  799.                            $File = $Array[1]
  800.                            $Accuracy = $Array[2]
  801.    
  802.                            $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  803.          
  804.                            If $Target = 1 Then
  805.                               MouseClick("LEFT")
  806.                               MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  807.                               $Count+=1
  808.                               Sleep(100)
  809.                               ExitLoop 2
  810.                            EndIf
  811.                         Next
  812.                      EndIf
  813.                   Else
  814.                      MouseClick("LEFT")
  815.                      MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 5)
  816.                      $Count+=1
  817.                      Sleep(100)
  818.                      ExitLoop
  819.                   EndIf
  820.                EndIf
  821.             Next
  822.          EndIf
  823.       EndIf
  824.       _ArrayDelete($Stash, $r)
  825.       Sleep(20 + $SellDelay)
  826.    WEnd
  827.    
  828.    ToLog("Salvaging... done - Salvaged " & $Count & " items")
  829. EndFunc
  830.  
  831. Func SellItems()  
  832.    If $Salvage = True Then
  833.       $SellCheck = 60
  834.    Else
  835.       $SellCheck = $KeepLevel
  836.    EndIf
  837.    
  838.    If $ShowLootArea = True Then
  839.       GUIDelete($LootAreaGUI)  
  840.    EndIf
  841.    
  842.    Switch TeleportToTown()
  843.       Case "LeftGame"
  844.          Return "LeftGame"
  845.       Case "Network connection lost"
  846.          Return "Network connection lost"
  847.       Case "Relogged"
  848.          Return "Relogged"
  849.    EndSwitch
  850.    
  851.    If $Sell = True Then
  852.       Switch MoveToMerchant()
  853.          Case "LeftGame"
  854.             Return "LeftGame"
  855.          Case "Network connection lost"
  856.             Return "Network connection lost"
  857.          Case "Relogged"
  858.             Return "Relogged"
  859.       EndSwitch
  860.    
  861.    ToLog("Selling...")
  862.    
  863.    $Count = 0
  864.    
  865.    RandomizeInventory()
  866.    
  867.    While UBOUND($Stash) > 0
  868.       $r = Random(0, UBOUND($Stash)-1, 1)
  869.      
  870.       $Array = StringSplit($ImageFiles[5][0],"|")
  871.       $File = $Array[1]
  872.       $Accuracy = $Array[2]
  873.      
  874.       $Target = _ImageSearchArea($ImgDir & $File, 1, $Stash[$r][0]-25, $Stash[$r][1]-25, $Stash[$r][0]+25, $Stash[$r][1]+25, 0, 0, $Accuracy)
  875.       If Not $Target = 1 Then
  876.          MouseMove($Stash[$r][0], $Stash[$r][1], 0)
  877.          Sleep(200 + $SellDelay)
  878.          $Array = StringSplit($ImageFiles[5][1],"|")
  879.          $File = $Array[1]
  880.          $Accuracy = $Array[2]
  881.      
  882.          $Target = _ImageSearchArea($ImgDir & $File, 0, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
  883.          If $Target = 1 Then
  884.             For $gI = 2 to 6
  885.                $Array = StringSplit($ImageFiles[5][$gI],"|")
  886.                $File = $Array[1]
  887.                $Accuracy = $Array[2]
  888.      
  889.                $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy, $ISx+420, $ISy+75, 0, 0, $Accuracy)
  890.          
  891.                If $Target = 1 Then
  892.                   If $KeepHighLevel = True Then
  893.                      Switch $SellCheck
  894.                         Case 60
  895.                            For $gI = 2 to 5
  896.                               $Array = StringSplit($ImageFiles[4][$gI],"|")
  897.                               $File = $Array[1]
  898.                               $Accuracy = $Array[2]
  899.      
  900.                               $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  901.          
  902.                               If $Target = 1 Then
  903.                                  ExitLoop 2
  904.                               EndIf
  905.                            Next
  906.                        
  907.                         Case 61
  908.                            For $gI = 3 to 5
  909.                               $Array = StringSplit($ImageFiles[4][$gI],"|")
  910.                               $File = $Array[1]
  911.                               $Accuracy = $Array[2]
  912.      
  913.                               $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  914.          
  915.                               If $Target = 1 Then
  916.                                  ExitLoop 2
  917.                               EndIf
  918.                            Next
  919.                        
  920.                         Case 62
  921.                            For $gI = 4 to 5
  922.                               $Array = StringSplit($ImageFiles[4][$gI],"|")
  923.                               $File = $Array[1]
  924.                               $Accuracy = $Array[2]
  925.      
  926.                               $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  927.          
  928.                               If $Target = 1 Then
  929.                                  ExitLoop 2
  930.                               EndIf
  931.                            Next
  932.                        
  933.                         Case 63
  934.                            $Array = StringSplit($ImageFiles[4][5],"|")
  935.                            $File = $Array[1]
  936.                            $Accuracy = $Array[2]
  937.      
  938.                            $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  939.          
  940.                            If $Target = 1 Then
  941.                               ExitLoop
  942.                            EndIf
  943.                      EndSwitch
  944.                      MouseClick("RIGHT")
  945.                      $Count+=1
  946.                      ExitLoop
  947.                   Else
  948.                      If $Salvage = True Then
  949.                         For $gI = 2 to 5
  950.                            $Array = StringSplit($ImageFiles[4][$gI],"|")
  951.                            $File = $Array[1]
  952.                            $Accuracy = $Array[2]
  953.      
  954.                            $Target = _ImageSearchArea($ImgDir & $File, 1, $ISx, $ISy+210, $ISx+140, $ISy+420, 0, 0, $Accuracy)
  955.          
  956.                            If $Target = 1 Then
  957.                               ExitLoop 2
  958.                            EndIf
  959.                         Next
  960.                      EndIf
  961.                      MouseClick("RIGHT")
  962.                      $Count+=1
  963.                      ExitLoop
  964.                   EndIf
  965.                EndIf
  966.             Next
  967.          EndIf
  968.       EndIf
  969.       _ArrayDelete($Stash, $r)
  970.    WEnd
  971.    
  972.    ToLog("Selling... done - Sold " & $Count & " items")
  973.    EndIf
  974.  
  975.    $RareLootAttempts    = 0
  976.    $MagicLootAttempts   = 0
  977.    $TomeLootAttempts    = 0
  978.    $GemLootAttempts     = 0
  979.    
  980.    If $Salvage = True Then
  981.       Switch MoveToSalvage()
  982.          Case "LeftGame"
  983.             Return "LeftGame"
  984.          Case "Network connection lost"
  985.             Return "Network connection lost"
  986.          Case "Relogged"
  987.             Return "Relogged"
  988.       EndSwitch
  989.    EndIf
  990.    
  991.    Switch MoveToStash()
  992.       Case "LeftGame"
  993.          Return "LeftGame"
  994.       Case "Network connection lost"
  995.          Return "Network connection lost"
  996.       Case "Relogged"
  997.          Return "Relogged"
  998.    EndSwitch
  999.      
  1000.    Sleep(150 + $ComputerLag)
  1001.    
  1002.    MouseClick("LEFT", $PortalLocation[0], $PortalLocation[1], 1, 10)
  1003.  
  1004.    Switch InCellar()
  1005.       Case "InCellar"
  1006.          If $ShowLootArea = True Then
  1007.             DrawLootArea() 
  1008.          EndIf
  1009.          Sleep(250 + ($ComputerLag/2))
  1010.          Return "InCellar"
  1011.       Case "LeftGame"
  1012.          Return "LeftGame"
  1013.       Case "Network connection lost"
  1014.          Return "Network connection lost"
  1015.       Case "Relogged"
  1016.          Return "Relogged"
  1017.       EndSwitch
  1018. EndFunc
  1019.  
  1020. Func PutInStash()  
  1021.    ToLog("Storing items in the stash...")
  1022.  
  1023.    RandomizeInventory()
  1024.  
  1025.    While UBOUND($Stash) > 0
  1026.       $r = Random(0, UBOUND($Stash)-1, 1)
  1027.       $Array = StringSplit($ImageFiles[5][0],"|")
  1028.       $File = $Array[1]
  1029.       $Accuracy = $Array[2]
  1030.      
  1031.       $Target = _ImageSearchArea($ImgDir & $File, 1, $Stash[$r][0]-25, $Stash[$r][1]-25, $Stash[$r][0]+25, $Stash[$r][1]+25, $ISx, $ISy, $Accuracy)
  1032.       If Not $Target = 1 Then
  1033.          MouseClick("RIGHT", $Stash[$r][0], $Stash[$r][1], 1, 0)
  1034.       EndIf
  1035.       If Not CheckStashFull() = 1 Then
  1036.          _ArrayDelete($Stash, $r)
  1037.       EndIf
  1038.       Sleep(50 + $StashDelay)
  1039.       If $UseStash = False Then
  1040.          ExitLoop
  1041.       EndIf
  1042.    WEnd
  1043.    
  1044.    ToLog("Storing items in the stash... done")
  1045. EndFunc
  1046.  
  1047. Func CheckStashFull()
  1048.    $Array = StringSplit($ImageFiles[6][3],"|")
  1049.    $File = $Array[1]
  1050.    $Accuracy = $Array[2]
  1051.    
  1052.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullStashSearchArea[0], $FullStashSearchArea[1], $FullStashSearchArea[2], $FullStashSearchArea[3], $ISx, $ISy, $Accuracy)
  1053.    If $Target = 1 Then
  1054.       Switch $StashBag
  1055.          Case 1
  1056.             ToLog("First stashbag is full - changing...")
  1057.             Sleep(100 + ($Computerlag/2))
  1058.             MouseClick("LEFT", $StashBag2[0], $StashBag2[1], 1, 5)
  1059.             $StashBag = 2
  1060.             Sleep(5000)
  1061.          Case 2
  1062.             ToLog("Second stashbag is full - changing...")
  1063.             Sleep(100 + ($Computerlag/2))
  1064.             MouseClick("LEFT", $StashBag3[0], $StashBag3[1], 1, 5)
  1065.             $StashBag = 3
  1066.             Sleep(5000)
  1067.          Case 3
  1068.             ToLog("Third stashbag is full - aborting...")
  1069.             $UseStash = False
  1070.       EndSwitch
  1071.       Return 1
  1072.    EndIf
  1073.    Return 0
  1074. EndFunc
  1075.  
  1076. Func RepairItems()
  1077.    If Not CheckForRepair() Then
  1078.       Return "NotDamaged"
  1079.    EndIf
  1080.    
  1081.    Switch MoveToMerchant()
  1082.       Case "LeftGame"
  1083.          Return "LeftGame"
  1084.       Case "Network connection lost"
  1085.          Return "Network connection lost"
  1086.       Case "Relogged"
  1087.          Return "Relogged"
  1088.    EndSwitch
  1089.    
  1090.    ToLog("Repairing...")
  1091.    MouseClick('LEFT', $RepairButton[0], $RepairButton[1], 1, 5)
  1092.    Sleep(100 + ($Computerlag/2))
  1093.    
  1094.    MouseClick('LEFT', $AllItemsButton[0], $AllItemsButton[1], 1, 5)
  1095.    Sleep(100 + ($Computerlag/2))
  1096.    
  1097.    Send("{ESC}")
  1098.    ToLog("Repairing... done")
  1099.    Return "Repaired"
  1100. EndFunc
  1101.  
  1102. Func CheckForRepair()
  1103.    $RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xFFE801, 10)
  1104.    If Not @error Then
  1105.       ToLog("We need to repair")
  1106.       Return True
  1107.    Else
  1108.       $RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xDE0000, 10)
  1109.       If Not @error Then
  1110.          ToLog("We need to repair")
  1111.          Return True
  1112.       Else
  1113.          Return False
  1114.       EndIf
  1115.    EndIf
  1116. EndFunc
  1117.  
  1118. Func MoveToSalvage()
  1119.    Sleep(350 + $Computerlag)
  1120.    ToLog("Waiting to get to the salvage... (TimeOut 8s)")
  1121.    
  1122.    ToLog("Moving to salvage - 1")
  1123.    Move($MoveToSalvage1[0], $MoveToSalvage1[1])
  1124.    Sleep($SleepToSalvage + $MoveDelay)
  1125.    
  1126.    ToLog("Moving to salvage - 2")
  1127.    Move($MoveToSalvage2[0], $MoveToSalvage2[1])
  1128.    Sleep($SleepToSalvage + $MoveDelay)
  1129.    
  1130.    ToLog("Moving to salvage - 3")
  1131.    MouseClick('LEFT', $SalvageLocation[0], $SalvageLocation[1], 1, 10)
  1132.    
  1133.    Switch AtSalvage()
  1134.       Case "LeftGame"
  1135.          Return "LeftGame"
  1136.       Case "Network connection lost"
  1137.          Return "Network connection lost"
  1138.       Case "Relogged"
  1139.          Return "Relogged"
  1140.    EndSwitch
  1141.    
  1142.    SalvageItems()
  1143.    Sleep(100 + ($Computerlag/2))
  1144.    Send("{ESC}")
  1145.    Return "Salvaged"
  1146. EndFunc
  1147.  
  1148. Func MoveToMerchant()
  1149.    Sleep(350 + $Computerlag)
  1150.    ToLog("Waiting to get to the merchant... (TimeOut 8s)")
  1151.    
  1152.    ToLog("Moving to merchant - 1")
  1153.    Move($MoveToMerchant[0] , $MoveToMerchant[1])
  1154.    Sleep(3500 + $MoveDelay)
  1155.    
  1156.    ToLog("Moving to merchant - 2")
  1157.    MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 10)
  1158.    
  1159.    Switch AtMerchant()
  1160.       Case "AtMerchant"
  1161.          Return "AtMerchant"
  1162.       Case "LeftGame"
  1163.          Return "LeftGame"
  1164.       Case "Network connection lost"
  1165.          Return "Network connection lost"
  1166.       Case "Relogged"
  1167.          Return "Relogged"
  1168.    EndSwitch
  1169. EndFunc
  1170.  
  1171. Func MoveToStash()
  1172.    ToLog("Waiting to get to the stash... (TimeOut 8s)")
  1173.    
  1174.    If $Salvage = True Or $Sell = True Then
  1175.    ToLog("Moving to stash - 1")
  1176.    Move($MoveToStash1[0] , $MoveToStash1[1])
  1177.    Sleep($SleepToStash + $MoveDelay)
  1178.    
  1179.    ToLog("Moving to stash - 2")
  1180.    Move($MoveToStash2[0] , $MoveToStash2[1])
  1181.    Sleep($SleepToStash + $MoveDelay)
  1182. EndIf
  1183.  
  1184.    If $UseStash = True Then
  1185.       $StashBag = 1
  1186.       MouseClick("LEFT", $StashLocation[0], $StashLocation[1], 1, 10)
  1187.       Switch AtStash()
  1188.          Case "LeftGame"
  1189.             Return "LeftGame"
  1190.          Case "Network connection lost"
  1191.             Return "Network connection lost"
  1192.          Case "Relogged"
  1193.             Return "Relogged"
  1194.       EndSwitch
  1195.       PutInStash()
  1196.       Sleep(100 + ($Computerlag/2))
  1197.       Send("{ESC}")
  1198.    EndIf
  1199.    Return "AtStash"
  1200. EndFunc
  1201.  
  1202.  
  1203. ;Check gamestate, disconnect and death
  1204. Func InLoginScreen()
  1205.    ToLog("Waiting to get into the login screen...")
  1206.    
  1207.    While 1
  1208.       $Array = StringSplit($ImageFiles[7][4],"|")
  1209.       $File = $Array[1]
  1210.       $Accuracy = $Array[2]
  1211.    
  1212.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  1213.       If $Target = 1 Then
  1214.          Return True
  1215.       Else
  1216.          Sleep(200)
  1217.       EndIf
  1218.    WEnd  
  1219. EndFunc
  1220.  
  1221. Func InGameLobby()
  1222.    ToLog("Waiting to get into the game lobby... (TimeOut 25s)")
  1223.    $TimeOutTimer = TimerInit()
  1224.    
  1225.    While 1
  1226.       $Array = StringSplit($ImageFiles[7][2],"|")
  1227.       $File = $Array[1]
  1228.       $Accuracy = $Array[2]
  1229.    
  1230.       $Target = _ImageSearchArea($ImgDir & $File, 1, $ResumeButtonSearchArea[0], $ResumeButtonSearchArea[1], $ResumeButtonSearchArea[2], $ResumeButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  1231.       If $Target = 1 Then
  1232.          $DisconnectState = 0
  1233.          Return "InGameLobby"
  1234.       Else
  1235.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 25 Then
  1236.             ToLog("GameLobby TimeOut - Trying again")
  1237.            
  1238.             If $Relogged = True Then
  1239.                Send("{ESC}")
  1240.                MouseClick("LEFT", $PasswordField[0]+250, $PasswordField[1], 1, 5)
  1241.                For $i = 0 to StringLen($Password)-1
  1242.                   Send("{BACKSPACE}")
  1243.                Next
  1244.                $Relogged = False
  1245.             Else
  1246.                MouseMove($ResumeButton[0], $ResumeButton[1]-100, 0)
  1247.                LeaveGame()
  1248.             EndIf
  1249.            
  1250.             Return "LeftGame"
  1251.          EndIf
  1252.          Switch CheckForDisconnect()
  1253.             Case "Network connection lost"
  1254.                Return "Network connection lost"
  1255.             Case "Relogged"
  1256.                Return "Relogged"
  1257.          EndSwitch
  1258.          Sleep(200)
  1259.       EndIf
  1260.    WEnd  
  1261. EndFunc
  1262.  
  1263. Func InGameplayScreen()
  1264.    ToLog("Waiting to get into the game... (TimeOut 14s)")
  1265.    $TimeOutTimer = TimerInit()
  1266.    
  1267.    While 1
  1268.       $Array = StringSplit($ImageFiles[7][3],"|")
  1269.       $File = $Array[1]
  1270.       $Accuracy = $Array[2]
  1271.    
  1272.       $Target = _ImageSearchArea($ImgDir & $File, 1, $PortalIconSearchArea[0], $PortalIconSearchArea[1], $PortalIconSearchArea[2], $PortalIconSearchArea[3], $ISx, $ISy, $Accuracy)
  1273.       If $Target = 1 Then
  1274.          $Alive = True
  1275.          $DisconnectState = 0
  1276.          Return "InGamePlayScreen"
  1277.       Else
  1278.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 14 Then
  1279.             $TimeOutTimer = TimerInit()
  1280.             ToLog("GameplayScreen TimeOut - Leaving")
  1281.             Return "LeftGame"
  1282.          EndIf
  1283.          If CheckForDeath() = "LeftGame" Then
  1284.             Return "LeftGame"
  1285.          EndIf
  1286.          Sleep(100)
  1287.          Switch CheckForDisconnect()
  1288.             Case "Network connection lost"
  1289.                Return "Network connection lost"
  1290.             Case "Relogged"
  1291.                Return "Relogged"
  1292.          EndSwitch
  1293.          Sleep(100)
  1294.       EndIf
  1295.    WEnd  
  1296. EndFunc
  1297.  
  1298. Func InCellar()
  1299.    ToLog("Waiting to get into the cellar... (TimeOut 8s)")
  1300.    $TimeOutTimer = TimerInit()
  1301.    
  1302.    While 1
  1303.       $Array = StringSplit($ImageFiles[7][0],"|")
  1304.       $File = $Array[1]
  1305.       $Accuracy = $Array[2]
  1306.    
  1307.       $Target = _ImageSearchArea($ImgDir & $File, 1, $CellarNameSearchArea[0], $CellarNameSearchArea[1], $CellarNameSearchArea[2], $CellarNameSearchArea[3], $ISx, $ISy, $Accuracy)
  1308.       If $Target = 1 Then
  1309.          Return "InCellar"
  1310.       Else
  1311.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 8 Then
  1312.             ToLog("Cellar TimeOut - Leaving")
  1313.             LeaveGame()
  1314.             Return "LeftGame"
  1315.          EndIf
  1316.          If CheckForDeath() = "LeftGame" Then
  1317.             Return "LeftGame"
  1318.          EndIf
  1319.          Sleep(100)
  1320.          Switch CheckForDisconnect()
  1321.             Case "Network connection lost"
  1322.                Return "Network connection lost"
  1323.             Case "Relogged"
  1324.                Return "Relogged"
  1325.          EndSwitch
  1326.          Sleep(100)
  1327.       EndIf
  1328.    WEnd
  1329. EndFunc
  1330.  
  1331. Func InTown()
  1332.    ToLog("Waiting to get into the town... (TimeOut 8s)")
  1333.    $TimeOutTimer = TimerInit()
  1334.    
  1335.    While 1
  1336.       $Array = StringSplit($ImageFiles[7][1],"|")
  1337.       $File = $Array[1]
  1338.       $Accuracy = $Array[2]
  1339.    
  1340.       $Target = _ImageSearchArea($ImgDir & $File, 1, $TownNameSearchArea[0], $TownNameSearchArea[1], $TownNameSearchArea[2], $TownNameSearchArea[3], $ISx, $ISy, $Accuracy)
  1341.       If $Target = 1 Then
  1342.          If $Repair And Not $FullBag Then
  1343.          Switch RepairItems()
  1344.             Case "LeftGame"
  1345.                Return "LeftGame"
  1346.             Case "Network connection lost"
  1347.                Return "Network connection lost"
  1348.             Case "Relogged"
  1349.                Return "Relogged"
  1350.             EndSwitch
  1351.          EndIf
  1352.          Return "InTown"
  1353.       Else
  1354.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 8 Then
  1355.             $TimeOutCount+=1
  1356.             If $TimeOutCount = 3 Then
  1357.                ToLog("Teleport TimeOut - Leaving")
  1358.                $TimeOutCount = 0
  1359.                LeaveGame()
  1360.                Return "LeftGame"
  1361.             EndIf
  1362.             $TimeOutTimer = TimerInit()
  1363.             ToLog("Teleport TimeOut - Trying to teleport again")
  1364.             ToLog("Teleporting to town...")
  1365.             Sleep(50 + ($Computerlag/2))
  1366.             Send("{t}")
  1367.          EndIf
  1368.          If CheckForDeath() = "LeftGame" Then
  1369.             Return "LeftGame"
  1370.          EndIf
  1371.          Sleep(100)
  1372.          Switch CheckForDisconnect()
  1373.             Case "Network connection lost"
  1374.                Return "Network connection lost"
  1375.             Case "Relogged"
  1376.                Return "Relogged"
  1377.          EndSwitch
  1378.          Sleep(100)
  1379.       EndIf
  1380.    WEnd  
  1381. EndFunc
  1382.  
  1383. Func AtSalvage()
  1384.    $TimeOutTimer = TimerInit()
  1385.    
  1386.    While 1
  1387.       $Array = StringSplit($ImageFiles[7][5],"|")
  1388.       $File = $Array[1]
  1389.       $Accuracy = $Array[2]
  1390.    
  1391.       $Target = _ImageSearchArea($ImgDir & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
  1392.       If $Target = 1 Then
  1393.          Return "AtSalvage"
  1394.       Else
  1395.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 8 Then
  1396.             ToLog("Salvage TimeOut - Leaving")
  1397.             LeaveGame()
  1398.             Return "LeftGame"
  1399.          EndIf
  1400.          If CheckForDeath() = "LeftGame" Then
  1401.             Return "LeftGame"
  1402.          EndIf
  1403.          Sleep(100)
  1404.          Switch CheckForDisconnect()
  1405.             Case "Network connection lost"
  1406.                Return "Network connection lost"
  1407.             Case "Relogged"
  1408.                Return "Relogged"
  1409.          EndSwitch
  1410.          Sleep(100)
  1411.       EndIf
  1412.    WEnd  
  1413. EndFunc
  1414.  
  1415. Func AtMerchant()
  1416.    $TimeOutTimer = TimerInit()
  1417.    
  1418.    While 1
  1419.       $Array = StringSplit($ImageFiles[7][5],"|")
  1420.       $File = $Array[1]
  1421.       $Accuracy = $Array[2]
  1422.    
  1423.       $Target = _ImageSearchArea($ImgDir & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
  1424.       If $Target = 1 Then
  1425.          Return "AtMerchant"
  1426.       Else
  1427.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 8 Then
  1428.             ToLog("Merchant TimeOut - Leaving")
  1429.             LeaveGame()
  1430.             Return "LeftGame"
  1431.          EndIf
  1432.          If CheckForDeath() = "LeftGame" Then
  1433.             Return "LeftGame"
  1434.          EndIf
  1435.          Sleep(100)
  1436.          Switch CheckForDisconnect()
  1437.             Case "Network connection lost"
  1438.                Return "Network connection lost"
  1439.             Case "Relogged"
  1440.                Return "Relogged"
  1441.          EndSwitch
  1442.          Sleep(100)
  1443.       EndIf
  1444.    WEnd  
  1445. EndFunc
  1446.  
  1447. Func AtStash()
  1448.    $TimeOutTimer = TimerInit()
  1449.    
  1450.    While 1
  1451.       $Array = StringSplit($ImageFiles[7][6],"|")
  1452.       $File = $Array[1]
  1453.       $Accuracy = $Array[2]
  1454.    
  1455.       $Target = _ImageSearchArea($ImgDir & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
  1456.       If $Target = 1 Then
  1457.          Return "AtStash"
  1458.       Else
  1459.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 8 Then
  1460.             ToLog("Stash TimeOut - Leaving")
  1461.             LeaveGame()
  1462.             Return "LeftGame"
  1463.          EndIf
  1464.          If CheckForDeath() = "LeftGame" Then
  1465.             Return "LeftGame"
  1466.          EndIf
  1467.          Sleep(100)
  1468.          Switch CheckForDisconnect()
  1469.             Case "Network connection lost"
  1470.                Return "Network connection lost"
  1471.             Case "Relogged"
  1472.                Return "Relogged"
  1473.          EndSwitch
  1474.          Sleep(100)
  1475.       EndIf
  1476.    WEnd  
  1477. EndFunc
  1478.  
  1479. Func CheckForDisconnect()
  1480.    $Array = StringSplit($ImageFiles[6][0],"|")
  1481.    $File = $Array[1]
  1482.    $Accuracy = $Array[2]
  1483.    
  1484.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, $Accuracy)
  1485.    If $Target = 1 And $DisconnectState = 0 Then
  1486.       ToLog("We got disconnected")
  1487.       $Disconnects+=1
  1488.       RefreshStats()
  1489.       $DisconnectState = 1
  1490.      
  1491.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1492.       Return "Network connection lost"
  1493.    EndIf
  1494.    
  1495.    $Array = StringSplit($ImageFiles[6][1],"|")
  1496.    $File = $Array[1]
  1497.    $Accuracy = $Array[2]
  1498.    
  1499.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
  1500.    If $Target = 1 Then
  1501.       ToLog("We got totally disconnected")
  1502.       If $DisconnectState = 0 Then
  1503.          $Disconnects+=1
  1504.          RefreshStats()
  1505.       EndIf
  1506.       $DisconnectState = 2
  1507.      
  1508.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1509.       InLoginScreen()  
  1510.      
  1511.       If $UseRelogging = True Then
  1512.          Relog()
  1513.          Return "Relogged"
  1514.       Else
  1515.          Terminate()
  1516.       EndIf
  1517.    EndIf
  1518.    Return "Connected"
  1519. EndFunc
  1520.  
  1521. Func CheckForDeath()
  1522.    If $Alive = True Then
  1523.       $Death = PixelSearch($DeathSearchArea[0], $DeathSearchArea[1], $DeathSearchArea[2], $DeathSearchArea[3], 0xFFFFFF)
  1524.       If Not @error Then
  1525.          $Alive = False
  1526.          ToLog("We are dead... :(")
  1527.          $Deaths+=1
  1528.          RefreshStats()
  1529.          LeaveGame()
  1530.          Return "LeftGame"
  1531.       EndIf
  1532.    EndIf
  1533.    Return "Alive"
  1534. EndFunc
  1535.  
  1536.  
  1537. ;Miscellaneous
  1538. Func ScriptStarted()
  1539.    CheckRequiredFiles()
  1540.    
  1541.    If $LootLegendaries Then
  1542.       Global $Legendaries   = 0
  1543.    Else
  1544.       Global $Legendaries   = "-"
  1545.    EndIf
  1546.    
  1547.    If $LootSets Then
  1548.       Global $Sets          = 0
  1549.    Else
  1550.       Global $Sets          = "-"
  1551.    EndIf
  1552.    
  1553.    If $LootRares Then
  1554.       Global $Rares         = 0
  1555.    Else
  1556.       Global $Rares         = "-"
  1557.    EndIf
  1558.    
  1559.    If $LootMagics Then
  1560.       Global $Magics        = 0
  1561.       Global $Tomes         = "-"
  1562.    Else
  1563.       Global $Magics        = "-"
  1564.       If $LootTomes Then
  1565.          Global $Tomes      = "0"
  1566.       Else
  1567.          Global $Tomes      = "-"
  1568.       EndIf
  1569.    EndIf
  1570.    
  1571.    If $LootGems Then
  1572.       Global $Gems          = 0
  1573.    Else
  1574.       Global $Gems          = "-"
  1575.    EndIf
  1576.    
  1577.    If $Sell Then
  1578.       Global $Sold          = 0
  1579.    Else
  1580.       Global $Sold          = "-"
  1581.    EndIf
  1582.    
  1583.    Pause()
  1584.    
  1585.    $RuntimeTimer = TimerInit()
  1586.  
  1587.    If $ShowLog = True Then
  1588.       DrawLog()
  1589.    EndIf
  1590.    
  1591.    If $ShowLog = True Or $SaveStats = True Then
  1592.       DirGetSize($SaveLogsPath)
  1593.       If @error= 1 Then
  1594.          DirCreate($SaveLogsPath)
  1595.       EndIf  
  1596.    EndIf
  1597.    
  1598.    ToLog("Bot started")
  1599.    
  1600.    WinActivate('Diablo III')  
  1601. EndFunc
  1602.  
  1603. Func CheckRequiredFiles()
  1604.    If (@OSArch = "X64" or @OSArch = "IA64") And Not @AutoItX64 Then
  1605.       MsgBox(4096, "Error", "You are running a 64bit system. You need to start the script" & @LF & "with 'Run Script (x64)' or 'Compile Script (x64)'" & @LF & "Exiting...")
  1606.       Exit 0
  1607.    EndIf
  1608.    
  1609.    Local $Files[3]
  1610.    $Files[0] = "msvcr110.dll"
  1611.    $Files[1] = "msvcr110d.dll"
  1612.    
  1613.    If @AutoItX64 Then
  1614.       $Files[2] = "ImageSearchDLL_x64.dll"
  1615.    Else
  1616.       $Files[2] = "ImageSearchDLL.dll"
  1617.    EndIf
  1618.    
  1619.    
  1620.    For $i = 0 to 2
  1621.       If Not FileExists(@WindowsDir & "\System32\" & $Files[$i]) Then
  1622.          If Not FileExists($Files[$i]) Then
  1623.             MsgBox(4096, "Error", "Couldn't find '" & $Files[$i] & "'." & @LF & "Make sure you have put that file into '" & @WindowsDir & "\System32\' or into the script folder." & @LF & "Exiting...")
  1624.             Exit 0
  1625.         EndIf
  1626.       EndIf
  1627.    Next
  1628.    
  1629.    For $i = 0 to UBound($ImageFiles, 1)-1
  1630.       For $x = 0 to UBound($ImageFiles, 2)-1
  1631.          If Not $ImageFiles[$i][$x] = "" Then
  1632.             $Array = StringSplit($ImageFiles[$i][$x], "|")
  1633.             $File = $Array[1]
  1634.             If Not FileExists($ImgDir & $File) Then
  1635.                MsgBox(4096, "Error", "Couldn't find '" & $File & "'." & @LF & "Either you have set the path to the image folder wrong or you haven't downloaded the latest required files." & @LF & "Exiting...")
  1636.                Exit 0
  1637.             EndIf
  1638.          EndIf
  1639.       Next
  1640.    Next
  1641. EndFunc
  1642.  
  1643. Func Pause()
  1644.    $Paused = Not $Paused
  1645.    If $Paused Then ToLog("Paused...")
  1646.      
  1647.    While $Paused
  1648.       Sleep(250)
  1649.       ToolTip('Paused... Press {PAUSE} to continue...', 850, 0)
  1650.    WEnd
  1651.    
  1652.    ToolTip("")
  1653. EndFunc
  1654.  
  1655. Func Initialize()
  1656.    OnAutoItExitRegister ('OnAutoItExit')
  1657.    Opt('MouseCoordMode', 2)
  1658.    Opt('PixelCoordMode', 2)
  1659.  
  1660.    HotKeySet('{PAUSE}', 'Pause')
  1661.    HotKeySet('{END}', 'Terminate')
  1662.  
  1663.    Global $LootAreaGUI
  1664.    Global $ImageFiles[8][7]
  1665.    Global $SoundFiles[6]
  1666.    Global $PasswordField[2]
  1667.    Global $ResumeButton[2]
  1668.    Global $LeaveButton[2]
  1669.    Global $DisconnectButton[2]
  1670.    Global $SalvageButton[2]
  1671.    Global $MoveToCellar1[2]
  1672.    Global $MoveToCellar2[2]
  1673.    Global $MoveToCellar3[2]
  1674.    Global $MoveInCellar1[2]
  1675.    Global $MoveInCellar2[2]
  1676.    Global $MoveToGoldLoot1a[2]
  1677.    Global $MoveToGoldLoot1b[2]         
  1678.    Global $MoveToGoldLoot2[2]          
  1679.    Global $MoveToGoldLoot3[2]  
  1680.    Global $MoveToSalvage1[2]
  1681.    Global $MoveToSalvage2[2]
  1682.    Global $MoveToMerchant[2]
  1683.    Global $MoveToStash1[2]
  1684.    Global $MoveToStash2[2]
  1685.    Global $CellarLocation[2]   
  1686.    Global $MonsterLocation[2]
  1687.    Global $SalvageLocation[2]
  1688.    Global $MerchantLocation[2]
  1689.    Global $StashLocation[2]
  1690.    Global $PortalLocation[2]
  1691.    Global $CharHitBox[4]
  1692.    Global $LoginButtonSearchArea[4]
  1693.    Global $ResumeButtonSearchArea[4]
  1694.    Global $PortalIconSearchArea[4]
  1695.    Global $CellarSearchArea[4]
  1696.    Global $CellarNameSearchArea[4]
  1697.    Global $TownNameSearchArea[4]
  1698.    Global $MerchStashSearchArea[4]
  1699.    Global $MonsterSearchArea[4]
  1700.    Global $LootingArea[4]
  1701.    Global $FullBagSearchArea[4]
  1702.    Global $SellItemsArea[4]
  1703.    Global $FullStashSearchArea[4]
  1704.    Global $RepairSearchArea[4] 
  1705.    Global $DeathSearchArea[4]
  1706.    Global $DisconnectSearchArea[4]
  1707.    Global $StashBag2[2]
  1708.    Global $StashBag3[2]
  1709.    Global $RepairButton[2]
  1710.    Global $AllItemsButton[2]
  1711.    Global $CellarOffset
  1712.    Global $CellarPixel
  1713.    Global $Log
  1714.    Global $Label
  1715.    Global $LogList
  1716.    Global $RuntimeTimer
  1717.    Global $TimeOutTimer
  1718.    Global $RunTimer
  1719.    Global $Paused
  1720.    Global $LegendaryLootAttempts    = 0
  1721.    Global $SetLootAttempts          = 0
  1722.    Global $RareLootAttempts         = 0
  1723.    Global $MagicLootAttempts        = 0
  1724.    Global $TomeLootAttempts         = 0
  1725.    Global $GemLootAttempts          = 0
  1726.    Global $StartTime                = @HOUR & ":" & @MIN
  1727.    Global $Runs                     = 0
  1728.    Global $Closed                   = 0
  1729.    Global $Runtime                  = "0h 0m 0s"
  1730.    Global $Disconnects              = 0
  1731.    Global $Deaths                   = 0
  1732.    Global $ISx                      = 0
  1733.    Global $ISy                      = 0
  1734.    Global $StashBag                 = 1
  1735.    Global $Alive                    = True
  1736.    Global $DisconnectState          = 0
  1737.    Global $FullBag                  = False
  1738.    Global $TimeOutCount             = 0
  1739.    Global $Relogged                 = False
  1740.    Global $SellCheck
  1741.    Global $SleepToSalvage
  1742.    Global $SleepToStash
  1743.  
  1744.    $ImageFiles[0][0]            = "legendaryA.png|65"
  1745.    $ImageFiles[0][1]            = "legendaryE.png|65"
  1746.    $ImageFiles[0][2]            = "legendaryI.png|65"
  1747.    $ImageFiles[0][3]            = "legendaryO.png|65"
  1748.    $ImageFiles[0][4]            = "legendaryU.png|65"
  1749.    
  1750.    $ImageFiles[1][0]            = "setA.png|90"
  1751.    $ImageFiles[1][1]            = "setE.png|90"
  1752.    $ImageFiles[1][2]            = "setU.png|90"
  1753.    $ImageFiles[1][3]            = "setO.png|90"
  1754.    $ImageFiles[1][4]            = "setI.png|90"
  1755.    
  1756.    $ImageFiles[2][0]            = "rareA.png|102"
  1757.    $ImageFiles[2][1]            = "rareE.png|102"
  1758.    $ImageFiles[2][2]            = "rareI.png|102"
  1759.    $ImageFiles[2][3]            = "rareO.png|102"
  1760.    $ImageFiles[2][4]            = "rareU.png|102"
  1761.    
  1762.    $ImageFiles[3][0]            = "blueA.png|70"
  1763.    $ImageFiles[3][1]            = "blueE.png|70"
  1764.    $ImageFiles[3][2]            = "blueI.png|70"
  1765.    $ImageFiles[3][3]            = "blueO.png|70"
  1766.    $ImageFiles[3][4]            = "blueU.png|70"
  1767.    
  1768.    $ImageFiles[4][0]            = "tome.png|140"
  1769.    $ImageFiles[4][1]            = "uare.png|110"
  1770.    $ImageFiles[4][2]            = "iLVL60.png|30"
  1771.    $ImageFiles[4][3]            = "iLVL61.png|30"
  1772.    $ImageFiles[4][4]            = "iLVL62.png|30"
  1773.    $ImageFiles[4][5]            = "iLVL63.png|30"
  1774.    
  1775.    $ImageFiles[5][0]            = "empty.png|75"
  1776.    $ImageFiles[5][1]            = "corner.png|10"
  1777.    $ImageFiles[5][2]            = "sellblueA.png|30"
  1778.    $ImageFiles[5][3]            = "sellblueE.png|30"
  1779.    $ImageFiles[5][4]            = "sellblueI.png|30"
  1780.    $ImageFiles[5][5]            = "sellblueO.png|30"
  1781.    $ImageFiles[5][6]            = "sellblueU.png|30"
  1782.    
  1783.    $ImageFiles[6][0]            = "network.png|10"
  1784.    $ImageFiles[6][1]            = "lost.png|10"
  1785.    $ImageFiles[6][2]            = "bg.jpg|5"
  1786.    $ImageFiles[6][3]            = "not.png|120"
  1787.    $ImageFiles[6][4]            = "you.png|100"
  1788.    
  1789.    $ImageFiles[7][0]            = "dank.png|120"
  1790.    $ImageFiles[7][1]            = "new.png|120"
  1791.    $ImageFiles[7][2]            = "game.png|20"
  1792.    $ImageFiles[7][3]            = "portal.png|120"
  1793.    $ImageFiles[7][4]            = "login.png|10"
  1794.    $ImageFiles[7][5]            = "merchant.png|20"
  1795.    $ImageFiles[7][6]            = "stash.png|20"
  1796.  
  1797.    $SoundFiles[0]               = "legendary.wav"
  1798.    $SoundFiles[1]               = "set.wav"
  1799.    $SoundFiles[2]               = "rare.wav"
  1800.    $SoundFiles[3]               = "magic.wav"
  1801.    $SoundFiles[4]               = "tome.wav"
  1802.    $SoundFiles[5]               = "gem.wav"
  1803.  
  1804.    $CharHitBox[0]               = 790
  1805.    $CharHitBox[1]               = 315
  1806.    $CharHitBox[2]               = 1200
  1807.    $CharHitBox[3]               = 730
  1808.  
  1809.    $LoginButtonSearchArea[0]    = 930
  1810.    $LoginButtonSearchArea[1]    = 845
  1811.    $LoginButtonSearchArea[2]    = 985
  1812.    $LoginButtonSearchArea[3]    = 860
  1813.  
  1814.    $ResumeButtonSearchArea[0]   = 250
  1815.    $ResumeButtonSearchArea[1]   = 410
  1816.    $ResumeButtonSearchArea[2]   = 310
  1817.    $ResumeButtonSearchArea[3]   = 425
  1818.  
  1819.    $PortalIconSearchArea[0]     = 1095
  1820.    $PortalIconSearchArea[1]     = 1000
  1821.    $PortalIconSearchArea[2]     = 1140
  1822.    $PortalIconSearchArea[3]     = 1060
  1823.    
  1824.    $CellarSearchArea[0]         = 164
  1825.    $CellarSearchArea[1]         = 0
  1826.    $CellarSearchArea[2]         = 375
  1827.    $CellarSearchArea[3]         = 110
  1828.  
  1829.    $CellarNameSearchArea[0]     = 1760
  1830.    $CellarNameSearchArea[1]     = 10
  1831.    $CellarNameSearchArea[2]     = 1820
  1832.    $CellarNameSearchArea[3]     = 30
  1833.  
  1834.    $TownNameSearchArea[0]       = 1745
  1835.    $TownNameSearchArea[1]       = 10
  1836.    $TownNameSearchArea[2]       = 1795
  1837.    $TownNameSearchArea[3]       = 30
  1838.  
  1839.    $MerchStashSearchArea[0]     = 225
  1840.    $MerchStashSearchArea[1]     = 30
  1841.    $MerchStashSearchArea[2]     = 300
  1842.    $MerchStashSearchArea[3]     = 115
  1843.  
  1844.    $MonsterSearchArea[0]        = 170
  1845.    $MonsterSearchArea[1]        = 75
  1846.    $MonsterSearchArea[2]        = 1270
  1847.    $MonsterSearchArea[3]        = 470
  1848.  
  1849.    $FullBagSearchArea[0]        = 795
  1850.    $FullBagSearchArea[1]        = 125
  1851.    $FullBagSearchArea[2]        = 830
  1852.    $FullBagSearchArea[3]        = 160
  1853.  
  1854.    $SellItemsArea[0]            = 960
  1855.    $SellItemsArea[1]            = 510
  1856.    $SellItemsArea[2]            = 1680
  1857.    $SellItemsArea[3]            = 910
  1858.  
  1859.    $FullStashSearchArea[0]      = 700
  1860.    $FullStashSearchArea[1]      = 135
  1861.    $FullStashSearchArea[2]      = 730
  1862.    $FullStashSearchArea[3]      = 155
  1863.  
  1864.    $RepairSearchArea[0]         = 1507
  1865.    $RepairSearchArea[1]         = 36
  1866.    $RepairSearchArea[2]         = 1512
  1867.    $RepairSearchArea[3]         = 41
  1868.  
  1869.    $DeathSearchArea[0]          = 538
  1870.    $DeathSearchArea[1]          = 335
  1871.    $DeathSearchArea[2]          = 542
  1872.    $DeathSearchArea[3]          = 339
  1873.  
  1874.    $DisconnectSearchArea[0]     = 840
  1875.    $DisconnectSearchArea[1]     = 410
  1876.    $DisconnectSearchArea[2]     = 950
  1877.    $DisconnectSearchArea[3]     = 440
  1878.  
  1879.    $CellarOffset                = 33
  1880. EndFunc
  1881.  
  1882. Func Randomize()
  1883.    $MoveToCellar1[0]        = Random(498, 503, 1)
  1884.    $MoveToCellar1[1]        = Random(248, 253, 1)
  1885.    $MoveToCellar2[0]        = Random(1, 4, 1)
  1886.    $MoveToCellar2[1]        = Random(368, 373, 1)
  1887.    $MoveToCellar3[0]        = Random(398, 403, 1)
  1888.    $MoveToCellar3[1]        = Random(598, 603, 1)  
  1889.  
  1890.    $MoveInCellar1[0]        = Random(114, 119, 1)
  1891.    $MoveInCellar1[1]        = Random(984, 989, 1)          
  1892.    $MoveInCellar2[0]        = Random(774, 779, 1)
  1893.    $MoveInCellar2[1]        = Random(326, 331, 1)
  1894.  
  1895.    $MoveToGoldLoot1a[0]     = Random(400, 405, 1)
  1896.    $MoveToGoldLoot1a[1]     = Random(304, 309, 1)
  1897.    $MoveToGoldLoot1b[0]     = Random(560, 575, 1)
  1898.    $MoveToGoldLoot1b[1]     = Random(300, 305, 1)
  1899.    $MoveToGoldLoot2[0]      = Random(1258, 1263, 1)
  1900.    $MoveToGoldLoot2[1]      = Random(349, 354, 1)
  1901.    $MoveToGoldLoot3[0]      = Random(909, 914, 1)
  1902.    $MoveToGoldLoot3[1]      = Random(692, 697, 1)
  1903.  
  1904.    $MoveToMerchant[0]       = Random(1688, 1693, 1)
  1905.    $MoveToMerchant[1]       = Random(100, 105, 1)
  1906.    $MerchantLocation[0]     = Random(928, 933, 1)
  1907.    $MerchantLocation[1]     = Random(134, 139, 1)
  1908.  
  1909.    If $Salvage = False Then
  1910.       If $Sell = True Then
  1911.          $MoveToStash1[0]       = Random(778, 783, 1)
  1912.          $MoveToStash1[1]       = Random(948, 953, 1)
  1913.          $MoveToStash2[0]       = Random(268, 273, 1)
  1914.          $MoveToStash2[1]       = Random(928, 933, 1)
  1915.          $StashLocation[0]      = Random(803, 808, 1)
  1916.          $StashLocation[1]      = Random(428, 433, 1)
  1917.          $PortalLocation[0]     = Random(648, 653, 1)
  1918.          $PortalLocation[1]     = Random(498, 503, 1)
  1919.       Else
  1920.          $StashLocation[0]      = Random(1047, 1052, 1)
  1921.          $StashLocation[1]      = Random(257, 262, 1)
  1922.          $PortalLocation[0]     = Random(877, 882, 1)
  1923.          $PortalLocation[1]     = Random(427, 432, 1)
  1924.       EndIf
  1925.    Else
  1926.       If $Sell = False Then
  1927.          $MoveToSalvage1[0]     = Random(1397, 1402, 1)
  1928.          $MoveToSalvage1[1]     = Random(497, 502, 1)
  1929.          $MoveToSalvage2[0]     = Random(1497, 1502, 1)
  1930.          $MoveToSalvage2[1]     = Random(497, 502, 1)
  1931.          $SalvageLocation[0]    = Random(1280, 1285, 1)
  1932.          $SalvageLocation[1]    = Random(397, 402, 1)
  1933.          $MoveToStash1[0]       = Random(397, 402, 1)
  1934.          $MoveToStash1[1]       = Random(482, 487, 1)
  1935.          $MoveToStash2[0]       = Random(597, 602, 1)
  1936.          $MoveToStash2[1]       = Random(447, 452, 1)
  1937.          $StashLocation[0]      = Random(852, 857, 1)
  1938.          $StashLocation[1]      = Random(347, 352, 1)
  1939.          $PortalLocation[0]     = Random(782, 787, 1)
  1940.          $PortalLocation[1]     = Random(427, 432, 1)
  1941.          $SleepToSalvage        = 1250
  1942.          $SleepToStash          = 1325
  1943.       Else
  1944.          $MoveToSalvage1[0]     = Random(812, 817, 1)
  1945.          $MoveToSalvage1[1]     = Random(957, 962, 1)
  1946.          $MoveToSalvage2[0]     = Random(937, 942, 1)
  1947.          $MoveToSalvage2[1]     = Random(942, 947, 1)
  1948.          $SalvageLocation[0]    = Random(1577, 1582, 1)
  1949.          $SalvageLocation[1]    = Random(587, 592, 1)
  1950.          $MoveToStash1[0]       = Random(397, 402, 1)
  1951.          $MoveToStash1[1]       = Random(482, 487, 1)
  1952.          $MoveToStash2[0]       = Random(597, 602, 1)
  1953.          $MoveToStash2[1]       = Random(447, 452, 1)
  1954.          $StashLocation[0]      = Random(870, 875, 1)
  1955.          $StashLocation[1]      = Random(382, 387, 1)
  1956.          $PortalLocation[0]     = Random(747, 752, 1)
  1957.          $PortalLocation[1]     = Random(447, 452, 1)
  1958.          $SleepToSalvage        = 1550
  1959.          $SleepToStash          = 1550
  1960.       EndIf
  1961.    EndIf
  1962.  
  1963.    $CellarLocation[0]       = Random(305, 309, 1)
  1964.    $CellarLocation[1]       = Random(72, 76, 1)
  1965.  
  1966.    $MonsterLocation[0]      = Random(575, 580, 1)
  1967.    $MonsterLocation[1]      = Random(181, 186, 1)
  1968.  
  1969.    $StashBag2[0]            = Random(508, 513, 1)
  1970.    $StashBag2[1]            = Random(358, 363, 1)
  1971.  
  1972.    $StashBag3[0]            = Random(508, 513, 1)
  1973.    $StashBag3[1]            = Random(488, 493, 1)
  1974.  
  1975.    $RepairButton[0]         = Random(515, 520, 1)
  1976.    $RepairButton[1]         = Random(481, 486, 1)
  1977.  
  1978.    $AllItemsButton[0]       = Random(221, 226, 1)
  1979.    $AllItemsButton[1]       = Random(590, 595, 1)
  1980.    
  1981.    $PasswordField[0]        = Random(818, 823, 1)
  1982.    $PasswordField[1]        = Random(703, 708, 1)
  1983.  
  1984.    $ResumeButton[0]         = Random(317, 322, 1)
  1985.    $ResumeButton[1]         = Random(414, 419, 1)
  1986.  
  1987.    $LeaveButton[0]          = Random(967, 972, 1)
  1988.    $LeaveButton[1]          = Random(580, 584, 1)
  1989.  
  1990.    $DisconnectButton[0]     = Random(958, 963, 1)
  1991.    $DisconnectButton[1]     = Random(628, 633, 1)
  1992.    
  1993.    $SalvageButton[0]        = Random(262, 267, 1)
  1994.    $SalvageButton[1]        = Random(292, 297, 1)
  1995. EndFunc
  1996.  
  1997. Func RandomizeInventory()
  1998.    Global $Stash[60][2]
  1999.    $c = 0
  2000.    $d = -2
  2001.    For $a = 0 to 59
  2002.       $d+=1
  2003.       If $a = 10 or $a = 20 or $a = 30 or $a = 40 or $a = 50 Then
  2004.          $c+=1
  2005.          $d=-1
  2006.       EndIf
  2007.       For $b = 0 to 1
  2008.             If $b = 0 Then
  2009.                $Stash[$a][$b] = Random(1473, 1483, 1) + (49 * $d)
  2010.             Else
  2011.                $Stash[$a][$b] = Random(606, 614, 1) + (49 * $c)
  2012.             EndIf
  2013.       Next
  2014.    Next
  2015. EndFunc
  2016.  
  2017. Func DrawLootArea()
  2018.    $LootingAreaWidth    = $LootingArea[2] - $LootingArea[0]
  2019.    $LootingAreaHeight   = $LootingArea[3] - $LootingArea[1]
  2020.    $LootAreaGUI = GUICreate("", $LootingAreaWidth + 2, $LootingAreaHeight + 2, $LootingArea[0], $LootingArea[1], $WS_POPUP, BitOR($WS_EX_LAYERED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  2021.    GuiSetBkColor(0xABCDEF)
  2022.    _WinAPI_SetLayeredWindowAttributes($LootAreaGUI, 0xABCDEF, 0xA0)
  2023.    WinSetOnTop($LootAreaGUI, "", 1)
  2024.    GUISetState(@SW_SHOWNOACTIVATE, $LootAreaGUI)
  2025.    $hDC = _WinAPI_GetWindowDC($LootAreaGUI)
  2026.    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x0000FF)
  2027.    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
  2028.    $user32_dll = DllOpen("user32.dll")
  2029.    _WinAPI_DrawLine($hDC, 0, 1, $LootingAreaWidth, 0)
  2030.    _WinAPI_DrawLine($hDC, 1, 0, 0, $LootingAreaHeight)
  2031.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, $LootingAreaWidth, 0)
  2032.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, 0, $LootingAreaHeight)
  2033.    
  2034.    _WinAPI_SetTextColor($hDC, 0x0000FF)
  2035.    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
  2036.    
  2037.    $tRECT = DllStructCreate($tagRect)
  2038.    DllStructSetData($tRECT, "Left", 5)
  2039.    DllStructSetData($tRECT, "Top", 5)
  2040.    DllStructSetData($tRECT, "Right", 250)
  2041.    DllStructSetData($tRECT, "Bottom", 50)
  2042.    
  2043.    _WinAPI_DrawText($hDC, "Loot Area", $tRect, 0)
  2044. EndFunc
  2045.  
  2046. Func DrawLog()
  2047.    $Width = 475
  2048.    $Height = 200
  2049.    $LogGUI = GUICreate("", $Width, $Height, 900 - $Width, 1080 - $Height - 2, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  2050.    GuiSetBkColor(0x000000)
  2051.    GUICtrlCreatePic($ImgDir & StringTrimRight($ImageFiles[6][2],2), 0, 0, 0, 0)
  2052.    _WinAPI_SetLayeredWindowAttributes($LogGUI, 0xEEEEEF, 0xEE) ;0xA0
  2053.    WinSetOnTop($LogGUI, "", 1)
  2054.    GUISetState(@SW_SHOWNOACTIVATE, $LogGUI)
  2055.    
  2056.    $Label = GUICtrlCreateLabel("", 0, 10, $Width, 100, $SS_CENTER)
  2057.    GUICtrlSetFont($Label, 8, 500, 0, "")
  2058.    GuiCtrlSetColor($Label, 0xFFFFFF)
  2059.    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
  2060.    
  2061.    $Version = GUICtrlCreateLabel("", 2, 2, 20, 20, $SS_CENTER)
  2062.    GUICtrlSetFont($Version, 7, 500, 0, "")
  2063.    GuiCtrlSetColor($Version, 0x000000)
  2064.    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
  2065.    GUICtrlSetData($Version, "v1.3")
  2066.    
  2067.    $Copyright = GUICtrlCreateLabel("", $Width-52, 2, 50, 20, $SS_CENTER)
  2068.    GUICtrlSetFont($Copyright, 7, 500, 0, "")
  2069.    GuiCtrlSetColor($Copyright, 0x000000)
  2070.    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
  2071.    GUICtrlSetData($Copyright, "©zEEneXx")
  2072.    
  2073.    $LogList = GUICtrlCreateList("", 5, 60, $Width - 10, $Height - 60, $LBS_NOSEL)
  2074.    GUICtrlSetColor($LogList, 0x000000)
  2075.    GUICtrlSetFont($LogList, 8)
  2076.    
  2077.    RefreshStats()
  2078. EndFunc
  2079.  
  2080. Func RefreshStats()
  2081.    If $ShowLog = True Then
  2082.       GUICtrlSetData($Label, "Start: " & $StartTime & "  |  Runs: " & $Runs & "  |  Closed:  " & $Closed & "  |  Deaths: " & $Deaths & "  |  Disconnects: " & $Disconnects & @LF & @LF & "Legendaries: " & $Legendaries & "  |  Sets: " & $Sets & "  |  Rares: " & $Rares & "  |  Magics: " & $Magics & "  |  Tomes: " & $Tomes & "  |  Gems: " & $Gems & "  |  Sold: " & $Sold)
  2083.    EndIf
  2084. EndFunc
  2085.  
  2086. Func ToLog($Text)
  2087.    If $ShowLog = True Then
  2088.       GUICtrlSetData($LogList, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  2089.       GUICtrlSendMsg($LogList, $WM_VSCROLL, $SB_LINEDOWN, 0)
  2090.    
  2091.       $Log = FileOpen($SaveLogsPath & "log.txt", 1)
  2092.       FileWriteLine($Log, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  2093.       If $Text = "Bot closed" Then
  2094.          FileWriteLine($Log, @LF)  
  2095.       EndIf
  2096.       FileClose($Log)
  2097.    EndIf
  2098. EndFunc
  2099.  
  2100. Func Relog()
  2101.    ToLog("Relogging...")
  2102.    MouseClick("LEFT", $PasswordField[0], $PasswordField[1], 1, 5)
  2103.    Send($Password)
  2104.    
  2105.    Sleep(1000 + $Computerlag)
  2106.    Send("{ENTER}")
  2107.    
  2108.    $Relogged = True
  2109.    $DisconnectState = 0
  2110. EndFunc
  2111.  
  2112. Func SaveStats()
  2113.    $File = FileOpen($SaveLogsPath & "statistics.txt", 1)
  2114.    FileWriteLine($File, "=========" & @HOUR & ":" & @MIN & ":" & @SEC & "=========")
  2115.    FileWriteLine($File, "Startime: " & @TAB & @TAB & $StartTime & @LF & "Runs: " & @TAB & @TAB & $Runs & @LF & "Closed: " & @TAB & @TAB & $Closed & @LF & "Deaths: " & @TAB & @TAB & $Deaths & @LF & "Disconnects: " & @TAB & $Disconnects & @LF & "Runtime: " & @TAB & @TAB & $Runtime & @LF & @LF & "Legendaries: " & @TAB & $Legendaries & @LF & "Sets: " & @TAB & @TAB & $Sets & @LF & "Rares: " & @TAB & @TAB & $Rares & @LF & "Magics: " & @TAB & @TAB & $Magics & @LF & "Tomes: " & @TAB & @TAB & $Tomes & @LF & "Gems: " & @TAB & @TAB & $Gems & @LF & "Sold: " & @TAB & @TAB & $Sold)
  2116.    FileWriteLine($File, @LF)
  2117.    FileClose($File)
  2118. EndFunc
  2119.  
  2120. Func Move($x, $y)
  2121.    MouseClick('MIDDLE', $x, $y, 1, 5)
  2122. EndFunc
  2123.  
  2124. Func Attack($x, $y)
  2125.    Send("{SHIFTDOWN}")
  2126.    MouseClick('LEFT', $x, $y, 1, 2)
  2127.    Send("{SHIFTUP}")
  2128. EndFunc
  2129.  
  2130. Func AttackNearbyMonsters()
  2131.    $Logged = False
  2132.    While 1
  2133.       $MonsterData =  PixelSearch($CharHitBox[0], $CharHitBox[1], $CharHitBox[2], $CharHitBox[3], 0xEE0000, 10)
  2134.       If @error Then
  2135.          ExitLoop
  2136.       EndIf
  2137.      
  2138.       If $Logged = False Then
  2139.          ToLog("Monster found...")
  2140.       EndIf
  2141.          
  2142.       Attack($MonsterData[0], $MonsterData[1])
  2143.       Sleep(100)
  2144.      
  2145.       $Logged = True
  2146.    WEnd
  2147. EndFunc
  2148.  
  2149. Func LeaveGame()
  2150.    $Sek     = Floor(TimerDiff($RuntimeTimer) / 1000)
  2151.    $Min     = Floor($Sek / 60)
  2152.    $Hour    = Floor($Min / 60)
  2153.    $Runtime = $Hour & "h " & ($Min - $Hour * 60) & "m " & ($Sek - $Min * 60) & "s"
  2154.    If $SaveStats = True Then
  2155.       SaveStats()
  2156.    EndIf
  2157.    
  2158.    ToLog("Leaving the game")
  2159.      
  2160.    Sleep(200 + ($Computerlag/2))
  2161.    
  2162.    Send("{ESC}")
  2163.    Sleep(100 + ($Computerlag/2))
  2164.      
  2165.    MouseClick('LEFT', $LeaveButton[0], $LeaveButton[1], 1, 5)
  2166.    Return "LeftGame"
  2167. EndFunc
  2168.  
  2169. Func Terminate()
  2170.    ToLog("Terminating... Good bye :)")
  2171.    Exit 0
  2172. EndFunc
  2173.  
  2174. Func _ImageSearchArea($FindImage,$ResultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $Tolerance)
  2175.     If $Tolerance > 0 Then $FindImage = "*" & $Tolerance & " " & $FindImage
  2176.        
  2177.     If @AutoItX64 Then
  2178.          $Result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  2179.       Else
  2180.          $Result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  2181.       EndIf
  2182.      
  2183.    If $Result = "0" Then Return 0
  2184.      
  2185.    $Array = StringSplit($Result[0],"|")
  2186.    
  2187.    If(UBound($Array) >= 4) Then
  2188.       $x=Int(Number($Array[2]))
  2189.       $y=Int(Number($Array[3]))
  2190.      
  2191.       If $ResultPosition=1 Then
  2192.          $x=$x + Int(Number($Array[4])/2)
  2193.          $y=$y + Int(Number($Array[5])/2)
  2194.       Endif
  2195.       Return 1
  2196.    EndIf
  2197. EndFunc
  2198.  
  2199. Func OnAutoItExit()
  2200.    $Sek     = Floor(TimerDiff($RuntimeTimer) / 1000)
  2201.    $Min     = Floor($Sek / 60)
  2202.    $Hour    = Floor($Min / 60)
  2203.    $Runtime = $Hour & "h " & ($Min - $Hour * 60) & "m " & ($Sek - $Min * 60) & "s"
  2204.    If $SaveStats = True Then
  2205.       SaveStats()
  2206.    EndIf
  2207.    ToLog("Bot closed")
  2208. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement