Skip to content

Commit

Permalink
fix: CombatHandler and TBaseScript
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Torwent committed Dec 4, 2023
1 parent 1fccb31 commit 90422d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 4 additions & 5 deletions osr/basescript.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
21 changes: 18 additions & 3 deletions osr/handlers/combathandler.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -221,7 +221,7 @@ begin
if Self.IsSetup then
Exit;

Self.Name := 'RSCombatHandler';
Self.Name := 'CombatHandler';

if Self.AttackMonsterDelay = 0 then
Self.AttackMonsterDelay := 5000;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 90422d3

Please sign in to comment.