SRL Archive - OSR Help

How to prioritize which loot to pick up?


Itankbots

2013-02-10 04:41:38

Im trying to choose which loot to pick up first, when both are the same color so i use the same TPA for both. Im choosing which loots based of the uptext and choose option.

I tried using this:

(*
ChooseOptionMulti
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function ChooseOptionMulti(Txt: TStringArray): Boolean;

Finds Popup menu, then clicks on it. Will look for the first string first and so on.

.. note::

by Wizzup? & N1ke!

Example:

.. code-block:: pascal

*)
function ChooseOptionMulti(Txt: TStringArray): Boolean;
begin
Result := ChooseOptionMultiEx(Txt, 'All', ClickLeft);
end;]

Even though it says it picks the first string first, thats not the case. it just loots the which ever item is on the top of the loot pile with a matching uptext.

Any functions that would pick whichever uptext first that i choose?

Example:

Im trying to loot cowhides first, then raw beef second if no cowhides are there, but since raw beef appears ontop of cowhide in the loot pile, it chooses the beef.

ChooseOptionMulti(['owhide','aw beef']);

Doesnt work even though i list cowhide first :/

i luffs yeww

2013-02-10 05:53:42

You'd want to have a loop that calls ChooseOption, passing the next loot each time.


Loots := ['owhide', 'aw beef', 'ones']; // Loots is a TStringArray, and I added 'ones' (bones) just to make it clear, hopefully, what's happening.
for i := 0 to High(Loots) do
begin
Mouse(x, y, 0, 0, False); // Right click where the mouse is to get the ChooseOption menu opened.
ChooseOption(Loots[i]); // Choose each option, in order, according to Loots (defined above).
end;

This will do what you've asked. :)

Shatterhand

2013-02-10 09:50:36

From: i luffs yeww
You'd want to have a loop that calls ChooseOption, passing the next loot each time.


Loots := ['owhide', 'aw beef', 'ones']; // Loots is a TStringArray, and I added 'ones' (bones) just to make it clear, hopefully, what's happening.
for i := 0 to High(Loots) do
begin
Mouse(x, y, 0, 0, False); // Right click where the mouse is to get the ChooseOption menu opened.
ChooseOption(Loots[i]); // Choose each option, in order, according to Loots (defined above).
end;

This will do what you've asked. :)

This is not a good solution. If it cant find 'owhide', it will move the mouse away, right click again on the spot, look for 'aw beef' …

You should do something like this:
procedure Loot(X,Y : Integer);
var
i, j : Integer;
Box : TBox;
Loots : Array of String;
Options : Array of TOptions;
begin
Loots := ['owhide', 'aw beef', 'ones'];
Mouse(X,Y,0,0,mouse_right);
Options := GetChooseOptions('action');
for i := 0 to High(Loots) do
for j := 0 to High(Options) do
begin
if Pos('Take ' + Loots[i],Options[j].Str) > 0 Then
begin
Box := Options[j].Bounds;
GetMousePos(X,Y);
if PointInBox(Point(X,Y),Box) then
ClickMouse2(mouse_left)
else
MouseBox(Box.x1,Box.y1,Box.x2,Box.y2,5,mouse_left);
end;
end;
end;

i luffs yeww

2013-02-10 21:44:59

From: Shatterhand
This is not a good solution. If it cant find 'owhide', it will move the mouse away, right click again on the spot, look for 'aw beef' …

You should do something like this:
procedure Loot(X,Y : Integer);
var
i, j : Integer;
Box : TBox;
Loots : Array of String;
Options : Array of TOptions;
begin
Loots := ['owhide', 'aw beef', 'ones'];
Mouse(X,Y,0,0,mouse_right);
Options := GetChooseOptions('action');
for i := 0 to High(Loots) do
for j := 0 to High(Options) do
begin
if Pos('Take ' + Loots[i],Options[j].Str) > 0 Then
begin
Box := Options[j].Bounds;
GetMousePos(X,Y);
if PointInBox(Point(X,Y),Box) then
ClickMouse2(mouse_left)
else
MouseBox(Box.x1,Box.y1,Box.x2,Box.y2,5,mouse_left);
end;
end;
end;


You're correct. I was just trying to get him on the right path with the loop, and let him do the rest. But now you've done it for him and my whole post was a waste! :)

Itankbots

2013-02-11 01:17:19

From: Shatterhand
This is not a good solution. If it cant find 'owhide', it will move the mouse away, right click again on the spot, look for 'aw beef' …

You should do something like this:
procedure Loot(X,Y : Integer);
var
i, j : Integer;
Box : TBox;
Loots : Array of String;
Options : Array of TOptions;
begin
Loots := ['owhide', 'aw beef', 'ones'];
Mouse(X,Y,0,0,mouse_right);
Options := GetChooseOptions('action');
for i := 0 to High(Loots) do
for j := 0 to High(Options) do
begin
if Pos('Take ' + Loots[i],Options[j].Str) > 0 Then
begin
Box := Options[j].Bounds;
GetMousePos(X,Y);
if PointInBox(Point(X,Y),Box) then
ClickMouse2(mouse_left)
else
MouseBox(Box.x1,Box.y1,Box.x2,Box.y2,5,mouse_left);
end;
end;
end;


I seem to get invalid number of parameters on the MouseBox Line when trying to use that.
Idk whats causing it.

Thank you both for the help. Still trying to learn all this stuff lol

riwu

2013-02-11 01:30:24

Remove the '5' in the MouseBox arguments.

MouseBox(Box.x1, Box.y1, Box.x2, Box.y2, mouse_left);