SRL Archive - Research & Development Lounge

findhuecol and findhueobj


Awkwardsaw

2009-07-03 05:25:07

im not sure if these are already in srl, but i made these functions out of sheer lazyness, and space saver

function FindObjHue(var a, b: integer; color: longint; x, y, cx1, cy1, cx2, cy2, tol: integer; hue, sat: extended; text: tstringarray): boolean;
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue, sat);
FindColorsSpiralTolerance(a, b, TPA, color, cx1, cy1, cx2, cy2, tol);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(a, b, 2, 2);
wait(10 + random(30));
if IsUpTextMultiCustom(text) then
begin
Result := True;
GetMousePos(a, b);
Break;
end;
end;
end;

function FindColHue(var a, b: integer; color: longint; x, y, cx1, cy1, cx2, cy2, tol: integer; hue, sat: extended): boolean;
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue, sat);
FindColorsSpiralTolerance(x, y, TPA, color, cx1, cy1, cx2, cy2, tol);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
Result := True;
GetMousePos(x, y);
Break;
end;
end;

how i use it in my script:
procedure EnterPortal;
var x, y, a, b: integer;
portal: boolean;
begin
makecompass('N');
wait(2000 + random(1000));
portal:= FindObjHue(x, y, 8226691, MSCX, MSCY, MSX1, MSY1, MSX2, MSY2, 20, 1.66, 0.60, ['Enchanters', 'nchanters', 'chant']);
if not portal then
begin
messup('cannot find portal to leave');
exit;
end;
mouse(x, y, 0, 0, true);
while not findsymbol(a, b, 'Transportation') do wait(10 + random(30));
gotocenter;
end;

:). this shaved off ~150 lines in this script so far, from taking away repeatedish functions.

and yes it does work, just would like to share it with you guys,

i know it has a hell of a lot of parameters, but long lines > 30 seconds and 21+ lines saved. although it would be nice to change this to xyz instead of hue

marpis

2009-07-09 10:27:39

You're using saturation modifiers too, not only hue.
and variables a, b should be fx, fy or something. a and b is distracting.

You should also do
SetColorSpeed2Modifiers(0.2, 0.2);
before returning the original CTS

but these are useful functions anyways :)

Awkwardsaw

2009-07-10 04:01:29

i almost forgot about these :P

there is one flaw though, in the obj finding one, if IsUpTextMultiCustom(text) then checks the whole screen for the color, and usually takes for ever to do so.

i'll keep playing around with it later :D

Cazax

2009-07-10 04:06:14

UpText is broken due to Jagex updates: http://www.villavu.com/forum/showthread.php?p=598963 That's why your function hovers every object in the main screen.

Awkwardsaw

2009-07-10 04:10:11

this was before, since i made/ tested this like a week ago. i havnt even botted since before the update :P

weequ

2009-07-10 04:45:26

I have been using almost exatly same thing ;)