Skip to content

Commit 4723a94

Browse files
committed
fix: read notes
- inventory actions now open the inventory first - worldswitcher doesn't run it's cooldown on startup now
1 parent 395def3 commit 4723a94

File tree

4 files changed

+38
-51
lines changed

4 files changed

+38
-51
lines changed

osrs/interfaces/gametabs/inventory.simba

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ WriteLn Inventory.IsSelected('Vial');
125125
*)
126126
function TRSInventory.IsSelected(slot: TBox): Boolean;
127127
begin
128+
if not Self.Open() then Exit;
128129
slot.Y1 += 8;
129130
Result := Target.HasColor(TRSItem.BorderWhite, 1, 1, slot);
130131
end;
@@ -150,6 +151,7 @@ function TRSInventory.GetSelected(): Integer;
150151
var
151152
slots: TBoxArray;
152153
begin
154+
if not Self.Open() then Exit(-1);
153155
slots := Self.Slots.Boxes();
154156
for Result := 0 to High(slots) do
155157
if Self.IsSelected(slots[Result]) then
@@ -188,6 +190,7 @@ var
188190
boxes: TBoxArray;
189191
b, tmp: TBox;
190192
begin
193+
if not Self.Open() then Exit;
191194
boxes := Self.Slots.Boxes();
192195
if slot > -1 then
193196
begin
@@ -214,6 +217,7 @@ var
214217
selected: Integer;
215218
slots: TIntegerArray;
216219
begin
220+
if not Self.Open() then Exit;
217221
selected := Self.GetSelected();
218222
slots := Self.Items.IndicesOf([item]);
219223

@@ -240,6 +244,7 @@ WriteLn Inventory.Combine('Coins', 'Asgarnian ale');
240244
*)
241245
function TRSInventory.Combine(slotA, slotB: Integer): Boolean;
242246
begin
247+
if not Self.Open() then Exit;
243248
Result := Self.Select(slotA);
244249
if Result then
245250
begin
@@ -256,6 +261,7 @@ var
256261
centers: TPointArray;
257262
i, j: Integer;
258263
begin
264+
if not Self.Open() then Exit;
259265
slotsA := Self.Items.IndicesOf([itemA]);
260266
if slotsA = [] then Exit;
261267

@@ -360,6 +366,7 @@ var
360366
b: TBox;
361367
i: Integer;
362368
begin
369+
if not Self.Open() then Exit;
363370
if Length(slots) = 0 then Exit(True);
364371

365372
boxes := Self.Slots.Boxes();
@@ -389,6 +396,7 @@ function TRSInventory.Drop(items: TRSItemArray; pattern: TIntegerArray = []): Bo
389396
var
390397
slots: TIntegerArray;
391398
begin
399+
if not Self.Open() then Exit;
392400
if pattern = [] then pattern := Self.RandomPattern();
393401
slots := Self.Items.IndicesOf(items);
394402
Result := (slots <> []) and Self.Drop(pattern.Intersection(slots));
@@ -417,6 +425,7 @@ var
417425
i: Integer;
418426
begin
419427
if Length(slots) = 0 then Exit(True);
428+
if not Self.Open() then Exit;
420429

421430
if not Self.ShiftEnabled then Exit(Self.Drop(slots));
422431

@@ -466,6 +475,7 @@ function TRSInventory.ShiftDrop(items: TRSItemArray; pattern: TIntegerArray): Bo
466475
var
467476
slots: TIntegerArray;
468477
begin
478+
if not Self.Open() then Exit;
469479
slots := Self.Items.IndicesOf(items);
470480
Result := (slots <> []) and Self.ShiftDrop(pattern.Intersection(slots));
471481
end;

osrs/interfaces/gametabs/worldswitcher.simba

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ Main record that interacts with the {ref}`WorldSwitcher`.
6363
const YELLOW: TColor = $00F0F0;
6464
end;
6565

66+
(*
67+
## TRSWorldSwitcher.Setup
68+
```pascal
69+
procedure TRSWorldSwitcher.Setup();
70+
```
71+
Interal method used to setup the {ref}`TRSWorldSwitcher` cooldown.
72+
73+
This is automatically called for you on the {ref}`WorldSwitcher variable`.
74+
*)
75+
procedure TRSWorldSwitcher.Setup();
76+
var
77+
t: Int64;
78+
begin
79+
t := Time();
80+
Self.Cooldown.FLength := 8000;
81+
Self.Cooldown.FStartTime := t-8000;
82+
Self.Cooldown.FFinishTime := t;
83+
Self.Cooldown.FPauseTime := 0;
84+
end;
85+
6686
(*
6787
## TRSWorldSwitcher.SetupGameTab
6888
```pascal
@@ -428,16 +448,11 @@ property TRSWorldSwitcher.World(next: Integer): Boolean;
428448
var
429449
current: Integer;
430450
begin
431-
if not Self.Cooldown.IsFinished then
432-
Exit;
433-
434-
if not Self.Open() then
451+
if not Self.Cooldown.IsFinished or not Self.Open() then
435452
Exit;
436-
437453
current := Self.World;
438454
if next = current then
439455
Exit(True);
440-
441456
Result := Self._Hop(next);
442457
end;
443458

@@ -455,11 +470,11 @@ begin
455470
if worlds = [current] then
456471
Exit(True);
457472

458-
next := worlds.IndexOf(current) + 1;
459-
if next > High(worlds) then
473+
next := worlds.IndexOf(current);
474+
if Inc(next) > High(worlds) then
460475
next := 0;
461476

462-
Result := Self._Hop(next);
477+
Result := Self._Hop(worlds[next]);
463478
end;
464479

465480
(*
@@ -473,9 +488,10 @@ the specified `world`
473488
*)
474489
function TRSWorldSwitcher.WaitSwitch(world: Integer; failCooldown: Boolean = True): Boolean;
475490
begin
476-
if not SleepUntil(MainScreen.IsServerMessage('Please wait'), 50, 600) then
491+
if not SleepUntil(MainScreen.IsServerMessage('Please wait'), 200, 3*TICK) then
477492
begin
478-
if failCooldown then Self.Cooldown.Restart(0, 7000);
493+
if failCooldown then
494+
Self.Cooldown.Restart(0, 7000);
479495
Exit;
480496
end;
481497

osrs/interfaces/setup.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ begin
157157
MM2MS.Projector.RSZoom := -1;
158158
RSMouseZoom.ZoomLevel := -1;
159159
RSMouseZoom.Enabled := True;
160-
WorldSwitcher.Cooldown.Start(8000);
160+
WorldSwitcher.Setup();
161161
FairyRing.Setup();
162162

163163
Antiban.Zoom.Max := 100;

utils/webgraph.simba

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -224,45 +224,6 @@ begin
224224
end;
225225
end;
226226

227-
function TWebGraph.NearestWalkablePoint(p: TPoint): TPoint;
228-
var
229-
pArea, obj, tpa, bestObj: TPointArray;
230-
pAreaClusters: T2DPointArray;
231-
i, bestLength, tempLength: Integer;
232-
begin
233-
pArea := TPointArray.CreateFromCircle(p, 20, True).Intersection(Self.WalkableSpace);
234-
pAreaClusters := pArea.Cluster(1);
235-
236-
if Self.ObjectClusters = [] then Exit(pArea.NearestPoint(p));
237-
238-
obj := [];
239-
for i := 0 to High(Self.ObjectClusters) do
240-
begin
241-
if not Self.ObjectClusters[i].Bounds().Contains(p) then Continue;
242-
if Self.ObjectClusters[i].Contains(p) then
243-
begin
244-
obj := Self.ObjectClusters[i];
245-
{$IFDEF DEBUG_WALKER}
246-
WriteLn('Point was inside object! with edges: ', obj);
247-
{$ENDIF}
248-
Break;
249-
end;
250-
end;
251-
252-
if obj = [] then Exit(pArea.NearestPoint(p));
253-
254-
for i := 0 to High(pAreaClusters) do
255-
begin
256-
tpa := pAreaClusters[i].Intersection(obj);
257-
tempLength := Length(tpa);
258-
if tempLength > bestLength then
259-
begin
260-
bestLength := tempLength;
261-
bestObj := tpa;
262-
end;
263-
end;
264-
Result := bestObj.NearestPoint(p);
265-
end;
266227

267228
function TWebGraph.PathBetween(a, b: TPoint; rnd: Double = 0; attempts: Integer = 3): TGraphNodeArray;
268229
var

0 commit comments

Comments
 (0)