Log in

View Full Version : Finding and opening doors



Mezzanine
06-19-2012, 11:38 AM
I've looked through tutorial island, and also Googled it of course :P, but I can't find anyone who explains how to find and open a door. My script is utilizing SPS walking if this makes a difference.

Thanks,
Mezz

Abu
06-19-2012, 11:47 AM
Open this in Simba

Simba\Includes\SRL\srl\misc\doorprofiles

See if that helps

ssshhhaaa
06-19-2012, 11:49 AM
Ive also had a problem with this, in the end i just gave up ;_;

Element17
06-19-2012, 04:14 PM
Try something like this maybe.

It finds the door handle color for the door to Maggies house. You can write your own opening procedure.

Function DoorFinder(var x, y: Integer): Boolean;
Var
CTS, I: Integer;
DoorTPA: TPointArray;
ATPA: Array of TPointArray;
Begin
If(Not(LoggedIn))Then Exit;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.84, 0.16);
FindColorsSpiralTolerance(MSCX, MSCY, DoorTPA, 3486513, MSX1, MSY1, MSX2, MSY2, 10);
ATPA := TPAToATPAEx(DoorTPA, 3, 3);


For I := 0 To High(ATPA) Do
Begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
If(IsUpTextMultiCustom(['pen','oor'])) Then
Begin
Writeln('Found Door');
GetMousePos(x, y);
Result := True;
Break;
End;
End;
End;

Runaway
06-19-2012, 09:17 PM
Just to give you an alternative to the way 14578 has posted, this one will find the door color and make a big ATPA out of it:


function FindDoor(Color, Tol, Min: Integer; Open: Boolean): Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
P: TPoint;
hATPA, i: Integer;
begin
Result := False;
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol);
if (Length(TPA) > Min) then
begin
ATPA := SplitTPAEx(TPA, 10, 20);
hATPA := High(ATPA);
for i := 0 to hATPA do
begin
P := MiddleTPA(ATPA[i]);
Mouse(P.x, P.y, 3, 3, mouse_move);
if WaitUptextMulti(['doo', 'oor'], 500) then
begin
if WaitUptext('pen', 250) then
begin
if Open then
begin
ClickMouse2(mouse_left);
while IsMoving do
Wait(500);
end;
Result := True;
Exit;
end else
begin
if not Open then
begin
ClickMouse2(mouse_left);
while IsMoving do
Wait(500);
end;
Result := True;
Exit;
end;
end;
end;
end;
end;


I suggestion using it with vars something like this:


if FindDoor(DoorColor, 5, 40, True) then
begin
// ...
end;


I don't know why you'd ever need to find a door and close it, but hey I like to plan for everything :p

Mezzanine
06-20-2012, 07:22 AM
Thank you for the help guys, I'll definitely try and utilize that function (or a similar one ;) ) in a script. I spent a while trying to figure out how to use the functions in DoorProfiles Abu, and it seemed like the right tools for the job, I just didn't know quite what to do with them, so I took the easy way out and used a simple FindObjTPA. If someone has any pointers on using the functions in DoorProfile that would be amazing.

Thanks again,
Mezzanine