Page 1 of 2 12 LastLast
Results 1 to 25 of 28

Thread: PercentBlackMM

  1. #1
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default PercentBlackMM

    I made it a bit more useful, gets the percent of a set area of the MM. Thanks to Zeph and mixster for fixing the annoying errors

    SCAR Code:
    {*******************************************************************************
    function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard
    Description: Gets the percent of an area of the minimap which is black, defined
    by the radials, and the radius.
    *******************************************************************************}


    function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A, Ps: Integer;
      Sector1, Sector2, Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Sector1 := (Pi * (StartRadius * StartRadius)) * (A / 360.0);
      Sector2 := (Pi * (EndRadius * EndRadius)) * (A / 360.0);
      Area := Sector2 - Sector1;
      Ps := Length(TPA);
      Result := Round((Ps * 100) / Area);
    end;
    Last edited by Richard; 06-06-2009 at 09:49 PM.

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    aPercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;

    Might want to change that .

    Looks good though, you can get rid of 2 variables by using them directly.

  3. #3
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    aPercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;

    Might want to change that .

    Looks good though, you can get rid of 2 variables by using them directly.
    Actually I could kill 3 variables, but this way is more readable.

  4. #4
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Richard View Post
    Actually I could kill 3 variables, but this way is more readable.
    Then to make it more readable, add StartRadius * StartRadius and visa versa, to another variable
    Last edited by Naum; 06-06-2009 at 09:53 PM.

  5. #5
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    SCAR Code:
    function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
    begin
      FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Result := Round((Length(TPA) * 100) / ((Pi * (EndRadius * EndRadius)) * ((EndRadial - StartRadial) / 360.0)-((Pi * (StartRadius * StartRadius)) * ((EndRadial - StartRadial) / 360.0))));
    end;

    There you go dear, if you like long sums

  6. #6
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Richard View Post
    SCAR Code:
    function PercentBlackMM(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
    begin
      FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Result := Round((Length(TPA) * 100) / ((Pi * (EndRadius * EndRadius)) * ((EndRadial - StartRadial) / 360.0)-((Pi * (StartRadius * StartRadius)) * ((EndRadial - StartRadial) / 360.0))));
    end;

    There you go dear, if you like long sums
    Ahh yeah! I love long sums!!

    Rep++!

  7. #7
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Ahh yeah! I love long sums!!

    Rep++!
    Thanks

    You're saying you would rather have that complicated thing than the easier to read version?

  8. #8
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Richard View Post
    Thanks

    You're saying you would rather have that complicated thing than the easier to read version?
    Complicated things make you seem more 1337. Like in Smart.scar:

    SCAR Code:
    SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));

  9. #9
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What would this be used for? haha

  10. #10
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by 99_ View Post
    What would this be used for? haha
    Dungeon walking mainly, gets you facing the right direction depending on the amount of black.

    I'm currently using it for a FoG script me and ToF are working on.

  11. #11
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    Complicated things make you seem more 1337. Like in Smart.scar:

    SCAR Code:
    SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));
    Thats so funny

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

    Default

    SCAR Code:
    function PercentBlackMMEx(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;

    Check my math please, not sure if its accurate.. Factored your equations, dropped some variables.

    Committed:

    SCAR Code:
    {*******************************************************************************
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard, and Nava2
    Description: Returns the percentage of colour on the minimap section defined by
                 StartRadial, EndRadial, StartRadius, and EndRadius.
    *******************************************************************************}

    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;
    Last edited by Nava2; 06-07-2009 at 09:42 PM.
    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

  13. #13
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice, and grats on getting it into srl ^^
    Personally, I preffere to create a circle close to the edge of the MM, and check on which points the MM is black. That way I can get every possible moving option... it's included in my essence miner...
    There is nothing right in my left brain and there is nothing left in my right brain.

  14. #14
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    SCAR Code:
    function PercentBlackMMEx(StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;

    Check my math please, not sure if its accurate.. Factored your equations, dropped some variables.

    Committed:

    SCAR Code:
    {*******************************************************************************
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard, and Nava2
    Description: Returns the percentage of colour on the minimap section defined by
                 StartRadial, EndRadial, StartRadius, and EndRadius.
    *******************************************************************************}

    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;
    So thats how you square in delphi, I was trying x^y but it doesn't like that syntax.

    Thanks for committing it

    Quote Originally Posted by Pure1993 View Post
    Nice, and grats on getting it into srl ^^
    Personally, I preffere to create a circle close to the edge of the MM, and check on which points the MM is black. That way I can get every possible moving option... it's included in my essence miner...
    If you mean a segment of a circle, I could have a go at some fun maths with that.

    http://mathworld.wolfram.com/CircularSegment.html

  15. #15
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Hey all.. Isn't this wrong

    Code:
    {*******************************************************************************
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard, and Nava2
    Description: Returns the percentage of colour on the minimap section defined by
                 StartRadial, EndRadial, StartRadius, and EndRadius.
    *******************************************************************************}
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;
    Isn't it should be Color



    ~Home

  16. #16
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Home View Post
    Hey all.. Isn't this wrong

    Code:
    {*******************************************************************************
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard, and Nava2
    Description: Returns the percentage of colour on the minimap section defined by
                 StartRadial, EndRadial, StartRadius, and EndRadius.
    *******************************************************************************}
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;
    Isn't it should be Color



    ~Home
    No 'colour' is proper English, what are you thinking?

  17. #17
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    No 'colour' is proper English, what are you thinking?
    Once again.. I feel stupid.. It won't compile Zeph.. Because there is Missing Variable..

    Well whatever

    ~Home

  18. #18
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    This is what Home was pointing out:
    Code:
    {*******************************************************************************
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    By: Richard, and Nava2
    Description: Returns the percentage of colour on the minimap section defined by
                 StartRadial, EndRadial, StartRadius, and EndRadius.
    *******************************************************************************}
    function PercentColorMMEx(Color, Tol, StartRadial, EndRadial, StartRadius, EndRadius: Integer): integer;
    var
      TPA: TPointArray;
      A: Integer;
      Area: Extended;
    begin
      A := EndRadial - StartRadial;
      FindColorsTolerance(TPA, Colour, MMX1, MMY1, MMX2, MMY2, Tol);
      FilterPointsPie(TPA, StartRadial, EndRadial, StartRadius, EndRadius, MMCX, MMCY);
      Area := (Pi * A / 360.0) * (sqr(StartRadius + 0.0) - sqr(EndRadius + 0.0));
      Result := Round(Length(TPA) * 100 / Area) ;
    end;
    Color <> Colour
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  19. #19
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Color > Colour.

    But use proper grammar when describing the function and author .
    By: Richard, and Nava2
    -> By: Richard and Nava2.

  20. #20
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Patato patato!
    Verrekte Koekwous

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

    Default

    Quote Originally Posted by mastaraymond View Post
    Patato patato!
    You just failed so hard..

    Potato. xD
    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

  22. #22
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    You just failed so hard..

    Potato. xD
    Proof me wrong
    Verrekte Koekwous

  23. #23
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

  24. #24
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    There's something wrong with the current function. When its used in PercentBlackMM, the Result is -100. I did some testing. The Area for a full minimap (MinRad = 0, MaxRad = 76, Angles 0 - 360) the area turns out to be 18145.8 something, the actual area is 18163.

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

    Default

    Hmm, the math is right for sure. I triple checked it. Cos bug maybe?
    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

Page 1 of 2 12 LastLast

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
  •