Skip to content

Commit a0f26e6

Browse files
committed
fix: world switcher finished
removed all `const` parameters, it didn't work as I thought it did.
1 parent 532afdb commit a0f26e6

22 files changed

+692
-239
lines changed

osrs/antiban/antiban.simba

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type
6767
OnFinishTask: procedure(task: PAntibanTask) of object;
6868
end;
6969

70-
function TAntiban.TimeRunningAtClock(const time: String; const randomness: Double = 0.10): Int64;
70+
function TAntiban.TimeRunningAtClock(time: String; randomness: Double = 0.10): Int64;
7171
var
7272
current, res: TDateTime;
7373
begin
@@ -94,7 +94,7 @@ end;
9494
(*
9595
## Antiban.AddTask
9696
```pascal
97-
procedure TAntiban.AddTask(const interval: Double; const method: TAntibanMethod; const randomness: Double = 0.2);
97+
procedure TAntiban.AddTask(interval: Double; method: TAntibanMethod; randomness: Double = 0.2);
9898
```
9999
Schedule a antiban task.
100100
An antiban task can be any procedure but they should be short actions that won't
@@ -113,7 +113,7 @@ Example:
113113
Antiban.AddTask(15 * ONE_MINUTE, @Antiban.HoverSkills); //Every 15 minutes the script will hover the skills.
114114
```
115115
*)
116-
procedure TAntiban.AddTask(const interval: Double; const method: TAntibanMethod; const randomness: Double = 0.2);
116+
procedure TAntiban.AddTask(interval: Double; method: TAntibanMethod; randomness: Double = 0.2);
117117
var
118118
task: TAntibanTask;
119119
begin
@@ -128,7 +128,7 @@ end;
128128
(*
129129
## Antiban.AddBreak
130130
```pascal
131-
procedure TAntiban.AddBreak(const interval, length: Double; const randomness: Double = 0.2; const logoutChance: Double = 0.33);
131+
procedure TAntiban.AddBreak(interval, length: Double; randomness: Double = 0.2; logoutChance: Double = 0.33);
132132
```
133133
Schedule a break. Breaks can be of short or medium length and should be shorter than any sleep breaks.
134134

@@ -144,7 +144,7 @@ Example:
144144
Antiban.AddBreak(30 * ONE_MINUTE, 5 * ONE_MINUTE); //Every 30 minutes the script will take a 5 minute break, subject to variance from the randomness variable.
145145
```
146146
*)
147-
procedure TAntiban.AddBreak(const interval, length: Double; const randomness: Double = 0.2; const logoutChance: Double = 0.33);
147+
procedure TAntiban.AddBreak(interval, length: Double; randomness: Double = 0.2; logoutChance: Double = 0.33);
148148
var
149149
task: TBreakTask;
150150
begin
@@ -160,7 +160,7 @@ end;
160160
(*
161161
## Antiban.AddSleep
162162
```pascal
163-
procedure TAntiban.AddSleep(const time: String; const length: Double; const randomness: Double = 0.10; const logoutChance: Double = 0.5);
163+
procedure TAntiban.AddSleep(time: String; length: Double; randomness: Double = 0.10; logoutChance: Double = 0.5);
164164
```
165165
Schedule a sleep break. A sleep break is a large break, it can be any length but
166166
it's usually the several hours and also the largest one/ones.
@@ -183,7 +183,7 @@ Example:
183183
Antiban.AddSleep('01:30:45', 8 * ONE_HOUR, 0.1, 0.8); //At 01:30:45 on our computer time the script will take a break for 8 hours, subject to variance from the randomness variable.
184184
```
185185
*)
186-
procedure TAntiban.AddSleep(const time: String; const length: Double; const randomness: Double = 0.10; const logoutChance: Double = 0.5);
186+
procedure TAntiban.AddSleep(time: String; length: Double; randomness: Double = 0.10; logoutChance: Double = 0.5);
187187
var
188188
task: TSleepTask;
189189
begin
@@ -451,7 +451,7 @@ while True do //Infinite loop
451451
Antiban.DoAntiban(); //Antiban.HoverSkills will be called every time 15 minutes passed when this is called.
452452
```
453453
*)
454-
function TAntiban.DoAntiban(const checkTasks, checkBreaks, checkSleeps: Boolean = True): Boolean;
454+
function TAntiban.DoAntiban(checkTasks, checkBreaks, checkSleeps: Boolean = True): Boolean;
455455
begin
456456
if Self.DoingAntiban then Exit;
457457
Self.DoingAntiban := True;
@@ -469,31 +469,31 @@ end;
469469
(*
470470
## Antiban.TimeUntilBreak
471471
```pascal
472-
function TAntiban.TimeUntilBreak(const task: TBreakTask): String;
472+
function TAntiban.TimeUntilBreak(task: TBreakTask): String;
473473
```
474474
Check how much time is left until the specified break `task` should be taken.
475475
*)
476-
function TAntiban.TimeUntilBreak(const task: TBreakTask): String;
476+
function TAntiban.TimeUntilBreak(task: TBreakTask): String;
477477
begin
478478
Result := FormatMilliseconds(Max(0, Round(task.Next - GetTimeRunning())), True);
479479
end;
480480

481481
(*
482482
## Antiban.TimeUntilSleep
483483
```pascal
484-
function TAntiban.TimeUntilSleep(const task: TSleepTask): String;
484+
function TAntiban.TimeUntilSleep(task: TSleepTask): String;
485485
```
486486
Check how much time is left until the specified sleep break `task` should be taken.
487487
*)
488-
function TAntiban.TimeUntilSleep(const task: TSleepTask): String;
488+
function TAntiban.TimeUntilSleep(task: TSleepTask): String;
489489
begin
490490
Result := FormatMilliseconds(Max(0, Round(task.Next - GetTimeRunning())), True);
491491
end;
492492

493493
(*
494494
## Antiban.SimulateBreaks
495495
```pascal
496-
procedure TAntiban.SimulateBreaks(const bottingDays: UInt64 = 1000);
496+
procedure TAntiban.SimulateBreaks(bottingDays: UInt64 = 1000);
497497
```
498498
Performs a simulation of `bottingDays` amount of days with the currently setup
499499
breaks and prints the results.
@@ -504,7 +504,7 @@ Antiban.AddBreak(30 * ONE_MINUTE, 5 * ONE_MINUTE);
504504
Antiban.SimulateBreaks();
505505
```
506506
*)
507-
procedure TAntiban.SimulateBreaks(const bottingDays: UInt64 = 1000);
507+
procedure TAntiban.SimulateBreaks(bottingDays: UInt64 = 1000);
508508
var
509509
active, inactive, len, prev: Double;
510510
i: Int32;

osrs/antiban/antibantasks.simba

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,8 @@ begin
9393
end;
9494

9595

96-
function TAntiban.RandomScroll(scroll: TRSScrollBar; down: Boolean = True): Boolean;
97-
var
98-
i: Integer;
99-
begin
100-
if not scroll.IsVisible() or not scroll.CanScroll() then Exit;
101-
102-
Result := True;
103-
104-
case down of
105-
True: if scroll.GetLevel() = 100 then Exit;
106-
False: if scroll.GetLevel() = 0 then Exit;
107-
end;
108-
109-
Mouse.Move(scroll.GetScrollArea());
110-
111-
for i := 1 to Biometrics.RandomModeInteger(5, 3, 8) do
112-
begin
113-
if down then
114-
Target.MouseScroll(-Random(1,3))
115-
else
116-
Target.MouseScroll(Random(1,3));
117-
end;
118-
end;
119-
120-
12196
//Stats antiban
122-
procedure TAntiban.HoverSkill(const skill: ERSSkill; const time: UInt32; const returnToCurrentTab: Boolean);
97+
procedure TAntiban.HoverSkill(skill: ERSSkill; time: UInt32; returnToCurrentTab: Boolean);
12398
var
12499
tab: ERSGameTab;
125100
begin
@@ -147,7 +122,7 @@ begin
147122
Self.HoverSkill(Self.Skills.Random(), Trunc(GaussRand(1000, 10000)), RandomBoolean(0.5));
148123
end;
149124

150-
procedure TAntiban.OpenSkill(const skill: ERSSkill; const time: Integer; const returnToCurrentTab: Boolean);
125+
procedure TAntiban.OpenSkill(skill: ERSSkill; time: Integer; returnToCurrentTab: Boolean);
151126
var
152127
tab: ERSGameTab;
153128
begin
@@ -185,7 +160,7 @@ end;
185160
procedure TAntiban.ChatScrolling();
186161
begin
187162
WriteLn GetDebugLn('Antiban', 'Random scrolling on chat');
188-
Self.RandomScroll(Chat.Scroll, False);
163+
Chat.Scroll.Scroll(Biometrics.RandomModeInteger(5, 3, 8), False);
189164
Biometrics.Sleep(5000, 8000);
190165
Chat.Scroll.SetLevel(100);
191166
end;
@@ -270,7 +245,7 @@ procedure TAntiban.BankScrolling();
270245
begin
271246
if not Bank.IsOpen() then Exit;
272247
WriteLn GetDebugLn('Antiban', 'Random scrolling on bank');
273-
Antiban.RandomScroll(Bank.Scroll, RandomBoolean(0.5));
248+
Chat.Scroll.Scroll(Biometrics.RandomModeInteger(5, 3, 8), RandomBoolean(0.5));
274249
end;
275250

276251
procedure TAntiban.RandomBankTab();

osrs/interfaces/chooseoption.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end;
7070
(*
7171
## ChooseOption.WaitOpen
7272
```pascal
73-
function TRSChooseOption.WaitOpen(const time: Integer; interval: Integer = -1): Boolean;
73+
function TRSChooseOption.WaitOpen(time: Integer; interval: Integer = -1): Boolean;
7474
```
7575
Returns True/False if the choose option menu is becomes visible/open within the specified `time`.
7676

@@ -79,7 +79,7 @@ Example:
7979
WriteLn ChooseOption.WaitOpen();
8080
```
8181
*)
82-
function TRSChooseOption.WaitOpen(const time: Integer; interval: Integer = -1): Boolean;
82+
function TRSChooseOption.WaitOpen(time: Integer; interval: Integer = -1): Boolean;
8383
begin
8484
if interval < 0 then interval := RandomMode(100, 50, 1500);
8585
Result := SleepUntil(Self.IsOpen(), interval, time);

osrs/interfaces/gametabs/gametabs.simba

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ ERSGameTab = enum(NONE, COMBAT, STATS, ACHIEVEMENTS, INVENTORY, EQUIPMENT, PRAYE
2222
(*
2323
(TRSGameTabs)=
2424
## type TRSGameTabs
25-
```pascal
26-
TRSGameTabs = record
27-
Bounds: TBox;
28-
Tabs: TBoxArray; //Hidden, you are meant to use the Get() method.
29-
const ActiveColor: TColorTolerance = [$14194A, 1.235, EColorSpace.HSL, [1.631, 1.084, 0.286]];
30-
end;
31-
```
25+
Main record responsible for handling the gametabs.
3226
*)
3327
TRSGameTabs = record
3428
Bounds: TBox;
@@ -115,7 +109,7 @@ end;
115109
(*
116110
## GameTabs.Get
117111
```pascal
118-
function TRSGameTabs.Get(const tab: ERSGameTab): TBox;
112+
function TRSGameTabs.Get(tab: ERSGameTab): TBox;
119113
```
120114
Get a GameTab button bounds.
121115

@@ -124,7 +118,7 @@ Example:
124118
ShowOnClient(GameTabs.Get(ERSGameTab.INVENTORY));
125119
```
126120
*)
127-
function TRSGameTabs.Get(const tab: ERSGameTab): TBox;
121+
function TRSGameTabs.Get(tab: ERSGameTab): TBox;
128122
begin
129123
Result := Self.Tabs[tab-1];
130124
end;
@@ -157,7 +151,7 @@ end;
157151
(*
158152
## GameTabs.IsOpen
159153
```pascal
160-
function TRSGameTabs.IsOpen(const tab: ERSGameTab): Boolean;
154+
function TRSGameTabs.IsOpen(tab: ERSGameTab): Boolean;
161155
```
162156
Returns true/false if the specified `tab` is currently open.
163157

@@ -166,15 +160,15 @@ Example:
166160
WriteLn GameTabs.IsOpen(ERSGameTab.INVENTORY);
167161
```
168162
*)
169-
function TRSGameTabs.IsOpen(const tab: ERSGameTab): Boolean;
163+
function TRSGameTabs.IsOpen(tab: ERSGameTab): Boolean;
170164
begin
171165
Result := Self.GetCurrent() = tab;
172166
end;
173167

174168
(*
175169
## GameTabs.WaitOpen
176170
```pascal
177-
function TRSGameTabs.WaitOpen(const tab: ERSGameTab; const time: Integer = 600; interval: Integer = -1): Boolean;
171+
function TRSGameTabs.WaitOpen(tab: ERSGameTab; time: Integer = 600; interval: Integer = -1): Boolean;
178172
```
179173
Returns true/false if the specified `tab` opens within the specified `time`.
180174

@@ -184,7 +178,7 @@ Mouse.Click(GameTabs.Get(ERSGameTab.INVENTORY), EMouseButton.LEFT);
184178
WriteLn GameTabs.WaitOpen(ERSGameTab.INVENTORY);
185179
```
186180
*)
187-
function TRSGameTabs.WaitOpen(const tab: ERSGameTab; const time: Integer = 600; interval: Integer = -1): Boolean;
181+
function TRSGameTabs.WaitOpen(tab: ERSGameTab; time: Integer = 600; interval: Integer = -1): Boolean;
188182
begin
189183
if interval < 0 then interval := RandomMode(100, 50, 1500);
190184
Result := SleepUntil(Self.IsOpen(tab), interval, time);
@@ -193,7 +187,7 @@ end;
193187
(*
194188
## GameTabs.Open
195189
```pascal
196-
function TRSGameTabs.Open(const tab: ERSGameTab): Boolean;
190+
function TRSGameTabs.Open(tab: ERSGameTab): Boolean;
197191
```
198192
Attempts to open the specified `tab` gametab.
199193

@@ -202,7 +196,7 @@ Example:
202196
WriteLn GameTabs.Open(ERSGameTab.INVENTORY);
203197
```
204198
*)
205-
function TRSGameTabs.Open(const tab: ERSGameTab): Boolean;
199+
function TRSGameTabs.Open(tab: ERSGameTab): Boolean;
206200
begin
207201
if Self.IsOpen(tab) then Exit(True);
208202

osrs/interfaces/gametabs/logout.simba

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,35 @@ Methods to interact with the logout tab.
88
{$ENDIF}
99

1010
type
11+
(*
12+
## Logout Enums
13+
```pascal
14+
ERSRating = (ONE, TWO, THREE, FOUR, FIVE);
15+
ERSLogoutButton = (WORLD_SWITCHER, CLICK_HERE);
16+
```
17+
Enums representing the buttons available in the logout gametab.
18+
*)
1119
ERSRating = (ONE, TWO, THREE, FOUR, FIVE);
1220
ERSLogoutButton = (WORLD_SWITCHER, CLICK_HERE);
21+
22+
(*
23+
(TRSLogout)=
24+
## type TRSLogout
25+
Main record that holds and the methods to interact with the logout gametab.
26+
*)
1327
TRSLogout = record
1428
Buttons: array [ERSLoginButton] of TRSButton;
1529
Ratings: array [ERSRating] of TRSButton;
1630
end;
1731

32+
(*
33+
## Logout.SetupInterface
34+
```pascal
35+
procedure TRSLogout.SetupInterface();
36+
```
37+
Internal method used to setup {ref}`TRSLogout` coordinates.
38+
This is called automatically for you on the {ref}`Logout` variable.
39+
*)
1840
procedure TRSLogout.SetupInterface();
1941
var
2042
btns: TBoxArray;
@@ -94,7 +116,7 @@ end;
94116
(*
95117
## Logout.Rate
96118
```pascal
97-
function TRSLogout.Rate(const star: ERSRating): Boolean;
119+
function TRSLogout.Rate(star: ERSRating): Boolean;
98120
```
99121
Click a star button to rate the game.
100122

@@ -103,7 +125,7 @@ Example:
103125
WriteLn Logout.Rate(ERSRating.FOUR);
104126
```
105127
*)
106-
function TRSLogout.Rate(const star: ERSRating): Boolean;
128+
function TRSLogout.Rate(star: ERSRating): Boolean;
107129
begin
108130
if Self.Ratings[star].Enabled() and
109131
((star = ERSRating.FIVE) or not Self.Ratings[star+1].Enabled()) then
@@ -116,7 +138,7 @@ end;
116138
(*
117139
## Logout.Logout
118140
```pascal
119-
function TRSLogout.Logout(const attempts: UInt32 = 5; const time: UInt32 = 20000): Boolean;
141+
function TRSLogout.Logout(attempts: UInt32 = 5; time: UInt32 = 20000): Boolean;
120142
```
121143
Attempts to logout of the game. Returns true if we succesfully logout of the game.
122144
If the {ref}`WorldSwitcher` is open, we will use {ref}`WorldSwitcher.Logout` instead.
@@ -126,7 +148,7 @@ Example:
126148
WriteLn Logout.Logout();
127149
```
128150
*)
129-
function TRSLogout.Logout(const attempts: UInt32 = 5; const time: UInt32 = 20000): Boolean;
151+
function TRSLogout.Logout(attempts: UInt32 = 5; time: UInt32 = 20000): Boolean;
130152
var
131153
i: Integer;
132154
interval: UInt32;
@@ -162,3 +184,11 @@ end;
162184

163185
var
164186
Logout: TRSLogout;
187+
188+
function TRSWorldSwitcher.Open(waitLoad: Boolean = True): Boolean; override;
189+
begin
190+
if not Logout.Open() then Exit;
191+
if WorldSwitcher._IsOpen() then Exit(True);
192+
Logout.Buttons[ERSLogoutButton.WORLD_SWITCHER].Click();
193+
Result := inherited;
194+
end;

0 commit comments

Comments
 (0)