Skip to content

Commit 41e8c6f

Browse files
committed
fix(Bank): SetQuantity and better uptext check
- json objects and npcs now calculate height properly like the game
1 parent 4919794 commit 41e8c6f

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

osrs/interfaces/mainscreen/bank.simba

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ end;
552552
(*
553553
## Bank.SetQuantity
554554
```pascal
555-
function TRSBank.SetQuantity(quantity: ERSItemQuantity): Boolean;
555+
function TRSBank.SetQuantity(quantity: ERSItemQuantity; amount: Integer = 0): Boolean;
556556
```
557557
Attempts to set the bank quantity to `quantity`, returns true if we succeed.
558558

@@ -561,11 +561,19 @@ Example:
561561
WriteLn Bank.SetQuantity(ERSItemQuantity.FIVE);
562562
```
563563
*)
564-
function TRSBank.SetQuantity(quantity: ERSItemQuantity): Boolean;
564+
function TRSBank.SetQuantity(quantity: ERSItemQuantity; amount: Integer = 0): Boolean;
565565
begin
566566
if Self.QuantityButtons[quantity].Enabled() then Exit(True);
567567
Result := Self.QuantityButtons[quantity].Enable();
568-
if Result then Sleep(600, 800);
568+
569+
if Result or (quantity <> ERSItemQuantity.CUSTOM) then
570+
Exit;
571+
572+
if Chat.AnswerQuery('Enter amount', ToString(amount), RandomLeft(1400, 2400)) then
573+
begin
574+
Self._Cache.Quantity := amount;
575+
Result := Self.QuantityButtons[quantity].Enabled();
576+
end;
569577
end;
570578

571579

@@ -943,6 +951,7 @@ function TRSBank._InteractionHelper(mode: ERSBankInteraction; slot: TBox; amount
943951
var
944952
quantity: ERSItemQuantity;
945953
amountStr, modeStr, upText: String;
954+
timeout: TCountDown;
946955
begin
947956
amountStr := ToString(amount);
948957
quantity := ERSItemQuantity.Integer2Quantity(amount);
@@ -954,7 +963,7 @@ begin
954963

955964
if useQuantityButton then
956965
begin
957-
if not Self.SetQuantity(quantity) then
966+
if not Self.SetQuantity(quantity, amount) then
958967
Exit;
959968

960969
Mouse.Move(slot);
@@ -970,9 +979,21 @@ begin
970979
Exit(True);
971980
end;
972981

973-
upText := MainScreen.UpText;
974-
if not upText.Contains(modeStr) then
975-
Exit;
982+
timeout.Start(Round(RandomMode(100, 85, 250)));
983+
984+
repeat
985+
if MainScreen._IsUpText(upText, [modeStr], True, 0.85) then
986+
begin
987+
Sleep(50);
988+
if MainScreen._IsUpText(upText, [modeStr], True, 0.85) then
989+
Break;
990+
end;
991+
992+
if timeout.IsFinished then
993+
Exit;
994+
Sleep(25);
995+
until False;
996+
976997

977998
upText := upText.Between(modeStr, ' ');
978999

osrs/interfaces/mainscreen/mainscreen.simba

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ end;
125125
(*
126126
### MainScreen._IsUpText
127127
```pascal
128-
function TRSMainScreen._IsUpText(strings: TStringArray; caseSensitive: Boolean; similarity: Single): Boolean;
128+
function TRSMainScreen._IsUpText(out upText: String; strings: TStringArray; caseSensitive: Boolean; similarity: Single): Boolean;
129129
```
130130
Internal helper method used in {ref}`MainScreen.IsUpText`.
131131

132132
`strings` casing must be lower case if `caseSensitive` is `False`.
133133

134134
You probably won't ever need to call this method directly.
135135
*)
136-
function TRSMainScreen._IsUpText(strings: TStringArray; caseSensitive: Boolean; similarity: Single): Boolean;
136+
function TRSMainScreen._IsUpText(out upText: String; strings: TStringArray; caseSensitive: Boolean; similarity: Single): Boolean;
137137
var
138-
upText, str: String;
138+
str: String;
139139
i: Integer;
140140
match: Double;
141141
begin
@@ -173,7 +173,6 @@ begin
173173
end;
174174
end;
175175

176-
177176
(*
178177
### MainScreen.IsUpText
179178
```pascal
@@ -199,7 +198,7 @@ function TRSMainScreen.IsUpText(strings: TStringArray; caseSensitive: Boolean =
199198
var
200199
timeout: TCountDown;
201200
strs: TStringArray;
202-
str: String;
201+
txt, str: String;
203202
begin
204203
if time = -1 then
205204
time := Round(RandomMode(100, 85, 250));
@@ -215,10 +214,10 @@ begin
215214
end;
216215

217216
repeat
218-
if Self._IsUpText(strings, caseSensitive, similarity) then
217+
if Self._IsUpText(txt, strings, caseSensitive, similarity) then
219218
begin
220219
Sleep(50);
221-
if Self._IsUpText(strings, caseSensitive, similarity) then
220+
if Self._IsUpText(txt, strings, caseSensitive, similarity) then
222221
Exit(True);
223222
end;
224223

osrs/position/map/entities.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ begin
120120
begin
121121
Result.Size.X := Item[0].AsInt * 0.8;
122122
Result.Size.Y := Item[1].AsInt * 0.8;
123-
Result.Size.Z := Item[2].AsInt / 40;
123+
Result.Size.Z := Item[2].AsInt / 128;
124124
end;
125125

126126
if Abs(Result.Size.Z) < 0.05 then

osrs/position/map/objects.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ begin
100100
begin
101101
Result.Size.X := Item[0].AsInt * 0.8;
102102
Result.Size.Y := Item[1].AsInt * 0.8;
103-
Result.Size.Z := Item[2].AsInt / 40;
103+
Result.Size.Z := Item[2].AsInt / 128;
104104
end;
105105

106106
if Abs(Result.Size.Z) < 0.05 then

0 commit comments

Comments
 (0)