SRL Archive - SRL Bugs

ChooseOption bugs (official)


Narcle

2012-02-01 18:46:41

Now that ChooseOption is done similar as UpText there will be bugs. This thread is more for reports that it's completely broken as there are some cases that I haven't been able to fix without breaking something else.

Known Bugs
  • Misreading of 'kt' or 'rt' and some others it returns 'M' instead. This is because the letters are actually connected in some cases. [Possible future fix, add 'rt' etc together which if found would return 2 letters - major rework for font system?]

Brandon

2012-02-01 18:53:48

I was thinking, what if you join two fonts such as "r" and "t" and when found on screen, it'll recognize it as rt.. that's one way to get around the mistakes no?

Narcle

2012-02-01 19:00:14

From: ggzz
I was thinking, what if you join two fonts such as "r" and "t" and when found on screen, it'll recognize it as rt.. that's one way to get around the mistakes no?


I thought about something similar. Actually adding a 'rt' character to fonts and then it returns 2 letters instead of one if its found. However idk if the text system can use/do that without major changes.

Wizzup?

2012-02-03 04:58:59

I think we'll need a SplitTPA with a ``leash'' - it can't differentiate itself more than n coordinates from some starty. (Something similar to x for a general case) That would prevent the SplitTPA from ``jumping'' to the next text. (You could even update this leash dynamically by using the mean of all points currently in the part of the atpa)

Sounds like fun. :D

Narcle

2012-02-03 07:01:59

This below fixes the problem just its only if they don't change the Height (for now its the same everytime).

Function GetChooseOptions(TextType: string): Array of TOptions;
var
B, BB, sB, BigBox: TBox;
TPA, TPA1, TPA2, TPA3: TPointArray;
ATPA, tempatpa: T2DPointArray;
I, L, target, bmp,w,h, cts: Integer;
BoxColors: TIntegerArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
// Black, Top Blue, grey
BoxColors := [131843, 3682593, 3552822];
SetLength(ATPA, Length(BoxColors));
for i := 0 to High(BoxColors) do
FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(ATPA);
If Length(TPA) < 100 Then
begin
ColorToleranceSpeed(cts);
Exit;
end;

ATPA := SplitTPA(TPA, 4);
For i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then
Break
else
B := IntToBox(0, 0, 0, 0);
end;

If (B.x2 = 0) then
begin
ColorToleranceSpeed(cts);
Exit;
end;

BigBox := B;

SetColorToleranceSpeed(3);
FindColorsTolerance(TPA2, 2827284, B.X1, B.Y1, B.X2, B.Y2, 16);//Background
FindColorsTolerance(TPA1, 6968358, B.X1, B.Y1, B.X2, B.Y2, 10);//Blue Highlight
TPA2 := CombineTPA(TPA2, TPA1);
sB := GetTPABounds(TPA2);
ReturnPointsNotInTPAWrap(TPA2, B, TPA);
FindColorsTolerance(TPA3, 460291, B.X1, B.Y1, B.X2, B.Y2, 6);//shadow
SetColorToleranceSpeed(cts);

bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
OffsetTPA(TPA, Point(-B.X1, -B.Y1));
OffsetTPA(TPA3, Point(-B.X1, -B.Y1));
FastDrawClear(bmp, 0);
DrawTPABitmap(bmp, TPA, clRed);//Text
DrawTPABitmap(bmp, TPA3, clPurple);//Shadow
ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
GetbitmapSize(bmp,w,h);
SetTargetBitmap(bmp); // new target for findcolorstolerance.
//findcolorstolerance(TPA, clRed, 0, 0, w-1,h-1, 0);
//ATPA := SplitTPAEx(TPA, 15, 2);
SetLength(ATPA, H/16);
for i := 0 to High(ATPA) do
FindColorsTolerance(ATPA[i], clRed, 0, 2+i*16, W-1, 18+i*16, 0);//+2 to y to line it up

L := High(ATPA);
SortATPAFromFirstPointY(ATPA, Point(w/2,0));

SetArrayLength(Result, Length(ATPA));
Result[0].BigBox := BigBox;
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 1, 10); // Split one into characters
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx'); //Writeln(Result[i].Str);
BB := GetTPABounds(ATPA[i]);
Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
setlength(tempatpa,0);
setlength(TPA,0);
end;
ColorToleranceSpeed(cts);
SetImageTarget(target);
FreeBitmap(bmp);
end;

I'd push it now but don't have GIT setup correctly on my laptop.

Harry

2012-02-07 15:07:27

How about the frequent crashes? Anyone have any ideas on this? It's pretty annoying; if you have a script that calls chooseoption a lot it will crash script relatively quickly.

Narcle

2012-02-07 17:19:45

I asked Wizzup about it too. I don't get why it says, "DrawATPA" and then only now and then it'll be on the DrawTPA line (in the function). I have yet to reproduce the error, so I haven't figured out whats causing it.

Any particular script this happens a lot in?

Kyle Undefined

2012-02-07 17:21:04

Any type of script that power drops items. (Power miner/chopper). Yet, I can't get it to reproduce a lot.


From: Kyle Undefined
It's very random, after doing 10 different DropAll's, I was only able to get it to error out twice and in two completely different places.

First place was in FindNPCChatText which is line 738 of text.simba.

Second place was in SortATPAFromFirstPointY at line 771, which is this:
DistArr[i] := Round(Sqr(From.y - a[i][0].y)); 
That function is called in GetChooseOptions at line 893 which is:
SortATPAFromFirstPointY(ATPA, Point(w/2,0)); 
I added WriteLn's through out the file to find out what was going on, and it stopped giving me those weird errors, which I don't know why :/

That's all I have for it at the moment, hope it helps.

Coh3n

2012-02-07 20:44:36

From what I've read, the FindNPCChatText out of range is very common. Happening with quite a few people when dropping, like you said. I got the SortATPAFromFirstPointY last night as well, but it was during MSI's walking.

Narcle

2012-02-07 20:52:31

When dropping huh? Maybe when text is highlighted? Its a pain to debug when its so random. I'll mess around with it tonight before I go to sleep.

Coh3n

2012-02-07 21:09:09

From: Narcle
When dropping huh? Maybe when text is highlighted? Its a pain to debug when its so random. I'll mess around with it tonight before I go to sleep.
I actually just noticed that sometimes if the option is already highlighted, ChooseOption will return false (not choose the option). That would explain why people are getting this error on the last items (when the 'drop' option is already highlighted).

Don't know why it would throw an out of range though.

Narcle

2012-02-07 21:12:07

Yeah it might not be grabbing the text then if the Highlighted color changed. I just don't have the time to get all the highlighted colors to make sure the correct tolerance is set. (cts 3 works really nice for it too)

Coh3n

2012-02-07 21:33:10

Should fix the out of range, should it not?

procedure SortATPAFromFirstPointY(var a: T2DPointArray; const From: TPoint);
var
i, l: Integer;
DistArr: TIntegerArray;
begin
l := high(a);
if (l < 0) then
exit;

setLength(DistArr, l + 1);
for i := 0 to l do
begin
if (length(a[i]) <= 0) then // prevent out of range errors
continue;

DistArr[i] := Round(Sqr(From.y - a[i][0].y));
end;

QuickATPASort(DistArr, a, 0, l, True);
end;
If the length of a was 0, it calls a[0], which would be an out of range. Same thing will have to be changed in SortATPAFromFirstPointX.

E: Also, that function is right below FindNPCChatText. My guess is that Simba's just giving the wrong line number sometimes.

Narcle

2012-02-07 21:46:21

From: Coh3n
Should fix the out of range, should it not?

procedure SortATPAFromFirstPointY(var a: T2DPointArray; const From: TPoint);
var
i, l: Integer;
DistArr: TIntegerArray;
begin
l := high(a);
if (l < 0) then
exit;

setLength(DistArr, l + 1);
for i := 0 to l do
begin
if (length(a[i]) <= 0) then // prevent out of range errors
continue;

DistArr[i] := Round(Sqr(From.y - a[i][0].y));
end;

QuickATPASort(DistArr, a, 0, l, True);
end;
If the length of a was 0, it calls a[0], which would be an out of range. Same thing will have to be changed in SortATPAFromFirstPointX.

E: Also, that function is right below FindNPCChatText. My guess is that Simba's just giving the wrong line number sometimes.


That makes sense then. If the hightlighted chooseoption isn't found (I search in boxes) then that ATPA[x] (of highlighted area) would be empty making it out of range in that function.

Both need to be added. I'm guessing in rare cases the FindColors just happens to not see highlighted color - a tolerance increase and a better average color should fix it.

Kyle Undefined

2012-02-07 21:47:55

I can run some tests if you'd like.

Narcle

2012-02-07 21:52:12

From: Kyle Undefined
I can run some tests if you'd like.


The biggest help would be picking all the different highlighted colors so we can get a average. Then you'd basically have it fixed. I still want to play with CTS3 more. I've just be playing with it painting on smart to see how high the tolerance needs to be for various functions (switching to it).

(if this is indeed the problem and i'm leaning towards it)

Coh3n

2012-02-08 00:58:59

I'll do some tweaking and commit a fix shortly.

E: I've fixed the out of ranges, but didn't have time to tweak the colors. But at least the runtime errors should be gone.

Narcle

2012-02-08 03:56:41

Nah error is still there after that fix. I figured it out. Its getting double points passed to ReturnPointsNotInTPAWrap which errors out either in that function or in DrawTPABitmap.

I tried using ClearDoubleTPA - it fixes it but makes it delay by ~1400 ms. Trying to lower tolerances to see if it'll stop overlapping TPoints found.

I'll have to get back to this when I have more free time.

Edit:
Pushed a fix, was working well for me. (only searches for one color now - yay cts3)

Kyle Undefined

2012-02-08 09:57:35

Awesome work Narcle! How does it handle the Choose Option box? I noticed the UpText and ChooseOption text, whatever color the UpText is, the ChooseOption text color is the same and the hover is the same aswell, but only lighter.

Narcle

2012-02-08 13:13:29

From: Kyle Undefined
Awesome work Narcle! How does it handle the Choose Option box? I noticed the UpText and ChooseOption text, whatever color the UpText is, the ChooseOption text color is the same and the hover is the same aswell, but only lighter.


I grabbed the various colors of the dark background of the ChooseOption got the best color for that then did the same when its Highlighted. Got the best color of the 2 together and CTS3 with 18 tolerance it'll get all the pixels around the text (including if its highlighted). Find the gaps and that's the letters. I also get the shadows of text to check it as well. Right now it works so well that you probably don't even need shadows but its better with it in for now, gives it a fail safe of sorts.

Coh3n

2012-02-08 14:58:01

Awesome! :)

Does this mean the OP is fixed as well?

Narcle

2012-02-08 15:06:27

From: Coh3n
Awesome! :)

Does this mean the OP is fixed as well?


For now yes. I'll edit it out. Hopefully I can let this thread die >.>

Brandon

2012-02-17 19:50:54

So I've noticed a bug with choose option..

There has to be an infinite loop somewhere in there because sometimes it will right click and instead of choosing the option, it just sits there with the menu open. Happens about once every 48 hrs for me assuming I run my script that long. So it is rare but it keeps happening more than often enough for me to feel the need to report it.

How to fix: Well it sits there, I disable smart and moved the mouse away from the menu, the script recognizes the menu isn't there and right clicks and chooses the option correctly. Seems moving the mouse away from the menu fixes it. So..?

Oh and another thing, the withdraw function definitely needs an update as it lags like hell!! I do not lag.. only that function lags me AND it doesn't always withdraw even if the DTM is found. I've tested it 100 times in a row to see if the dtm was found, it was found 100% of the time, but the item was only withdrawn 70% of the time. The more I run it, the more the function lags.

Narcle

2012-02-18 07:13:48

For ChooseOption
Screenshot when it gets like that?

Which Withdraw function? You mention DTM finding too. Because the current Withdraw function shouldn't have anything in it to "lag." Only thing to make it lag is if you use UpText (which'll wait 500ms) or ChooseOption bug.

Coh3n

2012-02-19 20:40:39

SRL's WithdrawEx and Withdraw don't use DTMs at all. If you're searching for a DTM in in a loop, make sure you have a wait(100+random(100)) each time. That's probably what's causing your lag.

Brandon

2012-02-19 20:48:38

function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;

Can be used like:

WithdrawItem(DTMHere, 'dtm', 10, 'potion', [10]); and that lags bad.

Its rare to get the chooseoption thing so I can't catch it all the time for a screenshot but I'll try.

Coh3n

2012-02-20 20:10:07

From: ggzz
function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;

Can be used like:

WithdrawItem(DTMHere, 'dtm', 10, 'potion', [10]); and that lags bad.

Its rare to get the chooseoption thing so I can't catch it all the time for a screenshot but I'll try.
Oh wow, didn't know there was a function like that, but I only looked in bank.simba. You'd think that's where all the banking functions would be. :p

So, you're saying using that function it doesn't always find the DTM, but when you use your function, it always works? Can you post the code you're using to test?

Brandon

2012-02-24 16:45:28

From: Coh3n
Oh wow, didn't know there was a function like that, but I only looked in bank.simba. You'd think that's where all the banking functions would be. :p

So, you're saying using that function it doesn't always find the DTM, but when you use your function, it always works? Can you post the code you're using to test?



Picture of the bug.. See.. It refuses to climb even when the options are there..

I'm using ChooseOptionMulti(['adder', 'up Lad', 'limb-up', 'dder', 'limb', 'mb-up']);

I actually caught it this time.. The thing is, ChooseOption is working 99% of the time.. the other 1% of the time, it gets in an infinite loop where it right clicks, sees the options, n then does nothing.. gets stuck in an infini loops until the menu goes away.. Now for that particular screenie, when it doesn't find the option, it moves the mouse away so that the menu disappears.. then tries again.. and fails for an infinite amount of times until I help it.

This bug is extremely rare and that's why it took me soo long to catch it doing that in a screenie.

For the inventory one with the banking and the lag, if I use:

FindDTM(DTMInteger, X, Y, ………….) it'll find the dtm's 100% of the time.. but when I use it in combination with withdrawex, a massive lag happens which might be causing it to fail:


Pouch := DTMFromString('m1gAAAHic42JgYDjIxMBwjAlC70PCIP4RKD4JxJyMDAxcQMwLxSA+GxIGiXEAcWFJPENxeSKDv78tGOcXxzIUlMQxFJUlMGSkhYDFyqqSGbiAdhODGYnECAAAECwT5g==');


NOBC:= ItemAmount('inv', 'dtm', Pouch, []);
while ((NOBC < NOB) or (Tries < 5)) do
begin
if (NOBC < NOB) then
if FindDTM(Pouch, X, Y, MBX1, MBY1, MBX2, MBY2) then
begin
MMouse(X, Y, 0, 0);
if (WaitUptextMulti(['yip pouch', 'unyip', 'Bunyip pouch', 'yip po'], 1200)) then
begin
BP:= MSTPointToBankPoint(Point(X, Y));
WithdrawEx(BP.X, BP.Y, NOB, ['yip pouch', 'unyip', 'Bunyip pouch', 'yip po']);
end;
end;
Inc(Tries);
T:= 0;
MarkTime(T);
while (TimeFromMark(T) < 2000) and (ItemAmount('inv', 'dtm', Pouch, []) < NOB) do
wait(1);

NOBC:= ItemAmount('inv', 'dtm', Pouch, []);
if (NOBC >= NOB) then
break;
end;

Tries:= 0;

It finds it like 80% of the time and lags extremely hard!! Lags so bad that sometimes I have to restart Simba or my computer.. I get this white outline of smart to the upper left of my screen when it does that.

So instead I just use my own custom functions for withdrawing.

EDIT: I finally caught it with the summoning potion..

That right there is one infinite loop in chooseoptionmulti.. it will not move until i get rid of the menu.. then when the menu is gone, it will right click and drink.. Which it did. It drank after I made menu go away (it right clicked and drank perfectly fine because the option was found :S)

Mat

2012-02-25 08:38:34

Getting the same problem.

Mat

2012-02-25 09:29:00

Here This is Mine Working:
This is my friends not working:
His Looks Darker and bolder.
I'm picking up on All.
Mat

Tickyy

2012-02-25 09:33:32

Why make 2 threads?

Edit: Use Multi?

Mat

2012-02-25 09:36:11

I deleted the other one I put it here as It more appropriate here, I tried that :/.

RISK

2012-02-25 09:41:44

Have you tried using WaitOption?

Mat

2012-02-25 09:51:47

I had it is a repeat

Repeat
Wait(50+random(10));
Until(ChooseOption('All');
Just ends up logging out.

RISK

2012-02-25 09:52:30

That's weird. Can you try WaitOption('All', RandomRange(850, 1250)); please?

Mat

2012-02-25 09:59:24

Nope :/

Nemesis3X

2012-02-25 10:20:24

Is your friend playing in low graphics? Maybe, if you want to know if it is really ChooseOption that isn't working. Ask your friend to Change his X value for something like 4500 and Change your Chooseoption for the number 4500.

2: ChooseOption('4500'); 

If it doesn't work after that, I can't think about a solution.

Narcle

2012-02-25 12:19:26

So its moving the mouse away but the menu doesn't disappear? Or does it disappear but clicks again?

Brandon

2012-02-25 12:33:45

What happens is that for the first screenshot, it will move the mouse away and the menu disappears but when it tries again, it will never choose the option to climb.. It'll do this an infinite amount of times.

For the second screenshot, it never moves the mouse away so the menu never disappears.. when I have to disable and re-enable smart.. When that is done, it tries again and chooses the right option. If I don't disable/re-enable smart, it'll stay there for an infinite amount of time with the menu open.

Coh3n

2012-02-26 16:03:17

@ggzz: For that banking function you posted, try increasing the wait(1) to something like wait(100).

John

2012-03-02 02:47:43

Same problem for me.

Sin

2012-03-02 10:09:25

I don't understand, it's working for me o.o
I just had a 6 hour proggy with my Astral Crafter.

Brandon

2012-03-02 10:43:46

From: Sin
I don't understand, it's working for me o.o
I just had a 6 hour proggy with my Astral Crafter.


Completely broken in Zanaris. Same with Uptext.

Kyle Undefined

2012-03-04 01:27:17

I'm having an issue when trying to teleport with gloves, it worked once and now it's just failing every time when I use text other than 'ort' as the option. Here's an image of the options:

All of these fail

ChooseOption('Teleport');
ChooseOption('eleport');
ChooseOption('leport');
ChooseOption('eport');
ChooseOption('port');

This works
ChooseOption('ort');


Nemesis3X

2012-03-04 01:42:13

From: Kyle Undefined
I'm having an issue when trying to teleport with gloves, it worked once and now it's just failing every time when I use text other than 'ort' as the option. Here's an image of the options:

All of these fail

ChooseOption('Teleport');
ChooseOption('eleport');
ChooseOption('leport');
ChooseOption('eport');
ChooseOption('port');

This works
ChooseOption('ort');




I did had problem with Teleport option too. Mine is

Chooseoption('rt');
that's the only string that work for teleport