Jump to content

Recommended Posts

Posted

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?

Posted

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?

Posted

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!

Posted

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.

Posted

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

"

Posted

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.

Posted

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?

Posted

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]
Posted (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 by Elku

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
  • Recently Browsing   0 members

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