Log in

View Full Version : Delete Values in T2DIntegerArray



Brandon
12-24-2011, 07:02 AM
My original Question has been removed.. By Myself.. I have found a new method of Grabbing Items By ID..

The code below will grab any GE item by ID!! Yes by ID just like reflection.. The problem is that when it comes to finding these items, Simba will NOT find them accurately :S I have absolutely no clue why.. I've been messing with bitmaps, contrasts, brightness, saturations, Masks.. Etc.. And I'm officially giving up on this idea since no one seems to care or knows how to help.. Thus why I'm releasing it now so that the future SRL'ers can work on it..

The items are almost the exact same size as in your bank, Inventory, and Equipped Item Slots.. Infact they are only approx 3 pixels off sometimes.. See below for example Items Grabbed by this plugin.

Example Images:

http://i.imgur.com/uVG8L.png http://i.imgur.com/VCD9Z.png http://i.imgur.com/3ZQic.png <---- Ignore the lines at the tops and left of the images.. thats from my screenshot.. thats y.. It actually does not have those lines.. Just the item alone.. AND the items have a nice transparent background instead of white.. but when converted to BMP, they turn black.. thus I had to code them to be white instead so that it's easier to see.

Original Item As IS!:

http://services.runescape.com/m=itemdb_rs/g=runescape/3583_obj_sprite.gif?id=1521
Image After Converting to Bitmap:

http://i.imgur.com/yWLhl.png

Finally the image that you had previously seen after changing the background to white and removing shadows:

http://i.imgur.com/3ZQic.png

Finally Some Larger Size Images Downloaded (WITHOUT Quality Loss) Even after resizing in simba, the quality is perfect still! Can resize down to 45x45 at MOST! Or else you get a loss of quality:
http://services.runescape.com/m=itemdb_rs/3583_obj_big.gif?id=1521


And Now the Code:

MUST HAVE SIMBA 0.98.2!!! Wizzup released it on 1/4/2012.. without this, FindDeformedBitmapToleranceIn, will NOT WORK!

program ImageProc;
{$loadlib SSecurity}
{$i SRL/SRL.simba}
{$I srl/srl/misc/debug.simba}

Function ImageProc(BMPName: String; ItemID: Integer; Bounds: TBox): String; //Don't touch this function..
var
Image, Path: string;
FP, Item, X, Y, SX, SY: Integer;
V: Extended;
begin
Image:= GetPage('http://services.runescape.com/m=itemdb_rs/g=runescape/3598_obj_sprite.gif?id=' + ToStr(ItemID));
Path:= ScriptPath + BMPName + '.bmp';
Path:= Trim(Path);
FP:= CreateFile(Path);
WriteFileString(FP, Image);
CloseFile(FP);

ImgToBMP(ScriptPath + BMPName + '.bmp');
Item:= LoadBitmap(ScriptPath + BMPName + '.bmp');
GetBitmapSize(Item, Sx, SY);

DebugBitmap(Item);
if FindDeformedBitmapToleranceIn(Item, X, Y, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2, 5, 0, True, V) then
MMouse(X + SX/2, Y + SY/2, 0, 0);
FreeBitmap(Item);
end;

Begin
SetupSRL;
ImageProc('law', 563, MIBox);
end.


The plugin used (1.72 MB):
http://www.multiupload.com/5F7FKV0ZYI (http://www.multiupload.com/CWQG8F0J12)

Narcle
12-24-2011, 07:07 AM
I think this should work:
For I:= 0 To High(ATIA) do
For II:= 0 To High(ATIA[I]) do
if(ATIA[I][II] = 0) then
begin
if Length(ATIA[I]) = 1 then
begin
Swap(ATIA[0], ATIA[i]);
SetLength(ATIA, Length(ATIA)-1);
end else
begin
Swap(ATIA[i][0], ATIA[i][ii]);
SetLength(ATIA[i], Length(ATIA[i])-1)
end;
end;

Edit:
Oh i'm swapping with 0, u can change that to High(ATIA[i])-1 or w/e

Brandon
12-24-2011, 06:30 PM
I think this should work:
Edit:
Oh i'm swapping with 0, u can change that to High(ATIA[i])-1 or w/e

Did not work.. all the zeros are still there :S

And I cannot figure out a way to write that back or draw it back to the screen/bitmap..

This is the code I have written..


program ImageProc;
{$loadlib SSecurity} //The ability to convert Images to Bitmaps, Png's, Gif, Jpeg Tiff, Decrypt, Encrypt, etc..
{$i SRL/SRL.scar}

Function GetItemByID(ItemID: Integer; ItemName: String): Boolean;
var
Path: String;
Item, X, Y, I, II: Integer;
V: Extended;
ATIA: T2DIntegerArray;
ATPA: T2DPointArray;
begin
Path:= ScriptPath + ItemName;
GetItem(ItemId, ScriptPath, ItemName, 'bmp'); //Downloads the Image in any format!
ImgToBmp(Path + '.bmp'); //Comverts it to a BMP that Simba can Read and returns the file format as a string.

Item:= LoadBitmap(Path + '.bmp');
DisplayDebugImgWindow(96, 96);
ATIA:= GetBitmapAreaColors(Item, 0, 0, 95, 95); //Ignore the last pixel..


Writeln(ATIA);
For I:= 0 To High(ATIA) do
For II:= 0 To High(ATIA[I]) do
if(ATIA[I][II] = 0) then
begin
if Length(ATIA[I]) = 1 then
begin
Swap(ATIA[0], ATIA[i]);
SetLength(ATIA, Length(ATIA)-1);
end else
begin
Swap(ATIA[i][0], ATIA[i][ii]);
SetLength(ATIA[i], Length(ATIA[i])-1)
end;
end;
writeln(ATIA); //Still prints all the black around the image.. Aka the 0's
//DrawATPABitmap(Item, ATIA); //Cannot figure out how to draw the bitmap..

DrawBitmapDebugImg(Item);
if(FindDeformedBitmapToleranceIn(Item, X, Y, MIX1, MIY1, MIX2, MIY2, 0, 0, False, V)) then
MMouse(X + 48, Y + 48, 5, 5); //If found.. Places the mouse close to the center of the object.
FreeBitmap(Item);
Sleep(2000);
ClearDebugImg;
Result:= True;

end;

Begin
SetupSRL;
GetItemByID(554, 'PureEssence');
end.


//Scroll Down for more..



//THIS DOES THE SAME AS THE ABOVE (DOWNLOADING AT LEAST).. EXCEPT IT DOES NOT USE THE PLUGIN.. THUS SIMBA CANNOT READ THE IMAGE..
//AS THE IMAGE IS NOT CONVERTED.

{

Code was removed for posting purposes.. will be released when ready..

}

Kyle Undefined
12-24-2011, 06:40 PM
AFAIK, all transparency in a bitmap gets turned into black.

Brandon
12-24-2011, 07:01 PM
AFAIK, all transparency in a bitmap gets turned into black.

Yeah And I wanna delete the Black Pixels.. Also in some bitmaps you can have the alpha channel.. ARGB bitmaps.

Aegis
12-25-2011, 05:05 AM
Seems like a very interesting concept! I'm almost certain I won't help at all, but I'll be sure to play around with this! Thanks, and I'm bookmarking this.

Zyt3x
12-25-2011, 12:01 PM
Very nice ggzz, you're not the only one working on such systems :)

dweg
12-25-2011, 05:59 PM
I like this concept... but doesn't Jagex dynamically change the shape and position of certain pixels on an item every time you log in and out or have the minimap load? Isn't that why DTMs fail so often for new/higher level items?

Hero
12-26-2011, 08:35 PM
If it grabs the item by the Item ID couldn't you just have a 'Master List' that is included somehow as a reference for the Item IDs, Kind of like how RSPS have their item lists. I know it might defeat the purpose of pulling it from the GE but you could use it with accuracy to pull the image and convert it to the BMP as I can see in your script. If you could develop this to pull the images out of the game or to make in game items with their ID or an ID that can be used in a script for better accuracy that would be great.

Example:
0- Null
1- Cannon
2- Cake

tls
12-26-2011, 08:38 PM
I like this concept... but doesn't Jagex dynamically change the shape and position of certain pixels on an item every time you log in and out or have the minimap load? Isn't that why DTMs fail so often for new/higher level items?

That's the point of FindDeformedBitmap

Brandon
12-26-2011, 09:40 PM
If it grabs the item by the Item ID couldn't you just have a 'Master List' that is included somehow as a reference for the Item IDs, Kind of like how RSPS have their item lists. I know it might defeat the purpose of pulling it from the GE but you could use it with accuracy to pull the image and convert it to the BMP as I can see in your script. If you could develop this to pull the images out of the game or to make in game items with their ID or an ID that can be used in a script for better accuracy that would be great.

Example:
0- Null
1- Cannon
2- Cake

If I were to do this, I'd have developed a new sort of reflection.. why? Because thats not possible to actually download images right from the client atm.. Well afaik.. I'd have to grab one of each item/object and assign it an ID. Of course I can always have simba save a screenshot of the client and crop it to an image that you may be looking for.. but that would actually be more tedious than if I were to do it manually with the Windows 7 built in Snipping tool.

If you mean download the images from GE and store them in a database then just do a database lookup on the ID's.. then I have no problem with implementing that. My problem is that this is barely even complete and I cannot see a way to actually find the items in the invent.

For example, I've written over 21 scripts so far each with different methods to try and find the downloaded images in one's invent.. It has never been found.. I've used every method simba has.. Find deformed bitmap, Countcolours and click where the most were found, find deformed with 0 accuracy.. Find bitmap masked (I programmatically masked all images).. All with no luck. That's why I released it to hopefully get some ideas on this.

Better Ideas, better implementation.. As two members have already told me though, I'm not the only one who seems to be trying such methods. ;)

Of course if Simba could read transparent images or GIF's I'm almost 100% sure this would be complete.