SRL Archive - Test corner

Fix for Counting stacks


Mr. Freeweed

2007-12-26 12:53:36

Edit: Counts money stacks, inventory, trades //yours and mine, shops PERFECT!!!!!!

I dont ussually make scripts that count stacks but I noticed srl doesnt work very well maybe due to updates so…

I fixed inventory counting. I ussually completely mod srl to my own purposes and dont share but since these couple functions mess up everything in amout.scar I thought it would be good to share.

Also you will need to replace a fontchar instructions below

{*******************************************************************************
procedure AreaInfo(area: String; var startx, starty, rowsize, colsize, colnumber, rownumber: Integer);
By: masquerader || Fixed by Mr. Freeweed
Description: Returns info on certain interfaces.
Example: row and col ammounts, startcoords, sizes for inventory, bans, shop, ...
*******************************************************************************}

procedure AreaInfo(area: string; var startx, starty, rowsize, colsize,
colnumber, rownumber: Integer);
begin
case LowerCase(area) of
'inv', 'inventory':
begin
startx := 560;
starty := 212;

rowsize := 36;
colsize := 42;

colnumber := 4;
rownumber := 7;
end
'shop':
begin
startx := 63;
starty := 97;

rowsize := 55;
colsize := 39;

colnumber := 10;
rownumber := 4; //?
end;
'bank':
begin
startx := 78;
starty := 61;

rowsize := 38;
colsize := 47;

colnumber := 8;
rownumber := 6;
end;
'trade':
begin
startx := 310;
starty := 75;

rowsize := 32;
colsize := 49;

colnumber := 4;
rownumber := 7;
end;
'your trade':
begin
startx := 24;
starty := 75;

rowsize := 32;
colsize := 49;

colnumber := 4;
rownumber := 7;
end;
else InvalidOption(area);
end;
end;

{*******************************************************************************
function GetAmount(itemx, itemy: Integer): Integer;
By: masquerader || Improved by Freddy1990 ||Updated June 4 2007 by Boreas || Fixed by Mr. Freeweed
Description: Returns the ammount of an item at a certain position.
*******************************************************************************}

function GetAmount(itemx, itemy: Integer): Integer;
//uses font cropped to work with "Opponent's Offer"
//you can get the coords from using IsTextInAreaEx w/ StatChars, but
//you probably shouldnt use this function directly (other functions use it)
//'K' and 'M' work (for approx values)
//non-stackable =1
//blank = 0
var
amountstr: string;
tempx, tempy, color: Integer;
begin
if findcolor(tempx, tempy, 65535, itemx, itemy, itemx + 10, itemy + 10) then
color := 65535;
if color = 0 then
if findcolor(tempx, tempy, 16777215, itemx, itemy, itemx + 10, itemy + 10) then
color := 16777215;
if color = 0 then
if findcolor(tempx, tempy, 8453888, itemx, itemy, itemx + 10, itemy + 10) then
color := 8453888;
amountstr := TrimOthers(GetTextAtEx(itemx, itemy + 4, 0, tradeChars, False, False, 0, 2, color, 10, True, tr_AlphaNumericChars));
if (Length(amountstr) > 0) then
begin
if (Pos('K', amountstr) > 0) then
begin
Delete(amountstr, Length(amountstr), Length(amountstr));
Result := StrToInt(amountstr) * 1000;
end else
if (Pos('M', amountstr) > 0) then
begin
Delete(amountstr, Length(amountstr), Length(amountstr));
Result := StrToInt(amountstr) * 1000000;
end else
Result := StrToInt(amountstr);
end else
if (FindColor(tempx, tempy, 65536, itemx, itemy, itemx + 30, itemy + 30)) then
Result := 1;
end;



Pm me If you think Im nuts and also replace 48 in font charstrade with bmp below

Pyro

2007-12-26 20:57:54

Wait so your sure these now work perfect? If so ill commit em for you.

Mr. Freeweed

2007-12-27 03:11:53

From: Pyro
Wait so your sure these now work perfect? If so ill commit em for you.


It now works perfect!!!!

Its ready to be Implemented into SRL and all amount.scar functions will work again =)

Sincerely
Mr. Freeweed

Pyro

2007-12-28 03:29:55

Alright then. Added. I kept your names in the headers… Not so sure about it. But you get them for now.

mastaraymond

2007-12-28 12:03:15

When i edited the 0, it was working perfect to. Without any changes :p

Mr. Freeweed

2007-12-28 14:51:58

Problem with just editing the zeros is that all but banking coords have changed and with the change i put in text reading you can read the full amount of cash you are looking for