Simba Code:
function MSI_TrackObject(ObjID: integer): boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
CTS, T, Tries: integer;
B: TBox;
Previous: TPoint;
BreakNext: boolean;
DistMultiplier: extended;
begin
if (not LoggedIn) then
Exit;
MSI_AddHeader('MSI_Track Object');
Result := true;
Track_Search(T_TrackObject);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(MSI_Objects[ObjID].Hue, MSI_Objects[ObjID].Sat);
// Preparing vars for loop
DistMultiplier := Distance(MSCX, MSCY, MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y) / 40;
if DistMultiplier < 1.0 then DistMultiplier := 1.0;
BreakNext := false;
Previous := Point(MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y);
T := GetSystemTime + 30000;
repeat
B := MSI_MakeBox(Point(MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y),
round(MSI_Objects[ObjID].W * DistMultiplier),
round(MSI_Objects[ObjID].H * DistMultiplier));
// Sets the limits of the box (so it doesn't exceed the Mainscreen)
if (B.X1 < MSX1) then B.X1 := MSX1;
if (B.Y1 < MSY1) then B.Y1 := MSY1;
if (B.X2 > MSX2) then B.X2 := MSX2;
if (B.Y2 > MSY2) then B.Y2 := MSY2;
if (MSI_SetupVars[SETUP_DEBUG_SMART]) then
SMART_DrawBoxEx(True, B, clYellow);
if MSI_FindObjectsTPA(TPA, ObjID, B) then
begin
ATPA := SplitTPA(TPA, MSI_Objects[ObjID].W);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
MiddleTPAEx(ATPA[0], MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y);
if tries = 1 then
begin
tries := 0;
DistMultiplier := DistMultiplier - 1.0; //setting the box back to 'normal' size
end;
end else begin
Inc(tries);
if tries = 1 then
begin
DistMultiplier := DistMultiplier + 1.0; //increasing search box
continue;
end else begin
MSI_Debug('Lost track of object');
Result := false;
break;
end;
end;
if BreakNext then Break;
if distance(Previous.X, Previous.Y, MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y) < DIST_PIXEL_MOVE then
if not FlagPresent then
if not IsMoving then
BreakNext := true;
Previous := Point(MSI_Objects[ObjID].X, MSI_Objects[ObjID].Y);
Wait(5);
until (T < GetSystemTime);
if Result then
Track_Success(T_TrackObject);
Track_Print(T_TrackObject);
MSI_CloseHeader('MSI_TrackObject: ' + BoolToStr(Result));
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(2);
end;
Procedure MSI_WaitWhileChopping(TreeID: integer);
Var
CTS, HalfWidth, HalfHeight, L, I, T, OldInvCount, NewInvCount, tDist, prevLen: Integer;
TotalChopTime, R, CT: Integer;
ATPA: T2DPointArray;
TPA: TPointArray;
Objs: TIntegerArray;
B: TBox;
TreeExists, Debug: Boolean;
Begin
if (not LoggedIn) then
Exit;
MSI_AddHeader('MSI_WaitWhileChopping');
Objs := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Trees;
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(MSI_Objects[TreeID].Hue, MSI_Objects[TreeID].Sat);
HalfWidth := Round(MSI_Objects[TreeID].W * 0.7);
HalfHeight := Round(MSI_Objects[TreeID].H * 0.7);
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 + MSI_Objects[TreeID].MaxTime + Random(5000));
TotalChopTime := (GetSystemTime + (4 * 60000));
Repeat
Debug := (Random(10) < 3);
If InvFull Then
Break;
MSI_FindRandoms(False);
MSI_AntiBan(RandomRange(0, 5000), ANTI_BAN_CHANCE);
// Check if the tree Exists
if (Debug) then
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);
SortTPAFrom(TPA, Point(MSCX, MSCY));
if (Length(TPA) > 0) then
begin
if (length(TPA) <= (prevLen / 2)) then
begin
MSI_Debug('Length(TPA) < half the previous, tree is gone');
break;
end;
if (MSI_SetupVars[SETUP_DEBUG_SMART]) then
SMART_DrawDotsEx(True, TPA, clYellow);
// Gets distance from closest point to player
tDist := Distance(TPA[0].x, TPA[0].y, MSCX, MSCY);
// Resets the tracking box to a box the size of the tree located around the closest point
B := MSI_MakeBox(Point(TPA[0].x, TPA[0].y), MSI_Objects[TreeID].W, MSI_Objects[TreeID].H);
if (MSI_SetupVars[SETUP_DEBUG_SMART]) then
SMART_DrawBoxEx(False, B, clBlue);
prevLen := length(TPA);
end;
if (Debug) then
MSI_Debug('Track box distance: '+IntToStr(tDist));
if (tDist > TREE_MAX_DIST) then
begin
if (Debug) then
MSI_Debug('Tracking box is over the maximum distance');
Break;
end;
TreeExists := Length(TPA) >= MSI_Objects[TreeID].Accuracy;
If (TreeExists) Then
If (Random(4) <> 0) Then
Wait(200 + Random(50))
Else
SleepAndMoveMouse(200 + Random(50));
if (random(20) < 5) then
if MSI_FindBirdNest then
Break;
// InvCount check
if (Debug) then
MSI_Debug('Checking inventory count');
NewInvCount := InvCount;
If (NewInvCount > OldInvCount) Then
Begin
if (Debug) then
MSI_SubDebug('New count > old count');
OldInvCount := NewInvCount;
T := (GetSystemTime + MSI_Objects[TreeID].MaxTime + Random(5000));
End;
// Prevent logout
If ((TotalChopTime - GetSystemTime) < 60000) Then
Begin
if (Debug) then
MSI_Debug('Preventing logout');
CT := GetCurrentTab;
Repeat
R := RandomRange(Tab_Combat, Tab_Notes);
Until(R <> CT);
GameTab(R);
if (Debug) then
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('MSI_WaitWhileChopping: Finished');
SetColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
End;
Since both procedures are both using Simba's color routines, it makes me think maybe there's a hole in Simba somewhere; although, I doubt it. Just throwing out ideas.