Gogeta70 Posted April 11, 2009 Share Posted April 11, 2009 Hey everyone. I just began using AutoIt recently, but i have been coding in PHP for several years. Currently, i have been working on making a bot for a game called KalOnline, an mmorpg. Two problems i'm seeing is that the script isn't detecting pixels properly (or at all), and when i try to send input using the Send() function, it has no effect in the game. Basically, this bot is supposed to do the following: -Find and kill enemies -Behead the enemy once they're dead -Auto-pot when health is low -Pick up drops once the enemy is dead I'm not getting any syntax errors when compiling, but nothing is happening when i run it either. Hopefully somebody can point me in the right direction... Here's the code: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: Gogeta70 Script Function: KalOnline Pixel Bot #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here $handle = ControlGetHandle("KalOnline", "", "") MsgBox(64, "Instructions", "Put your mouse over the area" & @CRLF & "of your health bar that when reached," & @CRLF & "the bot will auto-pot. When done, press enter.") $hcoord = MouseGetPos() $healthcolor = PixelGetColor($hcoord[0], $hcoord[1]) MsgBox(64, "Instructions", "Now do the same thing, except put it over the demon/monster that you want to kill, and press enter.") $dcoord = MouseGetPos() $demoncolor = PixelGetColor($dcoord[0], $dcoord[1]) MsgBox(64, "Instructions", "Ok, now one more time. This time, click on a demon but don't attack, just click off. Now hold your mouse" & @CRLF & " over the very left of the demon's health bar (still on the red part). When you do that, press enter.") $dhcoord = MouseGetPos() $demonhealth = PixelGetColor($dhcoord[0], $dhcoord[1]) MsgBox(0, "OK!", "Ok, now we have the coordinates of your health bar, the demon health bar, and the color of the demons." & @CRLF & "If you want to behead monsters, set it as your active skill.") WinSetOnTop("KalOnline", "", 0) Dim $behead[7][7] $winpos = WinGetPos("KalOnline") $winx = $winpos[0] $winy = $winpos[1] $width = $winpos[2] $height = $winpos[3] $battle = "no" $behead[0][0] = "404"+$winx $behead[0][1] = "405"+$winy $behead[1][0] = "366"+$winx $behead[1][1] = "351"+$winy $behead[2][0] = "406"+$winx $behead[2][1] = "351"+$winy $behead[3][1] = "351"+$winy $behead[4][0] = "403"+$winx $behead[4][1] = "316"+$winy $dummy = 1 while $dummy == 1 Dim $pcoords[2] $pcoords[0] = "406"+$winx $pcoords[1] = "351"+$winy $pcoords = ScrScan($winx, $winy, $width, $height, $demoncolor) If $pcoords <> "false" Then MsgBox(0, "You got this far", "You've gotten this far") MouseClick("main", $pcoords[0], $pcoords[1]) sleep(100) $tdh = PixelGetColor($dhcoord[0], $dhcoord[1]) If $tdh == $demonhealth Then $battle = "yes" Else Send("{LEFT down}") sleep(2000) Send("{LEFT up}") EndIf EndIf $myhealth = PixelGetColor($hcoord[0], $hcoord[1]) If $myhealth <> $healthcolor Then Send("4") sleep(1000) EndIf If $battle == "yes" Then While $battle == "yes" $myhealth = PixelGetColor($hcoord[0], $hcoord[1]) If $myhealth <> $healthcolor Then Send("4") Sleep(1000) EndIf $demonh = PixelGetColor($dhcoord[0], $dhcoord[1]) If $demonh <> $demonhealth Then MouseClick("secondary", $behead[0][0], $behead[0][1], 1, 0) MouseClick("secondary", $behead[1][0], $behead[1][1], 1, 0) MouseClick("secondary", $behead[2][0], $behead[2][1], 1, 0) MouseClick("secondary", $behead[3][0], $behead[3][1], 1, 0) MouseClick("secondary", $behead[4][0], $behead[4][1], 1, 0) Send("{SPACE}") Sleep(1000) Send("{SPACE}") Sleep(1000) Send("{SPACE}") $battle = "no" EndIf WEnd EndIf WEnd Func ScrScan($winx, $winy, $width, $height, $monster) $tempy = $winy + $height $tempx = $winx While $tempy > $winy $tempx = $winx While $tempx < $winx + $width $tcolor = PixelGetColor($tempx, $tempy) If $tcolor == $monster Then Return $tcoords EndIf $tempx = $tempx + 4 WEnd $tempy = $tempy - 10 WEnd Return "false" EndFunc Link to comment Share on other sites More sharing options...
zutto Posted April 11, 2009 Share Posted April 11, 2009 are you sure it wont find any pixels? try using tooltip or display to console to find for sure since some games block send("") function. Link to comment Share on other sites More sharing options...
Gogeta70 Posted April 11, 2009 Author Share Posted April 11, 2009 Yeah, it's not finding any pixels. The function returns false when it doesn't find any matching pixels, and if it does find a matching pixel (for debugging purposes) it opens up message box saying "You've gotten this far." If games block the Send() function, what should i use to send keystrokes then? Link to comment Share on other sites More sharing options...
Gogeta70 Posted April 11, 2009 Author Share Posted April 11, 2009 Just a heads up everyone, i fixed it by doing the following: -Changing all Send() functions to ControlSend() -Using PixelSearch() instead of my own function Good luck to you all on your projects! Link to comment Share on other sites More sharing options...
dexto Posted April 11, 2009 Share Posted April 11, 2009 Pixel Search is much much faster way also look in future release for added functionality for Pixel search that is going to help greatly in tasks like such. Link to comment Share on other sites More sharing options...
Gogeta70 Posted April 11, 2009 Author Share Posted April 11, 2009 Yeah, definitely. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now