Results 1 to 11 of 11

Thread: ~ Can reflection be used to detect doors / gaits?

  1. #1
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question ~ Can reflection be used to detect doors / gaits?

    ok, so for my script, there are two gaits that i need to walk though. the problem is that they could either be open or closed, what is the best way to detect there location, and if they need to be opened before they can be walked through? I looked through the reflection includes folder and couldnt find anything useful, so i came here

    actualy.. as i was writing this up i thought of something. would using reflection to get the two tiles that the gait runs between, converting that to MS coordinates, then finding a middle point between the two and surch for the color of the gait within a 20x20 box around the point work? idk.. if you guys have better ideas please share :]
    Lance. Da. Pants.

  2. #2
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yes, for doors.
    SCAR Code:
    function ClickDoor(DoorObj: integer; Dir, Action: string): Boolean;
    var
      Loc, MS: TPoint;
    begin
      if not FindObject(Loc, DoorObj) then Exit;
      case Lowercase(Dir) of
        'n': MS := TileToMSEx(Tile(Loc.x + 0.5, Loc.y + 1.1), 40);
        's': MS := TileToMSEx(Tile(Loc.x + 0.5, Loc.y + 0.1), 40);
        'w': MS := TileToMSEx(Tile(Loc.x + 0.1, Loc.y + 0.5), 40); //try x-.5, y-.1
        'e': MS := TileToMSEx(Tile(Loc.x + 1.1, Loc.y + 0.5), 40);
      end;
      if MS.x = 0 then Exit;
      Mouse(MS.x, MS.y, 3, 3, False);
      Result := R_ChooseOption(Action);
    end;

    ^ It will work with gates also, thats built in to reflection. But that takes a while, I would use this function I made.

    SCAR Code:
    function ClickDoorex(DoorObj: integer; Dir, Action: string): Boolean;
    var
      Loc, MS: TPoint;
    begin
      if not FindObjectex(Loc, DoorObj,20) then Exit;
      If(distancefrom(Loc)>4)then
      begin
        walktotile(Loc,0,1);
        wait(500+random(500));
      end;
      case Lowercase(Dir) of
        'n': MS := TileToMSEx(Tile(Loc.x + 0.5, Loc.y + 1.1), 40);
        's': MS := TileToMSEx(Tile(Loc.x + 0.5, Loc.y + 0.1), 40);
        'w': MS := TileToMSEx(Tile(Loc.x + 0.1, Loc.y + 0.5), 40); //try x-.5, y-.1
        'e': MS := TileToMSEx(Tile(Loc.x + 1.1, Loc.y + 0.5), 40);
      end;
      if MS.x = 0 then Exit;
      Mouse(MS.x, MS.y, 3, 3, False);
      Result := R_ChooseOption(Action);
    end;

    ^ I changed to findobjectex cause thats way faster. Also ^ would have to copied and pasted.

    A gate/door has a different i.d open or closed.
    I do visit every 2-6 months

  3. #3
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ProTip: If you're doing it in a place where the door color stands out, like Falador then
    use reflection to see if the door is open/close and use color to open/close it

  4. #4
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    sorry i shouldnt have said "door" there arnt any doors i have to go through. just a fence gait and a city wall gate lol. and both gaits are the same color as the wall / fence so it makes it alittle more trickey.
    And how do i get the ID of a gait?

    SCAR Code:
    ClickDoorex(DoorObj: integer; Dir, Action: string): Boolean;
    and just getting this streight, DoorObj is the ID of the door, action is oviously open / close, and would dir be the direction of the gate when your standing one tile next to it? can it only find the gate when your standing right beside it? or could it be anywhere on the screen? oh and my camera angle changes alot due to antiban, would that throw the dir off by any chance?
    Last edited by Lance; 06-27-2009 at 03:38 AM.
    Lance. Da. Pants.

  5. #5
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by lancerawks View Post
    sorry i shouldnt have said "door" there arnt any doors i have to go through. just a fence gait and a city wall gate lol. and both gaits are the same color as the wall / fence so it makes it alittle more trickey.
    And how do i get the ID of a gait?

    SCAR Code:
    ClickDoorex(DoorObj: integer; Dir, Action: string): Boolean;
    and just getting this streight, DoorObj is the ID of the door, action is oviously open / close, and would dir be the direction of the gate when your standing one tile next to it? can it only find the gate when your standing right beside it? or could it be anywhere on the screen? oh and my camera angle changes alot due to antiban, would that throw the dir off by any chance?
    Yes DoorObj = Id. Action is the option to choose when you right click and choose option. So 'pen' would work. With my ClickDoorex, it will walk to the tile if its on the minimap, but your not close enough to it. And you will have to test out Dir cause I don't know exactly.

    Your welcome
    I do visit every 2-6 months

  6. #6
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Note that each door/gate has its own ID (at least, I'm pretty sure that's the case). So you'll have to get the IDs for each gate you have to go through.

  7. #7
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    Note that each door/gate has its own ID (at least, I'm pretty sure that's the case). So you'll have to get the IDs for each gate you have to go through.
    Yup.

    And each door/gate has different IDs when it's closed. So, for example, when it's closed, it will have an ID of 8695, and when open, 8696.
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  8. #8
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Btw, AFAIK it's gate not gait.
    Just trying to help.
    ~Hermen

  9. #9
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Hermen View Post
    Btw, AFAIK it's gate not gait.
    Just trying to help.
    lol im horrible with spelling :S thanks

    Edit: actualy no one answered how i get the gate ID's, so how do i do that?
    Last edited by Lance; 06-27-2009 at 05:11 AM.
    Lance. Da. Pants.

  10. #10
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    2 options. RSBot Debug.

    Or this script.
    http://www.villavu.com/forum/showthread.php?t=43693


    There are other ways but the above are the best.
    I do visit every 2-6 months

  11. #11
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    procedure DumpObjectsDist(Dist: Integer; IgnoreTPA: TPointArray; IgnoreIDs: TIntegerArray);
    Var
      BaseTileX, BaseTileY, X, Y: Integer;
      O: UID;
      P: TPoint;
    Begin
      P := GetMyPos;
      BaseTileX := P.x - Dist;
      BaseTileY := P.y - Dist;
      For X := BaseTileX To (Dist + p.x) Do
       For Y := BaseTileY To (Dist + p.y) Do
        Begin
          O := GetObjectAt(X, Y);
          if o.objType = 0 then Continue;
          if PointInTPA(Point(x, y), IgnoreTPA) then Continue;
          if InIntArray(IgnoreIDs, o.objType) then Continue;
          WriteLn('X ' + IntToStr(X) + ' Y ' + IntToStr(Y) + ' Type ' + IntToStr(O.objType));
        End;
    End;

    You can use that as well. Its relatively simple. If you know id's that aren't right, then add them to the skipIDs, same with tpoints. Finally, distance is self explanatory as well.

    It works pretty well. Can be a pain to sort through though.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

Thread Information

Users Browsing this Thread

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

Posting Permissions

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