Elku Posted November 27, 2007 Posted November 27, 2007 Been trying to make a macro bot for an offline game but I seem to encounter some difficulty with the color coding. func EnemyScan() $Enemy = PixelSearch(674,180,693,535, 0xBD1313,0) if not @error Then Mouseclick("left",$Enemy[0], $Enemy[1]) sleep(2000) mouseclick("left",790,127) sleep(500) mouseclick("left",820,128) sleep(20000) Attack() SendDrone() else $currentAsteroid = $currentAsteroid+1 EndIf endfunc This here, works at 100%. Never had a single fail. func EnemyCheck() $TEMP = 0 while $TEMP = 0 $EnemyCheck = PixelSearch(811,117,830,140, 0xFF0000) if not @error Then sleep(5000) Else $TEMP = 1 EndIf WEnd EndFunc This, seems to fail like 50% of the time, even though the color stays and cannot change. ( I tried adding shades, didn't fix the problem). The area of scan is also very tiny. Precision about the game: It is in 3d, so I dunno if that can bug or something, and it has many "layers" (3d background, 3d objects and a 2d overview added over where I am scanning, but the overview got top priority and no transparency, so it is always pure red FF0000. Any idea?
Elku Posted November 27, 2007 Author Posted November 27, 2007 Alright, I've played around with the script that was having problem, I found out a way to put all the background as black and that it won't have any color. Now that this is like that, there are like big blocks of 0x808080 gray color in a pretty small area, so a lot of them, all same color. It still, somehow, has 50% success rate (meaning it says it errors even though the block is actually full of that color.). Now, how the script works is by using @error, think something else might be causing an error and gets detected?
Trait Posted November 27, 2007 Posted November 27, 2007 I've done pixel searches before to create bots and I find that there are times where window focus changes without you knowing it and screws with your search. Try adding a WinActivate() to your program to keep the focus where you want it. Good luck!
Elku Posted November 27, 2007 Author Posted November 27, 2007 Thanks! But I think the pixel search might be buggy as well. func EnemyCheck() while $TEMP = 0 PixelSearch(560,20,470,30, 0) if not @error Then $TEMP = 1 Else sleep(5000) EndIf WEnd $TEMP = 0 EndFunc It basically searches black in a black square... it says it finds none. Constantly. EVen if the square is pure black.
Trait Posted November 27, 2007 Posted November 27, 2007 I remember running into a problem with @error awhile back working on a bot for another game I play. My code went something like this " If $ManaBolt <> @error then Do whatever until 0 else ;manabolt not found endif " You get the idea. It broke half the time but I couldn't tell why. I switched all the logic so that it went more like " if $ManaBolt = @error then ;damn bolt not found! else Do whatever until 0 endif "
Elku Posted November 27, 2007 Author Posted November 27, 2007 And did the success rate change? I did not know the error value was associated with the pixelsearch variable. I tried the winactive and it didn't change anything. Same thing as usual, can't find the damn pixel even if it's there. I'll try your idea, trait.
Elku Posted November 28, 2007 Author Posted November 28, 2007 So, after a whole day of playing with the colors codes, shades, even tested on a picture, it kept on failing. Is there something I might be missing to have a 100% pixel find rate?
ame1011 Posted November 28, 2007 Posted November 28, 2007 I've done my fair share of pixel searching back in the day and this works flawlessly for me: Func EnemyCheck() While 1 $coords = PixelSearch(500, 500, 600, 600, 0x000000) If Not @error Then ExitLoop Else Sleep(5000) EndIf WEnd ConsoleWrite ("Found Pixel at : " & $coords[0] & "," & $coords[1] & @CRLF) EndFunc ;==>EnemyCheck [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Elku Posted November 30, 2007 Author Posted November 30, 2007 (edited) I tried your thing, and it still FAILS. Basically here what happens: It runs EnemyCheck(), does a pixel search in a tiny area.... success round 1! Does a pixel search in the same area, area which WAS NOT MODIFIED... FAIL! Why? Oho! Might have found the source of the problem. Basically, when my base locks a target and fires at it, no problem. When my base loses Lock due to range or just because the target dies, it seems to change every in-game settings for the background as if I wasn't on the map screen anymore. Even though I can't see it, I bet the program does, making it exit. Currently making a function to fix this. Edited November 30, 2007 by Elku
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