Jump to content

help for a total noob - script wont run at all


Recommended Posts

Hi,

I got this script for a simple follow bot for diablo 2 just for single player, so no cheating and the like. Just some single player fun. Got it off the net... so not my script.

in fact I have no clue how to or what to do with it.

I installed the autoit on a windows xp pc, and the script just gives me an error: unknown option or bad parameter specified. with - autoitSetOption ("color mode", 1)

now i went from vista to an other pc with windows 98.. and now a pc with xp.

I installed the latest version (not Beta) that was known to work.

Also read about the beta version need to install for some commands, but just want to confirm this first, and how to go about it.

As I have no idea what is what...

this is the script, if that is needed or helps?!

thanks in advance :D much appreciated

p.s. ehh it stated in the ini file to put the color to 16 bit mode, which I did

;########################################################################################

; Sgraffite's Follow Bot configuration

; FollowBot.au3

; Version 10.02.2006 BETA

;########################################################################################

#Include <Array.Au3>

;----------------------------------------------------------------------------------------

; Autoit options

;----------------------------------------------------------------------------------------

AutoItSetOption ("ColorMode", 1)

AutoItSetOption("WinTitleMatchMode", 3)

AutoItSetOption("WinWaitDelay", 250)

AutoItSetOption ("PixelCoordMode", 2)

AutoItSetOption ("MouseCoordMode", 2)

AutoItSetOption("MustDeclareVars", 1)

;----------------------------------------------------------------------------------------

; Calibrate game screen

;----------------------------------------------------------------------------------------

; Give focus to Diablo 2 window.

WinActivate("Diablo II")

; Move Diablo 2 window to coordinates (0,0).

WinMove("Diablo II","",0,0)

;----------------------------------------------------------------------------------------

; Constants

;----------------------------------------------------------------------------------------

Dim Const $ConfigFile = "FollowBot.ini" ; Configuration file to use.

Dim Const $Origin = _ArrayCreate(410,288) ; What we will consider the center of the screen.

Dim Const $ScreenBorder = _ArrayCreate(0, 0, 798, 551) ; Boundaries of game screen.

Dim Const $MouseSpeed = 0 ; Make mouse as fast as possible.

Dim Const $GREEN_BLOCK_Color = 65304 ; Color used to search for friendly players.

Dim Const $MERC_Color = 3252810 ; Color used to search for friendly mercenaries.

Dim Const $BLUE_BLOCK_Color = 14573857 ; Color used to search for self.

Dim Const $RED_BLOCK_Color = 11519 ; Color used to search for hostile/neutral players.

Dim Const $Heal_Potion_Color = 5395910 ; Color used to search for a heal pot.

Dim Const $Rejuv_Potion_Color = 7020659 ; Color used to search for a rejuv pot.

Dim Const $Mana_Potion_Color = 9711665 ; Color used to search for a mana pot.

Dim Const $Skill_Disabled_Color = 1055834 ; Color used to check if right skill is disabled (in town).

Dim Const $CheckPointX = _ArrayCreate (310, 510, 610, 610, 510, 310, 210, 210)

Dim Const $CheckPointY = _ArrayCreate (150, 150, 219, 288, 357, 357, 288, 219)

Dim $ValidTargets[8] ; Array used to compare against t ocheck for ValidTarget()

$ValidTargets[0] = _ArrayCreate (1, 1, 0, 0, 1, 1)

$ValidTargets[1] = _ArrayCreate (1, 0, 1, 0, 1, 0, 1)

$ValidTargets[2] = _ArrayCreate (1, 0, 0, 1, 1, 0, 0, 1)

$ValidTargets[3] = _ArrayCreate (1, 1, 0, 0, 1, 1, 0, 0, 1, 1)

$ValidTargets[4] = _ArrayCreate (1, 0, 0, 0, 0, 0, 0, 1)

$ValidTargets[5] = _ArrayCreate (1, 0, 0, 0, 0, 0, 1)

$ValidTargets[6] = _ArrayCreate (1, 0, 0, 0, 1)

$ValidTargets[7] = _ArrayCreate (1, 1, 0, 0, 0, 1, 1)

;----------------------------------------------------------------------------------------

; Globals

;----------------------------------------------------------------------------------------

Dim $Char_DrinkPotionLifePercent = 50 ; Initial value for character drink check.

Dim $Char_DrinkPotionManaPercent = 50 ; Initial value for character drink check.

Dim $Char_DrinkHealDelay = 0 ; Minimum wait time(milliseconds) between heal potion drinks.

Dim $Char_DrinkManaDelay = 0 ; Minimum wait time(milliseconds) between mana potion drinks.

Dim $LastHealDrank = TimerInit() ; Timestamp of last heal potion drank.

Dim $LastManaDrank = TimerInit() ; Timestamp of last mana potion drank.

Dim $Char_FollowDistance = 28 ; How close the bot comes to you before it stops.

Dim $Char_UseTeleport = 0 ; Use teleport when available.

Dim $RefreshRate = 250 ; How often the engine searches for other players. Default: 100 (milliseconds)

Dim $b1[2]

Dim $b2[2]

Dim $KEY_Belt = _ArrayCreate("", "", "", "")

Dim $Active = 0 ; Variable to store whether the script is running or not.

Dim $SnapshotOld[8]

Dim $SnapshotNew[8]

Dim $TargetLock = 0 ; Varaible to store whether a target has been aquired or not.

Dim $Target[2] ; Coordinates for the current target.

Dim $TargetQueue[1] ; Array for storing potential targets to follow.

; This array must be at least 1 element in size.

;----------------------------------------------------------------------------------------

; Main

;----------------------------------------------------------------------------------------

IniInit($ConfigFile)

While 1

Sleep($RefreshRate)

If $Active Then Loop()

WEnd

Exit(1)

;----------------------------------------------------------------------------------------

; Function IniInit() initialize keys from the file name passed in.

;----------------------------------------------------------------------------------------

Func IniInit($File)

; Read in game key configuration from .ini file and assign to variables.

$KEY_Belt[0] = IniRead($File, "Character", "Char_Key_PotionsRow1", "")

$KEY_Belt[1] = IniRead($File, "Character", "Char_Key_PotionsRow2", "")

$KEY_Belt[2] = IniRead($File, "Character", "Char_Key_PotionsRow3", "")

$KEY_Belt[3] = IniRead($File, "Character", "Char_Key_PotionsRow4", "")

Dim $Key_Attack = IniRead($File, "Character", "Char_Key_Attack", "")

Dim $Key_Teleport = IniRead($File, "Character", "Char_Key_Teleport", "")

Dim $Char_DrinkPotionLifePercent = IniRead($File, "Character", "Char_DrinkPotionLifePercent", "")

Dim $Char_DrinkPotionManaPercent = IniRead($File, "Character", "Char_DrinkPotionManaPercent", "")

Dim $Char_DrinkHealDelay = IniRead($File, "Character", "Char_DrinkHealDelay", "")

Dim $Char_DrinkManaDelay = IniRead($File, "Character", "Char_DrinkManaDelay", "")

Dim $Char_FollowDistance = IniRead($File, "Character", "Char_FollowDistance", "")

Dim $Char_UseTeleport = IniRead($File, "Character", "Char_UseTeleport", "")

; Read hotkey configuration from .ini file and set using HotKeySet().

Dim $KEY_Script_Start = IniRead($File, "Script", "Script_Key_Start", "")

Dim $KEY_Script_Stop = IniRead($File, "Script", "Script_Key_Stop", "")

Dim $KEY_Script_Terminate = IniRead($File, "Script", "Script_Key_Terminate", "")

HotKeySet($KEY_Script_Start, "Start")

HotKeySet($KEY_Script_Stop, "Stop")

HotKeySet($KEY_Script_Terminate, "Terminate")

EndFunc

;----------------------------------------------------------------------------------------

; Function Loop() is a container for the main looped functions.

;----------------------------------------------------------------------------------------

Func Loop()

Hydrate()

If $TargetLock Then

Track($Target)

Else

Scout()

EndIf

Move()

EndFunc

;----------------------------------------------------------------------------------------

; Function Start() starts the script.

;----------------------------------------------------------------------------------------

Func Start()

$Active = 1

EndFunc

;----------------------------------------------------------------------------------------

; Function Stop() stops the script.

;----------------------------------------------------------------------------------------

Func Stop()

$Active = 0

EndFunc

;----------------------------------------------------------------------------------------

; Function Terminate() terminates the script.

;----------------------------------------------------------------------------------------

Func Terminate()

Exit(1)

EndFunc

;----------------------------------------------------------------------------------------

; Function Move() make your way to your target (hopefully).

;----------------------------------------------------------------------------------------

Func Move()

Dim $Distance = ProcessTargetQueue()

If $Distance > $Char_FollowDistance Then

$TargetLock = 1

WhichBorder($Target)

If $Distance < ($Char_FollowDistance * 2) And $Char_UseTeleport == 0 Then

If $b1[0] = $b2[0] Then ; need to scale x value based on $Char_FollowDistance

If $b1[0] = 0 Then

Dim $x = $ScreenBorder[0] - $Origin[0]

$b1[0] = $Origin[0] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[0] = $b1[0]

Else

Dim $x = $ScreenBorder[2] - $Origin[0]

$b1[0] = $Origin[0] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[0] = $b1[0]

EndIf

Else ; need to scale y value based on $Char_FollowDistance

If $b1[1] = 0 Then

Dim $x = $ScreenBorder[1] - $Origin[1]

$b1[1] = $Origin[1] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[1] = $b1[1]

Else

Dim $x = $ScreenBorder[3] - $Origin[1]

$b1[1] = $Origin[1] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[1] = $b1[1]

EndIf

EndIf

EndIf

Dim $Destination = FindIntersection($Origin,$Target,$b1,$b2)

; Click left or right mouse button depending on return from RightSkillDisabled() function.

MouseClick(RightSkillDisabled(), $Destination[0], $Destination[1], 1, $MouseSpeed)

; If the bot gets stuck, click perpendicular to the original direction.

If IsStuck() Then PerpendicularClick(($Target[0] - $Origin[0]), ($Target[1] - $Origin[1]))

Else

$TargetLock = 0

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function Scout() searches the whole screen for targets.

;----------------------------------------------------------------------------------------

Func Scout()

; Use pixelsearch to find potential targets and store them in an array.

GridSearch($ScreenBorder[0], $ScreenBorder[1], $ScreenBorder[2], $ScreenBorder[3], 8, 8)

;ColumnSearch(0,0,799,551,15)

EndFunc

;----------------------------------------------------------------------------------------

; Function Track() tracks the specified target.

;----------------------------------------------------------------------------------------

Func Track($Target)

Dim $coord = PixelSearch($Target[0] - 20, $Target[1] - 20, $Target[1] + 20, $Target[1] + 20, $GREEN_BLOCK_Color, 0, 1)

If IsArray($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

Else

Scout()

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function WhichBorder() determines which edge of the screen you are heading toward and

; stores it in $b1 and $b2.

;----------------------------------------------------------------------------------------

Func WhichBorder($Target)

; Find the slope. y = mx + b

Dim $Slope = ($Target[1] - $Origin[1]) / ($Target[0] - $Origin[0])

If $Target[0] > $Origin[0] And ($Slope < (263/389) And $Slope > (288/(-389))) Then ; intersect east

; you know x = 799

$b1 = _ArrayCreate(799,0)

$b2 = _ArrayCreate(799,551)

ElseIf $Target[0] < $Origin[0] And ($Slope < (288/410) And $Slope > ((-263)/410)) Then ; intersect west

; you know x = 0

$b1 = _ArrayCreate(0,0)

$b2 = _ArrayCreate(0,551)

ElseIf $Target[1] < $Origin[1] Then ; intersect north

; you know y = 0

$b1 = _ArrayCreate(0,0)

$b2 = _ArrayCreate(799,0)

ElseIf $Target[1] > $Origin[1] Then ; intersect south

; you know y = 551

$b1 = _ArrayCreate(0,551)

$b2 = _ArrayCreate(799,551)

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function ProcessTargetQueue() removes all targets but the furthest.

;----------------------------------------------------------------------------------------

Func ProcessTargetQueue()

; Move the extra element from the beginning to the end so when

; deleting coordinates from the queue that zero will be left over

; leaving the queue with the minimum of 1 element.

_ArrayAdd($TargetQueue, 0)

_ArrayDelete($TargetQueue, 0)

; Process the queue of targets.

Dim $tempDist = 0

Dim $maxDist = 0

Dim $Target[2]

; Find the furthest target outside of the $Char_FollowDistance

; range and store the coordinates in the $Target array.

While UBound($TargetQueue) > 1

$tempDist = Distance($Origin,$TargetQueue)

If $tempDist > $maxDist Then

$maxDist = $tempDist

$Target[0] = $TargetQueue[0]

$Target[1] = $TargetQueue[1]

EndIf

; Delete checked elements in $TargetQueue.

_ArrayDelete ($TargetQueue, 0)

_ArrayDelete ($TargetQueue, 0)

WEnd

Return $maxDist

EndFunc

;----------------------------------------------------------------------------------------

; Function GridSearch() scans a grid for a specific color.

; (Currently Unused)

;----------------------------------------------------------------------------------------

Func GridSearch($xMin, $yMin, $xMax, $yMax, $xSplits, $ySplits)

Dim $xMod = Round($ScreenBorder[2]/$xSplits)

Dim $yMod = Round($ScreenBorder[3]/$ySplits)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[1] < $yMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + $xSplits, $Zone[1] + $yMod, $GREEN_BLOCK_Color, 0, 3)

If IsArray($coord) And ValidateTarget($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

EndIf

$Zone[0] = $Zone[0] + $xSplits

If $Zone[0] > $xMax Then

$Zone[0] = $xMin

$Zone[1] = $Zone[1] + $yMod

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function FrameSearch() scans a frame shaped area for a specific color.

; (Currently Unused)

;----------------------------------------------------------------------------------------

Func FrameSearch($xMin, $yMin, $xMax, $yMax, $xMod, $yMod)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[1] < $yMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + $xMod, $Zone[1] + $yMod, $GREEN_BLOCK_Color, 0, 3)

If IsArray($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

EndIf

$Zone[0] = $Zone[0] + $xMod

If $Zone[0] > $xMax Then

$Zone[0] = $xMin

$Zone[1] = $Zone[1] + $yMod

EndIf

; skip center area

If $Zone[1] > $yMin And $Zone[1] < $yMax - $yMod Then

If $Zone[0] == $xMin + $xMod Then $Zone[0] = $xMax - $xMod

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function ColumnSearch() scans a vertical column for a specific color.

;----------------------------------------------------------------------------------------

Func ColumnSearch($xMin, $yMin, $xMax, $yMax, $xMod)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[0] < $xMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + 1, $yMax, $GREEN_BLOCK_Color, 0, 1)

If IsArray($coord) And ValidateTarget($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

$Zone[1] = $coord[1] + 9

Else

$Zone[0] = $Zone[0] + $xMod

$Zone[1] = $yMin

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function ValidateTarget() determines if the green pixel belongs to a party member on the automap.

;----------------------------------------------------------------------------------------

Func ValidateTarget($Target)

; Verify it is player marker on the automap by taking a slice.

; Store green pixels as a 1 and others as a 0, compare vs. all

; possibilities stored in ValidTargets[]

Dim $Slice = _ArrayCreate (0)

For $i = -8 to 8

Dim $c = PixelGetColor($Target[0], $Target[1] + $i)

If $c == $GREEN_BLOCK_Color Then

_ArrayAdd ($Slice, 1)

ElseIf $c == $MERC_Color Then

_ArrayAdd ($Slice, 2)

Else

_ArrayAdd ($Slice, 0)

EndIf

Next

$Slice = TrimArray($Slice, 0)

If UBound($Slice) > 4 Then

For $i = 0 to UBound($ValidTargets) - 1

If MatchArray($Slice,$ValidTargets[$i]) Then Return 1

Next

EndIf

$Slice = TrimArray($Slice, 2)

$Slice = TrimArray($Slice, 0)

If UBound($Slice) > 4 Then

For $i = 0 to UBound($ValidTargets) - 1

If MatchArray($Slice,$ValidTargets[$i]) Then Return 1

Next

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function MatchArray() returns 1 if two arrays are equal in length and value.

;----------------------------------------------------------------------------------------

Func MatchArray($array1, $array2)

If UBound($array1) == UBound($array2) Then

For $j = 0 to UBound($array2) - 1

; Ignore 2's as they are wildcards in this case.

If $array1[$j] <> 2 And $array1[$j] <> $array2[$j] Then

Return 0

EndIf

Next

Return 1

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function TrimArray() removes the zeroes from both sides of an array.

;----------------------------------------------------------------------------------------

Func TrimArray($array, $value)

Dim $count = 0

If IsArray($array) And UBound($array) > 1 Then

While $array[0] == $value And $count < UBound($array) - 1

_ArrayDelete ($array, 0)

$count = $count + 1

WEnd

_ArrayReverse ($array)

$count = 0

While $array[0] == $value And $count < UBound($array) - 1

_ArrayDelete ($array, 0)

$count = $count + 1

WEnd

EndIf

Return $array

EndFunc

;----------------------------------------------------------------------------------------

; Function Distance() returns the distance between two points.

;----------------------------------------------------------------------------------------

Func Distance($p1, $p2)

Dim $Distance = Sqrt(($p1[0] - $p2[0])^2 + ($p1[1] - $p2[1])^2)

Return $Distance

EndFunc

;----------------------------------------------------------------------------------------

; Function PerpendicularClick() clicks on an angle perpendicular to the desired destination.

;----------------------------------------------------------------------------------------

Func PerpendicularClick($xSlope,$ySlope)

Dim $newCoords = $Origin

Dim $Dist = Round(Random (50, 150))

Dim $d = RandomDirection()

While Distance($Origin,$newCoords) < $Dist

$newCoords[0] = $newCoords[0] + (-1) * $ySlope * $d

$newCoords[1] = $newCoords[1] + $xSlope * $d

WEnd

MouseClick(RightSkillDisabled(), $newCoords[0], $newCoords[1], 1, $MouseSpeed)

Sleep (250)

EndFunc

;----------------------------------------------------------------------------------------

; Function RandomDirection() randomly returns a 1 or -1 multiplier.

;----------------------------------------------------------------------------------------

Func RandomDirection()

Dim $d = Round (Random (0, 1))

If $d = 0 Then Return 1

Return -1

EndFunc

;----------------------------------------------------------------------------------------

; Function IsStuck() returns a 1 if the bot should be moving but is not.

;----------------------------------------------------------------------------------------

Func IsStuck()

$SnapshotOld = $SnapshotNew

Dim $count = 0

For $i = 0 to 7

$SnapshotNew[$i] = PixelGetColor ($CheckPointX[$i], $CheckPointY[$i])

If $SnapshotOld[$i] = $SnapshotNew[$i] Then

$count = $count + 1

EndIf

Next

If $count > 5 Then ; character is stuck

Return 1

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function FindIntersection() find the point of intersection between two lines.

;----------------------------------------------------------------------------------------

Func FindIntersection($a1,$a2,$b1,$b2)

Dim $p1 = _ArrayCreate($a2[0] - $a1[0], $a2[1] - $a1[1])

Dim $p2 = _ArrayCreate($b2[0] - $b1[0], $b2[1] - $b1[1])

Dim $r = (($a1[1] - $b1[1]) * $p2[0] - ($a1[0] - $b1[0]) * $p2[1]) / ($p1[0] * $p2[1] - $p1[1] * $p2[0])

Dim $x = Round($a1[0] + $r * $p1[0])

Dim $y = Round($a1[1] + $r * $p1[1])

Dim $Destination = _ArrayCreate ($x, $y)

Return $Destination

EndFunc

;----------------------------------------------------------------------------------------

; Function Hydrate() determines if healing is needed and drinks potions accordingly.

;----------------------------------------------------------------------------------------

Func Hydrate()

If TimerDiff($LastHealDrank) > $Char_DrinkHealDelay Then

Dim $LifePercent = GetLifePercent()

If $LifePercent <= $Char_DrinkPotionLifePercent Then

; Check if there is a healing potion in the belt, if so drink the first one found.

Dim $PotionSlot = Scanbelt($Heal_Potion_Color)

; Otherwise check if there is a rejuv potion in the belt, if so drink the first one found.

If $PotionSlot = -1 Then $PotionSlot = Scanbelt($Rejuv_Potion_Color)

If $PotionSlot > -1 Then

Send($KEY_Belt[$PotionSlot])

$LastHealDrank = TimerInit()

EndIf

EndIf

EndIf

If TimerDiff($LastManaDrank) > $Char_DrinkManaDelay Then

Dim $ManaPercent = GetManaPercent()

If $ManaPercent <= $Char_DrinkPotionManaPercent Then

; Check if there is a mana potion in the belt, if so drink the first one found.

Dim $PotionSlot = Scanbelt($Mana_Potion_Color)

; Otherwise check if there is a rejuv potion in the belt, if so drink the first one found.

If $PotionSlot = -1 Then $PotionSlot = Scanbelt($Rejuv_Potion_Color)

If $PotionSlot > -1 Then

Send($KEY_Belt[$PotionSlot])

$LastManaDrank = TimerInit()

EndIf

EndIf

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function GetLifePercent() returns the approximate health percentage to the nearest 10%

;----------------------------------------------------------------------------------------

Func GetLifePercent()

Dim $LifePercent = 90

Dim $Ylife = 537 - 24

Do

Dim $Pix = PixelGetColor (84 - 2, $Ylife)

If (($Pix == 90) OR ($Pix == 543000)) Then

Return $LifePercent

Else

$LifePercent = $LifePercent - 10

$Ylife = $Ylife + 8

EndIf

Until ($LifePercent == 40)

$LifePercent = 0

Return $LifePercent

EndFunc

;----------------------------------------------------------------------------------------

; Function GetManaPercent() returns the approximate percentage to the nearest 10%

;----------------------------------------------------------------------------------------

Func GetManaPercent()

Dim $ManaPercent = 90

Dim $Ymana = 536 -24

While ($ManaPercent >= 20)

Dim $Pix = PixelGetColor (744 - 2, $Ymana)

If $Pix == 5898240 Then

Return $ManaPercent

Else

$ManaPercent = $ManaPercent - 10

$Ymana = $Ymana + 8

EndIf

Wend

Dim $Pix = PixelGetColor (735 - 2, 601 - 24)

If $Pix == 2690056 Then

$ManaPercent = 10

Return $ManaPercent

Else

$ManaPercent = 0

Return $ManaPercent

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function ScanBelt() scans for a heal or rejuv potion in belt.

;----------------------------------------------------------------------------------------

Func ScanBelt($PotionColor)

Dim $Belt = _ArrayCreate(432, 577, 446, 587)

Dim $x = 0

Dim $Drink = 0

For $n = 0 to 3

Dim $Potion = PixelSearch ($Belt[0] + $x, $Belt[1], $Belt[2] + $x, $Belt[3], $PotionColor, 0, 1)

If IsArray($Potion) Then

Return $n

EndIf

$x = $x + 30

Next

Return -1

EndFunc

;----------------------------------------------------------------------------------------

; Function RightSkillDisabled() check whether skill on the right side is disabled.

;----------------------------------------------------------------------------------------

Func RightSkillDisabled()

Dim $Pixel = PixelSearch (640, 576, 684, 620, $Skill_Disabled_Color, 0, 2)

If $Char_UseTeleport == 0 Or IsArray($Pixel) Then

Return 'left'

Else

Return 'right'

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function Type() sends text to the game.

; (Used for debugging)

;----------------------------------------------------------------------------------------

Func Type($Message)

Send ('{ENTER}')

Sleep (50)

Send ($Message, 1)

Sleep (50)

Send ('{ENTER}')

EndFunc

;MouseMove ($Pixel[0], $Pixel[1], $MouseSpeed)

Link to comment
Share on other sites

Remove it. They removed the 'ColorMode' option in 3.2.12.0.

And wrap the code in codebox tags.

Edited by system24
[center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]
Link to comment
Share on other sites

Remove it. They removed the 'ColorMode' option in 3.2.12.0.

And wrap the code in codebox tags.

Thanks heaps for that. your a legend :D

It did work sort of, though I didn't know what wrap the code meant (google came up empty), so don't know if it is running how it should.

As it's not working in the sense of doing the job it is supposed to do (but it seems to be running though, so maybe something else wrong?!). or is that code wrap essential?!...

I have no experience with autoit at all so... but also, could the code be obsolete?! being made with an older version?!

anybody that can help me? I know I'm asking for your time and effort...

But would appreciate it very much if somebody could just give me a kickstart into the world of autoit, as I love this sort of stuff, and would like to learn it.

just to see this work would give me insight how this coding works... in opposed to how it doesn't :D

(and I get to play with it too :o )

thanks heaps in advance.

and thanks again system24 for your quick reply, very much appreciated.

Edited by merrin77
Link to comment
Share on other sites

...though I didn't know what wrap the code meant (google came up empty), so don't know if it is running how it should.

...or is that code wrap essential?!

He only meant put code tags around the code in the forum post. Highlight the code and click the "Wrap in code tags" button (second from the right, just above the edit box).

Even better, when the code is that long, edit the [ code ] and [ /code ] tags (without the spaces) into [ codebox ] and [ /codebox ] (again, without the spaces). That will put it in a box with a vertical scroll bar.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

sorry about that :D ... thanks for the heads up :o..

here the code I have now, in the box, as I can't seem to edit my previous post..

CODE

;########################################################################################

; Sgraffite's Follow Bot configuration

; FollowBot.au3

; Version 10.02.2006 BETA

;########################################################################################

#Include <Array.Au3>

;----------------------------------------------------------------------------------------

; Autoit options

;----------------------------------------------------------------------------------------

AutoItSetOption("WinTitleMatchMode", 3)

AutoItSetOption("WinWaitDelay", 250)

AutoItSetOption ("PixelCoordMode", 2)

AutoItSetOption ("MouseCoordMode", 2)

AutoItSetOption("MustDeclareVars", 1)

;----------------------------------------------------------------------------------------

; Calibrate game screen

;----------------------------------------------------------------------------------------

; Give focus to Diablo 2 window.

WinActivate("Diablo II")

; Move Diablo 2 window to coordinates (0,0).

WinMove("Diablo II","",0,0)

;----------------------------------------------------------------------------------------

; Constants

;----------------------------------------------------------------------------------------

Dim Const $ConfigFile = "FollowBot.ini" ; Configuration file to use.

Dim Const $Origin = _ArrayCreate(410,288) ; What we will consider the center of the screen.

Dim Const $ScreenBorder = _ArrayCreate(0, 0, 798, 551) ; Boundaries of game screen.

Dim Const $MouseSpeed = 0 ; Make mouse as fast as possible.

Dim Const $GREEN_BLOCK_Color = 65304 ; Color used to search for friendly players.

Dim Const $MERC_Color = 3252810 ; Color used to search for friendly mercenaries.

Dim Const $BLUE_BLOCK_Color = 14573857 ; Color used to search for self.

Dim Const $RED_BLOCK_Color = 11519 ; Color used to search for hostile/neutral players.

Dim Const $Heal_Potion_Color = 5395910 ; Color used to search for a heal pot.

Dim Const $Rejuv_Potion_Color = 7020659 ; Color used to search for a rejuv pot.

Dim Const $Mana_Potion_Color = 9711665 ; Color used to search for a mana pot.

Dim Const $Skill_Disabled_Color = 1055834 ; Color used to check if right skill is disabled (in town).

Dim Const $CheckPointX = _ArrayCreate (310, 510, 610, 610, 510, 310, 210, 210)

Dim Const $CheckPointY = _ArrayCreate (150, 150, 219, 288, 357, 357, 288, 219)

Dim $ValidTargets[8] ; Array used to compare against t ocheck for ValidTarget()

$ValidTargets[0] = _ArrayCreate (1, 1, 0, 0, 1, 1)

$ValidTargets[1] = _ArrayCreate (1, 0, 1, 0, 1, 0, 1)

$ValidTargets[2] = _ArrayCreate (1, 0, 0, 1, 1, 0, 0, 1)

$ValidTargets[3] = _ArrayCreate (1, 1, 0, 0, 1, 1, 0, 0, 1, 1)

$ValidTargets[4] = _ArrayCreate (1, 0, 0, 0, 0, 0, 0, 1)

$ValidTargets[5] = _ArrayCreate (1, 0, 0, 0, 0, 0, 1)

$ValidTargets[6] = _ArrayCreate (1, 0, 0, 0, 1)

$ValidTargets[7] = _ArrayCreate (1, 1, 0, 0, 0, 1, 1)

;----------------------------------------------------------------------------------------

; Globals

;----------------------------------------------------------------------------------------

Dim $Char_DrinkPotionLifePercent = 50 ; Initial value for character drink check.

Dim $Char_DrinkPotionManaPercent = 50 ; Initial value for character drink check.

Dim $Char_DrinkHealDelay = 0 ; Minimum wait time(milliseconds) between heal potion drinks.

Dim $Char_DrinkManaDelay = 0 ; Minimum wait time(milliseconds) between mana potion drinks.

Dim $LastHealDrank = TimerInit() ; Timestamp of last heal potion drank.

Dim $LastManaDrank = TimerInit() ; Timestamp of last mana potion drank.

Dim $Char_FollowDistance = 28 ; How close the bot comes to you before it stops.

Dim $Char_UseTeleport = 0 ; Use teleport when available.

Dim $RefreshRate = 250 ; How often the engine searches for other players. Default: 100 (milliseconds)

Dim $b1[2]

Dim $b2[2]

Dim $KEY_Belt = _ArrayCreate("", "", "", "")

Dim $Active = 0 ; Variable to store whether the script is running or not.

Dim $SnapshotOld[8]

Dim $SnapshotNew[8]

Dim $TargetLock = 0 ; Varaible to store whether a target has been aquired or not.

Dim $Target[2] ; Coordinates for the current target.

Dim $TargetQueue[1] ; Array for storing potential targets to follow.

; This array must be at least 1 element in size.

;----------------------------------------------------------------------------------------

; Main

;----------------------------------------------------------------------------------------

IniInit($ConfigFile)

While 1

Sleep($RefreshRate)

If $Active Then Loop()

WEnd

Exit(1)

;----------------------------------------------------------------------------------------

; Function IniInit() initialize keys from the file name passed in.

;----------------------------------------------------------------------------------------

Func IniInit($File)

; Read in game key configuration from .ini file and assign to variables.

$KEY_Belt[0] = IniRead($File, "Character", "Char_Key_PotionsRow1", "")

$KEY_Belt[1] = IniRead($File, "Character", "Char_Key_PotionsRow2", "")

$KEY_Belt[2] = IniRead($File, "Character", "Char_Key_PotionsRow3", "")

$KEY_Belt[3] = IniRead($File, "Character", "Char_Key_PotionsRow4", "")

Dim $Key_Attack = IniRead($File, "Character", "Char_Key_Attack", "")

Dim $Key_Teleport = IniRead($File, "Character", "Char_Key_Teleport", "")

Dim $Char_DrinkPotionLifePercent = IniRead($File, "Character", "Char_DrinkPotionLifePercent", "")

Dim $Char_DrinkPotionManaPercent = IniRead($File, "Character", "Char_DrinkPotionManaPercent", "")

Dim $Char_DrinkHealDelay = IniRead($File, "Character", "Char_DrinkHealDelay", "")

Dim $Char_DrinkManaDelay = IniRead($File, "Character", "Char_DrinkManaDelay", "")

Dim $Char_FollowDistance = IniRead($File, "Character", "Char_FollowDistance", "")

Dim $Char_UseTeleport = IniRead($File, "Character", "Char_UseTeleport", "")

; Read hotkey configuration from .ini file and set using HotKeySet().

Dim $KEY_Script_Start = IniRead($File, "Script", "Script_Key_Start", "")

Dim $KEY_Script_Stop = IniRead($File, "Script", "Script_Key_Stop", "")

Dim $KEY_Script_Terminate = IniRead($File, "Script", "Script_Key_Terminate", "")

HotKeySet($KEY_Script_Start, "Start")

HotKeySet($KEY_Script_Stop, "Stop")

HotKeySet($KEY_Script_Terminate, "Terminate")

EndFunc

;----------------------------------------------------------------------------------------

; Function Loop() is a container for the main looped functions.

;----------------------------------------------------------------------------------------

Func Loop()

Hydrate()

If $TargetLock Then

Track($Target)

Else

Scout()

EndIf

Move()

EndFunc

;----------------------------------------------------------------------------------------

; Function Start() starts the script.

;----------------------------------------------------------------------------------------

Func Start()

$Active = 1

EndFunc

;----------------------------------------------------------------------------------------

; Function Stop() stops the script.

;----------------------------------------------------------------------------------------

Func Stop()

$Active = 0

EndFunc

;----------------------------------------------------------------------------------------

; Function Terminate() terminates the script.

;----------------------------------------------------------------------------------------

Func Terminate()

Exit(1)

EndFunc

;----------------------------------------------------------------------------------------

; Function Move() make your way to your target (hopefully).

;----------------------------------------------------------------------------------------

Func Move()

Dim $Distance = ProcessTargetQueue()

If $Distance > $Char_FollowDistance Then

$TargetLock = 1

WhichBorder($Target)

If $Distance < ($Char_FollowDistance * 2) And $Char_UseTeleport == 0 Then

If $b1[0] = $b2[0] Then ; need to scale x value based on $Char_FollowDistance

If $b1[0] = 0 Then

Dim $x = $ScreenBorder[0] - $Origin[0]

$b1[0] = $Origin[0] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[0] = $b1[0]

Else

Dim $x = $ScreenBorder[2] - $Origin[0]

$b1[0] = $Origin[0] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[0] = $b1[0]

EndIf

Else ; need to scale y value based on $Char_FollowDistance

If $b1[1] = 0 Then

Dim $x = $ScreenBorder[1] - $Origin[1]

$b1[1] = $Origin[1] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[1] = $b1[1]

Else

Dim $x = $ScreenBorder[3] - $Origin[1]

$b1[1] = $Origin[1] + Round($x * (($Distance - $Char_FollowDistance)/$Char_FollowDistance))

$b2[1] = $b1[1]

EndIf

EndIf

EndIf

Dim $Destination = FindIntersection($Origin,$Target,$b1,$b2)

; Click left or right mouse button depending on return from RightSkillDisabled() function.

MouseClick(RightSkillDisabled(), $Destination[0], $Destination[1], 1, $MouseSpeed)

; If the bot gets stuck, click perpendicular to the original direction.

If IsStuck() Then PerpendicularClick(($Target[0] - $Origin[0]), ($Target[1] - $Origin[1]))

Else

$TargetLock = 0

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function Scout() searches the whole screen for targets.

;----------------------------------------------------------------------------------------

Func Scout()

; Use pixelsearch to find potential targets and store them in an array.

GridSearch($ScreenBorder[0], $ScreenBorder[1], $ScreenBorder[2], $ScreenBorder[3], 8, 8)

;ColumnSearch(0,0,799,551,15)

EndFunc

;----------------------------------------------------------------------------------------

; Function Track() tracks the specified target.

;----------------------------------------------------------------------------------------

Func Track($Target)

Dim $coord = PixelSearch($Target[0] - 20, $Target[1] - 20, $Target[1] + 20, $Target[1] + 20, $GREEN_BLOCK_Color, 0, 1)

If IsArray($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

Else

Scout()

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function WhichBorder() determines which edge of the screen you are heading toward and

; stores it in $b1 and $b2.

;----------------------------------------------------------------------------------------

Func WhichBorder($Target)

; Find the slope. y = mx + b

Dim $Slope = ($Target[1] - $Origin[1]) / ($Target[0] - $Origin[0])

If $Target[0] > $Origin[0] And ($Slope < (263/389) And $Slope > (288/(-389))) Then ; intersect east

; you know x = 799

$b1 = _ArrayCreate(799,0)

$b2 = _ArrayCreate(799,551)

ElseIf $Target[0] < $Origin[0] And ($Slope < (288/410) And $Slope > ((-263)/410)) Then ; intersect west

; you know x = 0

$b1 = _ArrayCreate(0,0)

$b2 = _ArrayCreate(0,551)

ElseIf $Target[1] < $Origin[1] Then ; intersect north

; you know y = 0

$b1 = _ArrayCreate(0,0)

$b2 = _ArrayCreate(799,0)

ElseIf $Target[1] > $Origin[1] Then ; intersect south

; you know y = 551

$b1 = _ArrayCreate(0,551)

$b2 = _ArrayCreate(799,551)

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function ProcessTargetQueue() removes all targets but the furthest.

;----------------------------------------------------------------------------------------

Func ProcessTargetQueue()

; Move the extra element from the beginning to the end so when

; deleting coordinates from the queue that zero will be left over

; leaving the queue with the minimum of 1 element.

_ArrayAdd($TargetQueue, 0)

_ArrayDelete($TargetQueue, 0)

; Process the queue of targets.

Dim $tempDist = 0

Dim $maxDist = 0

Dim $Target[2]

; Find the furthest target outside of the $Char_FollowDistance

; range and store the coordinates in the $Target array.

While UBound($TargetQueue) > 1

$tempDist = Distance($Origin,$TargetQueue)

If $tempDist > $maxDist Then

$maxDist = $tempDist

$Target[0] = $TargetQueue[0]

$Target[1] = $TargetQueue[1]

EndIf

; Delete checked elements in $TargetQueue.

_ArrayDelete ($TargetQueue, 0)

_ArrayDelete ($TargetQueue, 0)

WEnd

Return $maxDist

EndFunc

;----------------------------------------------------------------------------------------

; Function GridSearch() scans a grid for a specific color.

; (Currently Unused)

;----------------------------------------------------------------------------------------

Func GridSearch($xMin, $yMin, $xMax, $yMax, $xSplits, $ySplits)

Dim $xMod = Round($ScreenBorder[2]/$xSplits)

Dim $yMod = Round($ScreenBorder[3]/$ySplits)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[1] < $yMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + $xSplits, $Zone[1] + $yMod, $GREEN_BLOCK_Color, 0, 3)

If IsArray($coord) And ValidateTarget($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

EndIf

$Zone[0] = $Zone[0] + $xSplits

If $Zone[0] > $xMax Then

$Zone[0] = $xMin

$Zone[1] = $Zone[1] + $yMod

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function FrameSearch() scans a frame shaped area for a specific color.

; (Currently Unused)

;----------------------------------------------------------------------------------------

Func FrameSearch($xMin, $yMin, $xMax, $yMax, $xMod, $yMod)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[1] < $yMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + $xMod, $Zone[1] + $yMod, $GREEN_BLOCK_Color, 0, 3)

If IsArray($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

EndIf

$Zone[0] = $Zone[0] + $xMod

If $Zone[0] > $xMax Then

$Zone[0] = $xMin

$Zone[1] = $Zone[1] + $yMod

EndIf

; skip center area

If $Zone[1] > $yMin And $Zone[1] < $yMax - $yMod Then

If $Zone[0] == $xMin + $xMod Then $Zone[0] = $xMax - $xMod

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function ColumnSearch() scans a vertical column for a specific color.

;----------------------------------------------------------------------------------------

Func ColumnSearch($xMin, $yMin, $xMax, $yMax, $xMod)

Dim $Zone = _ArrayCreate ($xMin, $yMin)

While $Zone[0] < $xMax

Dim $coord = PixelSearch ($Zone[0], $Zone[1], $Zone[0] + 1, $yMax, $GREEN_BLOCK_Color, 0, 1)

If IsArray($coord) And ValidateTarget($coord) Then

_ArrayAdd($TargetQueue, $coord[0])

_ArrayAdd($TargetQueue, $coord[1])

$Zone[1] = $coord[1] + 9

Else

$Zone[0] = $Zone[0] + $xMod

$Zone[1] = $yMin

EndIf

WEnd

EndFunc

;----------------------------------------------------------------------------------------

; Function ValidateTarget() determines if the green pixel belongs to a party member on the automap.

;----------------------------------------------------------------------------------------

Func ValidateTarget($Target)

; Verify it is player marker on the automap by taking a slice.

; Store green pixels as a 1 and others as a 0, compare vs. all

; possibilities stored in ValidTargets[]

Dim $Slice = _ArrayCreate (0)

For $i = -8 to 8

Dim $c = PixelGetColor($Target[0], $Target[1] + $i)

If $c == $GREEN_BLOCK_Color Then

_ArrayAdd ($Slice, 1)

ElseIf $c == $MERC_Color Then

_ArrayAdd ($Slice, 2)

Else

_ArrayAdd ($Slice, 0)

EndIf

Next

$Slice = TrimArray($Slice, 0)

If UBound($Slice) > 4 Then

For $i = 0 to UBound($ValidTargets) - 1

If MatchArray($Slice,$ValidTargets[$i]) Then Return 1

Next

EndIf

$Slice = TrimArray($Slice, 2)

$Slice = TrimArray($Slice, 0)

If UBound($Slice) > 4 Then

For $i = 0 to UBound($ValidTargets) - 1

If MatchArray($Slice,$ValidTargets[$i]) Then Return 1

Next

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function MatchArray() returns 1 if two arrays are equal in length and value.

;----------------------------------------------------------------------------------------

Func MatchArray($array1, $array2)

If UBound($array1) == UBound($array2) Then

For $j = 0 to UBound($array2) - 1

; Ignore 2's as they are wildcards in this case.

If $array1[$j] <> 2 And $array1[$j] <> $array2[$j] Then

Return 0

EndIf

Next

Return 1

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function TrimArray() removes the zeroes from both sides of an array.

;----------------------------------------------------------------------------------------

Func TrimArray($array, $value)

Dim $count = 0

If IsArray($array) And UBound($array) > 1 Then

While $array[0] == $value And $count < UBound($array) - 1

_ArrayDelete ($array, 0)

$count = $count + 1

WEnd

_ArrayReverse ($array)

$count = 0

While $array[0] == $value And $count < UBound($array) - 1

_ArrayDelete ($array, 0)

$count = $count + 1

WEnd

EndIf

Return $array

EndFunc

;----------------------------------------------------------------------------------------

; Function Distance() returns the distance between two points.

;----------------------------------------------------------------------------------------

Func Distance($p1, $p2)

Dim $Distance = Sqrt(($p1[0] - $p2[0])^2 + ($p1[1] - $p2[1])^2)

Return $Distance

EndFunc

;----------------------------------------------------------------------------------------

; Function PerpendicularClick() clicks on an angle perpendicular to the desired destination.

;----------------------------------------------------------------------------------------

Func PerpendicularClick($xSlope,$ySlope)

Dim $newCoords = $Origin

Dim $Dist = Round(Random (50, 150))

Dim $d = RandomDirection()

While Distance($Origin,$newCoords) < $Dist

$newCoords[0] = $newCoords[0] + (-1) * $ySlope * $d

$newCoords[1] = $newCoords[1] + $xSlope * $d

WEnd

MouseClick(RightSkillDisabled(), $newCoords[0], $newCoords[1], 1, $MouseSpeed)

Sleep (250)

EndFunc

;----------------------------------------------------------------------------------------

; Function RandomDirection() randomly returns a 1 or -1 multiplier.

;----------------------------------------------------------------------------------------

Func RandomDirection()

Dim $d = Round (Random (0, 1))

If $d = 0 Then Return 1

Return -1

EndFunc

;----------------------------------------------------------------------------------------

; Function IsStuck() returns a 1 if the bot should be moving but is not.

;----------------------------------------------------------------------------------------

Func IsStuck()

$SnapshotOld = $SnapshotNew

Dim $count = 0

For $i = 0 to 7

$SnapshotNew[$i] = PixelGetColor ($CheckPointX[$i], $CheckPointY[$i])

If $SnapshotOld[$i] = $SnapshotNew[$i] Then

$count = $count + 1

EndIf

Next

If $count > 5 Then ; character is stuck

Return 1

EndIf

Return 0

EndFunc

;----------------------------------------------------------------------------------------

; Function FindIntersection() find the point of intersection between two lines.

;----------------------------------------------------------------------------------------

Func FindIntersection($a1,$a2,$b1,$b2)

Dim $p1 = _ArrayCreate($a2[0] - $a1[0], $a2[1] - $a1[1])

Dim $p2 = _ArrayCreate($b2[0] - $b1[0], $b2[1] - $b1[1])

Dim $r = (($a1[1] - $b1[1]) * $p2[0] - ($a1[0] - $b1[0]) * $p2[1]) / ($p1[0] * $p2[1] - $p1[1] * $p2[0])

Dim $x = Round($a1[0] + $r * $p1[0])

Dim $y = Round($a1[1] + $r * $p1[1])

Dim $Destination = _ArrayCreate ($x, $y)

Return $Destination

EndFunc

;----------------------------------------------------------------------------------------

; Function Hydrate() determines if healing is needed and drinks potions accordingly.

;----------------------------------------------------------------------------------------

Func Hydrate()

If TimerDiff($LastHealDrank) > $Char_DrinkHealDelay Then

Dim $LifePercent = GetLifePercent()

If $LifePercent <= $Char_DrinkPotionLifePercent Then

; Check if there is a healing potion in the belt, if so drink the first one found.

Dim $PotionSlot = Scanbelt($Heal_Potion_Color)

; Otherwise check if there is a rejuv potion in the belt, if so drink the first one found.

If $PotionSlot = -1 Then $PotionSlot = Scanbelt($Rejuv_Potion_Color)

If $PotionSlot > -1 Then

Send($KEY_Belt[$PotionSlot])

$LastHealDrank = TimerInit()

EndIf

EndIf

EndIf

If TimerDiff($LastManaDrank) > $Char_DrinkManaDelay Then

Dim $ManaPercent = GetManaPercent()

If $ManaPercent <= $Char_DrinkPotionManaPercent Then

; Check if there is a mana potion in the belt, if so drink the first one found.

Dim $PotionSlot = Scanbelt($Mana_Potion_Color)

; Otherwise check if there is a rejuv potion in the belt, if so drink the first one found.

If $PotionSlot = -1 Then $PotionSlot = Scanbelt($Rejuv_Potion_Color)

If $PotionSlot > -1 Then

Send($KEY_Belt[$PotionSlot])

$LastManaDrank = TimerInit()

EndIf

EndIf

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function GetLifePercent() returns the approximate health percentage to the nearest 10%

;----------------------------------------------------------------------------------------

Func GetLifePercent()

Dim $LifePercent = 90

Dim $Ylife = 537 - 24

Do

Dim $Pix = PixelGetColor (84 - 2, $Ylife)

If (($Pix == 90) OR ($Pix == 543000)) Then

Return $LifePercent

Else

$LifePercent = $LifePercent - 10

$Ylife = $Ylife + 8

EndIf

Until ($LifePercent == 40)

$LifePercent = 0

Return $LifePercent

EndFunc

;----------------------------------------------------------------------------------------

; Function GetManaPercent() returns the approximate percentage to the nearest 10%

;----------------------------------------------------------------------------------------

Func GetManaPercent()

Dim $ManaPercent = 90

Dim $Ymana = 536 -24

While ($ManaPercent >= 20)

Dim $Pix = PixelGetColor (744 - 2, $Ymana)

If $Pix == 5898240 Then

Return $ManaPercent

Else

$ManaPercent = $ManaPercent - 10

$Ymana = $Ymana + 8

EndIf

Wend

Dim $Pix = PixelGetColor (735 - 2, 601 - 24)

If $Pix == 2690056 Then

$ManaPercent = 10

Return $ManaPercent

Else

$ManaPercent = 0

Return $ManaPercent

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function ScanBelt() scans for a heal or rejuv potion in belt.

;----------------------------------------------------------------------------------------

Func ScanBelt($PotionColor)

Dim $Belt = _ArrayCreate(432, 577, 446, 587)

Dim $x = 0

Dim $Drink = 0

For $n = 0 to 3

Dim $Potion = PixelSearch ($Belt[0] + $x, $Belt[1], $Belt[2] + $x, $Belt[3], $PotionColor, 0, 1)

If IsArray($Potion) Then

Return $n

EndIf

$x = $x + 30

Next

Return -1

EndFunc

;----------------------------------------------------------------------------------------

; Function RightSkillDisabled() check whether skill on the right side is disabled.

;----------------------------------------------------------------------------------------

Func RightSkillDisabled()

Dim $Pixel = PixelSearch (640, 576, 684, 620, $Skill_Disabled_Color, 0, 2)

If $Char_UseTeleport == 0 Or IsArray($Pixel) Then

Return 'left'

Else

Return 'right'

EndIf

EndFunc

;----------------------------------------------------------------------------------------

; Function Type() sends text to the game.

; (Used for debugging)

;----------------------------------------------------------------------------------------

Func Type($Message)

Send ('{ENTER}')

Sleep (50)

Send ($Message, 1)

Sleep (50)

Send ('{ENTER}')

EndFunc

;MouseMove ($Pixel[0], $Pixel[1], $MouseSpeed)

anybody has any experience with this follow bot?!

cheers anyways :D

Edited by merrin77
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...