Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 25.42 KB | None | 0 0
  1. #include <Array.au3>
  2.  
  3. ; BINDINGS
  4. HotKeySet("{F7}", "_exit")
  5.  
  6. Global Const $iTrue = 1
  7. Global Const $iFalse = 0
  8.  
  9. ; Minimap
  10. Global Const $arrMiniMap[4] = ["8", "808", "269", "1067"]
  11.  
  12. ; Lane Corridors
  13. Global Const $arrCorridorRadSafe[4] = ["61", "1039", "256", "1057"] ; Radiant Safe 61,1039 | 256,1057
  14. Global Const $arrCorridorDireOff[4] = ["239", "881", "258", "1054"] ; Dire Offlane 239,881 | 258,1054
  15. Global Const $arrCorridorDireSafe[4] = ["20", "820", "202", "840"] ; Dire Safe 20,820 |202,840
  16. Global Const $arrCorridorRadOff[4] = ["9", "824", "35", "1001"] ; Radiant Offlane 9,824 | 35,1001
  17. Global Const $arrCorridorMid[4] = ["53", "865", "213", "1029"] ; Mid Lane 53,865 | 213,1029
  18.  
  19.  
  20. ; Player Colors
  21. Global Const $arrColorPlayersRadiant[5] = ["2777816", "5824422", "11206827", "13881608", "14572544"]
  22. Global Const $arrColorPlayersDire[5] = ["14578857", "14513320", "9346622", "28699", "9394944"]
  23. Global Const $iColorPlayerCircle = 15921906
  24. Global Const $iColorLevelUp = 14269272
  25. Global Const $iColorHealth = 4502831
  26.  
  27. Global Const $iColorNeutralCamp = 6964480
  28. Global Const $iColorNeutralUnit = 11184810
  29.  
  30. ; Radiant Camp Positions
  31. Global Const $arrRadiantCamps_X[9] = ["228", "195", "145", "134", "106", "141", "73", "48", "95"]
  32. Global Const $arrRadiantCamps_Y[9] = ["1017", "1023", "1023", "997", "1017", "973", "922", "945", "952"]
  33.  
  34. ; Radiant Camp Positions
  35. Global Const $arrDireCamps_X[9] = ["64", "97", "107", "166", "137", "123", "184", "221", "216"]
  36. Global Const $arrDireCamps_Y[9] = ["878", "852", "858", "880", "879", "899", "937", "926", "944"]
  37.  
  38. ;Buildings
  39. Global Const $iColor_Frindly_Building = 8385024
  40. Global Const $iColor_Enemy_Building_Fog = 16711680
  41. Global Const $iColor_Enemy_Building = 16711680
  42.  
  43. ; Safelane Mid Offlane
  44. Global Const $arrRadiant_Tower_PosX[9] = ["228", "137", "68", "111", "77", "55", "26", "28", "20"]
  45. Global Const $arrRadiant_Tower_PosY[9] = ["1049", "1051", "1049", "964", "985", "1012", "905", "955", "1000"]
  46.  
  47. Global Const $arrDire_Tower_PosX[9] = ["54", "139", "204", "149", "184", "216", "252", "252", "254"]
  48. Global Const $arrDire_Tower_PosY[9] = ["830", "830", "834", "925", "898", "868", "969", "932", "884"]
  49.  
  50. ; Units
  51. Global Const $iColor_Frindly_Creep = 5415168
  52. Global Const $iColor_Enemy_Unit = 11141120
  53.  
  54. Global $iColorPlayer = 0
  55.  
  56.  
  57. ;-------------------------------------------
  58. ; @@@@@@@ MAIN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  59. ;-------------------------------------------
  60. While 1
  61.     Sleep(100)
  62.     _main()
  63. WEnd
  64.  
  65.  
  66.  
  67. Func _main()
  68.     ; Random Test Code
  69.     $posPlay = _findUnitPosition($arrMiniMap,$arrColorPlayersDire[0])
  70.     $posE = _findNextWave($posPlay)
  71.     _AttackAndMovement(1,$posE)
  72.     _tt("Pos Player | X: " & $posPlay[0] & " Y: " & $posPlay[1])
  73.     $posCamp = _findNextCamp($posPlay,$arrDireCamps_X,$arrDireCamps_Y)
  74.     _AttackAndMovement(1,$posCamp)
  75. EndFunc   ;==>_main
  76.  
  77. ; #FUNCTION# ====================================================================================================================
  78. ; Name ..........: _tt
  79. ; Syntax ........: _tt($sToolTip)
  80. ; Parameters ....: $sToolTip            - String to Display
  81. ; Example .......: No
  82. ; ===============================================================================================================================
  83. Func _tt($sToolTip)
  84.     If UBound($sToolTip) = 2 Then
  85.         ToolTip("X: " & $sToolTip[0] & "Y: "& $sToolTip[1], 0, 0)
  86.     Else
  87.         ToolTip($sToolTip, 0, 0)
  88.     EndIf
  89. EndFunc   ;==>_tt
  90.  
  91. ; #FUNCTION# ====================================================================================================================
  92. ; Name ..........: _generateBuildingState
  93. ; Description ...:  Iterates building position arrays and checks if up or down
  94. ; Syntax ........: _generateBuildingState($bIsFrindly, $arrX, $arrY, $iArrLengths)
  95. ; Parameters ....: $bIsFrindly          - 0 = enemy; 1 = Frindly
  96. ;                  $arrX                - Array with X Coordinates
  97. ;                  $arrY                - Array with Y Coordinates
  98. ; Return values .: Array with Building States; 0 or 1
  99. ; ===============================================================================================================================
  100. Func _generateBuildingState($bIsFrindly, $arrX, $arrY)
  101.     ; Exception Handling
  102.     If IsArray($arrX) And IsArray($arrY) And UBound($arrX) = UBound($arrY) Then
  103.         Local $iArrLength = UBound($arrX)
  104.         ; Initialize Array Range
  105.         Local $iBuildingStates[$iArrLength]
  106.         ; Check building state for every Index
  107.         For $i = 0 To $iArrLength - 1
  108.             Local $pos_current = _buildPoint($arrX[$i], $arrY[$i])
  109.             $iBuildingStates[$i] = _checkBuildingState($bIsFrindly, $pos_current)
  110.         Next
  111.         Return $iBuildingStates
  112.     Else
  113.         _tt(" _generateBuildingState: Wrong Data Type or Array Length not Matching")
  114.         Return 0
  115.     EndIf
  116. EndFunc   ;==>_generateBuildingState
  117.  
  118. ; #FUNCTION# ====================================================================================================================
  119. ; Name ..........: _checkBuildingState
  120. ; Description ...: Checks a Coordinate on Minimap for Building status
  121. ; Syntax ........: _checkBuildingState($bIsFrindly, $Pos)
  122. ; Parameters ....: $bIsFrindly          - 0 = Enemy; 1 = Frindly; Use 0,1
  123. ;                  $Pos                 - Building position on Minimap
  124. ; Return values .: True if Up / False if down
  125. ; ===============================================================================================================================
  126. Func _checkBuildingState($bIsFrindly, $Pos)
  127.     ; Check Exceptions
  128.     If IsArray($Pos) And ($bIsFrindly = 0 Or $bIsFrindly = 1) Then
  129.         ; Frindly Building
  130.         If $bIsFrindly = 1 Then
  131.             If PixelGetColor($Pos[0], $Pos[1]) = $iColor_Frindly_Building Then
  132.                 _tt("Frindly Building Up")
  133.                 Return 1
  134.             Else
  135.                 _tt("Frindly Building Down")
  136.                 Return 0
  137.             EndIf
  138.             ; Enemy Building
  139.         ElseIf $bIsFrindly = 0 Then
  140.             If PixelGetColor($Pos[0], $Pos[1]) = $iColor_Enemy_Building Or $iColor_Enemy_Building_Fog Then
  141.                 _tt("Enemy Building Up")
  142.                 Return 1
  143.             Else
  144.                 _tt("Enemy Building Down")
  145.                 Return 0
  146.             EndIf
  147.         EndIf
  148.     Else
  149.         ; Exception
  150.         _MsgBox("_checkBuildingState Wrong Parameters")
  151.         Exit
  152.     EndIf
  153. EndFunc   ;==>_checkBuildingState
  154.  
  155. ; #FUNCTION# ====================================================================================================================
  156. ; Name ..........: _findNextCamp
  157. ; Description ...: Returns nearest unfarmed creep camp
  158. ; Syntax ........: _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
  159. ; Parameters ....: $posPlayer           -   Current Player Position
  160. ;                  $arrCampsX           -   Array with X coordinates
  161. ;                  $arrCampsY           -   Array with Y coordinates
  162. ; Return values .: $arrPositions[$i]    -   Position of the nearest farmable camp
  163. ; Remarks .......: Determines and returns the position of the next free camp of given creep camps
  164. ; ===============================================================================================================================
  165. Func _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
  166.  
  167.     ; Dummy or Backup Return
  168.     Local Static $posBackup
  169.     Local $iLength = UBound($arrCampsX)
  170.     ; Build array with all point positions
  171.     Local $arrPositions[UBound($arrCampsX)]
  172.     Local $posTemp
  173.     $arrPositions = _buildPointArray($arrCampsX,$arrCampsY)
  174.     $posBackup = $arrPositions[0]
  175.     ; Array for Distances
  176.     Local $arrDistances [UBound($arrPositions)]
  177.     Local $iDistanceTemp
  178.     ; Calculate all distances
  179.     For $i = 0 To  UBound($arrPositions) - 1
  180.         $posTemp = _buildPoint($arrCampsX[$i],$arrCampsY[$i])
  181.         $iDistanceTemp = _calculatePointDistance($posPlayer,$posTemp)
  182.         $arrDistances[$i] = $iDistanceTemp
  183.     Next
  184.     ; Bubble Sort
  185.     ; Sort Distances and adjust Position array to match distance array
  186.     Local $iTemp
  187.     Local $bSwapped = True
  188.     While $bSwapped
  189.         $bSwapped = False
  190.         For $i = 0 To $iLength - 2
  191.             If $arrDistances[$i] > $arrDistances[$i+1] Then
  192.                 ; Swap
  193.                 $iTemp = $arrDistances[$i]
  194.                 $arrDistances[$i] = $arrDistances[$i+1]
  195.                 $arrDistances[$i+1] = $iTemp
  196.                 ; Swap
  197.                 $posTemp = $arrPositions[$i]
  198.                 $arrPositions[$i] = $arrPositions[$i+1]
  199.                 $arrPositions[$i+1] = $posTemp
  200.                 $bSwapped = True
  201.             EndIF
  202.         Next
  203.     WEnd
  204.     ; Iterate over all Positions until farmable position is found
  205.     For $i = 0 To $iLength - 1
  206.         ; When not at camp and camp exist, then return cordinates
  207.         If Not _checkPointProximity($posPlayer,$arrPositions[$i]) and (_MiniMapMarkerExist($iColorNeutralCamp,$arrPositions[$i],4) or _MiniMapMarkerExist($iColorNeutralUnit,$arrPositions[$i],4)) Then
  208.             $posBackup = $arrPositions[$i]
  209.             Return $arrPositions[$i]
  210.         EndIf
  211.     Next
  212.     _tt("Wit camps to Spawn")
  213.     Sleep(5000)
  214.     Return _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
  215. EndFunc     ;==>_findNextCamp
  216.  
  217. ; #FUNCTION# ====================================================================================================================
  218. ; Name ..........: _findNextWave
  219. ; Description ...: Finds nearest position of a creep wave
  220. ; Syntax ........: _findNextWave($posPlayer)
  221. ; Parameters ....: $posPlayer           -   Current Player Positions
  222. ; Return values .: $arrPositions[$i]    -   Position of the nearest visible wave
  223. ; Remarks .......: Determines and returns the position of the next visible wavw
  224. ; ===============================================================================================================================
  225. Func _findNextWave($posPlayer)
  226.     _TT("Find nearest Wave")
  227.     ; Variables
  228.     Local Static $posLastSeenWave
  229.     Local $arrDistances[3]
  230.     Local $iLength = UBound($arrDistances)
  231.     Local $arrEquilibriumPositions[3]
  232.     Local $posSafe
  233.     Local $posMid
  234.     Local $posOff
  235.  
  236.     ; Scan Safe Lane
  237.     $posSafe = _scanLaneEquilibrium($arrCorridorDireSafe)
  238.     If IsArray($posSafe) Then
  239.         $arrEquilibriumPositions[0] = $posSafe
  240.     ElseIf Not IsArray($posSafe) Then
  241.         $posSafe = _scanLaneEquilibrium($arrCorridorRadOff)
  242.         $arrEquilibriumPositions[0] = $posSafe
  243.     EndIF
  244.     ; Scan Mid Lane
  245.     $posMid = _scanLaneEquilibrium($arrCorridorMid)
  246.     If IsArray($posMid) Then
  247.         $arrEquilibriumPositions[1] = $posMid
  248.     EndIf
  249.     ; Scan Off Lane
  250.     $posOff = _scanLaneEquilibrium($arrCorridorDireOff)
  251.     If IsArray($posOff) Then
  252.         $arrEquilibriumPositions[2] = $posOff
  253.     ElseIf Not IsArray($posOff) Then
  254.         $posOff = _scanLaneEquilibrium($arrCorridorRadSafe)
  255.         $arrEquilibriumPositions[2] = $posOff
  256.     EndIf
  257.  
  258.     ; Calculate distances for returned Arrays
  259.     For $i = 0 To UBound($arrEquilibriumPositions) - 1
  260.         Local $posTemp = $arrEquilibriumPositions[$i]
  261.         If IsArray($posTemp) Then
  262.             Local $iDistanceTemp = _calculatePointDistance($posPlayer,$posTemp)
  263.             $arrDistances[$i] = $iDistanceTemp
  264.         Else
  265.             $arrDistances[$i] = 0
  266.         EndIf
  267.     Next
  268.  
  269.     ; Bubble Sort
  270.     ; Sort Distances and adjust Position array to match distance array
  271.     Local $iTemp
  272.     Local $bSwapped = True
  273.     While $bSwapped
  274.         $bSwapped = False
  275.         For $i = 0 To $iLength - 2
  276.             If $arrDistances[$i] > $arrDistances[$i+1] Then
  277.                 ; Swap
  278.                 $iTemp = $arrDistances[$i]
  279.                 $arrDistances[$i] = $arrDistances[$i+1]
  280.                 $arrDistances[$i+1] = $iTemp
  281.                 ; Swap
  282.                 $posTemp = $arrEquilibriumPositions[$i]
  283.                 $arrEquilibriumPositions[$i] = $arrEquilibriumPositions[$i+1]
  284.                 $arrEquilibriumPositions[$i+1] = $posTemp
  285.                 $bSwapped = True
  286.             EndIF
  287.         Next
  288.     WEnd
  289.  
  290.     ; Return Lowest Index that is not 0
  291.     For $i = 0 To Ubound($arrEquilibriumPositions) - 1
  292.         If IsArray($arrEquilibriumPositions[$i]) Then
  293.             $posLastSeenWave = $arrEquilibriumPositions[$i]
  294.             Return ($arrEquilibriumPositions[$i])
  295.         EndIf
  296.     Next
  297.  
  298.     ; NEEDS TO BE MODIFIED
  299.     If IsArray($posLastSeenWave) Then
  300.         Return $posLastSeenWave
  301.     Else
  302.         Return False
  303.     EndIf
  304.  
  305. EndFunc
  306.  
  307. ; #FUNCTION# ====================================================================================================================
  308. ; Name ..........: _scanLaneEquilibrium
  309. ; Description ...:  Scans a given lane corridor for creep eqilibrium
  310. ; Syntax ........: _scanLaneEquilibrium($arrLane)
  311. ; Parameters ....: $arrLane             - An array of unknowns.
  312. ; Return values .: Equilibrium Position or 0
  313. ; ===============================================================================================================================
  314. Func _scanLaneEquilibrium($arrLane)
  315.     Local $arrEquilibriumPositions
  316.     $arrEquilibriumPositions = _findUnitPosition($arrLane, $iColor_Enemy_Unit)
  317.     If IsArray($arrEquilibriumPositions) and _MiniMapMarkerExist($iColor_Frindly_Creep,$arrEquilibriumPositions, 15) Then
  318.         Return $arrEquilibriumPositions
  319.     Else
  320.         Return 0
  321.     EndIf
  322. EndFunc
  323.  
  324. ; #FUNCTION# ====================================================================================================================
  325. ; Name ..........: _findUnitPosition
  326. ; Description ...:  Find Unit position of a given color on minimap
  327. ; Syntax ........: _findUnitPosition($arrSearchRange, $iColor)
  328. ; Parameters ....: $arrSearchRange      - An array of TOPLEFT XY and BOTTOMRIGHT XY.
  329. ;                  $iColor              - Color value of Unit
  330. ; Return values .: Unit Position on Minimap / False
  331. ; ===============================================================================================================================
  332. Func _findUnitPosition($arrSearchRange, $iColor)
  333.     ; Exception Handling
  334.     If IsArray($arrSearchRange) Then
  335.         ; Search for Unit
  336.         Local $posUnit
  337.         Local Static $posBackUp
  338.         $posUnit = PixelSearch($arrSearchRange[0], $arrSearchRange[1], $arrSearchRange[2], $arrSearchRange[3], $iColor, 3)
  339.         If IsArray($posUnit) Then
  340.             $posBackUp = $posUnit
  341.             Return $posUnit
  342.         ElseIf Not @error Then
  343.             _tt("Unit Not Found")
  344.             Return $posBackUp
  345.         EndIf
  346.     Else
  347.         _tt("_findUnitPosition: Wrong Data Type")
  348.     EndIf
  349. EndFunc   ;==>_findUnitPosition
  350.  
  351. ; #FUNCTION# ====================================================================================================================
  352. ; Name ..........: _findPlayerColor
  353. ; Description ...: Find the color the player is currently playing
  354. ; Syntax ........: _findPlayerColor($arrColors)
  355. ; Parameters ....: $arrColors           - Array with all possible player colors.
  356. ; Return values .: Color of Player Unit; 0 if not found
  357. ; ===============================================================================================================================
  358. Func _findPlayerColor($arrColors)
  359.     ; Check if Player Color already determined
  360.     If $iColorPlayer > 0 Then
  361.         _tt("Player Color Already Determined")
  362.         Return $iColorPlayer
  363.     EndIf
  364.     Local $iColorCurrent
  365.     Local $posCurrentColor_Up, $posCurrentColor_Down
  366.     Local $posTemp_Up, $posTemp_Down
  367.     ;Rectangle Up
  368.     Local $posX1_up = 0
  369.     Local $posY1_up = 0
  370.     Local $posX2_up = 0
  371.     Local $posY2_up = 0
  372.     ; Rectangle down
  373.     Local $posX1_down = 0
  374.     Local $posY1_down = 0
  375.     Local $posX2_down = 0
  376.     Local $posY2_down = 0
  377.     ; Iterate Player Colors
  378.     For $i = 0 To UBound($arrColors) - 1
  379.         ; Grab Player Colors
  380.         $iColorCurrent = $arrColors[$i]
  381.         ; Get current color minimap position
  382.         $posCurrentColor_Up = _findUnitPosition($arrMiniMap, $iColorCurrent)
  383.         $posCurrentColor_Down = $posCurrentColor_Up
  384.         ; If found, search in offset range for white circle around player
  385.         If IsArray($posCurrentColor_Up) Then
  386.             ; Generate Bottom Rectangle
  387.             $posX1_up = $posCurrentColor_Up[0] - 5
  388.             $posY1_up = $posCurrentColor_Up[1] - 5
  389.             $posX2_up = $posCurrentColor_Up[0] + 5
  390.             $posY2_up = $posCurrentColor_Up[1]
  391.             ; Generate Bottom Rectangle
  392.             $posX1_down = $posCurrentColor_Down[0] - 5
  393.             $posY1_down = $posCurrentColor_Down[1]
  394.             $posX2_down = $posCurrentColor_Down[0] + 5
  395.             $posY2_down = $posCurrentColor_Down[1] + 5
  396.             ; Search Upper Rectangle for white Pixel around current player color
  397.             $posTemp_Up = PixelSearch($posX1_up, $posY1_up, $posX2_up, $posY2_up, $iColorPlayerCircle, 2)
  398.             If IsArray($posTemp_Up) Then
  399.                 _tt("Player Color Determined UP " & $iColorCurrent)
  400.                 Return $iColorCurrent
  401.             EndIf
  402.             ; Search Lower Rectangle for white Pixel around current player color
  403.             $posTemp_Down = PixelSearch($posX1_down, $posY1_down, $posX2_down, $posY2_down, $iColorPlayerCircle, 2)
  404.             If IsArray($posTemp_Down) Then
  405.                 _tt("Player Color Determined DOWN " & $iColorCurrent)
  406.                 Return $iColorCurrent
  407.             EndIf
  408.         EndIf
  409.     Next
  410.     ; Exception
  411.     If Not IsArray($posTemp_Down) And Not IsArray($posTemp_Up) Then
  412.         _tt("Player Color Not Determined")
  413.         Return 0
  414.     EndIf
  415. EndFunc   ;==>_findPlayerColor
  416.  
  417. ; #FUNCTION# ====================================================================================================================
  418. ; Name ..........: _MiniMapMarkerExist
  419. ; Description ...: Searches around a position for a given color in offset range
  420. ; Syntax ........: _MiniMapMarkerExist($iColor, $Pos, $iOffset)
  421. ; Parameters ....: $iColor              - Color to search for.
  422. ;                  $Pos                 - Position to seach around.
  423. ;                  $iOffset             - Position Offset to create Rectangles
  424. ; Return values .: True if Marker Exist Else False
  425. ; ===============================================================================================================================
  426. Func _MiniMapMarkerExist($iColor,$Pos,$iOffset)
  427.     ; Exception
  428.     If Not IsArray($Pos) Then
  429.         _MsgBox("_MiniMapMarkerExist: $Pos non Array")
  430.         Exit
  431.     EndIf
  432.     Local $posTemp
  433.     ; Build Top Rectangle
  434.     Local $posX1_up = $Pos[0] - $iOffset
  435.     Local $posY1_up = $Pos[1] - $iOffset
  436.     Local $posX2_up = $Pos[0] + $iOffset
  437.     Local $posY2_up = $Pos[1]
  438.     ; Build Bottom Rectangle
  439.     Local $posX1_down = $Pos[0] - $iOffset
  440.     Local $posY1_down = $Pos[1]
  441.     Local $posX2_down = $Pos[0] + $iOffset
  442.     Local $posY2_down = $Pos[1] + $iOffset
  443.     ; Check Top Rectangle
  444.     $posTemp = PixelSearch($posX1_up,$posY1_up,$posX2_up,$posY2_up,$iColor,1)
  445.     If IsArray($posTemp) Then
  446.         Return True
  447.     EndIf
  448.     ; Check Bottom Rectangle
  449.     $posTemp = PixelSearch($posX1_down,$posY1_down,$posX2_down,$posY2_down,$iColor,1)
  450.     If IsArray($posTemp) Then
  451.         Return True
  452.     EndIf
  453.     Return False
  454. EndFunc
  455.  
  456. ; #FUNCTION# ====================================================================================================================
  457. ; Name ..........: _checkLevelUp
  458. ; Syntax ........: _checkLevelUp()
  459. ; Return values .: True / False
  460. ; ===============================================================================================================================
  461. Func _checkLevelUp()
  462.     Local $Pos = PixelSearch(843, 937, 1096, 942, $iColorLevelUp, 1)
  463.     If IsArray($Pos) Then
  464.         _tt("Level Up")
  465.         Return True
  466.     Else
  467.         _tt("No Level Up")
  468.         Return False
  469.     EndIf
  470. EndFunc   ;==>_checkLevelUp
  471.  
  472. ; #FUNCTION# ====================================================================================================================
  473. ; Name ..........: _checkPointProximity
  474. ; Description ...:
  475. ; Syntax ........: _checkPointProximity($posCurrent, $posTarget)
  476. ; Parameters ....: $posCurrent          - A pointer value.
  477. ;                  $posTarget           - A pointer value.
  478. ; Return values .: None
  479. ; Author ........: Your Name
  480. ; Modified ......:
  481. ; Remarks .......:
  482. ; Related .......:
  483. ; Link ..........:
  484. ; Example .......: No
  485. ; ===============================================================================================================================
  486. Func _checkPointProximity($posCurrent,$posTarget)
  487.  
  488.     If Not IsArray($posCurrent) or Not IsArray($posTarget) Then
  489.         _MsgBox("_checkPointProximity: Called with Wrong Parameter")
  490.         Return 0
  491.     EndIf
  492.  
  493.     Local $iDistance = 9999
  494.     $iDistance = _calculatePointDistance($posCurrent,$posTarget)
  495.     If $iDistance <= 5 Then
  496.         Return True
  497.     ElseIf $iDistance > 6 Then
  498.         Return False
  499.     EndIf
  500. EndFunc
  501.  
  502. ; #FUNCTION# ====================================================================================================================
  503. ; Name ..........: _checkDead
  504. ; Syntax ........: _checkDead()
  505. ; Return values .: True / False
  506. ; ===============================================================================================================================
  507. Func _checkDead()
  508.     ; Check entire Health Bar for HealthColor
  509.     Local $Pos = PixelSearch(781, 1017, 1095, 1043, $iColorHealth, 10)
  510.     If IsArray($Pos) Then
  511.         _tt("Not Dead")
  512.         Return False
  513.     Else
  514.         _tt("Dead")
  515.         Return True
  516.     EndIf
  517. EndFunc   ;==>_checkDead
  518.  
  519. ; #FUNCTION# ====================================================================================================================
  520. ; Name ..........: _AttackAndMovement
  521. ; Description ...:
  522. ; Syntax ........: _AttackAndMovement($bAttack, $Pos)
  523. ; Parameters ....: $bAttack             - 0 = Move; 1 = Attack
  524. ;                  $Pos                 - Position
  525. ; ===============================================================================================================================
  526. Func _AttackAndMovement($bAttack,$Pos)
  527.     ; Expcetion
  528.     If Not IsArray($pos) Then
  529.         _MsgBox("_AttackAndMovement: $pos is no Array")
  530.         Exit
  531.     EndIf
  532.     ; Attack Move
  533.     If $bAttack = 1 Then
  534.         MouseMove($pos[0],$pos[1])
  535.         Send("a")
  536.         ; Needed to avoid Attack Canceling and complete movement
  537.         Sleep(500)
  538.     ; Movement Command
  539.     ElseIf $bAttack = 0 Then
  540.         MouseMove($pos[0],$pos[1])
  541.         Send("m")
  542.         ; Needed to complete movement (To fast update = no movement = might stuck)
  543.         Sleep(500)
  544.     Else
  545.         _MsgBox("_AttackAndMovement: Wrong Attack Parameter")
  546.         Exit
  547.     EndIf
  548. EndFunc
  549.  
  550. ; #FUNCTION# ====================================================================================================================
  551. ; Name ..........: _buildPoint
  552. ; Description ...:
  553. ; Syntax ........: _buildPoint($iX, $iY)
  554. ; Parameters ....: $iX                  - An integer value.
  555. ;                  $iY                  - An integer value.
  556. ; Return values .: Array with X Y
  557. ; ===============================================================================================================================
  558. Func _buildPoint($iX, $iY)
  559.     Local $posPoint[2]
  560.     $posPoint[0] = $iX
  561.     $posPoint[1] = $iY
  562.     Return $posPoint
  563. EndFunc   ;==>_buildPoint
  564.  
  565. ; #FUNCTION# ====================================================================================================================
  566. ; Name ..........: _buildPointArray
  567. ; Description ...:
  568. ; Syntax ........: _buildPointArray($arrX, $arrY)
  569. ; Parameters ....: $arrX                - X Coordinates
  570. ;                  $arrY                - Y Coordinates
  571. ; Return values .: Returns an array with Points
  572. ; ===============================================================================================================================
  573. Func _buildPointArray($arrX,$arrY)
  574.     ; Exception
  575.     If Not UBound($arrX) = UBound($arrY) Then
  576.         _MsgBox("_buildPointArray: Wrong Array Constraints")
  577.         Exit
  578.     EndIf
  579.     Local $arrPositions[UBound($arrX)]
  580.     For $i = 0 To UBound($arrX) - 1
  581.         $arrPositions[$i] = _buildPoint($arrX[$i],$arrY[$i])
  582.     Next
  583.     Return $arrPositions
  584. EndFunc
  585.  
  586. ; #FUNCTION# ====================================================================================================================
  587. ; Name ..........: _calculatePointDistance
  588. ; Syntax ........: _calculatePointDistance($pos_1, $pos_2)
  589. ; Parameters ....: $pos_1
  590. ;                  $pos_2
  591. ; Return values .: Distance between points (Pixel)
  592. ; ===============================================================================================================================
  593. Func _calculatePointDistance($pos_1, $pos_2)
  594.     ; Exception Handling
  595.     If IsArray($pos_1) And IsArray($pos_2) Then
  596.         ; Point 1
  597.         Local $pos_x1 = $pos_1[0]
  598.         Local $pos_y1 = $pos_1[1]
  599.         ; Point 2
  600.         Local $pos_x2 = $pos_2[0]
  601.         Local $pos_y2 = $pos_2[1]
  602.         ; Calculate Distance and make it Integer
  603.         Local $iDistance = Sqrt((($pos_x2 - $pos_x1) * ($pos_x2 - $pos_x1)) + (($pos_y2 - $pos_y1) * ($pos_y2 - $pos_y1)))
  604.         $iDistance = Int($iDistance)
  605.         Return $iDistance
  606.     Else
  607.         _MsgBox("_calculatePointDistance: Non Array Parameters")
  608.         Return 0
  609.     EndIf
  610. EndFunc   ;==>_calculatePointDistance
  611.  
  612. ; #FUNCTION# ====================================================================================================================
  613. ; Name ..........: _MsgBox
  614. ; Description ...: Debug Function
  615. ; Syntax ........: _MsgBox($sMsgbox)
  616. ; Parameters ....: $sMsgbox             - A string value.
  617. ; Return values .: None
  618. ; ===============================================================================================================================
  619. Func _MsgBox($sMsgbox)
  620.     MsgBox(0, "Debug", $sMsgbox)
  621. EndFunc   ;==>_MsgBox
  622.  
  623. ; #FUNCTION# ====================================================================================================================
  624. ; Name ..........: _convertTimer
  625. ; Description ...: Calculate Time in seconds
  626. ; Syntax ........: _convertTimer($timer)
  627. ; Parameters ....: $timer               - A dll struct value.
  628. ; Return values .: Timer in Seconds
  629. ; ===============================================================================================================================
  630. Func _convertTimer($timer)
  631.     Local $iConvertedTimer = Int(TimerDiff($timer) / 1000)
  632.     Return $iConvertedTimer
  633. EndFunc   ;==>_convertTimer
  634.  
  635. ; #FUNCTION# ====================================================================================================================
  636. ; Name ..........: _MouseMove
  637. ; Description ...:  Easy Mouse Move
  638. ; Syntax ........: _MouseMove($Pos)
  639. ; Parameters ....: $Pos                 - Postion to Move Mouse To
  640. ; ===============================================================================================================================
  641. Func _MouseMove($Pos)
  642.     If IsArray($Pos) and UBound($Pos) = 2 Then
  643.         MouseMove($pos[0],$pos[1])
  644.     Else
  645.         _MsgBox("_MouseMove: Wrong Array Constraints")
  646.     EndIf
  647. EndFunc
  648.  
  649. ; #FUNCTION# ====================================================================================================================
  650. ; Name ..........: _exit
  651. ; Syntax ........: _exit()
  652. ; Return values .: None
  653. ; ===============================================================================================================================
  654. Func _exit()
  655.     Exit
  656. EndFunc   ;==>_exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement