Aciid Posted January 22, 2008 Share Posted January 22, 2008 (edited) So i'm making an anti-AFK bot for World of Warcraft Battlegrounds just like everyone else and i have a big problem now. I made a special Addon for WoW that displayes a little colored square in the middle of your screen. I made it so that if you are outside the BG it turns into Blue, when you're inside the BG it turns into Red and when you're dead it turns into green. On to my problem.... I made a loop with random keypresses that starts when the square is Red. now sometimes when the BG is over my square turns into Blue but my bot still finishes his loop for when the square is Red. I dont want that to happen i want it to Stop the Loop when the Color of my square changes and restart the Function startBot to check the colors again. I searched the for and found many simlar problems but still couldnt solve it expandcollapse popupFunc startBot() While 1 If Not WinExists("World of Warcraft") Then MsgBox(1, "Bot", "World of Warcraft is not running!") ExitLoop ElseIf WinWaitActive("World of Warcraft") Then AdlibEnable("square", 1) Endif WEnd EndFunc Func square() $squareColor = PixelGetColor(450, 360) If $squareColor = 0x0000FF Then outBattleground() ElseIf $squareColor = 0xFF0000 Then InBattleground() ElseIf $squareColor = 0x00FF00 Then playerDead() EndIf EndFunc Func outBattleground() ;Joins the BG MouseClick("Right", 450, 360) Sleep(random(1000,3000)) Send("{NUMPAD6}") MouseClick("Left", 415, 136) EndFunc Func inBattleground() ;Bunch of key presses when in BG EndFunc Func playerDead() ;Do stuff when you're dead EndFunc Edited January 22, 2008 by Aciid Link to comment Share on other sites More sharing options...
Aciid Posted January 23, 2008 Author Share Posted January 23, 2008 Bump Link to comment Share on other sites More sharing options...
Rad Posted January 23, 2008 Share Posted January 23, 2008 Depending on how many keypresses you initiate the loop will not terminate until they have all been completed. You should probrably put the key pressed in a While loop until the pixel color is not equal to red anymore. Example Func square() $squareColor = PixelGetColor(450, 360) If $squareColor = 0x0000FF Then outBattleground() ElseIf $squareColor = 0xFF0000 Then InBattleground() ElseIf $squareColor = 0x00FF00 Then playerDead() EndIf EndFunc Func outBattleground() ... EndFunc Func inBattleground() While $squareColor = 0xFF0000 ;Single or few key presses here $squareColor = PixelGetColor(450, 360) Wend EndFunc Func playerDead() ... EndFunc If it gets laggy or anything you might consider adding a Sleep(200) to the beginning of the loop Link to comment Share on other sites More sharing options...
Aciid Posted January 23, 2008 Author Share Posted January 23, 2008 (edited) Thanks for your help it works now ! I just let it check the color before i do another keypress then if the color doesnt match it exits the loop. If anyone knows a cleaner/better way to do the same like this let me know cause it's gonna be verry anoying to put a color check after every key press i do Func inBattleground() $squareColor = PixelGetColor(450, 360) While $squareColor = 0xFF0000 If PixelGetColor(450, 360) <> 0xFF0000 Then ExitLoop Send("{NUMPAD7}") Sleep(random(1500,2000)) If PixelGetColor(450, 360) <> 0xFF0000 Then ExitLoop Send("{NUMPAD7}") Sleep(random(1500,2000)) If PixelGetColor(450, 360) <> 0xFF0000 Then ExitLoop) Send("{NUMPAD7}") Sleep(random(1500,2000)) If PixelGetColor(450, 360) <> 0xFF0000 Then ExitLoop Send("{w down}") Sleep(10000) Send("{w up}") WEnd EndFunc Edited January 23, 2008 by Aciid 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