Skip to content

Commit

Permalink
fix: read notes
Browse files Browse the repository at this point in the history
- compatibility with latest SRL-T which added support for the star rating buttons in the logout tab
- fixed a big issue with the biohash system caused by Int32 wrapping arround.
- small refactor of Interface.FindButtons()
  • Loading branch information
Torwent committed Dec 11, 2024
1 parent 35e9642 commit 3d0e991
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 76 deletions.
61 changes: 31 additions & 30 deletions osr/interfaces/core/interface.simba
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,54 @@ type
TRSDropDownArray = array of TRSDropDown;

//overriden to be able to pick Scroll UI Close button
function TRSInterface.FindButtons(Dimensions: TRSButtonDimensions): TRSButtonArray; override;
function TRSInterface.FindButtons(dimensions: TRSButtonDimensions): TRSButtonArray; override;
var
TPA: TPointArray;
ATPA: T2DPointArray;
I, W, H: Int32;
B: TBox;
Color: TCTS1Color;
Boxes: TBoxArray;
tpa: TPointArray;
atpa: T2DPointArray;
i, w, h: Int32;
b: TBox;
color: TCTS1Color;
boxes: TBoxArray;
begin
B := Self.Bounds();
b := Self.Bounds();

for Color in Self.ButtonColors do
if SRL.FindColors(TPA, Color, B) > 0 then
ATPA += TPA;
for color in Self.ButtonColors do
if SRL.FindColors(tpa, color, b) > 0 then
atpa += tpa;

ATPA := ATPA.Merge.Cluster(1);
atpa := atpa.Merge().Cluster(1);

for TPA in ATPA do


for tpa in atpa do
begin
if Length(TPA) < 50 then
Continue;
if Length(tpa) < 50 then Continue;

B := TPA.Bounds();
B.GetDimensions(W, H);
b := tpa.Bounds();
b.GetDimensions(w, h);

for I := 0 to High(Dimensions) do
for i := 0 to High(dimensions) do
begin
if ((W = Dimensions[I].Width) or (Dimensions[I].Width = 0)) and
((H = Dimensions[I].Height) or (Dimensions[I].Height = 0)) and
(TPA.Frameness > 57) then
Boxes += B;
if (w <> dimensions[i].Width) and (dimensions[i].Width <> 0) then Continue;
if (h <> dimensions[i].Height) and (dimensions[i].Height <> 0) then Continue;
if(tpa.Frameness() <= 57) then Continue;
boxes += b;
end;

{$IFDEF SRL_DEBUG_FINDBUTTONS}
Writeln(W, ', ', H);
Writeln(w, ', ', h);
{$ENDIF}
end;

Boxes.SortByXY(10);
boxes.SortByXY(10);

SetLength(Result, Length(Boxes));
for I := 0 to High(Boxes) do
SetLength(Result, Length(boxes));
for i := 0 to High(boxes) do
begin
Result[I].Index := I;
Result[I].Bounds := Boxes[I];
Result[I].Middle := Boxes[I].Center();
Result[I].EnabledColors := Self.ButtonEnabledColors;
Result[i].Index := i;
Result[i].Bounds := boxes[i];
Result[i].Middle := boxes[i].Center();
Result[i].EnabledColors := Self.ButtonEnabledColors;
end;
end;

Expand Down
64 changes: 23 additions & 41 deletions osr/interfaces/gametabs/logout.simba
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,41 @@ Extends SRL's TRSLogout.
{$I WaspLib/osr.simba}
{$ENDIF}


function TRSLogout.GetLikeButtons(): TRSButtonArray;
begin
Result := Self.FindButtons([[60, 30]]);
end;

function TRSLogout.GetLikeButton(): TRSButton;
var
buttons: TRSButtonArray;
begin
buttons := Self.GetLikeButtons();
if Length(buttons) = 2 then
Result := buttons[0];
end;

function TRSLogout.GetDislikeButton(): TRSButton;
var
buttons: TRSButtonArray;
begin
buttons := Self.GetLikeButtons();
if Length(buttons) = 2 then
Result := buttons[1];
end;

function TRSLogout.UsedLikeButtons(): Boolean;
var
button: TRSButton;
begin
for button in Self.GetLikeButtons() do
if button.Enabled() then
Exit(True);
end;


function TRSLogout.ClickLogout(Attempts: Int32 = 5; TryTime: Int32 = 20000): Boolean; override;
(*
## Logout.ClickLogout
```pascal
function TRSLogout.ClickLogout(attempts: Int32 = 5; time: Int32 = 20000): Boolean; override;
```
Clicks the logout button. Returns true if we succesfully logout of the game.
Depending on the account biohash it might use the start buttons to rate the game.
Example:
```pascal
WriteLn Logout.ClickLogout();
```
*)
function TRSLogout.ClickLogout(attempts: Int32 = 5; tryTime: Int32 = 20000): Boolean; override;
var
Interval: UInt64;
interval: UInt64;
i: Int32;
begin
if (not Self.Open()) or (not Self.CloseWorldSwitcher()) then
Exit;

Interval := TryTime div Attempts;
interval := tryTime div attempts;

if Antiban.BioDice(EBioBehavior.USES_LIKE_BUTTONS) then
if Antiban.BioDice(EBioBehavior.USES_STAR_BUTTONS) then
begin
if Antiban.BioDice(EBioBehavior.TENDS_TO_LIKE) then
Self.GetLikeButton().Enable()
i := Round(SRL.TruncatedGauss(5, 1))
else
Self.GetDislikeButton().Enable();
i := Round(SRL.TruncatedGauss(1, 5));

Self.DebugLn('Rating the game with ' + ToStr(i) + ' stars before logging out.');
Self.GetStarButton(i).Enable();
end;

for i := 1 to Attempts do
for i := 1 to attempts do
if Self.GetButton(ERSLogoutButton.CLICK_HERE).Click() and WaitUntil(not RSClient.IsLoggedIn(), 500, Interval + SRL.NormalRange(-2000, 2000)) then
Exit(True);
end;
6 changes: 3 additions & 3 deletions utils/biometrics.simba
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ EBioBehavior is a enum that represent biohaviors affected by the user BioHash.
ESCAPE_CHANCE, //Chance to use Escape to close interfaces
KEYBOARD_CHAT_CHANCE, //Chance to use to handle chat options with the keyboard.

REACTION_SPEED, //Decides how long the player will wait after things like changing tabs, opening choose options menu, etc.
SPAM_CLICK_CHANCE, //Chance to spam click things (walking, eating, etc).
REACTION_SPEED, //Decides how long the player will wait after things like changing tabs, opening choose options menu, etc.
SPAM_CLICK_CHANCE, //Chance to spam click things (walking, eating, etc).
DROP_PATTERN,
CONSUME_IN_BANK,
USES_LIKE_BUTTONS,
USES_STAR_BUTTONS,
TENDS_TO_LIKE
);

Expand Down
15 changes: 13 additions & 2 deletions utils/math.simba
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This file has math related methods.
## Double.GetDigit
```pascal
function Double.GetDigit(n: Int32): Int32;
function Double.GetDigit(n: Int64): Int64; overload;
```
Get the digit at the **n** place of the Double.
Example:
Expand All @@ -26,8 +26,19 @@ end;
```
*)
function Double.GetDigit(n: Int32): Int32;
var
s: String;
begin
s := ToStr(Self).Replace('.', '');
Result := StrToInt(s[n+1]);
end;

function Double.GetDigit(n: Int64): Int64; overload;
var
s: String;
begin
Result := Floor(Self * Power(10, n)) mod 10;
s := ToStr(Self).Replace('.', '');
Result := StrToInt64(s[n+1]);
end;

(*
Expand Down

0 comments on commit 3d0e991

Please sign in to comment.