SRL Archive - Reflection Development

R_ChooseOptionMulti


Bad Boy JH

2010-10-10 09:41:15

R_ChooseOptionMulti uses downto rather than to, which causes the lowest option to be chosen, rather than the first, this causes 2 things…

1. Non-Human actions, a human will take the first option in the list.
2. When Mining, it will pick exaMINE ROCK, rather than Mine Rock, which is irritating…

I suggest using 'to' rather than 'downto'

Camaro'

2010-10-12 15:20:32


{*******************************************************************************
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
By: Drags111 - 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
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 := High(MenuOptions) downto 0 do
begin
for i2 := High(Options) downto 0 do
begin
if(Pos(Lowercase(Options[i2]), Lowercase(MenuOptions[i])) <> 0)then
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;
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;

to


{*******************************************************************************
function R_ChooseOptionMulti(Options : TStringArray) : Boolean;
By: Drags111 - 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
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
for i2 := 0 to High(Options) do
begin
if(Pos(Lowercase(Options[i2]), Lowercase(MenuOptions[i])) <> 0)then
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;
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;

Haven't tested, but I'm sure it compiles.

Cstrike

2010-10-12 15:48:01

Compiles good :)!

Bad Boy JH

2010-10-14 23:09:14

why hasn't this been changed in the main thing, I have to change this every time reflection gets updated.

pyroryan

2010-10-14 23:34:18

Because we're busy and don't get around to everything. And I'm not planning on committing anything but hooks or emergency repairs.
But, I trust you so I'll commit it :)