Skip to content

Commit d0dbe7b

Browse files
committed
fix: several small fixes, read notes
- `TRSSlotInterface` now also has a checkfunction to open or check if the interface is open like `TRSItemInterface` - fixed a bug with `TRSWorldSwitcher.Open()` that would temporarily close it - `TRSProfiles.GetPlayer()` renamed to `TRSProfiles.Get()` - Removed left-over debugging I forgot about in `TRSItemFinder` - fix an issue with `TAntiban.HoverSkills` where it would wrap around the time value
1 parent 3da32a3 commit d0dbe7b

File tree

7 files changed

+44
-21
lines changed

7 files changed

+44
-21
lines changed

osrs/antiban/antiban.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ begin
493493
if checkSleeps and Self.DoSleep() then Result := True;
494494

495495
if not RSClient.IsLoggedIn() then
496-
Login.DoLogin(Profiles.GetPlayer());
496+
Login.DoLogin();
497497

498498
Self.DoingAntiban := False;
499499
Logger.TimeRunning.Start();

osrs/antiban/antibantasks.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ begin
119119
Exit;
120120
end;
121121

122-
Self.HoverSkill(Self.Skills.Random(), Trunc(GaussRand(1000, 10000)), RandomBoolean(0.5));
122+
Self.HoverSkill(Self.Skills.Random(), Biometrics.RandomModeInteger(3000, 1000, 8000), RandomBoolean(0.5));
123123
end;
124124

125125
procedure TAntiban.OpenSkill(skill: ERSSkill; time: Integer; returnToCurrentTab: Boolean);

osrs/finders/itemfinder.simba

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ begin
420420
border := new TImage(36, 32);
421421
border.DrawColor := $FFFFFF;
422422
border.DrawTPA(tpa);
423-
border.Show();
424423
//h*w*4=4608
425424
Result := HashData(EHashAlgo.CRC32, border.Data, 4608);
426425
end;

osrs/interfaces/login/login.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ var
588588
timeout: UInt64;
589589
begin
590590
if profile = Default(TProfile) then
591-
profile := Profiles[ProfileIndex];
591+
profile := Profiles.Get();
592592

593593
timeout := Time() + 40000;
594594

osrs/interfaces/slotinterface.simba

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ unless specified otherwise.
4848
Name: String;
4949
Slots: TBoxArray;
5050
SlotsFunction: function (): TBoxArray of object;
51+
CheckFunction: function (): Boolean of object;
5152
end;
5253

5354
(*
@@ -85,11 +86,12 @@ Bank.Slots.Setup('Bank.Slots', Bank.SlotBoxes, @Bank.FindItemBoundaries);
8586
Just in case people would like to access the bank's static slots through it's
8687
`Slots` variable.
8788
*)
88-
procedure TRSSlotInterface.Setup(name: String; slots: TBoxArray; slotsFunction: function (): TBoxArray of object = nil);
89+
procedure TRSSlotInterface.Setup(name: String; slots: TBoxArray; slotsFunction: function (): TBoxArray of object = nil; checkFunc: function (): Boolean of object = nil);
8990
begin
9091
Self.Name := name;
9192
Self.Slots := slots;
9293
Self.SlotsFunction := @slotsFunction;
94+
Self.CheckFunction := @checkFunc;
9395
end;
9496

9597
(*
@@ -310,6 +312,8 @@ var
310312
slots: TBoxArray;
311313
i: Integer;
312314
begin
315+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
316+
Exit;
313317
slots := Self.Boxes();
314318
for i := 0 to High(slots) do
315319
if Target.HasColor(TRSItem.Border, 8.5, 1, slots[i]) or
@@ -342,6 +346,8 @@ var
342346
slots: TBoxArray;
343347
i: Integer;
344348
begin
349+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
350+
Exit;
345351
slots := Self.Boxes();
346352
for i := 0 to High(slots) do
347353
if not Target.HasColor(TRSItem.Border, 8.5, 1, slots[i]) and
@@ -368,12 +374,14 @@ end.
368374
*)
369375
function TRSSlotInterface.IsUsed(slot: TBox): Boolean;
370376
begin
377+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
378+
Exit;
371379
Result := TRSItem.InBounds(slot);
372380
end;
373381

374382
function TRSSlotInterface.IsUsed(slot: Integer): Boolean; overload;
375383
begin
376-
Result := TRSItem.InBounds(Self.Box(slot));
384+
Result := Self.IsUsed(Self.Box(slot));
377385
end;
378386

379387
(*
@@ -394,12 +402,14 @@ end.
394402
*)
395403
function TRSSlotInterface.IsEmpty(slot: TBox): Boolean;
396404
begin
405+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
406+
Exit;
397407
Result := not TRSItem.InBounds(slot);
398408
end;
399409

400410
function TRSSlotInterface.IsEmpty(slot: Integer): Boolean; overload;
401411
begin
402-
Result := not TRSItem.InBounds(Self.Box(slot));
412+
Result := Self.IsEmpty(Self.Box(slot));
403413
end;
404414

405415

@@ -422,15 +432,16 @@ end.
422432
*)
423433
function TRSSlotInterface.IsFaded(slot: TBox): Boolean;
424434
begin
435+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
436+
Exit;
425437
Result := not TRSItem.InBounds(slot, 0) and TRSItem.InBounds(slot);
426438
end;
427439

428440
function TRSSlotInterface.IsFaded(slot: Integer): Boolean; overload;
429-
var
430-
b: TBox;
431441
begin
432-
b := Self.Box(slot);
433-
Result := not TRSItem.InBounds(b, 0) and TRSItem.InBounds(b);
442+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
443+
Exit;
444+
Result := Self.IsFaded(Self.Box(slot));
434445
end;
435446

436447

@@ -452,7 +463,8 @@ end.
452463
*)
453464
function TRSSlotInterface.WaitFade(slot: TBox; time: Integer = 200): Boolean;
454465
begin
455-
if not Self.IsFaded(slot) then Exit;
466+
if not Self.IsFaded(slot) then
467+
Exit;
456468
Result := SleepUntil(TRSItem.InBounds(slot, 0), 100, time);
457469
end;
458470

@@ -550,12 +562,14 @@ end.
550562
*)
551563
function TRSSlotInterface.ReadStack(slot: TBox): Integer;
552564
begin
565+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
566+
Exit;
553567
Result := TRSItem.ReadStack(slot);
554568
end;
555569

556570
function TRSSlotInterface.ReadStack(slot: Integer): Integer; overload;
557571
begin
558-
Result := TRSItem.ReadStack(Self.Box(slot));
572+
Result := Self.ReadStack(Self.Box(slot));
559573
end;
560574

561575

@@ -597,6 +611,8 @@ end.
597611
*)
598612
procedure TRSSlotInterface.Click(slot: Integer; button: EMouseButton = EMouseButton.LEFT);
599613
begin
614+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
615+
Exit;
600616
Self.Hover(slot);
601617
Target.MouseClick(button);
602618
end;
@@ -621,7 +637,11 @@ function TRSSlotInterface.Move(slot, destination: Integer): Boolean;
621637
var
622638
slots: TBoxArray;
623639
begin
624-
if slot = destination then Exit(True);
640+
if slot = destination then
641+
Exit(True);
642+
643+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
644+
Exit;
625645

626646
slots := Self.Boxes([slot, destination]);
627647

@@ -657,6 +677,8 @@ end.
657677
*)
658678
function TRSSlotInterface.Interact(slot: Integer; option: String = ''): Boolean;
659679
begin
680+
if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
681+
Exit;
660682
Self.Hover(slot);
661683

662684
if (option <> '') and not MainScreen.IsUpText(option) then

osrs/overrides.simba

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ WriteLn WorldSwitcher.Open();
167167
*)
168168
function TRSWorldSwitcher.Open(waitLoad: Boolean = True): Boolean; override;
169169
begin
170-
if not Logout.Open() then Exit;
171-
if WorldSwitcher._IsOpen() then Exit(True);
170+
if not GameTabs.Open(ERSGameTab.LOGOUT) then
171+
Exit;
172+
if WorldSwitcher._IsOpen() then
173+
Exit(True);
172174
Logout.Buttons[ERSLogoutButton.WORLD_SWITCHER].Click();
173175
Result := inherited;
174176
end;

utils/profiles.simba

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ begin
6969
end;
7070

7171
(*
72-
## Profiles.GetPlayer
72+
## Profiles.Get
7373
```pascal
74-
function TProfileArray.GetPlayer(): TRSAccountProfile;
74+
function TProfileArray.Get(): TRSAccountProfile;
7575
```
7676
Returns the currently selected TRSAccountProfile.
7777
The currently selected TRSAccountProfile is decided by `ProfileIndex` which
7878
is an index of the TRSAccountProfileArra.
7979

8080
Example:
8181
```pascal
82-
WriteLn Profiles.GetPlayer().Username;
82+
WriteLn Profiles.Get().Username;
8383
```
8484
*)
85-
function TProfileArray.GetPlayer(): TProfile;
85+
function TProfileArray.Get(): TProfile;
8686
begin
8787
if Self = [] then
8888
raise GetDebugLn('Profiles', 'No profiles declared: Add a profile if you want scripts to handle login.');
@@ -107,7 +107,7 @@ if BankPin.IsOpen() then
107107
*)
108108
function TProfileArray.GetPin(): String;
109109
begin
110-
Result := Self.GetPlayer().Pin;
110+
Result := Self.Get().Pin;
111111
if (Length(Result) <> 4) or (not Result.IsNumeric) then
112112
raise GetDebugLn('Profiles', 'Invalid bank pin.');
113113
end;

0 commit comments

Comments
 (0)