Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.2_zeenexx_hotfixed

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