SRL Archive - Research & Development Lounge

my object finding


Awkwardsaw

2009-08-10 04:46:18

this thread is just to post my personally fave object finding procedure(made by me of course)


procedure A_Debug(text: string); //posted because its used in A_FindObj
begin
writeln('[' + thetime + ']' + ' Error Occured at: ' + text + '.');
alert('[' + thetime + ']' + ' Error Occured at: ' + text + '.');
end;

function A_FindObj(color, tol : integer; uptext : string; left : boolean): boolean;
var
T : tpointarray;
i, x, y, d: integer;
time : integer;
begin
result:= true;
d:= 0;
if not loggedin then loginplayer;
ColorToleranceSpeed(3);
time := 0;
marktime(time);
while not FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
if time > 5000 then break;
end;
ColorToleranceSpeed(1);
if Length(T) = 0 then
begin
A_Debug('color not found');
result:= false;
exit;
end;
for i:= 0 to high(t) do
begin
mmouse(T[i].X, T[i].Y, 0, 0);
if isuptext(uptext) then
begin
getmousepos(x, y);
mouse(x, y, 0, 0, left);
wait(100 + random(2000));
end;
end;
if not result then
begin
A_Debug('Something has gone wrong');
players[currentplayer].active := false;
end;
end;

go ahead and post yours up here, if you have one :p i know i should add atpas, but imo for current use, this works just fine as it is

NCDS

2009-08-10 04:53:04

I've been using these together lately..

function GetColorPoints(x, y, Color, bp1, bp2, bp3, bp4, Width, Height, Tol: Integer): TPointArray;
var tpa: array of TPoint; i, o: SmallInt; atpa: T2DPointArray;
begin
FindColorsSpiralTolerance(x, y, tpa, Color, bp1, bp2, bp3, bp4, Tol);
atpa := TPAtoATPAEx(tpa, Width, Height);

for i := 0 to High(atpa) do
begin
o := GetArrayLength(Result);
SetArrayLength(Result, o + 1);
Result[o] := MiddleTPA(atpa[i]);
end;

WriteLn('Length(Array): '+IntToStr(i)+';');
end;


function ClickPointMM(tpa: TPointArray; ranX, ranY: Byte): Boolean;
var i: Integer; p: TPoint;
begin
if Length(tpa) = 0 then Exit;

for i := 0 to High(tpa) do
begin
p := Point(tpa[i].x + ranX, tpa[i].y + ranY);

if not RS_OnMiniMap(p.x, p.y) then
begin
Writeln('WARNING!: Point not on screen.');
Continue;
end;

Mouse(p.x, p.y, 3, 3, True);
Writeln('ClickedPoint('+IntToStr(p.x)+', '+IntToStr(p.y)+');');
Wait(RandomRange(1000, 2000));
FFlag(1 + Random(3));
Result := True;
Exit;
end;
end;


function MousePoint(tpa: TPointArray; UpText, Option: String; ranX, ranY: Byte): Boolean;
var i: Integer; p: TPoint;
begin
if Length(tpa) = 0 then Exit;

for i := 0 to High(tpa) do
begin
if (Distance(tpa[i].x, tpa[i].y, MSCx, MSCy) > 50) then
Exit
else
begin
p := Point(tpa[i].x + ranX, tpa[i].y + ranY);

if Random(3) <> 1 then Bool := True;
if Bool then
begin
Result := MouseEx(p.x, p.y, 2, 2, UpText, Bool)
GetMousePos(x, y);
TcPoint := Point(x, y);
else
Result := ChooseOption(Option);
end;
end;
Writeln('Clicked Point('+IntToStr(p.x)+', '+IntToStr(p.y)+');');
end;

Awkwardsaw

2009-08-10 04:55:31

i think i just got gf'd. :D they look pretty useful tbh

noidea

2009-08-10 05:20:02

awkwark: Its useless to use CTS3 if you're going to forget about The CTS3 Sensitivity. Cazax has a tut for it thats like sex (all of his tuts are like sex :p).

EC! realized that there is a bug with SCAR returning false with the FindColorsSpiralTolerance weather or not the function finds the points.

 
while not FindThis <-- make this a boolean var do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
FindThis := Length(T) > 0;
if time > 5000 then break;
end;

Awkwardsaw

2009-08-10 05:30:06

From: noidea
awkwark: Its useless to use CTS3 if you're going to forget about The CTS3 Sensitivity. Cazax has a tut for it thats like sex (all of his tuts are like sex :p).

EC! realized that there is a bug with SCAR returning false with the FindColorsSpiralTolerance weather or not the function finds the points.

 
while not FindThis <-- make this a boolean var do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
FindThis := Length(T) > 0;
if time > 5000 then break;
end;

thats odd, when i debugged cts3, it still worked better than without, but i will change it :)

and thanks for the feed back :) if i could + rep you i would lol

MylesMadness

2009-08-10 06:35:16

  while not FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
if time > 5000 then break;
end;

Why not
  while not FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) do
if time > 5000 then break;

Awkwardsaw

2009-08-10 06:36:28

From: MylesMadness
  while not FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
if time > 5000 then break;
end;

Why not
  while not FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol) do
if time > 5000 then break;


:o /facepalm. haha. thanks

Phran6

2009-08-11 09:33:40

From: noidea
awkwark: Its useless to use CTS3 if you're going to forget about The CTS3 Sensitivity. Cazax has a tut for it thats like sex (all of his tuts are like sex :p).

EC! realized that there is a bug with SCAR returning false with the FindColorsSpiralTolerance weather or not the function finds the points.

 
while not FindThis <-- make this a boolean var do
begin
FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
FindThis := Length(T) > 0;
if time > 5000 then break;
end;


FALSE CTS3 automaticaly set to 4 !!

from manual

procedure SetColorspeed3Modifiers(Sensitivity: Integer);
This works when ColorToleranceSpeed(3) has been set.
This sets the Sensitivity of the 3th color comparison mode.
The default Sensitivity is 4. (Note that this is carefully chosen and will be sufficient in most cases.)

noidea

2009-08-12 01:01:27

Francis: Some colours are found a whole lot mre easily if you define a certain sensitivity.
I didnt make a true or false statement. I'm just saying it's in hte functions best intrest to make a param for the sensitivity.

Darkcorn

2009-08-12 06:03:06

nice

Awkwardsaw

2009-08-12 06:13:51

From: Darkcorn
nice


sorry, but i count that as "spam to get scripts" :mad:

no real offence, but meh