Skip to content

Commit

Permalink
fix: removed the "compability layer"
Browse files Browse the repository at this point in the history
This was okay when Simba1500 was gonna be a thing, but as soon as it was not, this became a terrible thing that caused a lot of redundancy and had a bunch of methods that were called differently but did the same.
I removed everything that was not in use from it (compiled almost every script to test)
and moved most things that remain to SRL-T, and very few things to other places in WaspLib.

BREAKING CHANGE: This will require the latest SRL-T and some of my scripts will need to be updated.
  • Loading branch information
Torwent committed Feb 7, 2024
1 parent 22ae7d8 commit 53c3d16
Show file tree
Hide file tree
Showing 27 changed files with 119 additions and 331 deletions.
4 changes: 2 additions & 2 deletions optional/handlers/alchhandler.simba
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ var
i, attempt: Int32;
begin
if Inventory.Count() < 28 then
i := RandomLeft(0, 5)
i := SRL.TruncatedGauss(0, 5)
else
i := RandomLeft(3, 5);
i := SRL.TruncatedGauss(3, 5);

repeat
if Inc(attempt) > 10 then
Expand Down
2 changes: 1 addition & 1 deletion optional/interfaces/mainscreen/craftscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type
procedure ERSCraftItem.SetCraftItem(item: TRSItem);
begin
for Self := ERSCraftItem(0) to ERSCraftItem(High(ERSCraftItem)) do
if SameText(ToString(Self).Replace('_', ' '), ToString(item).Replace('(u)', '').Trim()) then
if SameText(ToString(Self).Replace('_', ' '), ToString(item).Replace('(u)', '').Strip()) then
Exit;
TerminateScript('That item is not available in the crafting interface!');
end;
Expand Down
8 changes: 4 additions & 4 deletions optional/interfaces/mainscreen/fairyring.simba
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

(*
Expand Down Expand Up @@ -299,7 +299,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

(*
Expand Down Expand Up @@ -920,7 +920,7 @@ begin
if contextMenuTeleport then
Exit(True);

if WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000) then
if WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000) then
Result := Self.HandleInterface(code);
end;

Expand Down Expand Up @@ -971,7 +971,7 @@ begin
if contextMenuTeleport then
Exit(True);

if WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000) then
if WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000) then
Result := Self.HandleInterface(code);
end;

Expand Down
26 changes: 13 additions & 13 deletions osr/antiban/antiban.simba
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ begin

str := ' Action : Antiban';
ProgressReport.ProgressArray[0] := str;
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Trim();
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Strip();
ProgressReport.ProgressArray[1] := str;

{$IFNDEF SRL_DISABLE_REMOTEINPUT}
Expand All @@ -29,9 +29,9 @@ begin
if Length(ProgressReport.ProgressArray) < 1 then
Exit;

str := ' Breaking : ' + SRL.MsToTime(countdown.TimeRemaining(), Time_Short).Trim();
str := ' Breaking : ' + SRL.MsToTime(countdown.TimeRemaining(), Time_Short).Strip();
ProgressReport.ProgressArray[0] := str;
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Trim();
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Strip();
ProgressReport.ProgressArray[1] := str;

{$IFNDEF SRL_DISABLE_REMOTEINPUT}
Expand All @@ -47,9 +47,9 @@ begin
if Length(ProgressReport.ProgressArray) < 1 then
Exit;

str := ' Sleeping : ' + SRL.MsToTime(countdown.TimeRemaining(), Time_Short).Trim();
str := ' Sleeping : ' + SRL.MsToTime(countdown.TimeRemaining(), Time_Short).Strip();
ProgressReport.ProgressArray[0] := str;
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Trim();
str := ' Runtime : ' + SRL.MsToTime(ProgressReport.PTimeRunning^.ElapsedTime, Time_Short).Strip();
ProgressReport.ProgressArray[1] := str;

{$IFNDEF SRL_DISABLE_REMOTEINPUT}
Expand Down Expand Up @@ -112,23 +112,23 @@ end;
// Mouse antibans
procedure TAntiban.SmallRandomMouse(); override;
var
B: TBox;
b: TBox;
P: TPoint;
t: TCountDown;
begin
Self.DebugLn('Random Mouse (Small)');

B := Box(Mouse.Position(), 350, 350);
b := Box(Mouse.Position(), 350, 350);
t.Init(30000);
repeat
P := SRL.RandomPoint(B);
P := SRL.RandomPoint(b);
if t.IsFinished() then
begin
WriteLn('Box: ', B);
WriteLn('Box: ', b);
WriteLn('Point: ', P);
Self.Fatal('Timed out!');
end;
until P.DistanceTo(B.Middle) < 50; // Make sure we move at least 50 distance
until P.DistanceTo(b.Center()) < 50; // Make sure we move at least 50 distance

ASyncMouse.Move(P);
end;
Expand Down Expand Up @@ -170,7 +170,7 @@ begin
begin
if Self.BioDice(50) then
begin
GameTabs.Open(ERSGameTab(RandomMean(Ord(ERSGameTab.COMBAT), Ord(ERSGameTab.MAGIC))));
GameTabs.Open(ERSGameTab(SRL.NormalRange(Ord(ERSGameTab.COMBAT), Ord(ERSGameTab.MAGIC))));
System.Wait(300, 3000, wdLeft);
end;

Expand All @@ -179,7 +179,7 @@ begin
begin
if Random() < 0.50 then
begin
GameTabs.Open(ERSGameTab(RandomMean(Ord(ERSGameTab.CLAN), Ord(ERSGameTab.MUSIC))));
GameTabs.Open(ERSGameTab(SRL.NormalRange(Ord(ERSGameTab.CLAN), Ord(ERSGameTab.MUSIC))));
System.Wait(0, 2500, wdLeft);
end;

Expand Down Expand Up @@ -368,7 +368,7 @@ begin
Exit;
end;

Self.OpenSkill(Self.Skills[Random(Length(Self.Skills))], RandomLeft(1000, 10000), SRL.Dice(50));
Self.OpenSkill(Self.Skills[Random(Length(Self.Skills))], SRL.TruncatedGauss(1000, 10000), SRL.Dice(50));
end;

procedure TAntiban.RandomAchievementTab();
Expand Down
2 changes: 1 addition & 1 deletion osr/basescript.simba
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ begin
elapsedTime := Self.TimeRunning.ElapsedTime();

Result += ' Action : ' + Self.Action;
Result += ' Runtime : ' + SRL.MsToTime(elapsedTime, Time_Short).Trim();
Result += ' Runtime : ' + SRL.MsToTime(elapsedTime, Time_Short).Strip();

Result += ' Total Actions : ' + ToStr(Self.TotalActions);
if Self.ActionLimit > 0 then
Expand Down
4 changes: 2 additions & 2 deletions osr/dotfilters.simba
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ begin
for i := 0 to High(Self) do
begin
if Self[i].TPA <> [] then
inPoly := PointInPolygon(P, Self[i].TPA);
inPoly := SRL.PointInPoly(P, Self[i].TPA);

if Self[i].Circle <> [] then
inCircle := p.InCircle(Self[i].Circle);
Expand All @@ -141,7 +141,7 @@ begin
for i := 0 to High(Self) do
begin
if Self[i].TPA <> [] then
inPoly := PointInPolygon(p, Self[i].TPA);
inPoly := SRL.PointInPoly(p, Self[i].TPA);

if Self[i].Circle <> [] then
inCircle := p.InCircle(Self[i].Circle);
Expand Down
4 changes: 2 additions & 2 deletions osr/interfaces/core/interface.simba
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ begin
begin
Result[I].Index := I;
Result[I].Bounds := Boxes[I];
Result[I].Middle := Boxes[I].Middle;
Result[I].Middle := Boxes[I].Center();
Result[I].EnabledColors := Self.ButtonEnabledColors;
end;
end;
Expand Down Expand Up @@ -143,7 +143,7 @@ begin
begin
Result[I].Index := I;
Result[I].Bounds := Boxes[I];
Result[I].Middle := Boxes[I].Middle;
Result[I].Middle := Boxes[I].Center();
Result[I].PParent := @Self;
end;
end;
Expand Down
4 changes: 2 additions & 2 deletions osr/interfaces/gametabs/magic.simba
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ begin

Result.Index := 0;
Result.Bounds := b;
Result.Middle := b.Middle();
Result.Middle := b.Center();
Result.EnabledColors := Self.ButtonEnabledColors;
end;

Expand Down Expand Up @@ -219,7 +219,7 @@ begin
begin
Result[i].Index := i;
Result[i].Bounds := tba[i];
Result[i].Middle := tba[i].Middle;
Result[i].Middle := tba[i].Center();
Result[i].EnabledColors := [CTS1(5284953, 57)];
end;
end;
Expand Down
2 changes: 1 addition & 1 deletion osr/interfaces/gametabs/options.simba
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ begin
b.Y2 -= 21;

Mouse.Click(b, MOUSE_LEFT);
Result := WaitUntil(not Self.IsHouseOptionsOpen(), RandomLeft(50, 1500), 5000);
Result := WaitUntil(not Self.IsHouseOptionsOpen(), SRL.TruncatedGauss(50, 1500), 5000);
end;

function TRSOptions.CallServant(): Boolean;
Expand Down
4 changes: 2 additions & 2 deletions osr/interfaces/mainscreen/collectbox.simba
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

function TRSCollectBox.WalkHover(walkerObject: PRSWalkerObject = nil): Boolean;
Expand Down Expand Up @@ -402,7 +402,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

(*
Expand Down
2 changes: 1 addition & 1 deletion osr/interfaces/mainscreen/mainscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ function TRSMainScreen.IsUpText(text: TStringArray; timeout: Int32; out index: I
upText := Self.GetUpText();

if not caseSensitive then
upText := upText.ToLower();
upText := upText.Lower();

for index := 0 to High(text) do
begin
Expand Down
2 changes: 1 addition & 1 deletion osr/mm2ms.simba
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ begin

tpa := Self.GetZoomRectangle().Totpa();

if PointInPolygon(p, tpa) then
if SRL.PointInPoly(p, tpa) then
Exit(True);

tpa := tpa.SortFrom(p);
Expand Down
12 changes: 6 additions & 6 deletions osr/walker/objects/walkerobjects.simba
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

function TRSBank.WalkHover(rsObject: TRSObject): Boolean;
Expand All @@ -2347,7 +2347,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;


Expand All @@ -2373,7 +2373,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen() or BankPin.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;

function TRSBank.WalkHover(rsNPC: TRSNPC): Boolean; overload;
Expand All @@ -2399,7 +2399,7 @@ begin
Exit;

Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;


Expand Down Expand Up @@ -2468,7 +2468,7 @@ begin
if rsobject.Click() or ChooseOption.Select(['Deposit B', 'Bank D']) then
begin
Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;
end;

Expand All @@ -2492,7 +2492,7 @@ begin
if rsobject.WalkClick() or ChooseOption.Select(['Deposit B', 'Bank D']) then
begin
Minimap.WaitMoving();
Result := WaitUntil(Self.IsOpen(), RandomLeft(50, 1500), 3000);
Result := WaitUntil(Self.IsOpen(), SRL.TruncatedGauss(50, 1500), 3000);
end;
end;

Expand Down
24 changes: 12 additions & 12 deletions osr/walker/walker.simba
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ begin
SetLength(hBitmaps, Length(Self.Regions));
for I := 0 to High(bitmaps) do
begin
Self.RegionOffsets[I] := TPoint.Create(aRegions[I].X1, aRegions[I].Y1);
Self.RegionOffsets[I] := Point(aRegions[I].X1, aRegions[I].Y1);

bitmaps[I] := Self.InternalLoadMap(FileName, aRegions[I]);
if not RSHeightMap.Disabled then
Expand All @@ -177,7 +177,7 @@ begin
hBitmaps[I].Pad(padding);
end;

Self.Regions[I] := TBox.Create(0, 0, bitmaps[I].GetWidth(), bitmaps[I].GetHeight());
Self.Regions[I] := Box(0, 0, bitmaps[I].GetWidth(), bitmaps[I].GetHeight());
end;

Self.Regions := Self.Regions.Pack();
Expand All @@ -196,9 +196,9 @@ begin

for I := 0 to High(Self.Regions) do
begin
Self.Map.DrawBitmap(bitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
Self.Map.DrawBitmap(bitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
if not RSHeightMap.Disabled then
RSHeightMap.Map.DrawBitmap(hBitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
RSHeightMap.Map.DrawBitmap(hBitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
end;

Self.ScaledMap.Init();
Expand Down Expand Up @@ -241,7 +241,7 @@ begin

hi := High(Self.Regions);

Self.RegionOffsets[hi] := TPoint.Create(aRegion.X1, aRegion.Y1);
Self.RegionOffsets[hi] := Point(aRegion.X1, aRegion.Y1);

bitmap := Self.InternalLoadMap(fileName, aRegion);
if not RSHeightMap.Disabled then
Expand All @@ -257,7 +257,7 @@ begin
hBitmap.Pad(padding);
end;

Self.Regions[hi] := TBox.Create(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
Self.Regions[hi] := Box(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
bitmaps += bitmap;
if not RSHeightMap.Disabled then
hBitmaps += hBitmap;
Expand All @@ -270,9 +270,9 @@ begin

for I := 0 to High(Self.Regions) do
begin
Self.Map.DrawBitmap(bitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
Self.Map.DrawBitmap(bitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
if not RSHeightMap.Disabled then
RSHeightMap.Map.DrawBitmap(hBitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
RSHeightMap.Map.DrawBitmap(hBitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
end;

Self.ScaledMap.Clear();
Expand Down Expand Up @@ -327,7 +327,7 @@ begin
if not RSHeightMap.Disabled then
hBitmap.Pad(padding);

Self.Regions[hi] := TBox.Create(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
Self.Regions[hi] := Box(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
bitmaps += bitmap;
if not RSHeightMap.Disabled then
hBitmaps += hBitmap;
Expand All @@ -340,9 +340,9 @@ begin

for I := 0 to High(Self.Regions) do
begin
Self.Map.DrawBitmap(bitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
Self.Map.DrawBitmap(bitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
if not RSHeightMap.Disabled then
RSHeightMap.Map.DrawBitmap(hBitmaps[I], TPoint.Create(Self.Regions[I].X1, Self.Regions[I].Y1));
RSHeightMap.Map.DrawBitmap(hBitmaps[I], Point(Self.Regions[I].X1, Self.Regions[I].Y1));
end;

Self.ScaledMap.Clear();
Expand Down Expand Up @@ -1153,7 +1153,7 @@ This are TRSWalker methods so they will exist both on TRSWalker and TRSWalker.
*)
function TRSWalker.InPoly(locArray: TPointArray): Boolean;
begin
Result := PointInPolygon(Self.GetMyPos(), locArray);
Result := SRL.PointInPoly(Self.GetMyPos(), locArray);
end;


Expand Down
Loading

0 comments on commit 53c3d16

Please sign in to comment.