SRL Archive - OSR Help

Putting two tpa's and searching cords


Troll

2011-01-14 17:09:55

Ok some stiles for fishing lobsters is really hard to find as he has colors like his surroundings so what i thought of was what if i use two tpas for two colors then say must find Color 1 and then Color 2 from 10 to 20 x higher so it finds two diffrent colors in a line.

Would this work? if so how could i go about it?

Thanks

Also if you have the time wound you mind wirting a basic basic just a couple of lines of where to go as i can build up (i learn best that way) Thanks :)

E: When did i get useful poster ? :p

Dgby714

2011-01-14 17:15:04

Read Sir R. Magician's Post below.

Sir R. M8gic1an

2011-01-14 17:16:57

Read about TPAs
Read about WizzyPluggin

And look for colorfinding / object finding tuts.

You'll want to search and save two different TPAs and then you would want to use an enlarged version of MatchTPA.

I don't know where the hell MatchTPA is anymore, but it just basically checks if two TPAs are around each other.

TPAs are TPointArrays. Arrays of TPoint

TPoint = record
x, y: integer


type
//To be used with CTS 2
TMultiColor = record
Color: integer;
tol: integer;
h, s: extended;
end;

TMultiColorArray: Array of TMultiColor;

function MColor(Color, tol: integer; h, s: extended): TMultiColor;
begin
Result.Color := Color;
Result.tol := tol;
Result.h := h;
Result.s := s;
end;

//to ensure correct passing of information
function MColorArray(MArray: array of TMultiColor): TMultiColorArray;
var
i, L: integer;
ThisColor: TMultiColor;
begin
L := Length(MArray);
SetLength(Result, L);

for i := 0 to L - 1 do
begin
with ThisColor do
begin
Color := MArray[i].Color;
Tol := MArray[i].Tol;
h := MArray[i].h;
s := MArray[i].s;
end;

Result[i] := ThisColor;
end;
end;

type
CTS2Mode = record
Speed: integer;
h, s: extended;
end;

var CurrentCTS, PreviousCTS, DefaultCTS: CTS2Mode;

procedure StartCTS2Mode;
begin
DefaultCTS.Speed := 2;
DefaultCTS.h := 2.00; //not sure if that's the default anymore
DefaultCTS.s := 2.00;

CurrentCTS.Speed := 2;
CurrentCTS.h := 2.00;
CurrentCTS.s := 2.00;
end;

Procedure Return2DefaultCTS;
begin
CurrentCTS.Speed := DefaultCTS.Speed;
CurrentCTS.h := DefaultCTS.h;
CurrentCTS.s := DefaultCTS.s;
end;

//Copy a CTS2Mode object
function CopyCTS(toCopy: CTS2Mode): CTS2Mode;
begin
Result.Speed := toCopy.Speed;
Result.h := toCopy.h;
Result.s := toCopy.s;
end;

//allows u to create a copy of the current CTS
function GetCurrentCTS: CTS2Mode;
begin
Result := CopyCTS(CurrentCTS);
end;

procedure mod2CTS(h, s: extended);
begin
PreviousCTS.Speed := CurrentCTS.Speed; // (do notice that this works here but not in java)
PreviousCTS.h := CurrentCTS.h;
PreviousCTS.s := CurrentCTS.s;

CurrentCTS.h := h;
CurrentCTS.s := s;
end;

procedure RecoverPreviousCTS;
var
NewCTS: CTS2Mode;
begin
NewCTS := CopyCTS(CurrentCTS);
CurrentCTS := CopyCTS(PreviousCTS);
PreviousCTS := CopyCTS(NewCTS);
end;

function Box(x1, y1, x2, y2: integer): TBox;
begin
Result.x1 := x1;
Result.y1 := y1;
Result.x2 := x2;
Result.y2 := y2;
end;

function FindDoubleColor(color1, color2, tol1, tol2: integer; Area:TBox, AreaTol: integer): TPointArray;
var
TPA1, TPA2: TPointArray;
begin
FindColorsTolerance(TPA1, color1, tol1, Area.x1, Area.y1, Area.x2, Area.y2);
FindColorsTolerance(TPA2, color2, tol2, Area.x1, Area.y1, Area.x2, Area.y2);

Result := MatchTPATolerance(TPA1, TPA2, AreaTol);
end;

function FindMultiColors(MColors: TMultiColorArray; Area: TBox; AreaTol: integer): TPointArray;
begin

end;

AreaTol being how far the points can be from each other.

The last time I think I saw MatchTPA was somewhere in MSI forums

~RM

Troll

2011-01-14 17:21:04

Ok thanks guys ;)
I was hopeing for an uber cool function that looked though 2 arrays and saw if there where two point so far apart. :p

So wizzy pluggin(never read the tut i saw when reading on tpas) or make a black around the first color thanks for the help ( too late now tho work on it tomorrow lazy me ) or search for something called MatchTPA

NCDS

2011-01-14 17:28:35

From: Troll Man
Ok thanks guys ;)
I was hopeing for an uber cool function that looked though 2 arrays and saw if there where two point so far apart. :p

So wizzy pluggin(never read the tut i saw when reading on tpas) or make a black around the first color thanks for the help ( too late now tho work on it tomorrow lazy me ) or search for something called MatchTPA


You could search with 2 TPA's like RM suggested, then get the MiddleTPA of each and do if Distance(MiddleTPA1, MiddleTPA2) < DistanceYouWant then etc.

Troll

2011-01-14 17:36:39

but with that it would bring the problem of the colors which are simlar and also very close so being able to find it in the first couple of trys is hard :( Which is why i was woundering is you could run two arays and see if anypoints where close without moving the mouse as the two colors as the same place should be him then it would work 1 or 2 mouse movements which would be great :)

Edit: At RM's edit i think thats what im looking for and a lot simpler then what i thought thanks <3

NCDS

2011-01-14 17:42:34

From: Troll Man
but with that it would bring the problem of the colors which are simlar and also very close so being able to find it in the first couple of trys is hard :( Which is why i was woundering is you could run two arays and see if anypoints where close without moving the mouse as the two colors as the same place should be him then it would work 1 or 2 mouse movements which would be great :)

Edit: At RM's edit i think thats what im looking for and a lot simpler then what i thought thanks <3


Just sort the TPA's before checking the distance(length checks etc.)

Sir R. M8gic1an

2011-01-14 18:07:57

Sorry for making the edit so long already, I got carried away >.<

BraK

2011-01-14 20:54:04

Just search multiple colors using a for to do loop. After each search add the new points to the array by combining the arrays. Something like this:

procedure FindColorsTPA(Colours : TIntegerArray);
var
I : Integer;
Array1, Array2 : TpointArray;
begin
for i = 0 to High(Colours) do
begin
if FindColors(Array1,Colours[i], MSX1, MSY1, MSX2, MSY2) then
Array2 := CombineTPA(Array1, Array2);
end;
end;

Believe something like this is what your talking about.

~BraK

E: You should look into FindObjThroughMM function. It's how I find the banker in the GE for my Herblore script.

Sir R. M8gic1an

2011-01-14 22:14:02

Found MatchTPAs.

http://villavu.com/forum/showthread.php?t=56920&highlight=MatchTPA

~RM