Simba Code:
Function MSI_FindObjectsIn(Objs: TIntegerArray; Var IndexFound: Integer; SearchBox: TBox; Action: fnct_ActionOptions): Boolean;
Var
TPA, TmpTPA: TPointArray;
TheOptions, UpTexts: TStringArray;
I, II, III, HH, HHH, Hi, J, c: Integer;
CheckUpText, inBadBox: Boolean;
Begin
if (not LoggedIn) then
Exit;
MSI_AddHeader('MSI_FindObjectsIn ' + ToStr(Objs));
Hi := High(Objs);
SetLength(TheOptions, Hi + 1);
SetLength(UpTexts, Hi + 1);
For I := 0 To Hi Do
Begin
UpTexts[I] := MSI_Objects[Objs[I]].UpText;
TheOptions[I] := MSI_Objects[Objs[I]].Option;
End;
For II := 0 To Hi Do
With MSI_Objects[Objs[II]] Do // <---- HERE!
begin
// Check the players level; if not high enough, skip object
if (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].SkillConst <> SKILL_NONE) then
if (MSI_Players[CurrentPlayer].ReportInfo.SkillLevels[CurrentScript] < MSI_Objects[Objs[II]].Level) then
begin
if (ii = hi) then
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := 'Skill requirement not met';
MSI_Debug('Not high enough level for object: ' + MSI_Objects[Objs[II]].Name);
Continue;
end;
If MSI_FindObjectsTPA(TmpTPA, Objs[II], SearchBox) Then
Begin
// If set to, the script will click the closest object (this negates Priority)
if (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].ClickClosest) then
begin
MSI_Debug('Clicking closest object to player');
for i := 0 to High(Objs) do
if (MSI_FindObjectsTPA(TmpTPA, Objs[i], SearchBox)) then
begin
//Writeln('Obj'+IntToStr(i));
TPA := CombineTPA(TPA, TmpTPA);
end;
SortTPAFrom(TPA, Point(MSCX, MSCY));
end else
TPA := TmpTPA;
HH := Min((Tries - 1), High(TPA));
MSI_Debug(IntToStr(Length(TPA))+' objects found!');
For I := 0 to HH Do
Begin
// Check to see if the point is in a bad box
if (Length(NotBoxes) > 0) then
for j := 0 to High(NotBoxes) do
if (PointInBox(TPA[i], NotBoxes[j])) then
begin
MSI_Debug('Point in bad box');
inBadBox := True;
Break;
end;
if (inBadBox) then
Continue;
X := TPA[I].X;
Y := TPA[I].Y;
IndexFound := II;
If (Action = Nothing) Then
Begin
Result := True;
MSI_CloseHeader('MSI_FindObjectsIn: ' + BoolToStr(Result));
NotBoxes := [];
Exit;
End;
HHH := High(UpTexts);
CheckUpText := True;
For III := 0 To HHH Do
If (UpTexts[III] = '') Then
Begin
CheckUpText := False;
Break;
End;
MMouse(TPA[I].X, TPA[I].Y, 2, 2);
Wait(20 + Random(50));
If CheckUpText Then
if (waitUptext(name, 200) and (not RightClickOnly)) then
begin
MSI_Debug('Found ground item');
c := invCount();
getMousePos(x, y);
mouse(x, y, 0, 0, true);
wait(randomRange(1000, 2000));
MSI_CloseHeader('MSI_FindObjectsIn: ' + BoolToStr(Result));
notBoxes := [];
exit;
end else
if (WaitUpTextMulti(UpTexts, 150 + Random(20))) then
begin
MSI_Debug('Uptext found!');
Result := True;
end else begin
SetLength(notBoxes, Length(notBoxes) + 1);
notBoxes[High(notBoxes)] := MSI_MakeBox(Point(TPA[I].X, TPA[I].Y), (W / 2), (H / 2));
end
Else
Result := True;
If (Action = Move) Then
begin
MSI_CloseHeader('MSI_FindObjectsIn: ' + BoolToStr(Result));
NotBoxes := [];
Exit;
end;
If Result Then
Begin
GetMousePos(X, Y);
If (RightClickOnly) Or InRange(Random(100), 0, 10) Or (Action = ClickRight) Then
Begin
Mouse(X, Y, 0, 0, False);
If (Action = ClickRight) or (Action = ClickLeft) Then
Result := (WaitOptionMulti(TheOptions, 750 + Random(100)) or waitOption('ake', 200))
Else
Result := DidClick(True, 1200);
End Else Begin
Mouse(X, Y, 0, 0, True);
Result := DidClick(True, 1200); ;
End;
if (result) then
if ((waitToMove) and (track)) then
MSI_TrackObject(objs[ii])
else
if (waitToMove) then
flag
else
if (track) then
MSI_TrackObject(objs[ii]);
MSI_CloseHeader('MSI_FindObjectsIn: ' + BoolToStr(Result));
NotBoxes := [];
Exit;
End Else Begin
MSI_FindRandoms(True);
MSI_Debug('Uptext didn''t match!');
End;
End;
End;
end;
MSI_CloseHeader('MSI_FindObjectsIn: ' + ToStr(Result));
MSI_FindRandoms(True);
End;
Any help is greatly appreciated.