SRL Archive - Research & Development Lounge

WaitUntilBitmapSafe


mrpickle

2009-05-15 01:52:42

EDIT: Smoothed the explanation abit. + I just realized it works for DTM too… So i change name.

This is a function that waits until an object is located, or the maximal time is reached.


//Delay: how long to wait before it gives a tick to the "Timer"
//MaxTime: Secondary stopping condition: if the ticks on the "Timer" reaches over the maxtime quantity, it will stop.
//Bitmap: Will repeat until it finds this bitmap.

// By Mixter
function WaitUntilBitmapFound(Delay, MaxTime, Bitmap : integer) : boolean;
var
T, x, y : integer;
begin
T := GetSystemTime;
Result := True;
while (GetSystemTime - T >= MaxTime) do
if (FindBitmap(Bitmap, x, y)) then
exit
else
wait(Delay);
Result := False;
end;

or as a procedure


//By: mrpickle
Procedure WaitForBitmap(DelayCounting, MaxDelayCounting, Bitmap:integer);
var timer:integer;
begin
repeat
wait(DelayCounting);
Timer := Timer + 1
If Timer > MaxDelayCounting then
Writeln ('Timed Out');
Break;
until (FindBitmap(Bitmap,x,y))
Timer := 0
end;

Shuttleu

2009-05-15 02:32:02

you could make the names of some of the vars more meaningful
like maxtime
i would put say 10000 for 10 seconds
but that wouldnt be it that would depend on how much you put in the delay
so if i put in 100 for the delay and 10000 for the maxtime then it wouldnt be 10 seconds it would be 100 seconds

~shut

mrpickle

2009-05-15 02:40:22

Alright =D, I hope this is more meaningful?

Shuttleu

2009-05-15 02:44:01

thats better
looks good
well done
keep up the good work :)
rep++

~shut

JPHamlett

2009-05-15 03:29:34

From: mrpickle
////////////////////////////////////////
//delaycount: how long to wait before it gives a tick to the "Timer"
////////////////////////////////////////
//maxdelaycount: Secondary stopping condition: if the ticks on the "Timer" reaches over the maxtime quantity, it will stop.
////////////////////////////////////////
//bitmap: Will repeat until it finds this bitmap.
////////////////////////////////////////
//By: mrpickle
Procedure WaitUntilBitmapSafe(delaycount, maxdelaycount, bitmap:integer);
var timer:integer;
begin
repeat
wait(delaycount);
Timer := Timer + 1
If Timer > maxdelaycount then
Writeln ('Timed Out');
Break;
until (FindBitmap(bitmap,x,y))
end;

using this for my in progress FPS bot! =D. just thought I share




looks good if u want any help i can help i play combat arms too not latly cause i ound cross fire but i can still help

Da 0wner

2009-05-15 04:01:43

function WaitUntilBitmapFound(Delay, MaxTime, Bitmap : integer) : boolean;
var
T, x, y : integer;
begin
T := GetSystemTime;
while (GetSystemTime - T >= MaxTime) do
begin
wait(Delay);
result := FindBitmap(Bitmap, x, y);
if result then
break;
end;
end;

I could have combined it into like 2 lines but then it wouldn't return a boolean :p.

mrpickle

2009-05-15 05:57:47

lolz, proves who can name things better too xD.

Edit: now you made me change its name:p

Da 0wner

2009-05-15 06:21:33

XD ;).
So basically this waits until a bitmap is found or the max time is reached?

JPHamlett

2009-05-15 06:26:25

mr pickle is it a deal

mrpickle

2009-05-15 06:35:45

p.s. Can I change the thread name to WaitForObject ?

From: Da 0wner
XD ;).
So basically this waits until a bitmap is found or the max time is reached?


lol yeah… simple. =D.



From: J_Pizzle
mr pickle is it a deal


Hun?

JPHamlett

2009-05-15 07:06:15

i can help i play combat arms too i think i remember seeing that in a diffrent script section for this script

i posted it earlier i jsut reworded it it dixnt make any sence when i read it again

Da 0wner

2009-05-15 07:31:26

Nah, it made since. It was just missing some periods lol.
You never seem to use periods..

mixster

2009-05-15 19:46:40


function WaitUntilBitmapFound(Delay, MaxTime, Bitmap : integer) : boolean;
var
T, x, y : integer;
begin
T := GetSystemTime;
Result := True;
while (GetSystemTime - T >= MaxTime) do
if (FindBitmap(Bitmap, x, y)) then
exit
else
wait(Delay);
Result := False;
end;

Shorter, but does that make it better?
Nothing was wrong with the original code except a missing begin and end for the if in the loop (it would break on every loop that way regardless of finding a bitmap of not) - fix this and success, though adjusting it to a function makes more sense :)