SRL Archive - SRL Suggestions

Shop.simba


Kyle Undefined

2012-04-22 04:29:07

I've been (slowly, but surely) working on a shop.simba file, to work with the new shop interface. I know there's a buysell.simba, and this could be incorporated into that if needed.

The following code is working, but isn't complete. I still need to add the code to change the amounts of an item you want to buy/sell. Also, possible scrolling of the scroll bar.

Feel free to add/change anything you see. I want to get this working 100%, and all ideas incorporated before even thinking about sending a pull request.

The grids work on both the buy and sell tab. However, the grids may be off for shops that give free items, like in Lumbridge.


(*
Shop
====

Supporting shop functions.

.. contents::

*)

const
SHOP_VIEW_ICON = 0;
SHOP_VIEW_FULL = 1;

SHOP_TAB_BUY = 0;
SHOP_TAB_SELL = 1;

SHOP_ICON_COL = 9;
SHOP_ICON_ROW = 3;
SHOP_ICON_W = 47;
SHOP_ICON_H = 50;
SHOP_ICON_DIFFX = 52;
SHOP_ICON_DIFFY = 56;
SHOP_ICON_STARTX = 41;
SHOP_ICON_STARTY = 90;

SHOP_FULL_COL = 3;
SHOP_FULL_ROW = 3;
SHOP_FULL_W = 150;
SHOP_FULL_H = 50;
SHOP_FULL_DIFFX = 155;
SHOP_FULL_DIFFY = 56;
SHOP_FULL_STARTX = 95;
SHOP_FULL_STARTY = 90;

SHOP_DISPLAY_ICON_X1 = 483;
SHOP_DISPLAY_ICON_Y1 = 42;
SHOP_DISPLAY_ICON_X2 = 500;
SHOP_DISPLAY_ICON_Y2 = 59;

SHOP_DISPLAY_FULL_X1 = 464;
SHOP_DISPLAY_FULL_Y1 = 42;
SHOP_DISPLAY_FULL_X2 = 481;
SHOP_DISPLAY_FULL_Y2 = 59;

SHOP_TAB_BUY_X1 = 41;
SHOP_TAB_BUY_Y1 = 46;
SHOP_TAB_BUY_X2 = 121;
SHOP_TAB_BUY_Y2 = 60;

SHOP_TAB_SELL_X1 = 139;
SHOP_TAB_SELL_Y1 = 48;
SHOP_TAB_SELL_X2 = 215;
SHOP_TAB_SELL_Y2 = 61;

(*
changeDisplay
~~~~~~~~~~~~~

.. code-block:: pascal

procedure changeDisplay(view : Integer);

Changes the shop display from either the Icon or Full view

.. note::

by Kyle Undefined

Example:
changeDisplay(SHOP_VIEW_FULL);
.. code-block:: pascal

*)
procedure changeDisplay(view : Integer);
var
b, c : Integer;
TPA : TPointArray;
tmpCTS : Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.34, 4.25);

case(view)of
SHOP_VIEW_ICON : begin
if(not(FindColorsSpiralTolerance(b, c, TPA, 5359090, SHOP_DISPLAY_ICON_X1, SHOP_DISPLAY_ICON_Y1, SHOP_DISPLAY_ICON_X2, SHOP_DISPLAY_ICON_Y2, 3)))then
MouseBox(SHOP_DISPLAY_ICON_X1, SHOP_DISPLAY_ICON_Y1, SHOP_DISPLAY_ICON_X2, SHOP_DISPLAY_ICON_Y2, mouse_Left);
end;

SHOP_VIEW_FULL : begin
if(not(FindColorsSpiralTolerance(b, c, TPA, 5359090, SHOP_DISPLAY_FULL_X1, SHOP_DISPLAY_FULL_Y1, SHOP_DISPLAY_FULL_X2, SHOP_DISPLAY_FULL_Y2, 3)))then
MouseBox(SHOP_DISPLAY_FULL_X1, SHOP_DISPLAY_FULL_Y1, SHOP_DISPLAY_FULL_X2, SHOP_DISPLAY_FULL_Y2, mouse_Left);
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

(*
setShopTab
~~~~~~~~~~

.. code-block:: pascal

procedure setShopTab(tab : Integer);

Sets the shop tab to either Buy or Sell

.. note::

by Kyle Undefined

Example:
setShopTab(SHOP_TAB_BUY);
.. code-block:: pascal

*)
procedure setShopTab(tab : Integer);
begin
case(tab)of
SHOP_TAB_BUY : MouseBox(SHOP_TAB_BUY_X1, SHOP_TAB_BUY_Y1, SHOP_TAB_BUY_X2, SHOP_TAB_BUY_Y2, mouse_Left);
SHOP_TAB_SELL : MouseBox(SHOP_TAB_SELL_X1, SHOP_TAB_SELL_Y1, SHOP_TAB_SELL_X2, SHOP_TAB_SELL_Y2, mouse_Left);
end;
end;

(*
chooseItem
~~~~~~~~~~

.. code-block:: pascal

procedure chooseItem(view, slot, clickType : Integer);

Chooses the item from the slot given, with a given view, and with a certain click

.. note::

by Kyle Undefined

Example:
chooseItem(SHOP_VIEW_ICON, 15, mouse_Move);
.. code-block:: pascal

*)
procedure chooseItem(view, slot, clickType : Integer);
var
b : TBox;
begin
changeDisplay(view);

case(view)of
SHOP_VIEW_ICON : b := GridBox(slot, SHOP_ICON_COL, SHOP_ICON_ROW, SHOP_ICON_W, SHOP_ICON_H, SHOP_ICON_DIFFX, SHOP_ICON_DIFFY, Point(SHOP_ICON_STARTX, SHOP_ICON_STARTY));
SHOP_VIEW_FULL : b := GridBox(slot, SHOP_FULL_COL, SHOP_FULL_ROW, SHOP_FULL_W, SHOP_FULL_H, SHOP_FULL_DIFFX, SHOP_FULL_DIFFY, Point(SHOP_FULL_STARTX, SHOP_FULL_STARTY));
end;

MouseBox(b.x1, b.y1, b.x2, b.y2, clickType);
end;

(*
chooseItemEx
~~~~~~~~~~~~

.. code-block:: pascal

procedure chooseItemEx(view, slot : Integer; opt : string);

Chooses the item from the slot given, with a given view, right clicks the item,
and chooses a given option

.. note::

by Kyle Undefined

Example:
chooseItemEx(SHOP_VIEW_ICON, 15, 'All');
.. code-block:: pascal

*)
procedure chooseItemEx(view, slot : Integer; opt : string);
begin
chooseItem(view, slot, mouse_Right);
Wait(RandomRange(500, 750));
ChooseOption(opt);
end;

(*
finishTransaction
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure finishTransaction;

Clicks the Buy/Sell/Take option

.. note::

by Kyle Undefined

Example:

.. code-block:: pascal

*)
procedure finishTransaction();
begin
MouseBox(454, 293, 492, 309, mouse_Left);
end;

Also, I updated the ShopScreen function, which is in amount.simba:

(*
ShopScreen
~~~~~~~~~~

.. code-block:: pascal

Function ShopScreen : Boolean;

Returns true if the shop screen is open.

.. note::

Author: ZephyrsFury
Last Modified: 4/16/2012 by Kyle Undefined

Example:

.. code-block:: pascal

if (ShopScreen) then
writeln('Shop screen is open!');
*)
Function ShopScreen : Boolean;
Begin
Result := FindTextTPA(12054007, 10, 54, 240, 172, 258, 'item', UpChars, Nothing);
End;

It seems that the Simba tags are messing with the comments for the functions. They lineup fine in Simba itself.

Here's my test code I've been using, if you want to use it.

program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/paintsmart.simba}
{$i srl/srl/misc/shop.simba}

begin
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;
SetupSRL();
ClearDebug();
SMART_ClearCanvas();

//SMART_DrawBoxEx(false, IntToBox(SHOP_DISPLAY_FULL_X1, SHOP_DISPLAY_FULL_Y1, SHOP_DISPLAY_FULL_X2, SHOP_DISPLAY_FULL_Y2), clRed);
//SMART_DrawBoxEx(false, IntToBox(SHOP_DISPLAY_ICON_X1, SHOP_DISPLAY_ICON_Y1, SHOP_DISPLAY_ICON_X2, SHOP_DISPLAY_ICON_Y2), clGreen);

//SMART_DrawBoxes(false, Grid(SHOP_FULL_COL, SHOP_FULL_ROW, SHOP_FULL_W, SHOP_FULL_H, SHOP_FULL_DIFFX, SHOP_FULL_DIFFY, Point(SHOP_FULL_STARTX, SHOP_FULL_STARTY)), clYellow);
//SMART_DrawBoxes(false, Grid(SHOP_ICON_COL, SHOP_ICON_ROW, SHOP_ICON_W, SHOP_ICON_H, SHOP_ICON_DIFFX, SHOP_ICON_DIFFY, Point(SHOP_ICON_STARTX, SHOP_ICON_STARTY)), clYellow);

//changeDisplay(SHOP_VIEW_FULL);
//setShopTab(SHOP_TAB_BUY);
//chooseItem(SHOP_VIEW_ICON, 15, mouse_Move);
//chooseItemEx(SHOP_VIEW_ICON, 15, 'All');
end.

Thanks for reading, and all ideas are appreciated! :)

begginer

2012-04-22 06:41:15

This would be cool. Well done till now.

Abu

2012-04-22 08:26:11

Very Good idea! I'll take a look at it properly later ;)

Olly

2012-04-22 09:43:51

Looks nice, not sure what script would buy/sell items to a shop but its handy to have. good work :)

xtrapsp

2012-04-22 13:14:36

we spoke about this :P Cause I said I really needed one for the new shop interface :P

Looks good!

sahibjs

2012-04-22 13:21:46

I could see this being used for some big time money making :)

very nice!

xtrapsp

2012-04-28 19:43:55

Just tried using it, It doesn't find the item? It darts about

Brandon

2012-04-28 20:53:19

I think you should call it Interface.Simba.. Other than that I like it.

The leprechaun interface when farming could be added I guess.

Kyle Undefined

2012-04-29 03:44:43

From: xtrapsp
Just tried using it, It doesn't find the item? It darts about


Hmm, well I haven't worked on it since I posted it. I honestly don't have the time. Feel free to edit it ;)

From: ggzz
I think you should call it Interface.Simba.. Other than that I like it.

The leprechaun interface when farming could be added I guess.


True, I had thought about this. Seems like a good idea.

xtrapsp

2012-04-29 05:16:17

From: Kyle Undefined
Hmm, well I haven't worked on it since I posted it. I honestly don't have the time. Feel free to edit it ;)



True, I had thought about this. Seems like a good idea.


Gotta learn about grids :P Will try tonight