DannyRS Gave me this function to find an object, and if it cannot find the uptext it moves on to the next:
Function ClickTree: Boolean;
Var
tmpCTS,i, L,Counter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X,Y,DMCount,Moves: Integer;
Begin
Moves:=0;
DMCount:=0;
tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.06, 0.20);
FindColorsTolerance(ObjTPA, 3166038, MSX1, MSY1, MSX2, MSY2, 5);
SplitTPAWrap(ObjTPA, 10, ObjATPA);
SortATPASize(ObjATPA,True);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
DMCount:=RandomRange(3,5);
L := High(ObjATPA)
MarkTime(Counter);
For i := 0 To L Do
Begin
MiddleTPAEx(ObjATPA[i], X, Y);
Repeat Begin
Status := ('Looking for tree');
WriteDebug;
Moves:=Moves+1;
mmouse(x, y, 1, 1);
Wait(RandomRange(140, 200));
If (P06_IsUpTextMultiCustom(['Willow','illow', 'llow'])) Then
Begin
Status := ('Cutting tree');
WriteDebug;
clickmouse2(mouse_Left);
Wait(700);
while (IsMoving) do
wait(100);
Exit;
End;
End; Until (Moves > DMCount)
If (TimeFromMark(Counter) > 5000) Then
Begin
Break;
End;
End;
Result:=False;
End;
I did not understand it at first, but as I began to use it more and more, I could do more with it, like this:
function Attack: Boolean;
var
tmpCTS, i, L, Counter, Fighter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X, Y, DMCount, Moves: Integer;
Begin
Moves := 0;
DMCount := 0;
tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(Hue_Monster, Sat_Monster);
FindColorsTolerance(ObjTPA, Col_Monster, 1, 1, 514, 338, Tol_Monster);
SplitTPAWrap(ObjTPA, 10, ObjATPA);
SortATPASize(ObjATPA, True);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
DMCount := RandomRange(3, 5);
L := High(ObjATPA) MarkTime(Counter);
for i := 0 to L do
Begin
MiddleTPAEx(ObjATPA[i], X, Y);
repeat
Begin
Moves := Moves + 1;
mmouse(x, y, 1, 1);
Status := ('Looking for ' + MonsterKill + 's')
WriteProgress;
Wait(RandomRange(400, 500));
if (P06_IsUpTextMultiCustom(['' + Uptext_1, '' + Uptext_2, '' + Uptext_3])) Then
Begin
clickmouse2(mouse_Left);
Wait(RandomRange(800, 1200));
Status := ('Fighting ' + MonsterKill + 's')
WriteProgress;
while IsFighting do
Wait(RandomRange(400, 800));
MarkTime(Fighter);
if not IsFighting Then
Begin
if (TimeFromMark(Fighter) > 1000) Then
Begin
if not IsFighting Then
Begin
Break;
End;
End;
if (TimeFromMark(Fighter) > TimeOut) Then
Begin
Break;
End;
End;
IncEx(XPGained, XpKill);
IncEx(MonsterKilled, 1);
Exit;
End;
End;
until (Moves > DMCount) if (TimeFromMark(Counter) > 5000) Then
Begin
Break;
End;
End;
Result := False;
End;
Right now, I am learning how to use 2 of them for sharp object detection:
function Bank: Boolean;
var
i, CTS, c, Timeout: Integer;
TPA, TPA1, TPA2: TPointArray;
ATPA: T2DPointArray;
P: TPoint;
begin
Result := False;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
Timeout := 5000 + Random(1000);
SetColorSpeed2Modifiers(BankHue_1, BankSat_1);
FindColorsTolerance(TPA1, BankCol_1, MSX1, MSY1, MSX2, MSY2, BankTol_1);
SetColorSpeed2Modifiers(BankHue_2, BankSat_2);
FindColorsTolerance(TPA2, BankCol_2, MSX1, MSY1, MSX2, MSY2, BankTol_2);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
CombineTPAWrap(TPA1, TPA2, TPA);
SplitTPAWrap(TPA, 5, ATPA);
SortATPASize(ATPA, True);
if Length(TPA) < 1 then
Exit;
for i := 0 to High(ATPA) do
if Length(ATPA[i]) > 30 then
begin
P := MiddleTPA(ATPA[i]);
HumanMMouse(P.X, P.Y, RandomRange( - 5, 5), RandomRange( - 5, 5));
if (P07_IsUpTextMultiCustom(['Use', 'Bank', 'ooth'])) then
begin
case LowerCase(ClickMethod) of
'booth':
Begin
RandomLeftClick;
clickmouse2(mouse_Right);
RandomChooseWait;
P07_ChooseOptionMultiHuman(['Use-q']);
RandomBankWait;
While (IsMoving) Do
FastWait;
If Not P07_BankScreen Then
Begin
Bank;
End;
Exit;
End;
'chest':
Begin
RandomRightClick;
clickmouse2(mouse_Left);
Wait(RandomRange(100, 700));
RandomBankWait;
While (IsMoving) Do
FastWait;
If Not P07_BankScreen Then
Begin
Bank;
End;
Exit;
End;
End;
Exit;
End;
End;
End;
Eventually I will understand it more and be able to utilize it