PDA

View Full Version : find fish



Feroc1ty
12-18-2009, 06:16 AM
program new;

function within(a,b,c:integer):boolean;
begin
result := true;
if a > b then
begin
a := a - c;
if a > b then
result := false;
end else
begin
a := a + c;
if a < b then
result := false;
end;
end;

function FindFish(fishtype:string):TPoint;
var i,c,x,y:integer;
tpa,ttpa: TPointArray;
t:boolean;
begin
FindColors(tpa,16025680,0,0,511,400);
t := true;
i := 0;
c := 1;
x := 0;
if length(tpa) = 0 then
exit;
while t do
begin
if i+c = high(tpa) then
begin
SetArrayLength(ttpa,x+1);
ttpa[x] := tpa[i];
t := false;
end;
if within(tpa[i].x,tpa[i+c].x,30) and within(tpa[i].y,tpa[i+c].y,30) then
begin
tpa[i].x := (tpa[i].x + tpa[i+c].x)/2
tpa[i].y := (tpa[i].y + tpa[i+c].y)/2
c := c + 1;
end else
begin
SetArrayLength(ttpa,x+1);
ttpa[x] := tpa[i];
x := x + 1;
i := i + c;
c := 1;
if i = high(tpa) then
t := false;
end;
end;
for i := 0 to high(ttpa) do
begin
tpa[i] := Point(i, Distance(ttpa[i].x,ttpa[i].y,255,160));
end;
for i := 0 to high(ttpa) do
begin
if tpa[i].y >
end;
end;

var pt:tpoint;

begin
pt := FindFish('a');
writeln(inttostr(pt.x) + ',' + inttostr(pt.y));
end.

this isn't complete, right now the ttpa array returns locations of all fishing spots found, problem is, is that they're supposed to be the averages of all points found instead of the first one

also i want to arrange ttpa from lowest to highest y value of tpa[0] upto tpa[high(ttpa)], cause that's the distance between the character and specific fishing spot, the x value of that point is the ttpa location of the spot, whilst y value is the distance

hope you understood what i was trying to say haha hard to explain

weequ
12-18-2009, 12:43 PM
Check srl -> misc -> wizzy plugin. You could use t2dpoint arrays and middletpa ;)