SRL Archive - SRL Archives

My New Object finding functioon!!! pwng..


n3ss3s

2007-08-06 05:22:10

Okay, first of all, my comp didnt let me download divi 3.11 so I dont have the function "AMin" in my scar to get the smallest value in an array.
So, I made it myself. What I know it has only one bug and that is that you cant use an array with only 1 slot. But, however the function works perfect with my object finding function. (the small function on the top is bobs :) )

I tried the object finder on a tree near champions guild and it worked good.
It spams your debug box a bit since I had to know what it does when testing..
So, just remove the writelns if you ever gonna use.

EDIT: Oops forgot usage instructions :D

for surecolor, set a color that is a color in the object which will like definetly be found. Then the array, put the array you have colors in there, for HowManyEnough, put how many colors is enough for the object to be really found. For area, put the area which is count from the coords of "surecolor". Tol and uptext everyone knows.


program New;
{.include SRL/SRL.scar}
var
AC: TIntegerArray;

{*******************************************************************************
function WhichArraySlot(Number: Integer; TheArray: TIntegerArray): Integer;
By: Bobarkinator
Description: Returns what array slot has the value "Number" in "TheArray".
*******************************************************************************}
function WhichArraySlot(Number: Integer;TheArray: TIntegerArray): Integer;
var
i: Integer;
begin
for i:= 0 to GetArrayLength(TheArray)-1 do
begin
if (Number = TheArray[i]) then
begin
Result:=i;
Exit;
end;
end;
end;


{*******************************************************************************
function SmallestInArray(TheArray: TIntegerArray): Integer;
By: n3ss3s
Description: Returns the smallest integer in an array.
*******************************************************************************}
function SmallestInArray(TheArray: TIntegerArray): Integer;
var
I, Ax, Ay, DimensionHandler, TRL: Integer;
var
TempResult: TIntegerArray;
begin
Ax := 0;
Ay := 1;
for I := 0 to GetArrayLength(TheArray) / 2 do
begin
Wait(10);
SetArrayLength(TempResult, GetArrayLength(TempResult) +1);
if(not(Ay > GetArrayLength(TheArray) /2)) or (not(Ax > GetArrayLength(TheArray) /2)) then
begin
TempResult[I] := Min(TheArray[Ax], TheArray[Ay]);
Ax := Ax + 2;
Ay := Ax + 1;
end else
begin
Break;
end;
end;
I := 0;
repeat
Ax := 0;
Ay := 1;
TRL := GetArrayLength(TempResult) / 2 ;
TRL := TRL - 1;
for I := 0 to TRL do
begin
if(Ax > GetArrayLength(TheArray))then
begin
Break;
end;
if(I > GetArrayLength(TempResult))then
begin
Break;
end;
TempResult[I] := Min(TheArray[Ax], TheArray[Ay]);
Ax := Ax + 2;
Ay := Ax + 1;
DimensionHandler := DimensionHandler + 1;
end;
SetArrayLength(TempResult, DimensionHandler);
DimensionHandler := 0;
Wait(10);
if(GetArrayLength(TempResult) = 1)then
begin
Result := TempResult[0];
Break;
end;
until(GetArrayLength(TempResult) = 2);
if(not(Result) = TempResult[0])then
begin
Result := Min(TempResult[0], TempResult[1]);
end;
end;



{*******************************************************************************
function FindObject(var FoX, FoY: Integer; Colors: TIntegerArray;
SureColor, Area, HowManyEnough, Tol: Integer; UpText: string): Boolean;
By: n3ss3s
Description: Finds object.
*******************************************************************************}
function FindObject(var FoX, FoY: Integer; Colors: TIntegerArray;
SureColor,Area, HowManyEnough, Tol: Integer; UpText: string): Boolean;
var
I, S, GoodOnes, F, Toler, L: Integer;
var
TPA: TPointArray;
var
DIA: TIntegerArray;
var
Dx, Dy: Integer;
var
Mx, My: Integer;
var
SCFound, HMEnough: Boolean;
begin
SetArrayLength(TPA, 0);
SetArrayLength(DIA, 0);
for S := 1 to 10 do
begin
if(FindColorTolerance(Dx, Dy, SureColor, MSX1, MSY1, MSX2, MSY2, 10 + S))then
begin
MMouse(Dx, Dy, 0, 0);
if(IsUpText(UpText))then
begin
Writeln('"Sure Color" found!');
Writeln(IntToStr(DX)+','+IntToStr(Dy));
SCFound := True;
Dx := Dx;
Dy := Dy;
Break;
end;
end;
end;
if(SCFound)then
begin
for I := 1 to 10 do
begin
for I := 0 to GetArrayLength(Colors) - 1 do
begin
if(FindColorTolerance(Mx, My, Colors[i], Dx - Area /2, Dy - Area /2,
Dx + Area /2, Dy + Area /2, Toler)) then
begin
MMouse(Mx, My, 0, 0);
if(IsUpText(UpText))then
begin
SetArrayLength(TPA, GetArrayLength(TPA) + 1);
GoodOnes := GoodOnes + 1;
Writeln('Found');
TPA[GetArrayLength(TPA) -1].x := Mx;
TPA[GetArrayLength(TPA) -1].y := My;
if(GoodOnes >= HowManyEnough)then
begin
Writeln('Enough colours found!');
HMEnough := True;
Break;
end;
end;
end;
if(HMEnough)then
begin
Break;
end;
end;
if(not(HMEnough)) then
begin
Toler := Toler + 2;
end else
begin
Break;
end;
end;
end;
if(HMEnough)then
begin
Writeln('Solving closest');
for F := 0 to GetArrayLength(TPA) -1 do
begin
SetArrayLength(DIA, GetArrayLength(DIA) +1);
DIA[f] := Distance(TPA[f].x, TPA[f].y, MMCX, MMCY);
Wait(100);
Writeln('solvin');
end;
Writeln('gettin closest');
L := WhichArraySlot(SmallestInArray(DIA), DIA);
Mx := TPA[L].x;
MY := TPA[L].y;
FoX := Mx;
FoY := My;
Writeln(IntToStr(FoX));
Writeln(IntToStr(FoY));
Result := True;
Exit;
Writeln('solved');
end;
end;

begin
SetupSRL;
SetArrayLength(AC, 8);
AC[0] := 865582;
AC[1] := 2179644;
AC[2] := 2048571 ;
AC[3] := 265998 ;
AC[4] := 1651255;
AC[5] := 728349;
AC[6] := 203546;
AC[7] := 7039858;
if(FindObject(x, y, AC, 536614, 100, 2, 10, 'down'))then
begin
Mouse(x, y, 0, 0, True);
end;
end.

Santa_Clause

2007-08-06 05:28:59

You should really make a script instead of heaps of functions :p

Nice anyway…

n3ss3s

2007-08-06 05:45:29

You should really make a script instead of heaps of functions

Nice anyway…

Why? Then I couldnt use it in scripts, if it was a script.

Bobarkinator

2007-08-06 07:23:10

Hey good work man. I'm gonna test this later but quick question, what do we put for SureColor?

n3ss3s

2007-08-06 07:28:02

what do we put for SureColor?

A color that will like definetly be found. Like umm, remember the ex guards? They had the red headband. That would be surecolor..

GoF

2007-08-07 04:18:43

Nice, but I don't understand why you put like "pwng" or that "functioon!!!!" kind of stuff to your messages and threads name :p

n3ss3s

2007-08-07 04:24:56

Nice, but I don't understand why you put like "pwng" or that "functioon!!!!" kind of stuff to your messages and threads name

You cannot miss that :)

Dark_Sniper

2007-08-08 00:32:34

why not be cool and make another findobj… using just one find obj in srl…


(just so you know thats a hit on SRL saying to clean the include up XD)
(look in obect.scar … there is like on findobj proc in there… and every other find obj proc in object.scar uses that findobj to find the obj…)

Pyro

2007-08-08 03:09:46

ummm its ok. Really i prefer using findcolorsSpiral notice the two s's. Try working that.. It will work better. by the look of your skills. If you used findcolors then it would be awesome

Santa_Clause

2007-08-08 03:21:10

I find them unreliable…

FindColorSkipBoxArrayTolerance!

n3ss3s

2007-08-08 03:57:27

Nice suggestions.. Now I gotta go draw me some siggies :)

EDIT: Umm why do I wanna use FindColorsSpiral? I mean, like where I need to find all the same colors?

EDIT EDIT: Holy…. Pyro I got awsum idea. FindColorsSpiral saves the all same colors to a TPointArray, right? I could make a two dimension array in my script, every color would have its own TPointArray! :O

SKy Scripter

2007-08-08 14:11:50

:)


function AMin(Data : TIntegerArray): Integer;
var
i, l : Integer;
begin
l := Length(Data);
if (l = 0) then exit;
Result := Data[0]
for i := 1 to l-1 do
if (Data[i] < Result) then
Result := Data[i];
end;

n3ss3s

2007-08-08 14:30:41

How much you want for removing that post, SKy? :D
Jk/Jk
A lil embarrasment since I was so proud of SmallestInArray lolmao

SKy Scripter

2007-08-08 15:11:37

From: n3ss3s
How much you want for removing that post, SKy? :D
Jk/Jk
A lil embarrasment since I was so proud of SmallestInArray lolmao


Lol, hmmm 1m :p jk
well you got a better one now? ;)

n3ss3s

2007-08-08 15:15:36

well you got a better one now?
??

SKy Scripter

2007-08-08 16:16:08

From: n3ss3s
??


Use Mine. im sure its faster or whatever lol :)

n3ss3s

2007-08-08 16:18:05

Maybe :)

bullzeye95

2007-08-08 16:51:53

function ArrMin(I: TIntegerArray): Integer;
var
C: Integer;
begin
Result:= I[0];
for C:= 1 to Length(I) - 1 do
if(Result > I[C])then Result:= I[C];
end;
Even shorter :p

By the way, yours didn't work with negative numbers.

n3ss3s

2007-08-08 16:56:09

nice :D

Well, mine was custom for the object finder :)

bullzeye95

2007-08-08 17:03:05

Jeez I still managed to get it shorter
function ArrMin(I: TIntegerArray): Integer;
begin
BubbleSort(I);
Result:= I[0];
end;
And I'll stop spamming your thread now :p

n3ss3s

2007-08-08 17:04:29

LMAO, the point is that it cant use Divi 3.11 :)
I <3 3.06 :D

SKy Scripter

2007-08-09 02:34:55

Bullzeye yours would get errors for things like 0 array length :p