+ Reply to Thread
Results 1 to 9 of 9

Thread: Another suggestion..

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Another suggestion..

    I was unsure whether this was the code itself or that it didn't track the TPAs well. It continually clicks the trees even though it chops away, and when it does this the player isn't even moving. That's why I suspect something's up with the TPAs. The last update was great (thanks Coh3n) but I'm still having this little issue. I'll check it out myself right now.

    E:
    Simba Code:
    Procedure MSI_WaitWhileChopping(TreeID: integer);
    Var
      CTS, HalfWidth, HalfHeight, L, I, T, OldInvCount, NewInvCount: Integer;
      TotalChopTime, R, CT: Integer;
      ATPA: T2DPointArray;
      TPA: TPointArray;
      B: TBox;
      TreeExists: Boolean;
    Begin
      MSI_AddHeader('MSI_WaitWhileChopping');

      CTS := GetColorToleranceSpeed;
      SetColorSpeed2Modifiers(MSI_Objects[TreeID].Hue, MSI_Objects[TreeID].Sat);

      HalfWidth := (MSI_Objects[TreeID].W / 2);
      HalfHeight := (MSI_Objects[TreeID].H / 2);
      B := IntToBox(MSI_Objects[TreeID].X - HalfWidth, MSI_Objects[TreeID].Y - HalfHeight,
                    MSI_Objects[TreeID].X + HalfWidth, MSI_Objects[TreeID].Y + HalfHeight);

      L := Length(MSI_Objects[TreeID].Colors);
      SetLength(ATPA, L);
      Dec(L);
      OldInvCount := InvCount;
      T := GetSystemTime + 20000 + Random(5000);
      TotalChopTime := GetSystemTime;

      MSI_AddHeader('Entering loop');
      Repeat
        If InvFull Then
          Break;

        MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);

        { Check if the tree Exists }
        MSI_Debug('Looking for tree');
        For I := 0 To L Do
          FindColorsTolerance(ATPA[I], MSI_Objects[TreeID].Colors[I],
                              B.X1, B.Y1, B.X2, B.Y2, MSI_Objects[TreeID].Tol);
        TPA := MergeATPA(ATPA);
        //WriteLn(Length(TPA));

        TreeExists := Length(TPA) >= MSI_Objects[TreeID].Accuracy;
        If (TreeExists) Then
          If (Random(4) <> 0) Then
            Wait(200 + Random(50))
          Else
            SleepAndMoveMouse(200 + Random(50));

        MSI_FindRandoms;
        MSI_FindBirdNest;

        { InvCount check }
        MSI_Debug('Checking inventory count');
        NewInvCount := InvCount;
        If (NewInvCount > OldInvCount) Then
        Begin
          MSI_SubDebug('New count > old count');
          OldInvCount := NewInvCount;
          T := GetSystemTime + 20000 + Random(5000);
        End;

        { Prevent logout }
        If ((GetSystemTime - TotalChopTime) > 60000) Then
        Begin
          MSI_Debug('Preventing logout');
          CT := GetCurrentTab;
          Repeat
            R := RandomRange(Tab_Combat, Tab_Notes);
          Until(R <> CT);
          GameTab(R);
          MSI_SubDebug('Clicking game tab: ' + IntToStr(R));
          Wait(RandomRange(500, 1000));
        End;

        if (GetCurrentTab <> tab_Inv) then
          MouseBox(646, 177, 662, 195, 1);
      Until(Not TreeExists) Or (GetSystemTime > T) Or (Not LoggedIn);
      MSI_CloseHeader('Out of loop');
      MSI_CloseHeader('MSI_WaitWhileChopping: Exit');
    End;

    Why not just add a while ... do loop in the tree finding procedure that will wait until it can't find the color in the spot anymore. I believe it might be searching for colors elsewhere and therefore not finding what it needs.
    Last edited by Sir R. M8gic1an; 09-17-2010 at 10:29 AM.

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

    Default

    Diff / what did you change?

    ~RM

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

  3. #3
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Sir R. Magician View Post
    Diff / what did you change?

    ~RM
    I didn't change anything, just wanted to show the procedure.

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

    Default

    TrackObject will cause the character to click an object multiple times generally. That's probably what your experiencing.

  5. #5
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by DeSnob View Post
    Why not just add a while ... do loop in the tree finding procedure that will wait until it can't find the color in the spot anymore. I believe it might be searching for colors elsewhere and therefore not finding what it needs.
    That's what it does, but if the player has to walk to the tree, the object can someones be lost and therefore has to click the tree again.

  6. #6
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    That's what it does, but if the player has to walk to the tree, the object can someones be lost and therefore has to click the tree again.
    The issue is that it continuously clicks WHILE at the tree (standing still).

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by DeSnob View Post
    The issue is that it continuously clicks WHILE at the tree (standing still).
    I've had it click it one or two times once it's already chopping, but nothing more. What tree is this happening with? Can you take a screenshot of/video of the SMART debugging when this happens?

    The tree colors may need to be updated. There may not be enough colors being found after clicking the tree.

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

    Default

    This was the same for mining. There error is here:
    Simba Code:
    {******************************************************************************}
    { Function MSI_ChopTree(Which: TIntegerArray): Boolean;                        }
    { By: marpis                                                                   }
    { Date: 25 June 2010                                                           }
    { Description: Chops tree                                                      }
    {******************************************************************************}
    Function MSI_ChopTree(Which: TIntegerArray): Boolean;
    Var
      TreeIndex: Integer;
    Begin
      If MSI_FindObjects(Which, TreeIndex, ClickLeft) Then
      begin
        Result := True;
        MSI_TrackObject(Which[TreeIndex]); //this is causing it
        MSI_WaitWhileChopping(Which[TreeIndex]);
      end;
    End;

    Wonder why?

    Simba Code:
    TREE_YEW:
          with MSI_Objects[whichObject] do
          begin
            Name               := 'Yew tree';
            UpText             := 'wn Yew';
            Option             := 'Chop down Yew';
            Colors             := [4162165];
            Tol                := 14;
            Hue                := 0.01;
            Sat                := 0.76;
            FindAllColors      := False;
            W                  := 35;
            H                  := 35;
            Accuracy           := 10;
            ExcludeSelf        := True;
            RightClickOnly     := False;
            Tries              := 5;
            Anim               := False;
            WaitToMove         := True; //because of this
            BadColors          := [];
            BadColorTolerance  := 10;
            AssociatedItems    := [LOGS_YEW];
          end;


    //and...
    Function MSI_FindObjectsIn
              If MSI_Objects[Objs[II]].WaitToMove Then
                MSI_TrackObject(Objs[II]);

    So it calls TrackObject twice. I fixed it up for mining. I'll take care of this in a sec.

    e: done. Rev 288

    ~RM

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

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

    Default

    Awesome! Nice find RM

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may post attachments
  • You may edit your posts
  •