Results 1 to 3 of 3

Thread: make it search crates?

  1. #1
    Join Date
    Oct 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question make it search crates?

    well guyzz,
    i'm trying to make a script that searches crates in Wydin's food shop (in Port Sarim), more specifically, the 2 crates stacked on top of each other, the one that gives you raw chicken.

    Now, I'm not really sure how I would go about doing this. I could use FindObjMulti() or sumthin but that might not work, since there are 2 other crates of pretty much the same color in that room...

    I could also use TPAs, but I am a beginning scripter, and I'm also kinda too lazy to learn about em :P

    The setup is with a pile of 2 crates on the North part of the small room, 1 crate in the middle part of the room (with a banana on top of it), and 1 crate slightly South of that (with a white apron on top of it). Each pile is spaced about 1~2 tiles apart from each other.

    Now if I really had to learn TPAs I shall commence to do that.
    But I really hope I don't have to yet :P

    I was wondering if I could somehow use DTMs or the fact that it is a stack of 2 crates, or the fact that there are items on top of the other crates, to get SIMBA to click the right crate.

    Any ideas?

    Thanks in advance,
    Peeweewoen
    Last edited by peeweewoen; 05-18-2012 at 02:51 AM.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Find Object In Object. Basically you find the colour of the floor the crates are on.. Pass it to the function below. Next find the outline of the crates and pass it to the previous call. Finally Find the one crate that stacks on the second crate and pass it to the function below. It will return you a TPA of the exact crate you want.

    Simba Code:
    Function FindObjectInObject(TPA: TPointArray; Color, Width, Height, Tolerance: Integer; Speed: TExtendedArray): TPointArray;
    var
      CTS, L, I: Integer;
      TPACopy: TPointArray;
      ATPA, ATPA2: T2DPointArray;
      B: TBox;
    begin
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Speed[0], Speed[1]);

      if (Length(TPA) < 1) then
        Exit;

      TPACopy:= CopyTPA(TPA);
      if (Length(TPACopy) < 1) then
        Exit;

      ATPA:= TPAToATPAEx(TPACopy, Width, Height);
      SortATPASize(ATPA, True);
      L := High(ATPA);
      SetArrayLength(ATPA2, L+1);

      For I:= 0 To L do
      begin
        B := GetTPABounds(ATPA[I]);
        with B do
        begin
          FindColorsTolerance(ATPA2[I], Color, B.X1, B.Y1, B.X2, B.Y2, Tolerance);
          if (Length(ATPA2[I]) < 1) then
            Continue;
        end;
      end;
      if (Length(ATPA2) > 0) then
        Result:= MergeATPA(ATPA2)
      else
        Result:= [];

      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.02, 0.02);
    end;



    Can be used like this:

    Crate On Crate In Outline on floor. Make sense I hope Example of Marble altar:

    Simba Code:
    Function FindAltar: Boolean;
    var
      CTS, X, Y: Integer;
      TPA, TPA2, TPA3: TPointArray;
    begin
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.10, 0.20);
      FindColorsTolerance(TPA, 3096661, 0, 0, 1000, 617, 11);   //Finds the brown outline of the altar..
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.02, 0.02);

      If Length(TPA) < 1 then
        Exit;

      TPA2:= FindObjectInObject(TPA, 10726065, 186, 138, 23, [0.37, 0.36]);   //With the brown outline, search inside it for the white marble..
      If (Length(TPA2) < 1) then
        Exit;

      TPA3:= FindObjectInObject(TPA2, 10458003, 186, 138, 16, [0.11, 0.14]);  //With the white marble, search inside that for the prayer book..
      If (Length(TPA3) < 1) then
        Exit;

      MiddleTPAEx(TPA3, X, Y);   //Our altar is found 100% of the time.
      MMouse(X, Y, 0, 0);
    end;
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Oct 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol Great idea!
    i would never have thought of that
    thanks for the input :]

    +rep

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
  •