diff --git a/optional/handlers/combathandler.simba b/optional/handlers/combathandler.simba index 707c473d..79518ebd 100644 --- a/optional/handlers/combathandler.simba +++ b/optional/handlers/combathandler.simba @@ -851,7 +851,7 @@ end; var CombatHandler: TRSCombatHandler; -function TRSXPBar.EarnedXP(currentXP: Int32): Boolean; override; +function TRSXPBar.EarnedXP(): Boolean; override; begin Result := inherited; diff --git a/osr/basescript.simba b/osr/basescript.simba index 6c56cd80..dfa200c0 100644 --- a/osr/basescript.simba +++ b/osr/basescript.simba @@ -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); diff --git a/osr/interfaces/mainscreen/xpbarsetup.simba b/osr/interfaces/mainscreen/xpbarsetup.simba index df3dff97..ce3530bb 100644 --- a/osr/interfaces/mainscreen/xpbarsetup.simba +++ b/osr/interfaces/mainscreen/xpbarsetup.simba @@ -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; diff --git a/osr/interfaces/xpbar.simba b/osr/interfaces/xpbar.simba index 8a0b6ab8..6402b41e 100644 --- a/osr/interfaces/xpbar.simba +++ b/osr/interfaces/xpbar.simba @@ -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; @@ -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; @@ -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; diff --git a/osr/rsclient.simba b/osr/rsclient.simba index a3bf8688..c7c58be3 100644 --- a/osr/rsclient.simba +++ b/osr/rsclient.simba @@ -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 diff --git a/tools/compile_test.simba b/tools/compile_test.simba index 99fe4438..415ef8ff 100644 --- a/tools/compile_test.simba +++ b/tools/compile_test.simba @@ -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