PDA

View Full Version : how to open a door only if its closed?



XcanadamanX
11-10-2006, 10:42 PM
How would i open a door if its only closed and so it doesnt do anything when its open? example plz...:duh:

solarwind
11-10-2006, 10:54 PM
- mouse over door
- read uptext
- if uptext says open then click
- if uptext says closed, then don't do anything

Simple. Try it yourself, you'll get much more satisfaction that way.

Boreas
11-10-2006, 10:55 PM
When a door is closed, it's uptext is Open door. When it is open, the uptext is Close Door. Both contain door (so you know you found it) and you can tell it's state from the other word.

If you can get real close to it with the red on the minimap that helps. Then use color/dtm/bitmap/random movement to find the door, move the mouse and check if uptext is door, then check the other word and take the right action. Check out what WT-Fakawi said. (http://www.villu-reborn.com/showthread.php?t=3687)

XcanadamanX
11-10-2006, 10:57 PM
thanks...that helps ALOT!!!

Ransom
11-10-2006, 11:09 PM
Yeah uptext is really a great thing. But also if you needed to open it to go somewhere it would be blocking your path if you were minimap walking. Assuming there are no other exits if your MMwalker clicks and fails to see the flag....it would mean the door is closed.

Just remember, program languages is only half. Problem solving is universal.

Ransom

Boreas
11-10-2006, 11:09 PM
O 1 more thing. Use loops like this:



program New;
{.include srl\srl.scar}

procedure lowestAngle; //based on highestangle by starblaster100
begin
if (Loggedin) then
begin
keydown(40);
sleep(1000 + random(100) + random(200));
keyup(40);
wait(1000 + random(100));
end;
end;

procedure bdoor;
var iter,iter2,iter3,dx,dy:integer;
done:boolean;
begin
lowestangle;
done:=false;
setrun(true);
repeat
iter3:=iter3+1;
iter:=0;
makecompass('n');
repeat
iter:=iter+1;
mousebox(231,76,280,165,0);
wait(100+random(100));
if IsUpTextMulti('Door','Doo','oor') then
begin
//writeln('found door'); //
if IsUpTextMulti('Close','los','ose') then
begin
done:=true;
//writeln('already open'); //
end;

if IsUpTextMulti('Open','pen','Ope') then
begin
//writeln('door is close'); //
iter2:=0;
repeat
GetMousePos(Dx, Dy);
Mouse(Dx, Dy, 0, 0, False);
//writeln('trying to open');//
wait(100+random(100));
if ChooseOption(Dx, Dy, 'pen') then
begin
done:=true;
//writeln('opened'); //
end;
iter2:=iter2+1;
until ((done) or (iter2=3));
end;

end;
until ((iter=5)or (done));
if not(done) then
begin
//writeln('couldnt find door at that angle, changing'); //
makecompass('w');
iter:=0;
repeat
iter:=iter+1;
mousebox(216,92,363,180,0);
wait(100+random(100));
if IsUpTextMulti('Close','los','ose') then
begin
done:=true;
//writeln('door is already open');//
end;
until ((iter=5) or (done));
end;
until ((iter3=5) or (done));
end;



begin
activateclient;
setupsrl;
bdoor;
end.


So if it fails it will fix itself (hopefully)

Edit: Ransom has a good point. That's why I click the red on the minimap first, stop at the door, do door stuff, then click the next place. BTW the red of the door is like 200-250

This finds the eastern most door, designed for port phasmatys furnace, you might need to tweak it.



program New;
{.include srl\srl.scar}

type tehpointfur = record
x,y,dist :integer;
active : boolean;
end;

type ybox = record
x1,y1,x2,y2,cx,cy:integer;
active:boolean;
end;
var gx,gy,a,b:integer;

function CheckColorAround(colorj, jx,jy :integer): boolean;
begin
if ( (getcolor(jx-1,jy-1)=colorj) or (getcolor(jx,jy-1)=colorj) or (getcolor(jx+1,jy-1)=colorj) or
(getcolor(jx-1,jy)=colorj) or (getcolor(jx+1,jy)=colorj) or (getcolor(jx-1,jy+1)=colorj) or
(getcolor(jx,jy+1)=colorj) or (getcolor(jx+1,jy+1)=colorj) ) then

result:=true;


end;


procedure findreds (var fx, fy:integer; PointsToFind,width,basex,basey,endx,endy:integer);
var
box :array of ybox;
ypoint : array of tehpointfur;
x,d,e{,f,i,g},rx,ry,tehcolor,lowest,lowestp,nob,{g x,gy,}currentpoint,row,prow,col,nor,noc:integer;//var
//x,d,nob,gx,gy,currentpoint,row,prow,col,nor,noc:in teger;

begin

//repeat
// if not(Loggedin) then break;
// if(TimeFromMark(Mark)>600000) then begin Logout; Exit; end;
// Until(FindSymbol(rx,ry,'furnace'));
//mmouse(rx,ry,0,0);//test

noc:=(( (endx-basex) - (width mod (endx-basex)))/width)+1;
nor:=(( (endy-basey) - (width mod (endy-basey)))/width)+1;
//noc:=round( (endx-basex)/width );
//nor:=round( (endy-basey)/width );

nob:=nor*noc;
setarraylength(box, ((nob)+2));
repeat
x:=x+1;
if ((x+noc) mod noc)>0 then
col:=((x+noc) mod noc);
if ((x+noc) mod noc) =0then
col:=noc;
prow:=0;
repeat
prow:=prow+1;
until ( x<=(noc*prow));
row:=prow;
box[x].x1:=(basex+ ((col-1)*width) );
box[x].x2:=(basex+(col*width));
box[x].y1:=(basey+ ((row-1)*width) );
box[x].y2:=(basey+(row*width));
box[x].cx:=round((box[x].x2+box[x].x1)/2);
box[x].cy:=round((box[x].y2+box[x].y1)/2);
box[x].active:=true;

{
movemouse(box[x].x1,box[x].y1);
holdmouse(box[x].x1,box[x].y1,true);
movemouse(box[x].x2,box[x].y2);
releasemouse(box[x].x2,box[x].y2,true);
}


until x>=nob;


currentpoint:=1;
d:=0;
setarraylength(ypoint, pointstofind+1);
repeat
d:=d+1;
if (box[d].active) then
begin
tehcolor:=210;
repeat
tehcolor:=tehcolor+1;
//if findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2) then
until (findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2) or (tehcolor>=260));
if (findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2))then
begin
if checkcoloraround(tehcolor,gx,gy)then
begin

ypoint[currentpoint].x :=gx;
ypoint[currentpoint].y :=gy;
//ypoint[currentpoint].dist:=Round(Sqrt(Sqr(ypoint[currentpoint].x - rx) + Sqr(ypoint[currentpoint].y- ry))) .//closest to furnace
ypoint[currentpoint].dist:=Round(Sqrt(Sqr(ypoint[currentpoint].x - 1000))) //closest to right


currentpoint:=currentpoint+1;
box[d].active:=false;
end;

end;
end;
until (( currentpoint= pointstofind)or (d=nob));

e:=0;
repeat
e:=e+1;
if (not(ypoint[e].x=0) and not(ypoint[e].y=0)) then
ypoint[e].active:=true;
until e=pointstofind;
e:=0;
lowest:=1000;
repeat
e:=e+1;
if ypoint[e].active then
begin
if ypoint[e].dist<lowest then
begin
lowestp:=e;
lowest:=ypoint[e].dist;
end;
end;
until e=pointstofind;
gx:=ypoint[lowestp].x;
gy:=ypoint[lowestp].y;
end;



begin
setupsrl;
//FindSymbol(gx,gy,'furnace');
//mMouse(gx,gy,0,0);

a:=getsystemtime;
findreds(gx,gy,10,40,556,11,727,153);
b:=getsystemtime;
mMouse(gx,gy,0,0);

writeln(inttostr(b-a));

end.

XcanadamanX
11-10-2006, 11:11 PM
also how would i make the camera angle change to have it so the door is bigger?

Boreas
11-10-2006, 11:20 PM
procedure lowestAngle; //based on highestangle by starblaster100
begin
if (Loggedin) then
begin
keydown(40);
sleep(1000 + random(100) + random(200));
keyup(40);
wait(1000 + random(100));
end;
end;


It's also good to try to find the door a couple times, if you can't find it then rotate (left or right button) and try again.

solarwind
11-10-2006, 11:25 PM
Function DoorWalk(color : Integer; uptext, direction : String) : Boolean;
begin

SolarDebug('Setting lowest angle to find door.', 3);
LowestAngle;
SolarDebug('Making compass direction of door.', 3);
MakeCompass(direction);
Sleep(100);
SolarDebug('Walking through door...', 2);
FindObj(x, y, uptext, color, 10);
Mouse(x, y, 0, 0, True);
Sleep(1000 + Random(100));
SolarDebug('Make compass back to north', 3);
MakeCompass('n');
HighestAngle;
Sleep(6000);


end;

This is my door opener, almost never fails. ;)

XcanadamanX
11-10-2006, 11:38 PM
Thanks so much you guys!!! your a big help!!