From 90422d3c5c55d40e2b3257b0b92e4ef189fa6741 Mon Sep 17 00:00:00 2001 From: Torwent Date: Mon, 4 Dec 2023 14:39:07 +0100 Subject: [PATCH] fix: CombatHandler and TBaseScript - CombatHandler tweaks to auto retaliate caching so tabs are not flickered so much on scripts startup - TBaseScript was printing states twice. - TBaseScript full report timer was reduced from 5 mins to 3 mins --- osr/basescript.simba | 9 ++++----- osr/handlers/combathandler.simba | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/osr/basescript.simba b/osr/basescript.simba index 6f11ab41..5c590a25 100644 --- a/osr/basescript.simba +++ b/osr/basescript.simba @@ -145,7 +145,6 @@ begin if Self.Action = Self.PreviousAction then Exit(ProgressReport.ProgressArray); - Self.DebugLn(Self.Action, Self.ExtraInfo); //add action and extra info the the log. elapsedTime := Self.TimeRunning.ElapsedTime(); Result += ' Action : ' + Self.Action; @@ -205,7 +204,7 @@ begin if not Self.PrintTimer.IsFinished() then begin if Self.PreviousAction <> Self.Action then - Self.DebugLn(Self.Action); + Self.DebugLn(Self.Action, Self.ExtraInfo); Self.PreviousAction := Self.Action; Exit; @@ -337,7 +336,7 @@ begin Self.TimeLimit := 0; WL.Activity.Init(260000); - Self.PrintTimer.Init(5 * ONE_MINUTE); + Self.PrintTimer.Init(3 * ONE_MINUTE); if Self.IsSetup then Exit; @@ -369,9 +368,9 @@ end; -procedure TBaseScript.SetAction(Action: String); +procedure TBaseScript.SetAction(action: String); begin - Self.Action := Action; + Self.Action := action; Self.PrintReport(); end; diff --git a/osr/handlers/combathandler.simba b/osr/handlers/combathandler.simba index 306488ce..48f63ef5 100644 --- a/osr/handlers/combathandler.simba +++ b/osr/handlers/combathandler.simba @@ -114,7 +114,7 @@ type MinHitPoints, MinPrayPoints, WeaponSpec, AttackMonsterDelay: Int32; TotalKills: UInt32; - ManageGear, GearIsSetup, AutoRetaliateEnabled, QuickPrayerIsSetup, + ManageGear, GearIsSetup, AutoRetaliateEnabled, AutoRetaliateChecked, QuickPrayerIsSetup, HandleCannon, CannonIsSetup, DoingSpec, UseSafeSpot, SlayerTaskFinishedVisible, SlayerTaskFinished, LootEnabled, BuryBones, IsFighting, Looted, IsSetup: Boolean; @@ -221,7 +221,7 @@ begin if Self.IsSetup then Exit; - Self.Name := 'RSCombatHandler'; + Self.Name := 'CombatHandler'; if Self.AttackMonsterDelay = 0 then Self.AttackMonsterDelay := 5000; @@ -252,7 +252,8 @@ begin if Self.HandleCannon then Self.DebugLn('Cannon and cannonballs detected. Cannon will be used.'); - Self.AutoRetaliateEnabled := Combat.GetAutoRetaliate(); + if not Self.AutoRetaliateChecked then + Combat.GetAutoRetaliate(); Self.Monster := rsMonster; Self.SafeSpot := safeSpotTile; @@ -865,7 +866,21 @@ begin CombatHandler.InCombatTimer.Restart(); end; +function TRSCombat.GetAutoRetaliate(): Boolean; override; +begin + CombatHandler.AutoRetaliateChecked := True; + Result := inherited; + CombatHandler.AutoRetaliateEnabled := Result; +end; + +function TRSCombat.SetAutoRetaliate(value: Boolean): Boolean; override; +begin + CombatHandler.AutoRetaliateChecked := True; + Result := inherited; + if Result then + CombatHandler.AutoRetaliateEnabled := value; +end; //TODO: NEED TO REVIEW EVERYTHING BELOW. This is probably all useless or not used. function TRSPrayer.HasProperPrayers(): Boolean;