Results 1 to 5 of 5

Thread: Help with clicking a moving shop owner

  1. #1
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Smile Help with clicking a moving shop owner

    Hello! I am trying to get my script to click on the shop owner and trade her, then to proceed to selling her my items. I need help finding a way to know whether I have successfully traded her (i.e. on shop screen) or I have missed her and in that case trying again. This is what I have so far.... It still loops even when I think I have found the shop screen. (used a colour on the shop screen - any better ways would be appreciated) Anyway, here is my code.


    Simba Code:
    procedure FindShopOwnerFinal;

    Var TPA : TPointArray;
     tmpCTS, I, X, Y, Found:Integer;
     ATPA : T2DPointArray;

    begin

    repeat
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.04, 0.37);
      FindColorsTolerance(TPA, 1520706, MSX1, MSY1, MSX2, MSY2, 7);
      SetColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      ATPA := TPAToATPAEx(TPA, 20, 20);
      DebugATPA(ATPA, ' ');
      SortATPASize(ATPA, True);
      FindNormalRandoms();

      For I := 0 To High(ATPA) Do //Loops through until it finds it
        If GetArraylength(ATPA[i]) > 10 Then
        begin //Similar to 'length'
          MiddleTPAEx(ATPA[i], X, Y); //Finds the middle via averaging
          MMouse(X, Y, 3, 3);
          sleep(50 + random(200));
          WriteLn(GetUpText);
          if waituptext('Talk', 300) then
          begin
              sleep(300 + random(200));
              clickmouse2(mouse_right);
              sleep(300 + random(200));
              chooseoption('Trade');
              sleep(8000 + random(3000));
              if FindColorTolerance(x,y,1692278,MSX1,MSY1,MSX2,MSY2,10) then
              WriteLn('Color Found ');
              break;
           end else
             FindShopOwnerFinal;



         end;




     until (False);
     FindTheESSDTM;
      end;

  2. #2
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    You could try something like this.

    Simba Code:
    function FindShopOwnerFunc(): boolean;
    var
      TPA : TPointArray;
      tmpCTS, I, X, Y, Found:Integer;
      ATPA : T2DPointArray;
    begin
      result := false;
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);

      SetColorSpeed2Modifiers(0.04, 0.37);
      FindColorsTolerance(TPA, 1520706, MSX1, MSY1, MSX2, MSY2, 7);

      SetColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (length(tpa) < 10) then //found barely any colour? no point going further
      begin
        writeln('Found no shop owner colors');
        result := false;
        exit;
      end;

      ATPA := TPAToATPAEx(TPA, 20, 20);
      DebugATPA(ATPA, ' ');
      SortATPASize(ATPA, True);
      FindNormalRandoms();

      for i := 0 to high(atpa) do //Loops through every atpa
        if (GetArraylength(ATPA[i]) > 10) Then
        begin
          MiddleTPAEx(ATPA[i], X, Y); //Finds the middle via averaging
          MMouse(X, Y, 3, 3);
          sleep(50 + random(50));
          WriteLn(GetUpText);

          if waituptext('Talk', 300) then
          begin
            sleep(300 + random(200));
            clickmouse2(mouse_right);
            sleep(300 + random(200));
            chooseoption('Trade');
            sleep(8000 + random(3000));

            if FindColorTolerance(x,y,1692278,MSX1,MSY1,MSX2,MSY2,10) then
            begin
              WriteLn('Color Found ');
              result := true;
              exit;
            end;
          end;
        end;
    end;

    procedure findShopOwner();
    var
      tries: integer;
    begin
      tries := 0;

      repeat
        if (findShopOwnerFunc()) then
          break;

        inc(tries); //  plus one to tries count
      until (tries > 10); // try for a max of 10 tries
    end;

  3. #3
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    You can make a dtm of the cross (exit shop) and if it finds the dtm then the shop is open and else shop isnt open.

  4. #4
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Ah making a nature-crafter are we? Give me a second and I'll show you mine with explanations.

    Both of these functions are a bit old and might need the colors updated, I'm not sure.
    Simba Code:
    Function openTheShop: Boolean;
    var
      mPnt: TPoint;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      i,CTS,F,X,Y,T: Integer;
    label
      Start;
    begin
      if ((not loggedIn()) or (not findSymbol(X, Y, 'Shop'))) then    // If no shop symbol is found on the MM or if not logged in, exit
        Exit;
      if shopOpen() then   // Is the shop already open?
        Exit(True);

      Start:
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.03, 0.67);

      for i:=0 to 5 do                     // Search for the shop owner colors 6 times
      begin
        findColorsSpiralTolerance(MSX1, MSY1, TPA, 5537195, MSX1, MSY1, MSX2, MSY2, 11);
        if (length(TPA) > 0) then
          break;
      end;

      setColorSpeed2Modifiers(0.02, 0.02);
      colorToleranceSpeed(1);
      if (F > 5) then
        Exit(False);

      if (length(TPA) < 1) then            // No shop owner colors found
      begin
        inc(F);
        if (F > 2) then
          Exit;
        GoTo Start;
      end;

      splitTPAExWrap(TPA, 10, 20, ATPA);  // Split the colors into, hopefully, 10x20 boxes
      sortATPASize(ATPA, True);           // Sort by size (# of colors found per box)

      for i:=0 to High(ATPA) do           // For each box do...
      begin
        mPnt := medianTPA(ATPA[i]);       // Check for uptext
        MMouse(mPnt.X, mPnt.Y, 0, 0);
        if waitUpTextMulti(['to Ji','Jimin','minua'], 300) then
          break;
      end;
                                          // Was the uptext ever found?  If not try again from the beginning (max of 6 attempts
      if not isUpTextMultiCustom(['to Ji','Jimin','minua']) then
      begin
        Inc(F);
        GoTo Start;
      end;

      clickMouse2(mouse_right);           // Trade and wait until we're close to the flag on the MM
      if chooseOptionMulti(['rade Ji','de Jim']) then
        fFlag(5);

      markTime(T);                        // Wait for the shop screen to appear (max of 5 seconds)
      repeat
        if not loggedIn() then
          Exit;
        if isMoving() then
          Wait(10);

        if shopOpen() then
          break;
      until(timeFromMark(T) > 5000)

      if not shopOpen() then              // Possibly a random event?
        findNormalRandoms();

      Result := shopOpen();               // If the shop screen is present then this function results True, False if not present
    end;

    Also you'll need this:
    Simba Code:
    Function shopOpen(): Boolean;
    var
      X,Y: Integer;
    begin
      Result := findColorTolerance(X, Y, 2070783, 185, 30, 250, 45, 30);
    end;
    Last edited by Flight; 09-30-2013 at 02:32 PM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #5
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Default

    Thanks very much for all the helpful replies. Ill try and implement when I get home!

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
  •