SRL Archive - Bugs

R_ChooseOptionMulti


Shuttleu

2010-12-02 09:10:44

With the current R_ChooseOptionMulti, it will choose the first option which has one of the "Options"

This will make sure that all the "Options" are in the option that it chooses

{*******************************************************************************
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
By: Drags111, Shuttleu - Based off nava2's and Lordsaturns.
Description: Chooses the first found option of "Options" from the Right
Click menu, returns True and Clicks if found, else it will Move the
mouse to a random Coord or select cancel.
*******************************************************************************}
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
var
ThisOption: Boolean;
i, i2, xOff, yOff, t: Integer;
P : TPoint;
MenuOptions: TStringArray;

begin
Result := False;
if not IsMenuOpen then
begin
MarkTime(t);
while(TimeFromMark(t) < 1000)do ;
if not IsMenuOpen then Exit;
end;

P := Point(SmartGetFieldInt(0, hook_static_MenuX) + 4, SmartGetFieldInt(0, hook_static_MenuY) + 4);
//Writeln('MenuX: '+ToStr(SmartGetFieldInt(0, hook_static_MenuX)));
//Writeln('MenuY: '+ToStr(SmartGetFieldInt(0, hook_static_MenuY)));
MenuOptions := GetMenuText;

for i := 0 to High(MenuOptions) do
begin
Result:= True;
for i2 := 0 to High(Options) do
begin
ThisOption:= (Pos(Lowercase(Options[i2]), Lowercase(MenuOptions[i])) <> 0);
Result:= (ThisOption and Result);
end;
if Result begin
xOff := RandomRange(4, 4 + Random(Length(MenuOptions[i]) * 4 - 4));
yOff := 21 + (16 * i) + RandomRange(2, 10);
Mouse(P.x + xOff, P.y + yOff, 0, 0, True);
Wait(RandomRange(80, 100));
Result := not IsMenuOpen;
Exit;
end;
end;

case Random(2) of
0: R_ChooseOptionMulti(['Cancel']);
1: while IsMenuOpen do
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
Wait(RandomRange(100, 200));
end;
end;
end;

~shut

Nava2

2010-12-02 09:59:36

From: Shuttleu
With the current R_ChooseOptionMulti, it will choose the first option which has one of the "Options"

This will make sure that all the "Options" are in the option that it chooses

{*******************************************************************************
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
By: Drags111, Shuttleu - Based off nava2's and Lordsaturns.
Description: Chooses the first found option of "Options" from the Right
Click menu, returns True and Clicks if found, else it will Move the
mouse to a random Coord or select cancel.
*******************************************************************************}
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
var
ThisOption: Boolean;
i, i2, xOff, yOff, t: Integer;
P : TPoint;
MenuOptions: TStringArray;

begin
Result := False;
if not IsMenuOpen then
begin
MarkTime(t);
while(TimeFromMark(t) < 1000)do ;
if not IsMenuOpen then Exit;
end;

P := Point(SmartGetFieldInt(0, hook_static_MenuX) + 4, SmartGetFieldInt(0, hook_static_MenuY) + 4);
//Writeln('MenuX: '+ToStr(SmartGetFieldInt(0, hook_static_MenuX)));
//Writeln('MenuY: '+ToStr(SmartGetFieldInt(0, hook_static_MenuY)));
MenuOptions := GetMenuText;

for i := 0 to High(MenuOptions) do
begin
Result:= True;
for i2 := 0 to High(Options) do
begin
ThisOption:= (Pos(Lowercase(Options[i2]), Lowercase(MenuOptions[i])) <> 0);
Result:= (ThisOption and Result);
end;
if Result begin
xOff := RandomRange(4, 4 + Random(Length(MenuOptions[i]) * 4 - 4));
yOff := 21 + (16 * i) + RandomRange(2, 10);
Mouse(P.x + xOff, P.y + yOff, 0, 0, True);
Wait(RandomRange(80, 100));
Result := not IsMenuOpen;
Exit;
end;
end;

case Random(2) of
0: R_ChooseOptionMulti(['Cancel']);
1: while IsMenuOpen do
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
Wait(RandomRange(100, 200));
end;
end;
end;

~shut


Thats not what its supposed to do, I am all for a separate function though. Or an EX for matching all or just one. :)

Shuttleu

2010-12-02 10:01:21

oh, i thought thats what it was meant to do as thats what it does in SRL

~shut

Zota

2010-12-02 10:24:23

From: Nava2
Thats not what its supposed to do, I am all for a separate function though. Or an EX for matching all or just one. :)




D: ?? So what is the equivalent Reflection multi option menu?

Nava2

2010-12-02 10:27:49

From: Shuttleu
oh, i thought thats what it was meant to do as thats what it does in SRL

~shut


The one in SRL actually picks the first occurrence as well. It was written by Naike for his Aviansie script back in the day. That's why it did that. It picks the first occurrence so when you have lots of drops it'll get the first present one. :)

Zota

2010-12-02 10:32:01

From: Nava2
The one in SRL actually picks the first occurrence as well. It was written by Naike for his Aviansie script back in the day. That's why it did that. It picks the first occurrence so when you have lots of drops it'll get the first present one. :)


It doesn't O_o… I'm using it right now. The Reflection one wasn't working for me and was simply choosing the first option no matter what string I entered.

SRL one is going by the string.

Luke-

Naike

2010-12-02 10:34:52

From: Nava2
The one in SRL actually picks the first occurrence as well. It was written by Naike for his Aviansie script back in the day. That's why it did that. It picks the first occurrence so when you have lots of drops it'll get the first present one. :)


Haha, good times :)



From: Zota
It doesn't O_o… I'm using it right now. The Reflection one wasn't working for me and was simply choosing the first option no matter what string I entered.

SRL one is going by the string.

Luke-


I'm rather sure that the reflection one works?
what parameters are you using?

Shuttleu

2010-12-02 10:36:32

if you have "Take Iron Sword" and "Examine Iron Sword" in the menu
if you put R_ChooseOptionMulti(['mine', 'word']); it will choose "Take Iron Sword"
but if you use the SRL one ChooseOptionMulti(['word', mine']); it will choose "Examine Iron Sword"

~shut

Naike

2010-12-02 18:03:02

From: Shuttleu
if you have "Take Iron Sword" and "Examine Iron Sword" in the menu
if you put R_ChooseOptionMulti(['mine', 'word']); it will choose "Take Iron Sword"
but if you use the SRL one ChooseOptionMulti(['word', mine']); it will choose "Examine Iron Sword"

~shut


I'm pretty sure it's not suppose to do that, "w" might be broken or something?
Or does it repeat with all items?

traveler

2010-12-02 19:32:36

The reflection one compares all the items in the string with the first menu option, and if on of the string matches, it chooses it. If none match, it goes to the second menu option and compares and so on

The srl one takes the first string option and compares it with all the menu items, then takes the second one and compares and so on.

I believe the reflection one should beset up like the srl one, or at least make a reflection function like the srl's one

mormonman

2010-12-02 21:40:40

From: Shuttleu
if you have "Take Iron Sword" and "Examine Iron Sword" in the menu
if you put R_ChooseOptionMulti(['mine', 'word']); it will choose "Take Iron Sword"
but if you use the SRL one ChooseOptionMulti(['word', mine']); it will choose "Examine Iron Sword"

~shut


For reflection there is no need to use just parts of words. Use the whole thing. It doesn't change the speed of the function at all.
Example:
good - R_ChooseOption('Examine Iron Sword');
bad - R_ChooseOptionMulti(['mine', 'word']);

lordsaturn

2010-12-02 23:16:26

From: mormonman
For reflection there is no need to use just parts of words. Use the whole thing. It doesn't change the speed of the function at all.
Example:
good - R_ChooseOption('Examine Iron Sword');
bad - R_ChooseOptionMulti(['mine', 'word']);


The reason that in srl's chooseoption we like to use parts of the word, is because there is a higher chance of OCR making mistakes when it reads capital letters and spaces. But in reflection we read the values directly from the client, which will either return the correct answer or null which means it failed.

mormonman

2010-12-03 01:12:28

From: lordsaturn
The reason that in srl's chooseoption we like to use parts of the word, is because there is a higher chance of OCR making mistakes when it reads capital letters and spaces. But in reflection we read the values directly from the client, which will either return the correct answer or null which means it failed.


Exactly. I don't know why we even have a "multi" option for reflection…