View Full Version : Using worn equipment
KingKong
12-08-2010, 07:05 AM
Hi guys, I want to if there is a command(s) to use worn equipment. Im probably not making any sense but here is an example: Say I want to use the explorer's ring and teleport to the cabbage patch, how would i go about doing it using predefined commands.
Frement
12-08-2010, 07:20 AM
You can make a bitmap, bitmap mask or a DTM of the items, then you search them, and click them. This obviously needs some failsafes and that sort of stuff, but basically thats it, there are no built-in commands to wear equipments afaik.
KingKong
12-09-2010, 09:40 AM
You can make a bitmap, bitmap mask or a DTM of the items, then you search them, and click them. This obviously needs some failsafes and that sort of stuff, but basically thats it, there are no built-in commands to wear equipments afaik.
I'm asking how to use equipment that i am already wielding, not how to wear items from inventory. Anyways i found it, and it uses inbuilt functions, here it is:
{************************************************* ******************************
procedure MouseEquippedItem(Which : String; Left : Integer);
By: Nava2
Description: Mouses Equipped item like MouseItem.
************************************************** *****************************}
and
{************************************************* ******************************
function ChooseOption(txt: String): Boolean;
By: Wizzup?
Description: Finds an option in a popup menu, then clicks on it.
************************************************** *****************************}
TomTuff
12-09-2010, 02:47 PM
function MockUpOperate: Boolean;
var
ExplorerBitmap, x, y, H, i: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
ExplorerBitmap := BitmapFromString(5, 5, 'alsjfa;lsjfa;lsfja');
if FindBitmapToleranceIn(ExplorerBitmap, x, y, MIX1, MIY1, MIX2, MIY2, 4) then
begin
MMouse(x, y, 15, 15);
if WaitUptext('plorer', 800) then
begin
ClickMouse2(False);
Result := WaitOption('bbage', 800);
end else
begin
Result := False;
Exit;
end;
end else
begin
Writeln('couldn''t find ring bitmap, attempting TPA');
if not FindColorsTolerance(TPA, 123456, MIX1, MIY1, MIX2, MIY2, 7) then
begin
Result := False;
Exit;
end;
ATPA := TPAtoATPAEx(TPA, 15, 15);
H := High(ATPA);
for i := 0 to H do
begin
MMouse(x, y, 15, 15);
if WaitUptext('plorer', 800) then
begin
ClickMouse2(False);
Result := WaitOption('bbage', 800);
if Result then
Break;
end;
end;
end;
end;
KingKong
12-10-2010, 12:13 AM
:eek: Thats a lot of coding for just right clicking explorer's ring. How long that did that take? But I think your method will only work for one or two versions of the ring since the 3rd and 4th are completely different from the 1st and 2nd ones, whereas those inbuilt functions can click any equipped item and operate them.
He included failsafes (Which is something every script should have). That is why the script is a lot just for clicking a simple ring. Something like he made only takes a few minutes at most if you know what you're doing exactly.
:eek: Thats a lot of coding for just right clicking explorer's ring. How long that did that take? But I think your method will only work for one or two versions of the ring since the 3rd and 4th are completely different from the 1st and 2nd ones, whereas those inbuilt functions can click any equipped item and operate them.
TomTuff
12-10-2010, 12:48 AM
:eek: Thats a lot of coding for just right clicking explorer's ring. How long that did that take? But I think your method will only work for one or two versions of the ring since the 3rd and 4th are completely different from the 1st and 2nd ones, whereas those inbuilt functions can click any equipped item and operate them.
it took 3 to 4 minutes. The colors, uptext, and options could be easily changed within 30 seconds to work with any item. Please note that that function won't work because the bitmap and colors are purely made up.
Edit:
BTW you should also call FreeBitmap(ExplorerBitmap) somewhere in there as well as a GameTab(tab_Gear) to make sure it's on the gear screen.
KingKong
12-10-2010, 02:42 AM
What's your opinion(s) on this code:
function OperateEquippedItem(EquipSlot: Integer): Boolean;
begin
Result := false;
if (GetCurrentTab <> tab_Equip) then
GameTab(tab_Equip);
if WaitUptext('xplorer', (652 + random(232))) then
begin
MouseEquippedItem(inttostr(Equipslot), 2);
Result:= WaitOption('abb', 562 + random(210));
end else
begin
writeln('Explorers ring is not equipped!');
Logout;
end;
end;
Note: The equipment slot constants are not the same for Reflection and SRL. The above function uses the constants for SRL. Also for the example i mentioned above, equipslot takes on the value of 11(it won't work for most people if not everyone, since the gametab.scar file for srl is missing the line for ring).
TomTuff
12-10-2010, 07:02 AM
What's your opinion(s) on this code:
function OperateEquippedItem(EquipSlot: Integer): Boolean;
begin
Result := false;
if (GetCurrentTab <> tab_Equip) then
GameTab(tab_Equip);
if WaitUptext('xplorer', (652 + random(232))) then
begin
MouseEquippedItem(inttostr(Equipslot), 2);
Result:= WaitOption('abb', 562 + random(210));
end else
begin
writeln('Explorers ring is not equipped!');
Logout;
end;
end;
Note: The equipment slot constants are not the same for Reflection and SRL. The above function uses the constants for SRL. Also for the example i mentioned above, equipslot takes on the value of 11(it won't work for most people if not everyone, since the gametab.scar file for srl is missing the line for ring).
Nope. Doesn't mouse first, so the uptext check will always be bad. Also, there's no need for randomness on WaitOption() or WaitUptext(). And if you are going to put randomness, why such a random number?
KingKong
12-10-2010, 08:20 AM
Yeah i forgot that bit, but ive scrapped the function and replaced it with the following to make it less lines of code and more efficient, since I already know that i have explorer's ring equipped(which doesn't need failsafe's logically):
MouseEquippedItem(inttostr(11), 2);
WaitOption('abb', 362 + randomrange(-100, 210));
Nope. Doesn't mouse first, so the uptext check will always be bad. Also, there's no need for randomness on WaitOption() or WaitUptext(). And if you are going to put randomness, why such a random number?
As for the random number, its just something that i personally do so that it seems more human(the emphasis being on the word 'more').
TomTuff
12-10-2010, 09:03 AM
Yeah i forgot that bit, but ive scrapped the function and replaced it with the following to make it less lines of code and more efficient, since I already know that i have explorer's ring equipped(which doesn't need failsafe's logically):
MouseEquippedItem(inttostr(11), 2);
WaitOption('abb', 362 + randomrange(-100, 210));
As for the random number, its just something that i personally do so that it seems more human(the emphasis being on the word 'more').
Checks are necessary in a good script. If you want to ever release public scripts and be considered a scripter by anyone, learn detection methods and failsafes.
as for the function WaitOption, you must not understand how it works. Here's an extrapolated version of what it does
function WaitOption(text: string; MaxWait: Integer);
var
T: Time;
begin
MarkTime(T);
repeat
if FindUptext(text) then
begin
Result := True;
Break;
end;
Wait(10 + random(25));
until(TimeFromMark(T) > MaxWait);
end;
so as you can see, the value of what maxwait is doesn't affect how human you seem.
KingKong
12-13-2010, 04:11 AM
Yeah, looks like i misunderstood the function, thanks for clearing it up though.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.