SRL Archive - Help and Support

Best way of opening doors?


rogeruk

2007-09-07 11:23:58

Hey all,

Whats the best way of opening a door, finding the color+tolerance? DDTM's? Bitmaps?

I tried to use the MMtoMS but couldn't get it to work.

There is only 1 door on the minimap and i need to open it just incase some1 closes it :)

Any help appreciated.

Killerdou

2007-09-07 11:26:50

findcolorsspiraltolerance —> differentiate —> check uptext of all groups which are aprox the size of a door

rogeruk

2007-09-07 11:32:07

I was hoping for something a bit more advanced. If the door is closed and i attempt to move the player it will not goto the location.

The minimap obviously changes to show the door open or close. If i could just check that and then walk it would be alot easier.

Boreas

2007-09-07 11:44:32

Are you saying the red on the minimap changes to show door is open?

rogeruk

2007-09-07 11:53:05

At first i did, now i know i was just stupid enough to think it did lol.

and now i see the Bug Fix doors in your profile :)

//Edit, "How many doors 0", it isnt finding the door, and its color 233

Boreas

2007-09-07 12:05:57

Ah ok. The only way I know of to tell if its closed on minimap is clicking the other side of it, and if the flag doesn't appear where you expect it to be, then it's closed.

Screenie please! Or at least tell me how many drop dots there were.

n3ss3s

2007-09-07 12:39:18

Umm, im really a noob with dealing doors, if someone has a thing that a) Checks if door is open or closed b) then if closed opens

I will credit him in my script and for(I = 0; I = 7; I ++) {incRep();}

rogeruk

2007-09-07 12:59:48

From: Boreas
Ah ok. The only way I know of to tell if its closed on minimap is clicking the other side of it, and if the flag doesn't appear where you expect it to be, then it's closed.

Screenie please! Or at least tell me how many drop dots there were.


Thanks for info.

Im a total newb when it comes to doors.


Edgeville door to the yews.

Boreas

2007-09-07 13:17:03

The colors are wrong on that pic, doesn't help. Try again until you get the same error, then take a screen shot of the either the whole screen or at least the whole client, save as bmp, upload on uppit.com, and pm me link. I won't report you :p

nielsie95

2007-09-07 13:19:01

I made this once, I'm not sure if it still works:


program DoorOpener;
{.Include SRL/SRL.SCAR}

const TDoorType = 2; // 1 - Normal doors, 2 - Lumbridge doors, 3 - Varrock doors, 4 - Falador, 5 - All kinds

function getArrayFromBox(arColor: TPointArray; Width, Height: Integer): TPointArray;
var
Count, Count3, arLength: Integer;
DoNotAccept : Boolean;
begin
SetArrayLength(Result, 1);
Result[0] := arColor[0];
arLength := GetArrayLength(arColor);
if ( arLength = 1 ) then
Exit;

for Count := 1 to arLength - 1 do
begin
if(arColor[Count].x < arColor[Count - 1].x + Width)and
(arColor[Count].y < arColor[Count - 1].y + Height)and
(arColor[Count].x > arColor[Count - 1].x - Width)and
(arColor[Count].y > arColor[Count - 1].y - Height)then
else
begin
DoNotAccept := False;
for Count3 := 0 to GetArrayLength(Result) - 1 do
begin
if (arColor[Count].x < Result[Count3].x + Width)and
(arColor[Count].y < Result[Count3].y + Height)and
(arColor[Count].x > Result[Count3].x - Width)and
(arColor[Count].y > Result[Count3].y - Height)then
DoNotAccept := True;
if DoNotAccept then
Break;
end;
if (DoNotAccept = False) then
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := arColor[Count];
end;
end;
end;
end;

function IsMultiUpTextColor(Color, Tol: Integer; Range: Byte; Text1, Text2, Text3: String): Boolean;
var
TempText: String;
begin
TempText := GetUpTextColor(Color, Tol, Range);
if Pos(Text1, TempText) <> 0 then Result := True else
if Pos(Text2, TempText) <> 0 then Result := True else
if Pos(Text3, TempText) <> 0 then Result := True;
end;

function FindObjDoor(var cx, cy: Integer; DoorType, x1, y1, x2, y2: Integer): Boolean;
var
tx, ty, i, c, Color, Count, H, bmp: integer;
Points, Ar1: TPointArray;
X, Y, Z: Extended;
begin
ColorToleranceSpeed(2); // 2640749 1989237 5730945 3956587
SetColorSpeed2Modifiers(0.1, 0.4); // You might want to take this out.
bmp := BitmapFromString(MSX2 + 20, MSY2 + 20, ' ');
CopyClientToBitmap(bmp, 0, 0, MSX2 +20, MSY2 +20);
H := GetClientWindowHandle;
SetTargetBitmap(bmp);

case DoorType of
1 : FindColorsSpiralTolerance(cx, cy, Points, 1989237, x1, y1, x2, y2, 10);
2 : FindColorsSpiralTolerance(cx, cy, Points, 2640749, x1, y1, x2, y2, 10);
3 : FindColorsSpiralTolerance(cx, cy, Points, 3956587, x1, y1, x2, y2, 10);
4 : FindColorsSpiralTolerance(cx, cy, Points, 6126219, x1, y1, x2, y2, 10);
5 : begin
FindColorsSpiralTolerance(cx, cy, Points, 1989237, x1, y1, x2, y2, 10);
FindColorsSpiralTolerance(cx, cy, Ar1, 2640749, x1, y1, x2, y2, 10);
Points := AddTPA(Points, Ar1);
FindColorsSpiralTolerance(cx, cy, Ar1, 3956587, x1, y1, x2, y2, 10);
Points := AddTPA(Points, Ar1);
FindColorsSpiralTolerance(cx, cy, Ar1, 5730945, x1, y1, x2, y2, 10);
Points := AddTPA(Points, Ar1);
end;
else begin WriteLn('Unknown DoorType'); Exit; end;
end;

if Length(Points) < 1 then Exit;

for i := 0 to GetArrayLength(Points) -1 do
begin
Color := FastGetPixel(bmp, Points[i].x, Points[i].y);
try
Count := CountColor(Color, Points[i].x -20, Points[i].y -20, Points[i].x +20, Points[i].y +20);
finally
if Count < 35 then
if Count > 10 then
begin
SetArrayLength(Ar1, GetArrayLength(Ar1) +1);
Ar1[GetArrayLength(Ar1) -1] := Points[i];
end;
except Break; end;
end;

if Length(Ar1) < 1 then Exit;

SetArrayLength(Points, 0);
for i := 1 to GetArrayLength(Ar1) -1 do
begin
Color := FastGetPixel(bmp, Ar1[i].x, Ar1[i].y);
ColorToXYZ(Color, X, Y, Z);
if ((DoorType = 1) or (DoorType = 5)) and SimilarColors(Color, 1989237, 10) then
begin
if (Y > 2.0) and (X > 11.5) then
begin
SetArrayLength(Points, Length(Points) +1);
Points[ Length(Points) -1] := Ar1[i];
end;
end else
if ((DoorType = 2) or (DoorType = 5)) and SimilarColors(Color, 2640749, 10) then
begin
if (Y > 2.7) and (X > 9.0) then
begin
SetArrayLength(Points, Length(Points) +1);
Points[ Length(Points) -1] := Ar1[i];
end;
end else
if (DoorType = 3) or (DoorType = 5) and SimilarColors(Color, 3956587, 10) then
begin
if (Y > 4.0) and (X > 10.0) then
begin
SetArrayLength(Points, Length(Points) +1);
Points[ Length(Points) -1] := Ar1[i];
end;
end else
if (DoorType >= 4) and SimilarColors(Color, 6126219, 10) then
begin
if (Y > 8.0) and (X > 16.0) then
begin
SetArrayLength(Points, Length(Points) +1);
Points[ Length(Points) -1] := Ar1[i];
end;
end
end;

Ar1 := Points;
if Length(Ar1) < 1 then Exit;
ColorToleranceSpeed(1);
Points := getArrayFromBox(Ar1, 35, 35);

for i := 0 to Length(Points) -1 do
begin
FindColorsTolerance(Ar1, FastGetPixel(bmp, Points[i].x, Points[i].y), Points[i].x -35, Points[i].y -35, Points[i].x +35, Points[i].y +35, 10);
if Length(Ar1) <> 0 then
begin
for c := 0 to Length(Ar1) -1 do
begin
tx := tx + Ar1[c].x;
ty := ty + Ar1[c].y;
end;
tx := tx / Length(Ar1);
ty := ty / Length(Ar1);
end else
begin
tx := Points[i].x;
ty := Points[i].y;
end;
MMouse(tx, ty, 2, 2);
Wait(120 + Random(150));
if IsMultiUpTextColor(13159171, 60, tr_Letters, 'oor', 'or', 'Do') then
begin
Result := True;
cx := tx;
cy := ty;
FreeBitmap(bmp);
SetClientWindowHandle(H);
Exit;
end;
tx := 0;
ty := 0;
end;
FreeBitmap(bmp);
SetClientWindowHandle(H);
end;

begin
SetupSRL;
x := MSCX;
y := MSCY;
if FindObjDoor(x, y, TDoorType, MSX1 +5, MSY1 +5, MSX2 -5, MSY2 -5) then WriteLn('Found!');
end.

But a normal FindObj will do too ;)

n3ss3s

2007-09-07 13:43:40

Thanks ill look into that later!

rogeruk

2007-09-07 14:32:34

From: Boreas
The colors are wrong on that pic, doesn't help. Try again until you get the same error, then take a screen shot of the either the whole screen or at least the whole client, save as bmp, upload on uppit.com, and pm me link. I won't report you :p


What same error?

PM sent :stirthepot:

Boreas

2007-09-07 14:44:47

"//Edit, "How many doors 0", it isnt finding the door, and its color 233"

That error.