n3ss3s
2007-06-20 09:02:44
FindNearestObj
What it is, what it does and WHY IT DOES -
* It is another object finding function with 3 different text and color params.
* The difference to FindObj is that it looks for the closest object identified by Color1,Color2,Color3 and Text1,Text2,Text3 , StartTol and MaxTol within the range in pixels from MainScreen center defined in "MaxDist"
*WHY? Because some times you need to look for an object near you as possible.
Good example is flax picking - It looks very botty if the character runs around the flax field picking different flaxes with like 7 tiles distance.
Also, if mining rocks and you dont want it to mess someones characters hair or something.
Works good for me and should work for you too.
That example in mainloop works at flaxfield. Change the 300 (MaxDist) to your liking.
What it is, what it does and WHY IT DOES -
* It is another object finding function with 3 different text and color params.
* The difference to FindObj is that it looks for the closest object identified by Color1,Color2,Color3 and Text1,Text2,Text3 , StartTol and MaxTol within the range in pixels from MainScreen center defined in "MaxDist"
*WHY? Because some times you need to look for an object near you as possible.
Good example is flax picking - It looks very botty if the character runs around the flax field picking different flaxes with like 7 tiles distance.
Also, if mining rocks and you dont want it to mess someones characters hair or something.
Works good for me and should work for you too.
program New;
{.include srl/srl.scar}
function FindNearestObj(var Nx, Ny: integer; Color1, Color2, Color3,
StartTol, MaxTol, MaxDist: integer; Text1, Text2, Text3: string): boolean;
var i, j: integer;
begin
if (not (LoggedIn)) then Exit;
for j := 5 to MaxDist do
begin
for i := StartTol to MaxTol do
begin
if (FindColorTolerance(x, y, Color1, MSCX - j, MSCY - j, MSCX + j, MSCY + j, I))
or (FindColorTolerance(x, y, Color2, MSCX - j, MSCY - j, MSCX + j, MSCY + j, I))
or (FindColorTolerance(x, y, Color3, MSCX - j, MSCY - j, MSCX + j, MSCY + j, I)) then
begin
Break;
MMouse(x, y, 0, 0);
if (IsUpText(Text1))
or (IsUpText(Text2))
or (IsUpText(Text3)) then
begin
GetMousePos(Nx, Ny);
Result := True;
Break;
end;
end;
end;
end;
end;
// Example below
begin
setupsrl;
FindNearestObj(x, y, 15197342, 14999694, 14868361, 10, 50, 300, 'Flax', 'Fla', 'lax');
MMouse(x, y, 0, 0);
end.
// End Example
That example in mainloop works at flaxfield. Change the 300 (MaxDist) to your liking.