SRL Archive - Reflection Development

R_WithdrawItemID


Bad Boy JH

2010-11-30 19:00:03

well, here it is, its a withdrawing function, which uses Reflection. The code looks messy, but it works a damn treat
function R_WithdrawItemID(ID, Amount: Integer): Boolean;
var
I, WhichBankTab, ItemSlot: Integer;
BankTabItemIDs: TIntegerArray;
RelPoint: TPoint;
TabBox, ItemBox: TBox;
begin
for ItemSlot := 0 to 515 do
if ID = GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) then
Break;
if GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) = -1 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
if ItemSlot = 515 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
if (RelPoint.x = 0) then
begin
SetLength(BankTabItemIDs, 9);
for I := 1 to 9 do
BankTabItemIDs[I - 1] := GetInterfaceComponentID(INTERFACE_BANK, 47 + ((9 - I) * 2));
for I := ItemSlot downto 0 do
if InIntArrayEx(BankTabItemIds, WhichBankTab, GetChildComponentID(INTERFACE_BANK, 93, I)) then
Break;
TabBox.x1 := GetInterfaceComponentRelativeX(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.y1 := GetInterfaceComponentRelativeY(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.x2 := TabBox.x1 + GetInterfaceComponentWidth(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
TabBox.y2 := TabBox.y1 + GetInterfaceComponentHeight(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
MouseBox(TabBox.x1, TabBox.y1, TabBox.x2, TabBox.y2, 1);
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
end;
ItemBox.x1 := RelPoint.x + GetInterfaceComponentRelativeX(INTERFACE_BANK, 93) + 4;
ItemBox.y1 := RelPoint.y + GetInterfaceComponentRelativeY(INTERFACE_BANK, 93) + 4;
ItemBox.x2 := ItemBox.x1 + GetChildComponentWidth(INTERFACE_BANK, 93, ItemSlot)
ItemBox.y2 := ItemBox.y1 + GetChildComponentHeight(INTERFACE_BANK, 93, ItemSlot)
if Amount = 1 then
begin
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 1);
Result := True;
Exit;
end;
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 2);
if Amount = 0 then
Result := R_ChooseOption('Withdraw-All') else
if OptionExists('Withdraw-' + IntToStr(Amount)) then
Result := R_ChooseOption('Withdraw-' + IntToStr(Amount)) else
begin
if R_ChooseOption('Withdraw-X') then
begin
Wait(RandomRange(1200, 1500));
//I personally don't like this, but its how both RSBot and Tribot does it
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;

Cstrike

2010-11-30 19:05:09

Beautiful. Eating dinner right now, but will comment soon on how to help you with the last part. I was working on this myself believe it or not ;)

Heres a paste
  // Get position finder open
if not (pos('nter the name', GetInterfaceComponentText(752, 4)) > 0) then
begin
Mouse (83+RandomRange(-4,4), 307+RandomRange(-4,4), 0, 0, true); // Clicks search button
MarkTime(t);
repeat
wait (50+random(50));
until (pos('nter the name', GetInterfaceComponentText(752, 4)) > 0) or (TimeFromMark(t) > 7000)
if TimeFromMark(t) > 7000 then Exit;
end;
Detects when the interface chat is open where it says "Enter name of item you want to search"

I assume it works and I can test it when I get back?

Shuttleu

2010-11-30 19:08:21

for your last bit i would wait until the needed interface comes up, then wait 500+Random(500) then type

~shut

Bad Boy JH

2010-11-30 19:20:18

there aren't any interface changes, it is always there, i checked using both simba and RSBot.

Shuttleu

2010-11-30 19:21:05

From: Bad Boy JH
there aren't any interface changes, it is always there, i checked using both simba and RSBot.


well you should check for it, maybe a dtm or bitmap?
~shut

Cstrike

2010-11-30 19:23:46

From: Bad Boy JH
there aren't any interface changes, it is always there, i checked using both simba and RSBot.


For mine as well?
I just checked and interface 752, 4 changes to "Enter text…" upon clicking the search button.

Bad Boy JH

2010-11-30 19:35:02

I'm not using the search button.

Bad Boy JH

2010-11-30 20:28:41

Just made a minor modification that allows the scripter to save the index of the item, simmilar to WithdrawItemEx

Edit: Clearly I forgot to post it

function R_WithdrawItemIDEx(ID, Amount: Integer; var Index: Integer): Boolean;
var
I, WhichBankTab, ItemSlot: Integer;
BankTabItemIDs: TIntegerArray;
RelPoint: TPoint;
TabBox, ItemBox: TBox;
begin
if (Index = -1) or (ID <> GetChildComponentID(INTERFACE_BANK, 93, Index)) then
begin
for ItemSlot := 0 to 515 do
if ID = GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) then
Break;
if GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) = -1 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
if ItemSlot = 515 then
Exit;
Index := ItemSlot;
end else
ItemSlot := Index;
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
if (RelPoint.x = 0) then
begin
Writeln('not in current tab, switching tabs');
SetLength(BankTabItemIDs, 9);
for I := 1 to 9 do
BankTabItemIDs[I - 1] := GetInterfaceComponentID(INTERFACE_BANK, 47 + ((9 - I) * 2));
for I := ItemSlot downto 0 do
if InIntArrayEx(BankTabItemIds, WhichBankTab, GetChildComponentID(INTERFACE_BANK, 93, I)) then
Break;
TabBox.x1 := GetInterfaceComponentRelativeX(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.y1 := GetInterfaceComponentRelativeY(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.x2 := TabBox.x1 + GetInterfaceComponentWidth(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
TabBox.y2 := TabBox.y1 + GetInterfaceComponentHeight(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
MouseBox(TabBox.x1, TabBox.y1, TabBox.x2, TabBox.y2, 1);
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
end;
ItemBox.x1 := RelPoint.x + GetInterfaceComponentRelativeX(INTERFACE_BANK, 93) + 4;
ItemBox.y1 := RelPoint.y + GetInterfaceComponentRelativeY(INTERFACE_BANK, 93) + 4;
ItemBox.x2 := ItemBox.x1 + GetChildComponentWidth(INTERFACE_BANK, 93, ItemSlot)
ItemBox.y2 := ItemBox.y1 + GetChildComponentHeight(INTERFACE_BANK, 93, ItemSlot)
if Amount = 1 then
begin
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 1);
Result := True;
Exit;
end;
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 2);
if Amount = 0 then
Result := R_ChooseOption('Withdraw-All') else
if OptionExists('Withdraw-' + IntToStr(Amount)) then
Result := R_ChooseOption('Withdraw-' + IntToStr(Amount)) else
begin
if R_ChooseOption('Withdraw-X') then
begin
Wait(RandomRange(1200, 1500));
//I personally don't like this, but its how both RSBot and Tribot does it
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;

Bad Boy JH

2010-12-08 06:49:50

What in this needs to be modified to have this included in the SVN?

Shuttleu

2010-12-08 07:13:57

surely there would be a inteface change, some thing like the text changing to something like 'How many to withdraw'
im not at home atm so i dont know what it says

~shut

Bad Boy JH

2010-12-08 08:15:22

it doesn't actually change, I may do some experementing to see if ANYTHING changes, but RSBot and Tribot both just use a RandomWaitLength

Edit:
Well, however many minutes later, I found something, possibly useable.

When you first open the Bank,
Interface Component 752 - 4
is blank
when you click Withdraw-X for the FIRST time, it changes to "Enter amount:" however when you enter the text, and hit enter, it stays there…which is why it is unusable, HOWEVER the amount you entered, stays in 752 - 5 UNTIL you click withdraw-X a second time, when it gets changed to nothing…

Finally a noticable change when using Withdraw-X, its not perfect, but it will do.

basically code would be something like this

function ReadyForValue: Boolean;
begin
Result := (Pos('nter amount', GetInterfaceComponentText(752, 4)) > 0) and
(GetInterfaceComponentText(752, 5) = '');
end;

Cstrike

2010-12-08 14:44:02

Could it cause problems if you withdraw everything, slots shift and the person remembers the slot number at all?

Bad Boy JH

2010-12-08 16:54:50

(ID <> GetChildComponentID(INTERFACE_BANK, 93, Index))

checks the ID, if the item moves, then that will return True, and it will search for the item

Shuttleu

2010-12-08 17:15:48

after reading through properly, i have one problem

if the item is on the tab that you are on, and the item is below the bottom of the bank screen (so for example the item position is in the chat box) then it will click on the chat box

~shut

EDIT: also something else
    for I := 1 to 9 do
BankTabItemIDs[I - 1] := GetInterfaceComponentID(INTERFACE_BANK, 47 + ((9 - I) * 2));
for I := ItemSlot downto 0 do
if InIntArrayEx(BankTabItemIds, WhichBankTab, GetChildComponentID(INTERFACE_BANK, 93, I)) then
this will only work if the item we are trying to find is in the first position of the bank tab

Bad Boy JH

2010-12-08 18:29:23

I will comment the procedure to show you what I am doing. Cause no, thats not an error.

Edit: When commenting it, I had trouble following it, and I wrote it…

function R_WithdrawItemIDEx(ID, Amount: Integer; var Index: Integer): Boolean;
var
I, WhichBankTab, ItemSlot: Integer;
BankTabItemIDs: TIntegerArray;
RelPoint: TPoint;
TabBox, ItemBox: TBox;
begin
//this finds the item
if (Index = -1) or (ID <> GetChildComponentID(INTERFACE_BANK, 93, Index)) then //this checks if the item is in the slot specified by the variable "Index", if its not, it then searches for it.
begin
for ItemSlot := 0 to 515 do
if ID = GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) then
Break;
if GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) = -1 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
if ItemSlot = 515 then
Exit;
Index := ItemSlot; //This makes the Index variable input, the index of the item.
end else
ItemSlot := Index; //if the item was in that slot, this just makes the ItemSlot the index
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
if (RelPoint.x = 0) then //this checks if its on the current tab, if its not the Relative Point will be 0
begin
Writeln('not in current tab, switching tabs');
SetLength(BankTabItemIDs, 9);
//it then searches IDs of the items on the tabs
for I := 1 to 9 do
BankTabItemIDs[I - 1] := GetInterfaceComponentID(INTERFACE_BANK, 47 + ((9 - I) * 2));
and then searches the Bank, starting at the slot with the item we want to withdraw any of the items, and goes down, searching for any of the Items it found above. Basically it determines the Tab the item is on.
for I := ItemSlot downto 0 do
if InIntArrayEx(BankTabItemIds, WhichBankTab, GetChildComponentID(INTERFACE_BANK, 93, I)) then
Break;
//This then clicks the correct Bank Tab
TabBox.x1 := GetInterfaceComponentRelativeX(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.y1 := GetInterfaceComponentRelativeY(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2)) + 4;
TabBox.x2 := TabBox.x1 + GetInterfaceComponentWidth(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
TabBox.y2 := TabBox.y1 + GetInterfaceComponentHeight(INTERFACE_BANK, 47 + ((8 - WhichBankTab) * 2));
MouseBox(TabBox.x1, TabBox.y1, TabBox.x2, TabBox.y2, 1);
RelPoint.x := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot);
RelPoint.y := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot);
end;
//this then gets the box of the Item we want to withdraw.
ItemBox.x1 := RelPoint.x + GetInterfaceComponentRelativeX(INTERFACE_BANK, 93) + 4;
ItemBox.y1 := RelPoint.y + GetInterfaceComponentRelativeY(INTERFACE_BANK, 93) + 4;
ItemBox.x2 := ItemBox.x1 + GetChildComponentWidth(INTERFACE_BANK, 93, ItemSlot);
ItemBox.y2 := ItemBox.y1 + GetChildComponentHeight(INTERFACE_BANK, 93, ItemSlot);
//then it withdraws the items
if Amount = 1 then
begin
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 1);
Result := True;
Exit;
end;
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 2);
if Amount = 0 then
Result := R_ChooseOption('Withdraw-All') else
if OptionExists('Withdraw-' + IntToStr(Amount)) then
Result := R_ChooseOption('Withdraw-' + IntToStr(Amount)) else
begin
if R_ChooseOption('Withdraw-X') then
begin
Wait(RandomRange(1200, 1500));
//I personally don't like this, but its how both RSBot and Tribot does it
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;

Shuttleu

2010-12-08 18:57:54

hmmm still dont understand, but from what i read i get this
    for I := 1 to 9 do // loops from 1 to 9 (the abs)
BankTabItemIDs[I - 1] := GetInterfaceComponentID(INTERFACE_BANK, 47 + ((9 - I) * 2)); //gets the component id of each tab which is the item in the first slot of each tab
// at this point BankTabItemsIDs only hold the items which are the first in each tab
for I := ItemSlot downto 0 do
if InIntArrayEx(BankTabItemIds, WhichBankTab, GetChildComponentID(INTERFACE_BANK, 93, I)) then // checks if the component id of the itemslot (the item id) is in the array we made above (which only holds the items which is in the first tab)
Break; // breaks if one of the items is found to be in a first tab (which it will do)

thats what i see anyway

~shut

Bad Boy JH

2010-12-08 19:06:50

This uses some of your procedures, might be easier to understand, cause I did have trouble myself.
function R_GetItemIDAtBankSlot(BankSlot: Integer): Integer;
begin
Result := GetChildComponentID(INTERFACE_BANK, 93, BankSlot);
end;

function R_TabItemIsOn(ItemSlot: Integer): Integer;
begin
Result := -1;
SetLength(BankTabItemIDs, R_NumberOfBankTabs);
for I := 0 to High(BankTabItemIDs) do
BankTabItemIDs := GetInterfaceComponentID(INTERFACE_BANK,R_BankTabID(I + 1));
BankTabItemIDs[0] := R_GetItemIDAtBankSlot(0);
for I := ItemSlot downto 0 to
if InIntArrayEx(BankTabItemIDs), Result, R_GetItemIDAtBankSlot(I)) then
begin
Inc(Result);
Exit;
end;
end;

function R_WithdrawItemID(ID, Amount: Integer): Boolean;
var
I, WhichBankTab, ItemSlot: Integer;
BankTabItemIDs: TIntegerArray;
RelPoint: TPoint;
TabBox, ItemBox: TBox;
begin
for ItemSlot := 0 to 515 do
if ID = GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) then
Break;
if GetChildComponentID(INTERFACE_BANK, 93, ItemSlot) = -1 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
if ItemSlot = 515 then
begin
Writeln('ItemID ' + IntToStr(ID) + ' not found.');
Exit;
end;
if (GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot) <= 0) then
R_BankTab(R_TabItemIsOn(ItemSlot);
ItemBox.x1 := GetChildComponentRelativeX(INTERFACE_BANK, 93, ItemSlot) + GetInterfaceComponentRelativeX(INTERFACE_BANK, 93) + 4;
ItemBox.y1 := GetChildComponentRelativeY(INTERFACE_BANK, 93, ItemSlot) + GetInterfaceComponentRelativeY(INTERFACE_BANK, 93) + 4;
ItemBox.x2 := ItemBox.x1 + GetChildComponentWidth(INTERFACE_BANK, 93, ItemSlot);
ItemBox.y2 := ItemBox.y1 + GetChildComponentHeight(INTERFACE_BANK, 93, ItemSlot);
if Amount = 1 then
begin
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 1);
Result := True;
Exit;
end;
MouseBox(ItemBox.x1, ItemBox.y1, ItemBox.x2, ItemBox.y2, 2);
if Amount = 0 then
Result := R_ChooseOption('Withdraw-All') else
if OptionExists('Withdraw-' + IntToStr(Amount)) then
Result := R_ChooseOption('Withdraw-' + IntToStr(Amount)) else
begin
if R_ChooseOption('Withdraw-X') then
begin
MarkTime(Mark);
while not ((Pos('nter amount', GetInterfaceComponentText(752, 4)) > 0) and (GetInterfaceComponentText(752, 5) = '')) do
begin
Wait(RandomRange(100, 250));
if TimeFromMark(Mark) > 15000 then
Exit;
end;
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;

Shuttleu

2010-12-08 19:15:15

fixed a error here
but essentially what your doing here is the following
  for I := 0 to High(BankTabItemIDs) do  //looping through however many tabs you have
BankTabItemIDs[i] := R_BankTabID(I + 1); //setting the array to the Bank interface component id for each tab
for I := ItemSlot downto 0 to
if InIntArrayEx(BankTabItemIDs), Result, R_GetItemIDAtBankSlot(I)) then //checking to see if the item id at each bank slot is equal to one of the tab interface ids

~shut

EDIT: also check the other thread, i updated the interfaces bit

Bad Boy JH

2010-12-08 19:24:46

On each tab you see a picture of the first item in the tab
GetInterfaceComponentID(INTERFACE_BANK,R_BankTabID(I + 1))
gets the ItemID of that (so if it was a raw lobster it gets 377).

Also, i need to make BankTabItemIDs[0] to be the first item in the bank, so it realises that it needs to switch to the first tab, and not return null

Shuttleu

2010-12-08 19:33:03

From: Bad Boy JH
On each tab you see a picture of the first item in the tab
GetInterfaceComponentID(INTERFACE_BANK,R_BankTabID(I + 1))
gets the ItemID of that (so if it was a raw lobster it gets 377).

Also, i need to make BankTabItemIDs[0] to be the first item in the bank, so it realises that it needs to switch to the first tab, and not return null


exactly, so if the raw lobster was say, 5 in the tab, then it wont get 377

~shut

Bad Boy JH

2010-12-08 19:38:20

its checking which tab it needs to switch to, its found the item, lets say a cooked lobster, at slot 45, which is 5th in Tab number 4.
The first item in Tab 4 is a raw lobster.
It Starts at ItemSlot (45) and starts searching down for the items shown at the top, and first in the slot, so when it gets to 41, which is the raw lobster, R_TabItemIsOn returns 4, and your R_BankTab switches to Tab 4

Shuttleu

2010-12-08 19:39:52

Ahhhhh… i see now
clever thinking, i would never have thought of that

well done, you have beat me

~shut