Results 1 to 14 of 14

Thread: finddoor

  1. #1
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default finddoor

    heres a simple find door procedure, tell me if it works.

    finddoor
    SCAR Code:
    function FindDoor(var X, Y: Integer): Boolean;
    var
      X1, Y1, X2, Y2, I, Dots, R, G, B: Integer;
      SkipCoords: TPointArray;
      TempBMP, TheColor: Integer;
    begin
      repeat
        TempBMP := BitmapFromString(5, 5, '');
        if FindColorSkipCoordsTolerance(X1, Y1, 255, 569, 8, 715, 160, 25, SkipCoords) then
        begin
          CopyClientToBitmap(TempBMP, X1 - 2, Y1 - 2, X1 + 2, Y1 + 2);
          TheColor := FastGetPixel(TempBMP, 2, 2);
          ColorToRGB(TheColor, R, G, B);
          if (G > 1) or (B > 1) then
          begin
            SetArrayLength(SkipCoords, I + 1);
            SkipCoords[I].X := X1;
            SkipCoords[I].Y := Y1;
            I := I + 1;
          end else
          begin
            for X2 := 0 to 4 do
            begin
              for Y2 := 0 to 4 do
              begin
                if TheColor = FastGetPixel(TempBMP, X2, Y2) then
                begin
                  Dots := Dots + 1;
                end;
              end;
            end;
          end;
          if Dots > 2 then
          begin
            X := X1;
            Y := Y1;
            Result := true;
            FreeBitmap(TempBMP);
            Exit;
          end else
          begin
            SetArrayLength(SkipCoords, I + 1);
            SkipCoords[I].X := X1;
            SkipCoords[I].Y := Y1;
            I := I + 1;
            Dots := 0;
          end;
        end else
        begin
          Break;
        end;
      until (false);
      FreeBitmap(TempBMP);
    end;

    finddoormulti
    SCAR Code:
    function FindDoorMulti(var Coords: TPointArray; NumberOfDoors: Integer): Boolean;
    var
      X1, Y1, X2, Y2, I, Dots, R, G, B, N: Integer;
      SkipCoords: TBoxArray;
      TempBMP, TheColor: Integer;
    begin
      SetArrayLength(Coords, NumberOfDoors + 1);
      TempBMP := BitmapFromString(5, 5, '');
      repeat
        if FindColorSkipBoxArrayTolerance(X1, Y1, 255, 569, 8, 715, 160, 25, SkipCoords) then
        begin
          CopyClientToBitmap(TempBMP, X1 - 2, Y1 - 2, X1 + 2, Y1 + 2);
          TheColor := FastGetPixel(TempBMP, 2, 2);
          ColorToRGB(TheColor, R, G, B);
          if (G > 1) or (B > 1) then
          begin
            SetArrayLength(SkipCoords, I + 1);
            SkipCoords[I].X1 := X1;
            SkipCoords[I].Y1 := Y1;
            SkipCoords[I].X2 := X1;
            SkipCoords[I].Y2 := Y1;
            I := I + 1;
          end else
          begin
            for X2 := 0 to 4 do
            begin
              for Y2 := 0 to 4 do
              begin
                if TheColor = FastGetPixel(TempBMP, X2, Y2) then
                begin
                  Dots := Dots + 1;
                end;
              end;
            end;
          end;
          if Dots > 2 then
          begin
            Coords[N].X := X1;
            Coords[N].Y := Y1;
            N := N + 1;
            SetArrayLength(SkipCoords, I + 1);
            SkipCoords[I].X1 := X1 - 4;
            SkipCoords[I].Y1 := Y1 - 4;
            SkipCoords[I].X2 := X1 + 4;
            SkipCoords[I].Y2 := Y1 + 4;
            I := I + 1;
            if N >= NumberOfDoors then
            begin
              Result := true;
              FreeBitmap(TempBMP);
              Exit;
            end;
          end else
          begin
            SetArrayLength(SkipCoords, I + 1);
            SkipCoords[I].X1 := X1;
            SkipCoords[I].Y1 := Y1;
            SkipCoords[I].X2 := X1;
            SkipCoords[I].Y2 := Y1;
            I := I + 1;
            Dots := 0;
          end;
        end else
        begin
          Break;
        end;
      until (false);
      FreeBitmap(TempBMP);
    end;

  2. #2
    Join Date
    Aug 2007
    Posts
    282
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow, looks very nice.. only one thing...

    never do until(false) just incase the script is in the wrong place.. do like until tries=10 or (not (loggedin)

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

    Default

    you gonnsa use this dvd?
    ~Hermen

  4. #4
    Join Date
    Aug 2007
    Posts
    282
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by hermpie View Post
    you gonnsa use this dvd?
    um, no... im making my own.. this one will work well if 1 door is on the minimap... but im dealing with 2

  5. #5
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by dvdcrayola View Post
    wow, looks very nice.. only one thing...

    never do until(false) just incase the script is in the wrong place.. do like until tries=10 or (not (loggedin)
    notice the

    SCAR Code:
    end else
    begin  
      Break;
    end;

    in the last couple lines, the until (false) is there for reason. scar searches for the door color in the entire mini map skipping the coordinates which contain the door color but do not have enough of the same color in the area to be a door. when there is no more of the door color on the mini map (with the coordinates skipped appropriately) the "end else" is executed and it breaks out of the loop with the result of the function being false.

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

    Default

    Quote Originally Posted by dvdcrayola View Post
    um, no... im making my own.. this one will work well if 1 door is on the minimap... but im dealing with 2
    you dealing with 4
    ~Hermen

  7. #7
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i added multi door finding in a new function called finddoormulti, which was pretty simple, now maybe someone will test it?

  8. #8
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Look in SRL/Core/DoorProfiles. Its all there. With on top
    SCAR Code:
    function GetDoors: array of DoorProfile;
    It returns an array of all coords of doors in the minimap.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by WT-Fakawi View Post
    Look in SRL/Core/DoorProfiles. Its all there. With on top
    SCAR Code:
    function GetDoors: array of DoorProfile;
    It returns an array of all coords of doors in the minimap.
    I think this is for mainscreen?



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #10
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Color 255 in an area of 569, 8, 715, 160.. I think this is the MM.
    Hup Holland Hup!

  11. #11
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    Color 255 in an area of 569, 8, 715, 160.. I think this is the MM.
    Ah, alright, the Multi kinda cofused me.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  12. #12
    Join Date
    Mar 2007
    Posts
    107
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol i thought doorprofile.scar was for main screen also, well looks like my efforts have been in vain

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

    Default

    At least you learned something

  14. #14
    Join Date
    Jun 2007
    Location
    I'm not sure...
    Posts
    581
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    And thats all that matters.
    ---------------------------------------------------------


    Pm me if you need any math functions made. Me = l0ving t3h mathz

    ---------------------------------------------------------

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
  •