SRL Archive - Reflection Help

Use reflection to click items on shop screen


TomTuff

2010-10-23 05:01:12

So i'm making a script that i want to be pure reflection. How do i use reflection to interact with items that pop up while in a shop screen?

also, i just have to show off my genius in this function really quick :redface:
[brag]

procedure SellFood;
var
ToSell, ToSellFives, ToSellOnes, DivBy, i, sold: integer;
SellString: string;
begin
GameTab(Tab_inv);
ToSell := 28 - R_InvCount;
SellString := IntToStr(ToSell);

case length(SellString) of
1: DivBy := 1;
2: DivBy := 10;
end;

for i := 0 to ((Floor(ToSell/DivBy)) - 1) do
begin
R_ClickItemID((SetFoodID + 1), false, 'Sell 10');
IncEx(Sold, 10);
Wait(RandomRange(100,300));
end;

ToSellFives := (Floor((ToSell - Sold)/5));
for i := 0 to (ToSellFives - 1) do
begin
R_ClickItemID((SetFoodID + 1), false, 'Sell 5');
incEx(Sold, 5);
Wait(RandomRange(100,300));
end;

ToSellOnes := (ToSell - Sold);
for i := 0 to (ToSellOnes - 1) do
begin
R_ClickItemID((SetFoodID + 1), false, 'Sell 1');
Inc(Sold);
Wait(RandomRange(100,300));
end;
end;
[/brag]

mormonman

2010-10-23 05:30:26

We need a couple new hooks to do it correctly.

JPHamlett

2010-10-23 06:55:43

To interact with the items in a shop screen you need to use an interface. The only way I can think of atm to debug interfaces is use RSBot's interface explorer script. Granted I havn't coded for reflection or actually done anything with reflection for a while just cause my life has been really busy, but I think that's how it's done.

Cstrike

2010-10-23 10:30:34

In a large new script I'm working on, it has most interface hooks covered. If you need any help post what hooks you need (see RSBot) an I can get you the functions [with hooks properly coded] you need [hopefully, not guaranteed].

TomTuff

2010-10-23 13:54:50

From: cstrike
In a large new script I'm working on, it has most interface hooks covered. If you need any help post what hooks you need (see RSBot) an I can get you the functions [with hooks properly coded] you need [hopefully, not guaranteed].


how do i get what hook i need?

Cstrike

2010-10-23 15:03:17

From: TomTuff
how do i get what hook i need?


What interface thing are you looking for?

TomTuff

2010-10-23 15:29:43

From: cstrike
What interface thing are you looking for?


ummm i'm not sure what you mean exactly by the question, so i'll just say what i want to do…

Trade the NPC (Jossik in the lighthouse tower) (function already written), sell noted food to Jossik (function already written), then buy back the food.

mormonman

2010-10-23 16:16:56

From: TomTuff
ummm i'm not sure what you mean exactly by the question, so i'll just say what i want to do…

Trade the NPC (Jossik in the lighthouse tower) (function already written), sell noted food to Jossik (function already written), then buy back the food.


To be honest you might as well just use a bitmap or dtm. Otherwise you are going to have to write a lot of code just to do one thing.

Naike

2010-10-23 18:22:51

Interface stuff @ SRL.

Combine them for the best result :)

TomTuff

2010-10-23 18:24:52

From: mormonman
To be honest you might as well just use a bitmap or dtm. Otherwise you are going to have to write a lot of code just to do one thing.


yeah oh well i was just going to try and see if i could get this to be pure reflection… but there's some other small things i need to do in color as well so the dream is spoiled =P

Cstrike

2010-10-23 18:35:38

From: TomTuff
ummm i'm not sure what you mean exactly by the question, so i'll just say what i want to do…

Trade the NPC (Jossik in the lighthouse tower) (function already written), sell noted food to Jossik (function already written), then buy back the food.


So I assume that the buy back would be looking for which slot your 'item you desire' is in, and then clicking it?
If that's it, that is 100% do-able. Hell, I've made a banking reflection procedure that can find any item in your bank flawlessly (including scroll) ;)
So this IS doable 100% reflection.

You need to get component ID's. I'll try and find it for you – though bear w/ me as I'm sort of sick today.

TomTuff

2010-10-23 20:16:32

hey cstrike add me on msn so we can talk faster @ [email]tommyk1995@gmail.com[/email]
i'm really curious about this, and i have a few other quick questions as well.

Cstrike

2010-10-23 21:26:17

From: TomTuff
hey cstrike add me on msn so we can talk faster @ [email]tommyk1995@gmail.com[/email]
i'm really curious about this, and i have a few other quick questions as well.


MSN doesnt work on my computer :(
Gotta catch me on IRC – only thing for me that works ATM.


Yes i hate my comp, yes I'm getting a new one soon :p

i luffs yeww

2010-10-23 22:10:40

@cstrike, meebo? :)

Cstrike

2010-10-23 23:12:07

From: i luffs yeww
@cstrike, meebo? :)


Whats meebo? :)

Ive probably heard of it but never checked into it




For TomTuff:
// Cstrike + Thanks to some help from ZephyrsFury
function Inf_GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
var
Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Result := SmartGetFieldInt(Comp, hook_interface_GetID);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;

That will help you get component ID's, search the components with a:

for i:=0 to [how many components show up in the guy's selling screen for item locations] do
begin
if Inf_GetComponentID(ParentIDYouPutHere, ChildIDYouPutHere, i) = [ID of number you are selling] then // stuff here
end;

i luffs yeww

2010-10-24 01:31:34

meebo.com. Online msn/aim/facebook/yahoo/myspace/blah blah blah stuff in a browser.

Have you tried pidgin?

TomTuff

2010-10-24 03:00:28

From: cstrike
Whats meebo? :)

Ive probably heard of it but never checked into it


meebo




From: cstrike
For TomTuff:
// Cstrike + Thanks to some help from ZephyrsFury
function Inf_GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
...

That will help you get component ID's, search the components with a:

for i:=0 to [how many components show up in the guy's selling screen for item locations] do
begin
if Inf_GetComponentID(ParentIDYouPutHere, ChildIDYouPutHere, i) = [ID of number you are selling] then // stuff here
end;


how do i determine ParentID and ChildID?

Cstrike

2010-10-24 10:25:52

From: TomTuff
meebo






how do i determine ParentID and ChildID?


RSBot :)

Download the newest one, and when you log in to your character, go to File–> Run, and chose "Interface Explorer"

If you need any more help on the subject [as it can be a pain] post back and I'll do my best to help you in more detail

TomTuff

2010-10-24 20:29:49

I've decided to use a simple TBox since there will always be the same number of items in the general store before you sell the noted fish.

However, i do have a new question; How do i, say, go up a ladder, or through a door with reflection?

i luffs yeww

2010-10-24 20:40:53

Those would be objects, right? :) Check Objects.simba? I think that exists. :p Get the ID of it and click it.

Cstrike

2010-10-24 22:26:46

From: TomTuff

However, i do have a new question; How do i, say, go up a ladder, or through a door with reflection?


http://villavu.com/forum/showthread.php?t=59400

I know it's in there somewhere ;)

TomTuff

2010-10-24 23:56:35

function DoLadder1(up: boolean): boolean; //Goes Up/Down the ladder in the ground floor of the lighthouse
{****MESSY****}
var
Ladder: TRSObject;
LPoint: TPoint;
ObjTile: TTile;
x, y, i, height, ID: integer;
warn: string;
begin
Case up of
true:
begin
ID := 4412;
ObjTile := Tile(2519, 9994);
warn := 'couldnt go up the lighter to the lighthouse ground floor.';
height := 170;
end;
false:
begin
ID := 4383;
ObjTile := Tile(2509, 3644);
warn := 'Player oom has been logged out and deactivated because: couldnt go down the ladder in the lighthouse ground floor.'
height := 220;
end;
end;

Result := false;
Ladder := GetObjectByID(ID, OBJECT_TYPE_INTERACTABLE, 52);
if not(TileOnMS(Ladder.Tile, 0)) then
begin
WalkToTile(ObjTile, 2, 0);
Wait(RandomRange(150,250));
Ladder := GetObjectByID(ID, OBJECT_TYPE_INTERACTABLE, 52);
end;
LPoint := TileToMS(Ladder.Tile, height);
for i := 0 to 9 do
begin
MMouse(LPoint.X, LPoint.Y, 1, 1);
Wait(RandomRange(50,150));
Result := IsUpText('ron');
if Result then
begin
Break;
end;
Wait(RandomRange(100,300));
GetMousePos(x, y);
MMouse(x,y,1,1);
Wait(RandomRange(700,800));
LPoint := TileToMS(Ladder.Tile, height-1);
end;
if not(Result) then
begin
//Die('couldnt go down the ladder in the lighthouse ground floor.');
end else
begin
Wait(RandomRange(600,800));
GetMousePos(x, y);
Mouse(x,y,0,0,true);
end
end;

that's what i came up wtih, and it doesnt work very well at all =(

Cstrike

2010-10-25 00:14:16

Try

LPoint := TileToMS(Ladder.Tile, height);

Use:
LPoint := TileToMS(Ladder.Tile, 0);

I've never had a problem with object finding using zero [though it's not the best habit to get into ;)].

TomTuff

2010-10-25 00:15:47

From: cstrike
Try

LPoint := TileToMS(Ladder.Tile, height);

Use:
LPoint := TileToMS(Ladder.Tile, 0);

I've never had a problem with object finding using zero [though it's not the best habit to get into ;)].


it's really weird how the ladder i want to climb is… idk how to explain it, but the clicking is very stingy :\

Cstrike

2010-10-25 00:17:50

From: TomTuff
it's really weird how the ladder i want to climb is… idk how to explain it, but the clicking is very stingy :\


Is it a normal ladder or wall ladder? If it's one of those wall ones that will make life much harder


Or if it's something like a thin rope you're SOL :( (but it can still be done with reflection)

TomTuff

2010-10-25 00:28:04

its a ladder that goes into the ground… just a sec, i'll get a screeny….
(Offtopic, but saying just a sec in a forum post that is all going to be posted at the same time is so weird >_< oh well i'm not gonna fix my time-tenses… moving on…)
i took this in HD so it could be easier to see.

i luffs yeww

2010-10-25 00:39:32

Take a picture in SD.

TomTuff

2010-10-25 00:45:48


Cstrike

2010-10-28 00:46:11

From: TomTuff


In that image, where is the area you have to click? Theres a TileToMSEx which you can use if TileToMS doesnt work
TileToMS always does the center, but I think TileToMSEx allows you to go closer to edges

In addition, if you wanted you could MakeCompass north, then TileToMS the ladder, then knowing where the mouse is, shift it slightly to see if you're near the ladder

TomTuff

2010-10-28 01:15:52

i have to click on the portion of the ladder that's on top of the tile in the yellow box
and yes, i beleive i could use the offsets of (0, 1/3) … I'll try that later :)

i luffs yeww

2010-10-28 01:48:55

I still think that if you mouse around in the general area of the points you can click while checking the uptext you'd get the best results.

Naike

2010-10-29 09:35:14

TileToMSEx(Tile, 0.5, 0.0, 0)

Counting from the yellow square.
Or it's the other way around :)

TomTuff

2010-10-29 09:42:07

I pretty much got this working. It makes it to the ladder 90% of the time correctly on the first MMouse.
Here's the func:
function DoLadder1(down: boolean): boolean;
var
OID, ran, : integer;
xmod, ymod: extended;
Ladder: TRSObject;
begin
case down of
true:
begin
OID := 4383;
ran := 0;
xmod := 0.5;
ymod := 0.97500;
end;
false:
begin
OID := 4412;
ran := 10;
xmod := 0.5;
ymod := 0.5;
end;
end;
SetAngle(true);
MakeCompass('n');
Ladder := GetObjectByID(OID, OBJECT_TYPE_INTERACTABLE, 52);
if (down = false) then
Ladder.Tile.Y := Ladder.Tile.Y +1;
repeat
LPoint := TileToMSEx(Ladder.Tile, xmod, ymod, 0);
MMouse(Ladder.Tile.X, Ladder.Tile.Y, ran, ran);
Wait(400 + Random(200));
if (R_IsUpText('limb')) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, false);
Result := R_ChooseOption('Climb');
if Result then break;
end else
begin
GetMousePos(x, y);
MMouse(x, y, 50, 50);
end;
FindNormalRandoms;
if not(LoggedIn) then exit;
until(Result);
end;
That also goes up the corresponding later in the basement. combining the functions shortened the script by about 30 lines.

Naike

2010-10-29 09:44:32

Ain't the ladders static?
as in, not switching around?

TomTuff

2010-10-29 10:08:12

From: Naike
Ain't the ladders static?
as in, not switching around?

explain further? I'm not sure what you mean.

Naike

2010-10-29 11:15:31

It's always on the same tile?
As in, haven't been moved for the latest 4 years or so..

If so, you could skip the object part, as you know what tile it's on from the very beginning.