Results 1 to 12 of 12

Thread: Function Request

  1. #1
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function Request

    Hey guys. Im just wondering if anyone has made a function that finds the closest point in every direction. (that didnt describe it very well) so i have this TPA (uploaded picture) the TPA is in Red. I want to get the box around the furnace symbol. Even if someone hasnt made the function i need, maybe a suggestion on how i could do it? I cant figure it out and ive looked through wizzy plugin/simba but cant find anything i could use...

  2. #2
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Couldn't you use MiddleTPA/MiddleTPAEx? If you do it by hand the first time to find it, then if MiddleTPA = whatever, then it's true? I hope you know what I mean.. It'd work, I think.

    Or GetTPABounds.

  3. #3
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm I think this could work:
    scar Code:
    Function FurnaceBox(TPA : TPointArray): TBox;
    Var
      Bounds : TBox;
      orangeTPA : TPointArray;
    Begin
      Bounds := GetTPABounds(TPA);
      FindColorsTolerance(orangeTPA, FurnaceOrangeColor, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2);
      {HSL check:
      For I := 0 To High(orangeTPA) Do
      Begin
        ColorToHSL(GetColor(orangeTPA[I].X, orangeTPA[I].Y), H, S, L);
        If (H >= MinRange) and (H <= MaxRange) Then //can be H, S or L, even RGB
        Begin
          SetLength(NewTPA, Length(NewTPA) + 1);
          newTPA[High(newTPA)] := TPA[I];
        End;
      End; }

      Result := GetTPABounds(orangeTPA);
    End;
    But that'll work if you do an accurate HSL(or RGB) check that doesn't confuse with other items(dropped things, the kebab symbol maybe?) with a low range(less than 10). FindSymbol('furnace') should work fine too.
    Last edited by Cazax; 05-06-2010 at 12:40 AM.


  4. #4
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Couldn't you use MiddleTPA/MiddleTPAEx? If you do it by hand the first time to find it, then if MiddleTPA = whatever, then it's true? I hope you know what I mean.. It'd work, I think.

    Or GetTPABounds.
    Thats pretty much what im doing right now. it works but if i could find the wall surrounding the furnace then i can find the middle of the furnace room really easily.

  5. #5
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Wouldn't GetTPABounds do that? And isn't it always the same shape/size? Seems like it could be pretty simple.

  6. #6
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No GetTPABounds doesnt work. if you look at the picture you will see that there is the other rooms beside the furnace room and my TPA is the Red lines. There are those lines from the other rooms that i do not want to have in my TPA. How is the shape/size going to help?

  7. #7
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    I've thought about this many times; Never did it. Here's an idea:

    find symbol center. Store it as TP.
    Find Walls. Store as TPA.

    and now just simply find four points.

    Draw a vertical line from the TP, and the first point up and the first point down should be the top and bottom walls of the furnace.

    Draw a horizontal line and you should find yourself the right and left walls
    Then you can easily find the center of the room

    Give it a go, and let me know if it works I might have some work to do in AK soon

    e: If you're not sure how to do it, here's an inefficient way:
    SCAR Code:
    Function FindRoom(WallTPA: TPointArray; Symbol: TPoint): TPoint;
    var
      i: integer
      Room : TBox;
    begin

      while Room.x1 = 0 do
      begin
        inc(i)
        Symbol.x - i;
        if PointInTPA(Point(Symbol.x-i, Symbol.y)) then
          Room.x1 := Symbol.x - i;
      end;  

    end;

    Perhaps it would be much faster to sort through the WallTPA first. Find all the points that have the same x value as your Symbol and then just get the two closest ones to your point. An algorithm similar to bubblesort short be fast enough. Remeber that you'll need one point above and one below.

    (Repeat process with y coord)

    SCAR Code:
    var
      x, y, i: integer;
      b: boolean;
    begin
      b := true;
      x := 500000;

      while b do
      begin
        b := false;
        for i := 0 to High(WallTPA) do
          if WallTPA[i].x < x then
            if WallTPA[i].x > Symbol.x then // for finding the point above.
            begin
              x := WallTPA[i].x ;
              b := true;
            end;
      end;

    e2: Heh, I'll definitely be using something like this next time I do an Alkharider..

    ~RM
    Last edited by Sir R. M8gic1an; 05-06-2010 at 05:56 PM.

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  8. #8
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    I've thought about this many times; Never did it. Here's an idea:

    find symbol center. Store it as TP.
    Find Walls. Store as TPA.

    and now just simply find four points.

    Draw a vertical line from the TP, and the first point up and the first point down should be the top and bottom walls of the furnace.

    Draw a horizontal line and you should find yourself the right and left walls
    Then you can easily find the center of the room

    Give it a go, and let me know if it works I might have some work to do in AK soon

    ~RM
    WOW! Thats the most genius idea i have seen in a while! I would have never thought of that.
    There used to be something meaningful here.

  9. #9
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    OR :]
    You can find that cluster of cactus-rock-cactus sandwich
    ( http://www.rsbandb.com/interactive_r...75146484375/10 )
    and just click x-10, y+5 (or however many units is proper)

  10. #10
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    WOW! Thats the most genius idea i have seen in a while! I would have never thought of that.
    Take into consideration how many months it took me to come up with such a thing I first thought of it when I was doing my smelter... which has now been outdated for a few months, and i only just now thought of how to solve this problem.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  11. #11
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Take into consideration how many months it took me to come up with such a thing I first thought of it when I was doing my smelter... which has now been outdated for a few months, and i only just now thought of how to solve this problem.

    ~RM
    Well, whatever you do, dont die young! Every great man always dies young. Its true you know
    There used to be something meaningful here.

  12. #12
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Take into consideration how many months it took me to come up with such a thing I first thought of it when I was doing my smelter... which has now been outdated for a few months, and i only just now thought of how to solve this problem.

    ~RM
    Thanks! Ive been trying to figure out a way for awhile. Ill try to implement tonight or tomorrow sometime! thanks again!

    OR :]
    You can find that cluster of cactus-rock-cactus sandwich
    ( http://www.rsbandb.com/interactive_r...75146484375/10 )
    and just click x-10, y+5 (or however many units is proper)
    Im pretty sure that the map is outdated and there is no longer that cactus-rock-cactus sandwich :P Thanks for your help
    Last edited by XcanadamanX; 05-06-2010 at 10:13 PM.

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
  •