Skip to content

Commit be71e31

Browse files
committed
Merge branch 'pr/142'
2 parents f2a2b3f + bff0296 commit be71e31

File tree

2 files changed

+105
-12
lines changed

2 files changed

+105
-12
lines changed

osrs/antiban/antibantasks.simba

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,91 @@ procedure TAntiban.HoverMakeItem();
162162
var
163163
boxes: TBoxArray;
164164
begin
165-
if not Bank.IsOpen() then Exit;
166-
WriteLn GetDebugLn('Antiban', 'Hovering a random make item button');
165+
if not Make.IsOpen() then Exit;
166+
WriteLn GetDebugLn('Antiban', 'Hovering a random make item');
167+
boxes := Make.GetItemBoxes();
168+
if boxes = [] then Exit;
169+
Mouse.Move(boxes.Random());
170+
end;
171+
172+
procedure TAntiban.HoverMakeQuantity();
173+
var
174+
boxes: TBoxArray;
175+
begin
176+
if not Make.IsOpen() then
177+
Exit;
178+
if not Make.CloseHint() then
179+
Exit;
180+
181+
WriteLn GetDebugLn('Antiban', 'Hovering a random make quantity button');
182+
boxes := Make.GetQuantityBoxes();
183+
if boxes = [] then Exit;
184+
Mouse.Move(boxes.Random());
185+
Biometrics.Sleep(500, 2000, ERandomDir.LEFT);
186+
end;
187+
188+
procedure TAntiban.ReadMakeItemHint();
189+
var
190+
boxes: TBoxArray;
191+
begin
192+
if not Make.IsOpen() then Exit;
193+
WriteLn GetDebugLn('Antiban', 'Reading a random make item hint');
167194
boxes := Make.GetItemBoxes();
195+
if boxes = [] then Exit;
168196
Mouse.Move(boxes.Random());
197+
if Make.WaitHint(2000) then
198+
begin
199+
Biometrics.Sleep(1000, 3000, ERandomDir.LEFT);
200+
Make.CloseHint();
201+
end;
202+
end;
203+
204+
procedure TAntiban.ToggleMakeQuantity();
205+
var
206+
randomBtn: TRSMakeQuantityButton;
207+
quantityBtns: array of TRSMakeQuantityButton;
208+
currentBtn, customQuantity, i: Integer;
209+
begin
210+
if not Make.IsOpen() then
211+
Exit;
212+
if not Make.CloseHint() then
213+
Exit;
214+
215+
WriteLn GetDebugLn('Antiban', 'Toggling make quantity buttons');
216+
217+
quantityBtns := Make.FindQuantityButtons;
218+
if quantityBtns = [] then Exit;
219+
currentBtn := Make.GetCurrentQuantity();
220+
randomBtn := quantityBtns[Random(Length(quantityBtns))];
221+
222+
if randomBtn.UpText = 'Other' then
223+
begin
224+
for i := 0 to High(quantityBtns) do
225+
if (quantityBtns[i].Quantity = ERSItemQuantity.CUSTOM)
226+
and (quantityBtns[i].UpText <> 'Other') then
227+
begin
228+
customQuantity := StrToInt(quantityBtns[i].UpText);
229+
end;
230+
231+
Make.SetQuantity(Random(1, 27));
232+
Biometrics.Sleep(1000, 3000, ERandomDir.LEFT);
233+
234+
if customQuantity > 0 then
235+
begin
236+
Make.SetQuantity(customQuantity);
237+
Biometrics.Sleep(1000, 3000, ERandomDir.LEFT);
238+
end;
239+
end
240+
else
241+
begin
242+
// Just click the random button
243+
randomBtn.Button.Enable();
244+
Biometrics.Sleep(1000, 3000, ERandomDir.LEFT);
245+
end;
246+
247+
// Restore original
248+
if Make.IsOpen() then
249+
Make.SetQuantity(currentBtn);
169250
end;
170251

171252
//Chatbox antiban
@@ -654,6 +735,16 @@ begin
654735
end;
655736
end;
656737

738+
procedure TAntiban.RandomMakeTask();
739+
begin
740+
case Random(0, 10) of
741+
0..3: Self.HoverMakeItem();
742+
4..6: Self.HoverMakeQuantity();
743+
7..8: Self.ReadMakeItemHint();
744+
9..10: Self.ToggleMakeQuantity();
745+
end;
746+
end;
747+
657748
procedure TAntiban.RandomChatTask();
658749
begin
659750
case Random(30) of
@@ -893,6 +984,10 @@ const
893984
['HoverSkills', @Antiban.HoverSkills],
894985
['OpenSkills', @Antiban.OpenSkills],
895986
['HoverMakeItem', @Antiban.HoverMakeItem],
987+
['HoverMakeQuantity', @Antiban.HoverMakeQuantity],
988+
['ReadMakeItemHint', @Antiban.ReadMakeItemHint],
989+
['ToggleMakeQuantity', @Antiban.ToggleMakeQuantity],
990+
['RandomMakeTask', @Antiban.RandomMakeTask],
896991
['ChatScrolling', @Antiban.ChatScrolling],
897992
['RandomChatTab', @Antiban.RandomChatTab],
898993
['ToggleChatTab', @Antiban.ToggleChatTab],

osrs/interfaces/chat/make.simba

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ begin
306306
Result := StrToInt(current.UpText);
307307
end;
308308

309+
309310
(*
310311
## Make.HasHint
311312
```pascal
@@ -362,7 +363,8 @@ var
362363
tpa: TPointArray;
363364
begin
364365
tpa := Target.FindColor($A0FFFF, 0, Chat.Bounds);
365-
if tpa <> [] then Result := tpa.Bounds();
366+
if tpa <> [] then
367+
Result := tpa.Bounds();
366368
end;
367369

368370
(*
@@ -399,6 +401,9 @@ var
399401
tpa: TPointArray;
400402
b: TBox;
401403
begin
404+
if not Self.HasHint() then
405+
Exit(True);
406+
402407
tpa := TPointArray.CreateFromBox(Chat.Bounds, True);
403408
for b in Self.GetItemBoxes() do
404409
tpa := tpa.ExcludeBox(b.Expand(1));
@@ -454,19 +459,12 @@ end;
454459
*)
455460
function TRSMake.FindQuantityButton(amount: Integer): TRSMakeQuantityButton;
456461
var
457-
hintPt: TPoint;
458462
idx: Integer;
459463
quantity: ERSItemQuantity;
460464
quantitybtns: array of TRSMakeQuantityButton;
461465
begin
462-
if Self.HasHint() then
463-
begin
464-
hintPt := Self.GetHintBox().TopRight;
465-
if (hintPt.Y <= Self.QuantityButtonBoxes[5].Y2) and (hintPt.X >= Self.QuantityButtonBoxes[5].X1) then
466-
467-
if not Self.CloseHint() then
468-
raise GetDebugLn('Make', 'Failed to close the tooltip which is covering the quanitty buttons');
469-
end;
466+
if not Self.CloseHint() then
467+
raise GetDebugLn('Make', 'Failed to close the tooltip which could be covering the quantity buttons');
470468

471469
quantitybtns := Self.FindQuantityButtons();
472470
quantity := ERSItemQuantity.Integer2Quantity(amount);

0 commit comments

Comments
 (0)