Skip to content

Commit

Permalink
fix: compatibility with latest SRL-T, read notes
Browse files Browse the repository at this point in the history
- XP tracking is now built in the XPBar interface so that's what's being used now.
- WL.XP is remaining for now for 2 scripts that rely on it, but it won't track XP anymore
  • Loading branch information
Torwent committed Apr 17, 2024
1 parent 1dee43f commit 63f28e8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 43 deletions.
2 changes: 1 addition & 1 deletion optional/handlers/combathandler.simba
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ end;
var
CombatHandler: TRSCombatHandler;

function TRSXPBar.EarnedXP(currentXP: Int32): Boolean; override;
function TRSXPBar.EarnedXP(): Boolean; override;
begin
Result := inherited;

Expand Down
4 changes: 2 additions & 2 deletions osr/basescript.simba
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ begin

Result += ' Actions/Hour : ' + ToStr(NumberPerHour(Self.TotalActions, elapsedTime));

Result += ' Total Exp : ' + SRL.FormatNumber(WL.XP.Previous - WL.XP.Start, 2);
Result += ' Exp/Hour : ' + SRL.FormatNumber(NumberPerHour(WL.XP.Previous - WL.XP.Start, elapsedTime), 2);
Result += ' Total Exp : ' + SRL.FormatNumber(XPBar.TotalEarnedXP(), 2);
Result += ' Exp/Hour : ' + SRL.FormatNumber(NumberPerHour(XPBar.TotalEarnedXP(), elapsedTime), 2);

Result += ' Total Profit : ' + SRL.FormatNumber(Self.TotalProfit, 2);
Result += ' Profit/Hour : ' + SRL.FormatNumber(NumberPerHour(Self.TotalProfit, elapsedTime), 2);
Expand Down
2 changes: 1 addition & 1 deletion osr/interfaces/mainscreen/xpbarsetup.simba
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ begin
Result := (Self.GetSetting(ERSXPBarSetupDropDown.DURATION) = 'Permanent')
and
(Self.GetSetting(ERSXPBarSetupDropDown.COUNTER) = 'Total XP');
WL.XP.IsSetup := Result;
XPBar.Tracker.IsSetup := Result;

if Result then
WL.GameSettings.XPBarIsSetup := True;
Expand Down
59 changes: 22 additions & 37 deletions osr/interfaces/xpbar.simba
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@ Extensions to SRL's {ref}`XPBar`
{$I WaspLib/osr.simba}
{$ENDIF}

function TRSXPBar.EarnedXP(currentXP: Int32): Boolean;
begin
Result := currentXP > WL.XP.Previous;

if Result then
begin
if WL.XP.Previous > 0 then
StatsPayload.Update(currentXP-WL.XP.Previous, 0, 0);
WL.Activity.Restart();
WL.XP.Previous := currentXP;
end;
end;

function TRSXPBar.EarnedXP(): Boolean; overload;
begin
Result := Self.EarnedXP(Self.Read());
end;

function TRSXPBar.WaitXP(waitTime: Int32 = 600; interval: Int32 = -1): Boolean;
begin
if (interval = -1) then
interval := SRL.TruncatedGauss(50, 200);

Result := WaitUntil(Self.EarnedXP(), interval, waitTime);
end;

function TRSXPBar.Read(): Int32; override;
var
i: Int32;
Expand All @@ -46,24 +20,22 @@ begin

Result := OCR.RecognizeNumber(Self.Bounds(), TOCRColorFilter.Create([$FFFFFF]), Self.Font);

WL.XP.IsSetup := (Result > 0) and (Result >= WL.XP.Previous);
Self.Tracker.IsSetup := (Result > 0) and (Result >= Self.Tracker.Current);

if not WL.XP.IsSetup and (WL.XP.Previous = 0) and MainScreen.HasInterface() then
begin
if not Self.Tracker.IsSetup and (Self.Tracker.Current = 0) and MainScreen.HasInterface() then
if MainScreen.CloseInterface() then
begin
Self.IsSetup := False;
Exit(Self.Read());
end;
end;

if WL.XP.IsSetup then
if Self.Tracker.IsSetup then
begin
if WL.XP.Start = 0 then
WL.XP.Start := Result;
if Self.Tracker.Start = 0 then
Self.Tracker.Start := Result;

if WL.XP.Previous = 0 then
WL.XP.Previous := Result;
if (Self.Tracker.Current = 0) or (Result > Self.Tracker.Current) then
Self.Tracker.Current := Result;

Exit;
end;
Expand All @@ -83,10 +55,23 @@ begin
until Self.Enable();

Result := OCR.RecognizeNumber(Self.Bounds(), TOCRColorFilter.Create([$FFFFFF]), Self.Font);
WL.XP.IsSetup := (Result > 0) and (Result >= WL.XP.Previous);
Self.Tracker.IsSetup := (Result > 0) and (Result >= Self.Tracker.Current);

if not WL.XP.IsSetup then
if not Self.Tracker.IsSetup then
XPBarSetup.Fix();
end;
end;

function TRSXPBar.EarnedXP(): Boolean; override;
var
previous: Int32;
begin
previous := Self.Tracker.Current;
Result := Self.Read() > previous;

if Result and Self.Tracker.IsSetup then
begin
StatsPayload.Update(Self.Tracker.Current-previous, 0, 0);
WL.Activity.Restart();
end;
end;
2 changes: 1 addition & 1 deletion osr/rsclient.simba
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ begin
if not WL.GameSettings.RoofsHidden then
WL.GameSettings.RoofsHidden := Options.HideRoofs();

if WL.XP.Previous = 0 then
if XPBar.Tracker.Current = 0 then
XPBar.Read();

if WLSettings.SaveVideo.Enabled and not WL.IsRecording then
Expand Down
2 changes: 1 addition & 1 deletion tools/compile_test.simba
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Returns the scripts that failed compiling.
{$I SRL-T/osr.simba}

const
PATH: String = ScriptPath + 'waspcripts.com';
PATH: String = ScriptPath + 'waspscripts.com';
VERBOSE: Boolean = True;

var
Expand Down

0 comments on commit 63f28e8

Please sign in to comment.