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

Thread: MMFinding.scar

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

    Default MMFinding.scar

    My latest project
    Thanks to Home for the idea.

    I explain the "main" function called FindObjectsFromMM.. Depending on the parameters it will get the dots from Minimap. Valid ones are NPCs, Players or Items(It can find one, two or all three of them). When it finds them it creates a nice box of 150*150 pixels around all the items and searches for the colors/tol thats been given on the mainscreen. At the end it hovers these points searching for the giving uptext, if it's found it results true and wolhaa! You found a object using the MM to narrow down your search area

    Example of usage:
    SCAR Code:
    FindObjectsFromMM(x, y, ['item'], ['eather'], [12106177], 10);

    would search for a feather...

    Note: Needs high angle.

    Hope you like it.

    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               ยป Minimap finding Routines                    --//
    //-----------------------------------------------------------------//
    // * Function MMToMS(MM: TPoint): TPoint;                          // * by N1ke! (Thanks to Special Ed for insparation)
    // * Function MMToMSBox(MM: TPoint; Space: Integer): TBox;         // * by N1ke!
    // * Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;   // * by N1ke!
    // * Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean;   // * by N1ke!
    // * Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;   // * by N1ke!
    // * Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean;   // * by N1ke!
    //-----------------------------------------------------------------//

    {*******************************************************************************
    Function MMToMS(MM: TPoint): TPoint;
    By: N1ke!
    Description: Turns a Minimap point into a close MS point.
    *******************************************************************************}

    Function MMToMS(MM: TPoint): TPoint;
    var
      X, Y: Integer;
      Dis: TPoint;
    begin
      X := ((MM.X - 647));
      Y := ((MM.Y - 84));

      Dis := Point( (MMCX - MM.X)*-1, (MMCY - MM.Y)*-1);
      Result := Point(Round((259.5 + X)+ Dis.X*10), Round((170.0 + Y)+ Dis.Y*6.5));

      If Not IntInBox(Result.X, Result.Y, IntToBox(MSX1, MSY1, MSX2, MSY2))then
        Result := Point(-1, -1);
    end;

    {*******************************************************************************
    Function MMToMSBox(MM: TPoint; Space: Integer): TBox;
    By: N1ke!
    Description: Same as MMToMS but creates a TBox, it size depending on
    given parameter(Space).
    *******************************************************************************}

    Function MMToMSBox(MM: TPoint; Space: Integer): TBox;
    var
      Cords: TPoint;
    begin
      Cords := MMToMS(MM);
      Result := IntToBox(Cords.X-Space, Cords.Y-Space, Cords.X+Space, Cords.Y+Space);
    end;

    {*******************************************************************************
    Function GetMMDotsTPA(Kind: TStringArray): TPointArray;
    By: N1ke!
    Description: Gets the a TPA of the all the dots on Minimap.
    Valid kinds are
    - npc/yellow
    - item/red
    - player/white
    *******************************************************************************}

    Function GetMMDotsTPA(Kind: TStringArray): TPointArray;
    var
      I, H: Integer;
      TPA, tTPA: TPointArray;
    begin
      H := High(Kind);
      For I:=0 to H do
      begin
        tTPA := GetMiniMapDots(Kind[I]);
        Result := CombineTPA(Result, tTPA);
      end;
    end;

    {*******************************************************************************
    Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    By: N1ke!
    Description: Finds multiplie objects using a MM cords to narrow down the used
    search area.
    *******************************************************************************}

    Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    var
      MSCords: TPoint;
      TPA, tTPA: TPointArray;
      I, II, H, HH, XX, YY: Integer;
      ATPA: T2DPointArray;
    begin
      Result := False;

      H := High(MM);
      For I:=0 to H do
      begin
        MSCords := MMToMS(MM[I]);
        If (MSCords.X = -1)then
          Continue;
        HH := High(Colors);
        For II:=0 to HH do
        begin
          FindColorsTolerance(tTPA, Colors[II], MSCords.X-75, MSCords.Y-75, MSCords.X+75, MSCords.Y+75, Tol);
          TPA := CombineTPA(TPA, tTPA);
        end;
      end;
      ClearDoubleTPA(TPA);

      If GetArrayLength(TPA) = 0 then
        Exit;

      ATPA := SplitTPA(TPA, 5);
      SortATPAFrom(ATPA, Point(MSCX, MSCY));

      H := High(ATPA);
      For I:=0 to H do
      begin
        MiddleTPAEx(ATPA[I], XX, YY);
        MMouse(XX, YY, 4, 4);
        If WaitUptextMulti(UpTexts, 250+Random(100))then
        begin
          GetMousePos(X, Y);
          Result := True;
          Exit;
        end;
      end;
    end;

    {*******************************************************************************
    Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean;
    By: N1ke!
    Description: Same as FindObjectsMM, but only finds one.
    *******************************************************************************}

    Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean;
    begin
      Result := FindObjectsMM(X, Y, [MM], [UpText], [Color], Tol);
    end;

    {*******************************************************************************
    Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    By: N1ke!
    Description: Finds dots on Minimap and searches for the object.
    Valid kinds are
    - npc/yellow
    - item/red
    - player/white
    *******************************************************************************}

    Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    var
      I, H: Integer;
      TPA: TPointArray;
    begin
      Result := False;
      TPA := GetMMDotsTPA(Kind);
      If GetArrayLength(TPA) = 0 then
        Exit;
      Result := FindObjectsMM(X, Y, TPA, UpTexts, Colors, Tol);
    end;

    {*******************************************************************************
    Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean;
    By: N1ke!
    Description: Same as FindObjectsFromMM, but only looks for one.
    *******************************************************************************}

    Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean;
    begin
      Result := FindObjectsFromMM(X, Y, [Kind], [UpText], [Color], Tol);
    end;
    Last edited by Naike; 07-03-2009 at 09:07 PM.

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

    Default

    See Everyone! Me In the Idea thing! MEEE!

    Good job man I knew that you can do it.. And yes i think this should be in SRL Include!
    Once again! Good JOB!

    Your Friend,
    ~Home

  3. #3
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Only problem is that the compass angle is off by MANY degrees :/

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

    Default

    After
    SCAR Code:
    TPA := CombineTPA(TPA, tTPA);
    Do
    SCAR Code:
    ClearDoubleTPA(TPA);
    Most of the points your finding will be duplicates. Anyway I picked up 1 coin on the ground with it, so its cool

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

    Default

    Quote Originally Posted by Zyt3x View Post
    Only problem is that the compass angle is off by MANY degrees :/
    It still works as the Minimap rotates aswell...

    Quote Originally Posted by MylesMadness View Post
    After
    SCAR Code:
    TPA := CombineTPA(TPA, tTPA);
    Do
    SCAR Code:
    ClearDoubleTPA(TPA);
    Most of the points your finding will be duplicates. Anyway I picked up 1 coin on the ground with it, so its cool
    Ohh shit, my bad ^^ Thanks

  6. #6
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by N1ke! View Post
    It still works as the Minimap rotates aswell...
    Yeah but the compass rotation and the main screen rotation are different.

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

    Default

    Not by that much that this will miss it..

    To prove my point I suggest you try the function out..

    FindObjectsFromMM.

  8. #8
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by N1ke! View Post
    Not by that much that this will miss it..

    To prove my point I suggest you try the function out..

    FindObjectsFromMM.
    Ok, I'll test it

    EDIT: It worked 50% of the time, sometimes the item was clearly visible and the color was there but it still did not found it. The compass was directed at SE.
    Last edited by Zyt3x; 07-03-2009 at 05:37 AM.

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

    Default

    What item did you use, and what tolerance?

    also, having it at the last tile on the MS won't make it try..


    Edit: Just tested it again, Zyt3x your doing something wrong.. as it's flawless for me.
    Last edited by Naike; 07-03-2009 at 08:08 AM.

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

    Default

    Looks good.
    One thing:
    SCAR Code:
    Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    var
      I, H: Integer;
      TPA, tTPA: TPointArray;
    begin
      Result := False;
     
      H := High(Kind);
      For I:=0 to H do
      begin
        tTPA := GetMiniMapDots(Kind[i]);
        TPA := CombineTPA(TPA, tTPA);
      end;

      If GetArrayLength(TPA) < 1 then
        Exit;

      Result := FindObjectsMM(X, Y, TPA, UpTexts, Colors, Tol);
    end;

    you don't need that first result:= false;, this is because SCAR sets the default boolean to false.

    You can also do If Not GetArrayLength(Arr) Then, as SCAR recognizes 0's as false and 1's as true.
    Last edited by Naum; 07-03-2009 at 02:51 PM.

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

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Looks good.
    One thing:
    SCAR Code:
    Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
    var
      I, H: Integer;
      TPA, tTPA: TPointArray;
    begin
      Result := False;
     
      H := High(Kind);
      For I:=0 to H do
      begin
        tTPA := GetMiniMapDots(Kind[i]);
        TPA := CombineTPA(TPA, tTPA);
      end;

      If GetArrayLength(TPA) < 1 then
        Exit;

      Result := FindObjectsMM(X, Y, TPA, UpTexts, Colors, Tol);
    end;

    you don't need that first result:= false;, this is because SCAR sets the default boolean to false.

    You can also do If Not GetArrayLength(Arr) Then, as SCAR recognizes 0's as false and 1's as true.
    It's fine as it is, and it's good practice to initialize the result.

    GJ mate.

    ~RM

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

  12. #12
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by N1ke! View Post
    What item did you use, and what tolerance?

    also, having it at the last tile on the MS won't make it try..


    Edit: Just tested it again, Zyt3x your doing something wrong.. as it's flawless for me.
    That explains it, it was on one of the tiles at the end of the MS.

  13. #13
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    you don't need that first result:= false;, this is because SCAR sets the default boolean to false.[/QUOTE]

    Runme:
    SCAR Code:
    program ProofNaumanIsWrong;
    function CountItems : integer ;//Something similar to this actually happened with CountItems, took over two years before we noticed it
    var
      TestArray : array of boolean;
      i : integer;
    begin
      TestArray := [false, false, true, false, true, true];
      for i := 0 to high(testarray) do
        if testarray[i] then
          inc(result);
    end;
    var hoi : integer;
    begin
    repeat
      hoi := countitems;
      writeln(inttostr(hoi));
      wait(100);
    until false;
    end.
    Ofcourse this isn't with booleans but with integers, but the same thing can happen with booleans.
    And no it' s not a bug, it's a feature.

  14. #14
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    Runme:
    Code:
    program ProofNaumanIsWrong;
    function CountItems : integer ;//Something similar to this actually happened with CountItems, took over two years before we noticed it
    var
    TestArray : array of boolean;
    i : integer;
    begin
    TestArray := [false, false, true, false, true, true];
    for i := 0 to high(testarray) do
    if testarray[i] then
    inc(result);
    end;
    var hoi : integer;
    begin
    repeat
    hoi := countitems;
    writeln(inttostr(hoi));
    wait(100);
    until false;
    end.

    Ofcourse this isn't with booleans but with integers, but the same thing can happen with booleans.
    And no it' s not a bug, it's a feature.
    What exactly makes him wrong? Explain.[/quote]
    Each time you run the function the result adds up. Common sense says that each time it will only result 3, but it actually results 3 * EachTimeRun, so if you run this function 3 times then it would result 9.

    Markus: I didn't know about that :O
    That is impressive...

    EDIT: Gah, all the posts are mucked up thanks to our beloved markus who had a [/quote] in his post >_<"

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

    Default

    Quote Originally Posted by Zyt3x View Post
    What exactly makes him wrong? Explain.
    Each time you run the function the result adds up. Common sense says that each time it will only result 3, but it actually results 3 * EachTimeRun, so if you run this function 3 times then it would result 9.

    Markus: I didn't know about that :O
    That is impressive...[/QUOTE]

    Yes, I just saw that before you told me .

    I thought he was incrementing or something .

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

    Default

    What's up with the quotes?

    Btw, Naum the script would mess up badly, since it counts up like everyone said.
    I mean the variable can't just be emptied sometime(Without doing so), that would be very inefficient.
    ~Hermen

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

    Default

    Markus started the quotes being retarded.

    He has a [/quote] in his message without a [quote] .

    (on purpose )

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

    Default

    Quote Originally Posted by Markus View Post
    you don't need that first result:= false;, this is because SCAR sets the default boolean to false.
    Runme:
    SCAR Code:
    program ProofNaumanIsWrong;
    function CountItems : integer ;//Something similar to this actually happened with CountItems, took over two years before we noticed it
    var
      TestArray : array of boolean;
      i : integer;
    begin
      TestArray := [false, false, true, false, true, true];
      for i := 0 to high(testarray) do
        if testarray[i] then
          inc(result);
    end;
    var hoi : integer;
    begin
    repeat
      hoi := countitems;
      writeln(inttostr(hoi));
      wait(100);
    until false;
    end.
    Ofcourse this isn't with booleans but with integers, but the same thing can happen with booleans.
    And no it' s not a bug, it's a feature.
    Quote Originally Posted by Hermen View Post
    What's up with the quotes?

    Btw, Naum the script would mess up badly, since it counts up like everyone said.
    I mean the variable can't just be emptied sometime(Without doing so), that would be very inefficient.
    Markus, I was pointing out that for his case, for that particular function:

    SCAR Code:
    program Proof_that_I_am_right;
    {.Include SRL/SRL.Scar}

    Var x, y : Integer;

    Function A : Boolean;
    Begin
      If Result Then
        Writeln('I am wrong')
      Else
        WriteLn('I am right');
    End;

    begin
      SetupSRL;
      A;
    end.

    It is set to false, also I never mentioned that it was a bug.

    Also Hermen did you even read the post? Furthemore, he calls:

    SCAR Code:
    Result := FindObjectsMM(X, Y, TPA, UpTexts, Colors, Tol);
    At the end of the function, if it does not find it then it is set to false, which is fine.
    Its the same as doing:
    SCAR Code:
    Function GESellMenu: boolean;
    begin
      if not InGE then exit;
      Result := (GetColor(187, 73) = 45055); //
    end;
    @Rasta: I'm not saying it's not good practice to initialize a result, but it is not really needed in that case.
    Last edited by Naum; 07-03-2009 at 11:47 PM.

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

    Default

    SCAR happends to bug up sometimes..
    Markus got some good examples

    afaik 60% of all the SRL functions starts with Result := False;

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

    Default

    As he said, it's not a bug. It is a feature .

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

    Default

    Quote Originally Posted by Da 0wner View Post
    As he said, it's not a bug. It is a feature .
    It is a feature put in for us to use

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

    Default

    Well duh...

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

    Default

    Of course you would use it if it is a feature.........

  24. #24
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    you don't need that first result:= false;, this is because SCAR sets the default boolean to false.

    [...]

    Ofcourse this isn't with booleans but with integers, but the same thing can happen with booleans.
    And no it' s not a bug, it's a feature.
    .. weren't you telling me otherwise some time ago? D:
    Something about there being a bug in SCAR which wouldn't default the result to false under special circumstances..?


    Anyway, great job on this, Nicklas. I've seen several threads on this issue, and I have to admit that I'll be really impressed if your formulas turn out to be more accurate that the ones presented on the other threads.

    You really deserve a cookie .. e__e

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

    Default

    Quote Originally Posted by Da 0wner View Post
    Of course you would use it if it is a feature.........
    Exactly..

    Anyway, how would anyone rate the usefulness of this. It's very useful in my thoughts (it's not often i say that). Great for picking up cowhides without confuzzle.
    I vouch it should be added to SRL.

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
  •