Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.4_zeenexx

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