Log in

View Full Version : CountBitmap!



caused
06-05-2012, 06:14 PM
Where is it :o ?

Does Simba have something similar ?

putonajonny
06-05-2012, 06:21 PM
(*
CountItems
~~~~~~~~~~

.. code-block:: pascal

function CountItems(ItemType: string; Identifier: Integer; tol: TIntegerArray): Integer;

Counts Items in the inventory:

- ItemType: 'dtm', 'bitmap', 'bitmap mask', 'color'
- Item: name/value of your dtm/bmp/color/bmpmask.
- Tol:

* 'dtm' - [] (dtm's can't have tolerance).
* 'bmp' - [BMPTol].
* 'color' - [COLOUR Tol, Colour Count].
* 'bmpmask' - [BMPTol, ContourTol].

.. note::

by WT-Fakawi / Sumilion

Example:

.. code-block:: pascal

numbOfItems := CountItems('dtm', TheDTM, []);

*)

Or get the array length of the result of this:
(*
ItemCoordinates
~~~~~~~~~~~~~~~

.. code-block:: pascal

function ItemCoordinates(Area, ItemType: string; Item, Tol: TIntegerArray): TPointArray;

Returns a TPA with the positions of all occurances of the item.
Parameters:

Area: 'inv', 'shop', 'bank', 'trade', 'your trade'.
ItemType: DTM, Color, BitmapMask, Bitmap
Item: name/value of your dtm/bmp/color/bmpmask.

Tol:
'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Minimum Colour Count].
'bmpmask' - [BMPTol, ContourTol].

.. note::

Author: masquerader
Last Modified: Unknown by ZephyrsFury

Example:

.. code-block:: pascal

if (Length(ItemCoordinates('inv', 'dtm', dtm_Hatchet, []) > 0) then
Writeln('Hatchet found!');
*)

caused
06-05-2012, 06:34 PM
Can't use those :o .. they scan for stuff in Runescape.

I'm not writing stuff for RS.. but i will see if i can rewrite those.

Brandon
06-05-2012, 06:44 PM
Not sure where they got the values for AreaInfo.. but this would do if you can figure it out.


function ItemCoordinates(ItemType: string; Item: Integer; Tol: TIntegerArray): TPointArray;
var
startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
x1, y1, x2, y2: Integer;
itemx, itemy, L: Integer;
begin
AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
SetLength(Result, RowNumber * ColNumber);
for row := 0 to rownumber - 1 do
for col := 0 to colnumber - 1 do
begin
x1 := startx + col * colsize;
y1 := starty + row * rowsize;
x2 := x1 + colsize;
y2 := y1 + rowsize;
if FindItem(Itemx, Itemy, ItemType, Item, x1, y1, x2, y2, Tol) then
begin
Result[L].x := ItemX;
Result[L].y := ItemY;
Inc(L);
end;
end;
SetLength(Result, L);
end;


Function CountItems(............): Integer;
begin
Length(ItemCoordinates(........));
end;




Now for my solution:

{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}

Function FindBitmaps(BMP, Tolerance: Integer; Area: TBox): TPointArray;
var
W, H, I, J, X, Y: Integer;
Count: Integer;
TPA: TPointArray;
begin
GetBitmapSize(BMP, W, H);
Count:= 0;

For J:= Area.Y1 To Area.Y2 Do
begin
For I:= Area.X1 To Area.X2 Do
begin
if FindBitmapToleranceIn(BMP, X, Y, I, J, Area.X2, Area.Y2, Tolerance) then
begin
SetLength(TPA, Length(TPA) + 1);
TPA[Count]:= Point(X + (W div 2), Y + (H div 2));
Inc(Count);
end;
IncEx(I, W);
ClearDebug;
end;
ClearDebug;
IncEx(J, H);
end;
Result:= TPA;
end;

Function CountBitmaps(BMP, Tolerance: Integer; Area: TBox): Integer;
begin
Result:= Length(FindBitmaps(BMP, Tolerance, Area));
end;