SRL Archive - SRL Archives

function FindKarajamaRoadColour: Integer;


Daniel

2009-07-28 14:27:20

function FindKarajamaRoadColour: Integer;

This function automatically detects the Karajama Road colour. I've tested this on over 30 occasions (with over 20 logging in and out, and changing worlds :)) and it works perfectly.

This is for the Karajama Road Colour, that olive colour which represents the road in Karajama when you get off the wharf, which holds the boat from Port Sarim.

Follow these instructions to include it into your script :):
Append (place at the last line) the following code into SRL\SRL\core\AutoColor.scar:

{*******************************************************************************
function FindKarajamaRoadColour: Integer;
by: Dan's The Man
Description: Autodetecs the Karajama Road Colour on the Minimap
*******************************************************************************}
function FindKarajamaRoadColour: Integer;
var
TPA: TPointArray;
i, bI, BakColour: Integer;
Red, Green, Blue: Integer;
TemporaryCTS: Integer;
begin
TemporaryCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 1341335, MMX1, MMY1, MMX2, MMY2, 40);
bI := High(TPA);
if(bI + 1 > 0) then
begin
for i := 0 to bI do
begin
BakColour := GetColor(TPA[i].X, TPA[i].Y);
ColorToRGB(BakColour, Red, Green, Blue);
if(InRange(Red, 120, 175)) then
if(InRange(Green, 80, 155)) then
if(InRange(Blue, 10, 30)) then
if(GetColor(TPA[i].X + 2, TPA[i].Y) = BakColour) then
if(GetColor(TPA[i].X, TPA[i].Y + 2) = BakColour) then
if(GetColor(TPA[i].X + 2, TPA[i].Y + 2) = BakColour) then
if(GetColor(TPA[i].X + 1, TPA[i].Y) = BakColour) then
begin
Result := BakColour;
Writeln('Found the Karajama Road Colour');
ColorToleranceSpeed(TemporaryCTS);
Exit;
end;
end;
end;
Writeln('Could not find the Karajama Road Colour =(');
ColorToleranceSpeed(TemporaryCTS);
end;

Enjoy :)

Naum

2009-07-28 14:31:13

Looks good, but you might want to set the Result := -1; at the beginning, in case it doesn't find it. Good work, this should be added in AutoColor.Scar :)

Daniel

2009-07-28 14:42:43

From: NaumanAkhlaQ
Looks good, but you might want to set the Result := -1; at the beginning, in case it doesn't find it. Good work, this should be added in AutoColor.Scar :)


Good idea, done ;)

Sir R. M8gic1an

2009-07-28 17:22:42

color has big changes not when you switch worlds, but when you re-load the client. Meaning you either re-load smart or the RS client.

~RM

Daniel

2009-07-29 10:52:03

From: Rasta Magician
color has big changes not when you switch worlds, but when you re-load the client. Meaning you either re-load smart or the RS client.

~RM


Thanks, taken note :) Updated ;)