Kyle Undefined
2011-12-27 02:13:44
I have been wanting to do something like this ever since it was released, and I didn't see anyone attempt to do this. Here's my take on the ToolBelt. The functions find if an item is in your ToolBelt or not. It works rather well, I was surprised at how simple it was to make this. I'm sure the code can be cleaned up a bit.
Here's a test script I used while building it.
Hope you enjoy! :)
function toolBeltScreen() : Boolean;
begin
Result := (CountColorTolerance(1158880, 192, 18, 264, 33, 9) > 120);
end;
function itemSlotFilled() : Boolean;
var
TPA : TPointArray;
tmpCTS : Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.86, 0.06);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5855064, 211, 199, 298, 273, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := Length(TPA) > 0;
end;
procedure openToolBelt();
begin
MouseBox(691, 413, 732, 453, 1);
Wait(RandomRange(250, 750));
end;
procedure setCategory(Category : string);
var
catBox : TBox;
TPA : TPointArray;
tmpCTS : Integer;
begin
case(LowerCase(Category))of
'general' : catBox := IntToBox(161, 86, 188, 107);
'fishing' : catBox := IntToBox(219, 86, 246, 104);
'crafting' : catBox := IntToBox(275, 87, 305, 104);
'farming' : catBox := IntToBox(332, 88, 359, 105);
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.34, 0.80);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1810641, catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if(not(Length(TPA) > 0))then
MouseBox(catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 1);
end;
function checkToolBeltFor(Category, Tool : string) : Boolean;
var
I, catCount : Integer;
begin
if(not(toolBeltScreen()))then
openToolBelt();
setCategory(Category);
case(LowerCase(Category))of
'general', 'crafting' : catCount := 13;
'fishing' : catCount := 8;
'farming' : catCount := 5;
end;
for I := 1 to catCount do
begin
if(not(FindTextTpa(1158880, 9, 167, 146, 352, 161, Tool, SmallChars, Nothing)))then
begin
Mouse((375 + 397) / 2, (147 + 163) / 2, 1, 1, True);
Wait(RandomRange(250, 750))
end else
Break;
end;
Result := itemSlotFilled;
end;
Here's a test script I used while building it.
program toolBelt;
{$I SRL/SRL.scar}
function toolBeltScreen() : Boolean;
begin
Result := (CountColorTolerance(1158880, 192, 18, 264, 33, 9) > 120);
end;
function itemSlotFilled() : Boolean;
var
TPA : TPointArray;
tmpCTS : Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.86, 0.06);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5855064, 211, 199, 298, 273, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := Length(TPA) > 0;
end;
procedure openToolBelt();
begin
MouseBox(691, 413, 732, 453, 1);
Wait(RandomRange(250, 750));
end;
procedure setCategory(Category : string);
var
catBox : TBox;
TPA : TPointArray;
tmpCTS : Integer;
begin
case(LowerCase(Category))of
'general' : catBox := IntToBox(161, 86, 188, 107);
'fishing' : catBox := IntToBox(219, 86, 246, 104);
'crafting' : catBox := IntToBox(275, 87, 305, 104);
'farming' : catBox := IntToBox(332, 88, 359, 105);
end;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.34, 0.80);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1810641, catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 9);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if(not(Length(TPA) > 0))then
MouseBox(catBox.X1, catBox.Y1, catBox.X2, catBox.Y2, 1);
end;
function checkToolBeltFor(Category, Tool : string) : Boolean;
var
I, catCount : Integer;
begin
if(not(toolBeltScreen()))then
openToolBelt();
setCategory(Category);
case(LowerCase(Category))of
'general', 'crafting' : catCount := 13;
'fishing' : catCount := 8;
'farming' : catCount := 5;
end;
for I := 1 to catCount do
begin
if(not(FindTextTpa(1158880, 9, 167, 146, 352, 161, Tool, SmallChars, Nothing)))then
begin
Mouse((375 + 397) / 2, (147 + 163) / 2, 1, 1, True);
Wait(RandomRange(250, 750))
end else
Break;
end;
Result := itemSlotFilled;
end;
begin
SetupSRL();
ClearDebug();
if(GameTab(tab_Equip))then
GameTab(tab_Equip);
Wait(RandomRange(250, 750));
if(checkToolBeltFor('Fishing', 'Small'))then
WriteLn('Item is in Toolbelt!')
else
WriteLn('Item is NOT in Toolbelt!');
end.
Hope you enjoy! :)