Results 1 to 5 of 5

Thread: Objects.scar - FindObjectThroughMM

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

    Default Objects.scar - FindObjectThroughMM

    Thanks to Rasta magican and Nava2 for pushing this forward...

    This works great for object finding, if theres a dot.
    Otherwise it acts like normal FindObj...

    Note: It needs MMToMS, which I've posted before.

    Example of usage:
    SCAR Code:
    FindObjectThroughMM('item', [1478833], [5], ['oin'], 5, 5);

    Function discription:
    SCAR Code:
    {*******************************************************************************
    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 FindObjectThroughMM(Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
    By: N1ke!
    Description: Finds a object with the given parameters.
    Uses minimap dots to get locations of objects.
    Will put the matching areas first in the TPA array,so it hovers those
    first.

    Note: It still searches the whole screen, but it puts items first in
          the array.

    Valid kinds are
    - npc/yellow
    - item/red
    - player/white
    *******************************************************************************}

    Function FindObjectThroughMM(Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
    var
      ATPA: T2DPointArray;
      TPA, TPA2, TPA3: TPointArray;
      I, II, H, HH, ArrC, X, Y: Integer;
    begin
      SetLength(ATPA, Length(Colors));

      H := High(Colors);
      For I:= 0 to H do
        FindColorsTolerance(ATPA[i], Colors[i], MSX1, MSY1, MSX2, MSY2, Tol[i]);

      TPA := MergeATPA(ATPA);
      ATPA := TPAToATPAEx(TPA, Width, Height);

      SetLength(TPA, GetArrayLength(ATPA));
      H := High(TPA)
      for i:= 0 to H do
        TPA[i] := MiddleTPA(ATPA[i]);

      TPA2 := GetMiniMapDots(Kind);
      H := High(TPA2);
      For I:=0 to H do
        TPA2[i] := MMToMS(TPA2[i]);

      H := High(TPA);
      HH := High(TPA2);
      SetArrayLength(TPA3, GetArrayLength(TPA));
      For I:=0 to H do
        For II:=0 to HH do
         If IntInBox(TPA[i].X, TPA[i].Y, IntToBox(TPA2[II].X-55, TPA2[II].Y-55, TPA2[II].X+55, TPA2[II].Y+55))then
         begin
           TPA3[ArrC] := TPA[i];
           Inc(ArrC);
           Break;
         end;
      SetArrayLength(TPA3, ArrC);
      ClearTPAFromTPA(TPA, TPA3);
      TPA := CombineTPA(TPA3, TPA);

      H := High(TPA);
      For I:=0 to H do
      begin
        MMouse(TPA[i].X, TPA[i].Y, 4, 4);
        If WaitUptextMulti(UpText, 250+Random(100))then
        begin
          GetMousePos(X, Y);
          Result := True;
          Exit;
        end;
      end;
    end;

    Enjoy

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

    Default

    Done.

  3. #3
    Join Date
    Nov 2008
    Location
    Arizona
    Posts
    236
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    gonna use this in my next script..will deff help alot.
    I'm Back.

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Very nice job with this

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

    Default

    N1ke!, you should be at developer status. Nao. Good work.

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
  •