Hi,
I suggest to replace current InvBox and ExistsItem -functions with below I've written. The current ones are over-complicated and doesn't even work. For instance, if you have coal bag in your inventory, current ExistsItem returns false.
Simba Code:
function InvBox(s: integer): TBox;
begin
if not InRange(s, 1, 28) then begin
result := IntToBox(-1, -1, -1, -1);
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(s), warn_AllVersions);
exit;
end;
Dec(s);
with result do begin
x1 := 559 + (s and 3) * 42;
y1 := 210 + (s shr 2) * 36;
x2 := x1 + 40;
y2 := y1 + 34;
end;
end;
function ExistsItem(s: integer): boolean;
var
b: TBox;
begin
GameTab(tab_Inv);
b := InvBox(s);
result := (CountColor(srl_outline_black, b.x1, b.y1, b.x2, b.y2) > 0);
end;