Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.3c_memoryfixed__zeenexx

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