Results 1 to 7 of 7

Thread: A way to check if on other side of auto-closing door?

  1. #1
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default A way to check if on other side of auto-closing door?

    My current code
    PHP Code:
    procedure exitDoor;
    begin
          repeat
          FindMSColorTol
    (x,y,933465,5);//find the door
          
    MMouse(x,y,1,1);
          
    until (IsUpText('oor'));//when the door is found
          
    Mouse(x,y,1,1,true); //click it to open
          
    wait(5000+Random(500));//wait till your outside the house
    end
    The only problem with this is that if someone opens the door before I do, but after I have already clicked to go open the door, my character stops. Then the rest of the script still tries to run, but I am standing in the wrong location.

    Is there a way to use mapwalk or something that can tell if i have moved beyond the door.
    For example:
    Take the x,y of the mouse click, and compare it with the distance of the characters current position to where it clicked the door. Then in a loop with a wait to allow movement time I suppose, keep clicking the door untill the characters final position is greater in the one direction(towards the door) than the original distance between the character and the closed door.

    EDIT: YAY! I am now a dark wizard

  2. #2
    Join Date
    Sep 2006
    Posts
    161
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There's a red line of the door, right? Try making a way to check whether that line is on one side of the minimap or the other, as you know you are at its direct center.


    Wow. I've been away quite a while. Real life, yea, way unpredictable. Sorry, y'all, if I've caused any inconvenience.

  3. #3
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    I wrote a procedure called findyellows that finds the yellow banker dots in port phasmatys bank, in their configuration, ignoring the other npc yellow dots. Then I modified it to findreds which finds the closest red door to the furnace symbol, so it's messy code. I commented out the furnace part, you'll have to change that to rx:=mmcx ry:=mmcy or something, so it will find the closest red to the middle. It will return gx and gy, so then make something to determine which side gx,gy is on. Theres probably more stuff you have to change to make it work for you situation, or it might not even help you at all, but it's a start.





    SCAR Code:
    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:integer;

    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,{gx,gy,}currentpoint,row,prow,col,nor,noc:integer;//var
    //x,d,nob,gx,gy,currentpoint,row,prow,col,nor,noc:integer;

    begin

    //---------------
    // replace this section of code with setting rx and ry to the center of the minimap


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

    //---------------------------------------------
    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
          ypoint[currentpoint].x :=gx;
          ypoint[currentpoint].y :=gy;
          ypoint[currentpoint].dist:=Round(Sqrt(Sqr(ypoint[currentpoint].x - rx) + Sqr(ypoint[currentpoint].y- ry)))
          currentpoint:=currentpoint+1;
          box[d].active:=false;
        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;
    //if ypoint[e].dist<5 then
    //ypoint[e].active:=false;
    until e=pointstofind;
    e:=0;
    lowest:=1000;
    repeat
    e:=e+1;
    if ypoint[e].active then
    begin
    if ypoint[e].dist<lowest then
    lowestp:=e;
    lowest:=min(lowest, ypoint[e].dist);
    end;
    until e=pointstofind;
    gx:=ypoint[lowestp].x;
    gy:=ypoint[lowestp].y;
    end;

  4. #4
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    BAH-GEE-BEE! Time to start with something easier. Everytime I get it working and test it on a new chaacter, something else breaks! Anyone have an idea of a good starting script to make? Besides going for a tutorial isle runner :S

  5. #5
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Wanna finish an air crafter? It stays on world 16 and trades with runners, so no walking , no doors, no banking, just trading and crafting. It's almost done and just needs tweaking.

  6. #6
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sure, I wouldnt mind taking a look. I dont exactly have the resources to test it (trading money and ess) but I am sure I could learn from it.

  7. #7
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    It's messy and uncommented, so proabably annoying to follow. (I'll clean it up and comment when I get time).

    The other file is for my intro credits lol. Put it in your includes folder for it to work. I'll make one for you too if you finish it. (I'll write a tutorial on how I made it (easier than you think) when I get time.)

    Basically it just needs debugging and finetuning. Have fun!





    Thanks guys, can't believe I missed that lol.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Check if door is open
    By itSchRis917 in forum OSR Help
    Replies: 10
    Last Post: 05-26-2008, 04:15 AM
  2. The Dark Side Of Life
    By danman1212 in forum News and General
    Replies: 1
    Last Post: 05-09-2008, 04:48 AM
  3. w00t! lol check it out auto talker
    By chrissy2k7 in forum First Scripts
    Replies: 1
    Last Post: 04-02-2007, 06:24 PM
  4. Door check/open
    By Boreas in forum OSR Help
    Replies: 14
    Last Post: 11-25-2006, 11:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •