SRL Archive - SRL Archives

Inventory.scar ~ InvBox.


Naike

2009-07-12 00:13:11

InvBox was broken since long back, runscapian brought it up once again
so I made a new try to get this changed :)

Note: Only the cords have been changed.

{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: WT-Fakawi/Wizzup?
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}

Function InvBox(i :Integer): TBox;
var
row, col: Integer;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
row :=i mod 4; if row = 0 then row := 4;
col := i / 4 ; if i mod 4 <> 0 then Inc(col);
Result.x1 := 523 + (row * 42); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 177 + (col * 36); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 547 + (row * 42);
Result.y2 := 205 + (col * 36);
end;

Baked0420

2009-07-12 00:35:12

good job, I didn't test it but I'll take your word for it that it works. Maybe later I'll use something to see if it mouse the right spots. Rep++

Runescapian321

2009-07-12 00:59:45

Rep++

I tested it on two loads and it worked great (old one failed like 10 times per load :p). Gj.

ZaSz

2009-07-12 01:14:04

Good. Now I don't have to use my own that doesnt have much randomness.

ZephyrsFury

2009-07-12 14:22:53

I don't think this works. Before the dimensions of the box were 42x38. With your edit its only 24x28. Also your X1 for the first slot cuts off half my iron ore.

Naum

2009-07-12 15:25:47

Zephy does this look right?

Function InvBox(i :Integer): TBox;
var
row, col: Integer;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
row :=i mod 4; if row = 0 then row := 4;
col := i / 4 ; if i mod 4 <> 0 then Inc(col);
Result.x1 := 564 + ((row-1) * 41); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 213 + ((col-1) * 36); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 594 + ((row-1) * 41);
Result.y2 := 244 + ((col-1) * 36);
end;

That should work much better.

EDIT: I know I changed one pixel, but 1 pixel can turn into 28 when you push it to the boundary.

ZephyrsFury

2009-07-12 16:21:59

From: NaumanAkhlaQ
Zephy does this look right?

Function InvBox(i :Integer): TBox;
var
row, col: Integer;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
row :=i mod 4; if row = 0 then row := 4;
col := i / 4 ; if i mod 4 <> 0 then Inc(col);
Result.x1 := 564 + ((row-1) * 41); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 213 + ((col-1) * 36); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 594 + ((row-1) * 41);
Result.y2 := 244 + ((col-1) * 36);
end;

That should work much better.

EDIT: I know I changed one pixel, but 1 pixel can turn into 28 when you push it to the boundary.


Honestly I don't see anything wrong with the one we currently have. Debugging shows it fits the inventory like it should.

Boreas

2009-07-13 08:49:47

function InvBox2(i :Integer): TBox;
begin
if (i < 1) or (i > 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
{1 x1 563 y1 213 x2 594 y2 244}
{6 x1 605 y1 249}
Result.x1 :=563+((((i+3)mod 4))*(605-563));
Result.y1 :=213+((((i-1)/4))*(249-213));
Result.x2 := Result.x1+(594-563);
Result.y2 := Result.y1+(244-213);
end;
Thats really old, but my point is that its simple if you do it like this: hover over slot 1, and move the mouse exactly up to the boundaries of where the uptext is for the item, get X1,Y1,X2,Y2 for spot 1, and X1,Y1 for spot 6 (second on second row). Then plug those numbers in here.


Result.x1 :=[COLOR="Red"]1X1[/COLOR]+((((i+3)mod 4))*([COLOR="Blue"]6X1[/COLOR]-[COLOR="Red"]1X1[/COLOR]));
Result.y1 :=[COLOR="Red"]1Y1[/COLOR]+((((i-1)/4))*([COLOR="Blue"]6Y1[/COLOR]-[COLOR="Red"]1Y1[/COLOR]));
Result.x2 := Result.x1+([COLOR="Red"]1X2[/COLOR]-[COLOR="Red"]1X1[/COLOR]);
Result.y2 := Result.y1+([COLOR="Red"]1Y2[/COLOR]-[COLOR="Red"]1Y1[/COLOR]);

Runescapian321

2009-07-15 18:28:44

From: ZephyrsFury
Honestly I don't see anything wrong with the one we currently have. Debugging shows it fits the inventory like it should.


Something is definitely wrong with it :\ Some people using my PowerMiner are complaining that it misclicks the ores when dropping pretty often. Others who have applied this fix say it works fine (including me, though I only tested it for 2 loads).

Infantry001

2009-07-15 18:38:27

Is it possible it's the script?

Runescapian321

2009-07-15 18:42:59

I guess, though the dropping goes something like this (cbf getting the exact code, it's on my laptop which doesn't have internet access):


procedure DropAll;
begin
if not LoggedIn then LoginPlayer;
gametab(tab_inv);
R_DropAllExcept([333,154,939]);
end;

So I don't see how something could be wrong with that, unless it's R_DropAllExcept.

Though it works with the fix, so I'm assuming that that's what was wrong.

ZephyrsFury

2009-07-15 19:09:28

Using SRL's InvBox:
Using N1ke's InvBox:

As you can see N1ke's function cuts off the edges of many items so maybe dtms would need to be remade. SRL's one works for all items but if you're moving the mouse to a random coord in the box then theres a greater chance of it missing the item.

Runescapian321

2009-07-15 20:33:56

Ah, that helps.

The problem with SRL's is that a good bit of an item's region is a neutral, empty region. Thus, it cannot be clicked, meaning that all functions (mouseitem, etc.) are basically broken. EDIT: Oh, you said that :p Though I see what you're saying about N1ke's too. So neither are suitable for all uses :(

Boreas

2009-07-16 04:08:00

{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: Boreas. Coords by Ogre July 15th 2009.
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}

function InvBox(i :Integer): TBox;
var Slot1, Slot6: TBox;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
Slot1 := IntToBox(563,213,594,244); //update these
Slot6 := IntToBox(605,249,31415,92653); //except pi :p
Result.x1 :=Slot1.X1+((((i+(4-1))mod 4))*(Slot6.X1-Slot1.X1)); //4 for number
Result.y1 :=Slot1.Y1+((((i-1)/4))*(Slot6.Y1-Slot1.Y1)); //of columns
Result.x2 := Result.x1+(Slot1.X2-Slot1.X1);
Result.y2 := Result.y1+(Slot1.Y2-Slot1.Y1);
end;

//when i click i dont just click within the black outline
procedure MMouseItem2(i: Integer);
var
TB: TBox;
begin
GameTab(tab_inv);
TB:=InvBox(I);
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2,3);
end;
Zeph could you try the red box thing with this one please?



Edit: NaumanAkhlaQ
I know, actually I might even have been the one who first wrote a screenshot taking function that automatically takes off the +3, it's just that I don't have paint, or SCAR, or SMART; I wrote that in nano. (Wizz keep the vi>nano comments to yourself please :p).

Naum

2009-07-16 11:16:23

Boreas, it could be done in paint, if you +3 co-ords then 'Mouse' the bounds.

ZephyrsFury

2009-07-16 13:37:12

From: Boreas
{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: Boreas. Coords by Ogre July 15th 2009.
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}

function InvBox(i :Integer): TBox;
var Slot1, Slot6: TBox;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
Slot1 := IntToBox(563,213,594,244); //update these
Slot6 := IntToBox(605,249,31415,92653); //except pi :p
Result.x1 :=Slot1.X1+((((i+(4-1))mod 4))*(Slot6.X1-Slot1.X1)); //4 for number
Result.y1 :=Slot1.Y1+((((i-1)/4))*(Slot6.Y1-Slot1.Y1)); //of columns
Result.x2 := Result.x1+(Slot1.X2-Slot1.X1);
Result.y2 := Result.y1+(Slot1.Y2-Slot1.Y1);
end;

//when i click i dont just click within the black outline
procedure MMouseItem2(i: Integer);
var
TB: TBox;
begin
GameTab(tab_inv);
TB:=InvBox(I);
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2,3);
end;
Zeph could you try the red box thing with this one please?


Its a bit better, but I think it still will cut some items off around the edges.

I just had a look at (M)MouseItem. It uses GetInvItemBounds which gets the black outline and trims off the edges outside the black outline. For most items (M)MouseItem would work well however for long, thin items such as the baguette, it would miss a lot of the time. I am confused about how your script misses the ores though, since the ore image pretty much cover the whole area.

Runescapian321

2009-07-16 21:01:54

From: ZephyrsFury

Its a bit better, but I think it still will cut some items off around the edges.

I just had a look at (M)MouseItem. It uses GetInvItemBounds which gets the black outline and trims off the edges outside the black outline. For most items (M)MouseItem would work well however for long, thin items such as the baguette, it would miss a lot of the time. I am confused about how your script misses the ores though, since the ore image pretty much cover the whole area.


Ah, yeah I never checked exactly what they used. I guess R_DropAllExcept doesn't? (Can't check at the moment :\). I think it uses a Mouse using InvBox, though I'm not sure. It messes up because the current InvBox includes areas outside the clickable area for each ore (I think :p).

senrath

2009-07-16 22:00:04

From: Runescapian aka Tad
Ah, yeah I never checked exactly what they used. I guess R_DropAllExcept doesn't? (Can't check at the moment :\). I think it uses a Mouse using InvBox, though I'm not sure. It messes up because the current InvBox includes areas outside the clickable area for each ore (I think :p).


This is from R_DropAllExcept:

B := InvBox(i+1);
MouseBox(B.x1, B.y1, B.x2, B.y2, 1);

Boreas

2009-07-16 23:27:35

That will now work fine with the new InvBox, Zeph just added it to OpenDevSVN.

ZephyrsFury

2009-07-17 07:34:29

From: senrath
This is from R_DropAllExcept:

B := InvBox(i+1);
MouseBox(B.x1, B.y1, B.x2, B.y2, 1);


Ah so its a Reflection problem. :p

Anyway as Boreas said, he's modified InvBox to only cover the clickable area of each item. So no more chance of misclicks and all dtms will still work.

Nava2

2009-07-17 07:38:14

Is the clickable area constant or is it dependant on item size?

ZephyrsFury

2009-07-17 08:00:50

From: Nava2
Is the clickable area constant or is it dependant on item size?


Constant as Boreas pointed out to me.