From 3d0e991001e3b3bbec8b1dc69ac8c3c8bae3fd76 Mon Sep 17 00:00:00 2001 From: Torwent Date: Wed, 11 Dec 2024 12:35:28 +0100 Subject: [PATCH] fix: read notes - 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() --- osr/interfaces/core/interface.simba | 61 +++++++++++++------------- osr/interfaces/gametabs/logout.simba | 64 ++++++++++------------------ utils/biometrics.simba | 6 +-- utils/math.simba | 15 ++++++- 4 files changed, 70 insertions(+), 76 deletions(-) diff --git a/osr/interfaces/core/interface.simba b/osr/interfaces/core/interface.simba index c828bf4e..8f54891a 100644 --- a/osr/interfaces/core/interface.simba +++ b/osr/interfaces/core/interface.simba @@ -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; diff --git a/osr/interfaces/gametabs/logout.simba b/osr/interfaces/gametabs/logout.simba index 3b7780dd..178d2785 100644 --- a/osr/interfaces/gametabs/logout.simba +++ b/osr/interfaces/gametabs/logout.simba @@ -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; diff --git a/utils/biometrics.simba b/utils/biometrics.simba index c558f70d..e38e506f 100644 --- a/utils/biometrics.simba +++ b/utils/biometrics.simba @@ -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 ); diff --git a/utils/math.simba b/utils/math.simba index 56802357..ed6f2839 100644 --- a/utils/math.simba +++ b/utils/math.simba @@ -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: @@ -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; (*