Le Jingle
2012-08-18 23:57:34
How Long have You Played Runescape?
6 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
HTML, Pascalscript
Are you a member of any other communities?
No
Tell us about yourself…
Please show us one (or multiple) of your scripts.
6 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
HTML, Pascalscript
Are you a member of any other communities?
No
Tell us about yourself…
From: Le Jingle
I'm a first year university student (starting in 20 days), going into to the programming section of learning. I enjoy computer programming and watching Netflix. BTD5 and RS too, sometimes. I used to be an active outdoors man (hiking, rock climbing, frisbee), however with touching up on study before school, I don't find time for that now.
Please show us one (or multiple) of your scripts.
program VCG_Cook;
{$DEFINE SMART}
{$i srl/srl.simba}
{ *** Credits/Acknowledgements ***
Runaway's : TPA help/examples
Flight's : variable handles
Brandon's : updates
Harry's : login
Kyle's : git
Demise's : dtm guide
« AND » The SRL Community « !!! »
___-___-_________
}
{ * * * * * SETUP * * * * }
Const
SRLStats_User = '';
SRLStats_Pass = '';
Rs_Username = 'zezima';
Rs_Password = '123abc';
{ _____ Choose a Number, then fill it in 'The_Food' _____
1:Rocktails,
2:Cavefish,
3:Sharks,
4:Monkfish,
5:Swordfish,
6:Lobster,
7:Tuna
} The_Food = 1; { <-----
^
|
|
}
// Are you using strong urns? (True = Yes)
use_urns = true;
// Logout character if Random Event detected/found?
log_player = true;
{ Use the Random Tool, when a random is found?
- CANNOT use if 'log_player = true;'
- This will sound music and wait 1 minute until attempting to solve the random}
use_tool = false;
// Keep this TRUE, until you are familair with what needs to happen.
do_requirements = true;
// False = Good/Smooth Script, True = There's a problem, use to find out which.
ShowDebug = false;
{ * * * * * END SETUP * * * * }
{------------------------------------------------------------------------------
Anything beyond this point is for people who know what they are doing!!!
-------------------------------------------------------------------------------}
//Record to use for ease on loading cooking variables
type cook_r = record
name, uptext: string;
clvl, cxp, cdtm1, cdtm2, cdtm3: integer;
__r: tpoint;
end;
//Custom Variables:
var
cook_r_base: cook_r;
//Stats Variables:
CommitTime, Stats_RawFood, Stats_CookXP: integer;
//Report Variables:
StartOfScript, UrnT, Raw_C: integer;
//Other:
Version : String;
Strong_Urn : Integer;
procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0;
with Players[0] do
begin
Name := Rs_Username;
Pass := Rs_Password;
Active := True;
Integers[0] := 0;
Integers[1] := 0;
end;
end;
// Cancels the script, leaving an explanation as to why the script canceled.
procedure CancelScript(s:string);
begin
writeln(s);
terminatescript;
end;
// User defined, optional debug.
procedure LeDebug(s:string);
begin
if ShowDebug then
writeln(s);
end;
// User defined, optional Wav Download for random settings.
procedure WAVCheck;
var
count, Handle: Integer;
Page: String;
begin
count := 0;
if not FileExists(ScriptPath+'RandomSound.wav') then
count := 1;
if not FileExists('C:\Simba\Includes\MSI\MSI\RandomSound.wav') then
count := 1;
if (count=1) then
begin
LeDebug('downloading a .wav file from the MSI git (source): will alert if system tray sound = on!');
LeDebug('https://github.com/Kyle-Undefined/MSI/blob/master/MSI/RandomSound.wav');
Page := GetPage('https://github.com/Kyle-Undefined/MSI/blob/master/MSI/RandomSound.wav');
Handle := CreateFile(scriptpath+'randomsound.wav');
if WriteFileString(Handle, Page) then
LeDebug('Created a .wav file to use for the random tool extension.');
CloseFile(Handle);
end else
LeDebug('you have a .wav file, good! (no download required)');
end;
// Clears X'able windows from the RS mainscreen
// (close all windows doesn't close this screen)
function _x_Closer(): boolean;
var
x, y: integer;
summer_fun: integer;
begin
result := false;
// *** The X by itself ***
summer_fun := BitmapFromString(8, 8, 'meJxjYMAJUk/8RubabXwHZ0ee/gsV' +
'3PkDTZfHib8OB/9imgYUtNn+BU0Qrt1o+mm4oOX6p8hqtBpW4XYjA' +
'wDXYBaq');
if findbitmaptolerancein(summer_fun, x, y, msx1, msy1, msx2, msy2, 15) then
begin
mouse(x, y, 3, 3, mouse_left);
result := true;
end;
freebitmap(summer_fun);
end;
procedure Closures;
begin
LeDebug('Checking mainscreen for RS pop-up''s.');
findnormalrandoms;
ExitSquealOfFortune();
_x_closer();
end;
// Checks the weapon slot for the Drawven Army Axe
function IsWearAxe: boolean;
var
i, t, x, y, color: Integer;
RBox: TBox;
colors: TIntegerArray;
WeapTPA: TPointArray;
begin
result := false;
if not LoggedIn then
Exit;
MarkTime(t);
if GameTab(tab_equip) then
begin
RBox := GetEquippedItemBounds(5);
WeapTPA := TPAfromBox(RBox);
colors := [3621758,5658714,4276547,3816252,3626594,4737354];
for i := 0 to High(WeapTPA) do
begin
if timefrommark(t)>15000 then
exit;
color := colors[i];
if FindColorsSpiralTolerance(x,y,WeapTPA,colors[i],RBox.x1,RBox.y1,RBox.x2,RBox.y2,5) then
begin
Result := True;
Break;
end;
end;
end;
end;
// Overviews requirements for the user.
// - Optional.
procedure Requirements;
begin
if do_requirements then
begin
LeDebug('Checking for gaunts, dwarven army axe + required tasks, and cooking level.');
gametab(tab_Stats);
if (getskilllevel(skill_cooking) >= cook_r_base.clvl) then
LeDebug('Cooking level checks out.')
else
cancelscript('cooking level is too low (check your food/level)... ciao!');
wait(random(1000));
if IsWearAxe then
LeDebug('Wearing the Axe... but no support for +3 Xp (yet)');
end else
WriteLn('No requirement checks preformed.');
end;
// Accounts for the login lag at the beginning of loading RS
// (basically a good buffer to start a script off with, IMO)
procedure LoginLag;
begin
Wait(RandomRange(500, 1000));
Closures;
CompassMovement(30, 150, false);
Wait(RandomRange(100, 1500));
MakeCompass('w');
SetAngle(SRL_ANGLE_HIGH);
Wait(RandomRange(400, 600));
Requirements;
end;
// The summation of some above procedures/functions, as well as setup
procedure LeSet;
begin
ClearDebug;
Version := '1.0.0.1';
if (SRLStats_User = '') Or (SRLStats_Pass = '') then
SetupSRLStats(1226, 'Anonymous', 'anon1337')
else
SetupSRLStats(1226, SRLStats_User, SRLStats_Pass);
ActivateClient;
DeclarePlayers;
LogInPlayer;
Wait(RandomRange(200, 6000));
loginlag;
if use_tool then
wavcheck;
if (log_player = true) and (use_tool = true) then
cancelscript('you cannot use both of these random settings: try again.');
MarkTime(CommitTime);
MarkTime(StartOfScript);
end;
// Login to help aid the ability of the script
procedure LeLogin;
var
t: integer;
begin
MarkTime(t);
while (not LoggedIn) do
begin
wait(500+Random(500));
if LoginPlayer then
begin
Wait(RandomRange(200, 6000));
closures;
loginlag;
break;
end;
wait(1000+random(500));
if (TimeFromMark(t)>=360000) then
begin
LeDebug('did not login after 6 minutes.. ciao');
terminatescript;
end;
end;
end;
// Random check that acts as a failsafe for being loggedin + adding reports to
// the Progress Report
function RandomChecker: boolean;
begin
Result := False;
if not LoggedIn then
LeLogin;
if FindNormalRandoms then
begin
Inc(Players[CurrentPlayer].Integers[0]);
writeln(' *** Found a Random Event *** ');
Result := True;
end;
end;
// Basic Information about supported fish
{
Raw rocktail; never stop burning -> stop buring @ 94 IF wearing cook gaunts
raw cavefish; "" ""
raw shark; "" ""
raw monkfish; stop buring @ 90 on a range, or 90 with cook gaunts (range/fire)
raw swordfish; stop burning = 86 (81 w/ gaunts)
raw lobster; stop burning = 74 (68 w/ gaunts)
raw tuna; stop burning = 64 (63 w/ gaunts)
}
// Loads the food type record variables to be used in the script.
procedure LoadFood(The_Food:integer);
{#:Food correlation
1:Rocktails, 2:Cavefish, 3:Sharks, 4:Monkfish, 5:Swordfish, 6:Lobster, 7:Tuna}
begin
if not inrange(The_Food, 1, 5) then
cancelscript('you didn''t enter a food value to cook (1-5).');
LeDebug('setting up the food information to use throughout the script');
case The_Food of
1:begin
with cook_r_base do
begin
name := 'Rocktail';
uptext := 'Use Raw rocktail -> Range';
clvl := 93;
cxp := 225;
cdtm1{Cook}:= DTMFromString('mVAEAAHicpc47DkBQEIXhYQGuKBQ3IV5LZAtWqSESQggS0fqLqZTXJN85zSkmFJEEKSxiRChQolI5Mt1aFcBgQ48BIybtDjNW7Lhw48GJBQfauiF9Z0b/cOX99L0XpsES/A==');
cdtm2{Raw} := DTMFromString('mfgEAAHicrcrNCkBAFMXxywso76JkYSMjifL+C1FK+YoSS/+pWSh25tbvdLodX0RSZEgQI0KAEBUKlIbu+cdeb2e06NBjwIQVzeM3YsGGAycu03eoWpHubx5pg2PJ+256DheA');
cdtm3{Burn}:= DTMFromString('mVAEAAHicpcnBCkBQEIXhYX/xihIpSt0FHtZGUkSUpOz8alaW7tR3zkwTiYhVJXKkqNFqv78KBRLEyHRvsKLHgBGT9owNJy7c2LHofaBDYAzp/xaSLjxH33kAy48W4g==');
__r := Point(4,7);
end;
end;
2:begin
with cook_r_base do
begin
name := 'Cavefish';
uptext := 'Use Raw cavefish -> Range';
clvl := 88;
cxp := 214;
cdtm1 := DTMFromString('mPwEAAHicpcjBBoBAFIXhW61SDEUMadMDDj3UvMWUSBGl3qh/cRdpOR2+czhGRGrVwKJFp2v1r1AiRwGDHhvCy4QFO07c6sKBFTNGeDfQaZSMjpX88MkDFJ4Oyg==');
cdtm2 := DTMFromString('maQEAAHicrcpBCkBQEMbxwQmcRaQk4kUWLuJKFk6ChfJKKW7kv5iFsnymft83UxOKSK5K1GjQo0Ord4UCBhkSRIiRwmJ+WbFgw44Dtzq1L92t/o3TQPpOAtKV94PPPFgIE4s=');
cdtm3 := DTMFromString('mVAEAAHicpcpRCkBQEIXhYQOs5pbFICmiJHmwOhSFKLEjv5onj+7Ud6ZTxxeRHAVqdGjRaK9Q6iZBiAgxUmTY0GPEgBkLdpy4cOt/+4EVk+4DY0j3N4+04Vj63gO7KhTT');
__r := Point(5,7);
end;
end;
3:begin
with cook_r_base do
begin
name := 'Shark';
uptext := 'Use Raw shark -> Range';
clvl := 80;
cxp := 210;
cdtm1 := DTMFromString('mVAEAAHicpc7NCkBQEIbhw/KgzoJioyR7t+Am3JmfopBEFsodetWsLI+p55uavsUYpVSEGCEMPNnvPUGKDDkKBPClpzGhQ4sGNy4cWNFjxIIdA2ZsOFFXJela0/KHLeen7zwqDw0G');
cdtm2 := DTMFromString('maQEAAHicrcq7CYBAEEXR1QbEWvyBIAYmworYz0YW4QcMFNZAELFFbzBGhuvAeQxvJlRKlahQo0CODCkSxIikf381GrTosGHCjBEDFuktDly4ZbdyX7HjRG8M6TsJSFfeDz7zAP2mEaQ=');
cdtm3 := DTMFromString('maQEAAHicrcpNCkBQFMXxxwZkWW9gC76ihIkBVuKjSJIUA2WH/oM7M3xu/U6d23GVUjlKZEgRI0KIABVqNGjho5B9IpsVA3p0GDHLf5c+YcGGEwcu3HjgaU3aRhzSlPWDz73dnxOy');
__r := Point(7,8);
end;
end;
4:begin
with cook_r_base do
begin
name := 'Monkfish';
uptext := 'Use Raw monkfish -> Range';
clvl := 62;
cxp := 150;
cdtm1 := DTMFromString('mVAEAAHicpctNCkBQFIbhy0yEGChKKQMLMTa2FYooil17b76R4XXqOb+d1BiTIUeBStXOCQJECBGjQYsaJTqsuGXGJLZfsOHQfdf+xKU6Dj3Zd+b++fJ++sYDOFgKuQ==');
cdtm2 := DTMFromString('mPwEAAHic42dgYLADYnsgdgViKyA2g2JTILYGYgeonCcQewOxHxAHAXEgENcBcSUQVyHheiBuAeJOKG4H4laoeBWUDRLP9rUBkkxkYfJ0QTAjBRgNAADwjAy8');
cdtm3 := DTMFromString('maQEAAHicrcrLCkBQFIXhw9DMC5ibeCOhXJKUlHKLEsVb+3ftmeGx61utWts3xpTIkSJGggwFarSo0KDDiAGr6rFhVtIP3HiU9EnJz4Idp24XojAgXSseacv5wededj0RCA==');
__r := Point(5,5);
end;
end;
5:begin
with cook_r_base do
begin
name := 'Swordfish';
uptext := 'Use Raw swordfish -> Range';
clvl := 45;
cxp := 140;
cdtm1 := DTMFromString('m6wAAAHic42ZgYBAGYkkglgNiRSAWAWJ+IBaFigsAMR8QiwNxJBAHQnEolE4C4lioXASU7QfEZcG1QJKJKMwPtZMYzEgCRgIANMgGww==');
cdtm2 := DTMFromString('mFQEAAHic42VgYLADYmcgdoDSHkDsDcS+QGwPxDZAbA7EFkBsBeVHAHEgEPsDcSSUHQoVjwXieCBOgbJBYsFAvKBwJZBkIgnzA0lSMSMZGAUAACT8Cms=');
cdtm3 := DTMFromString('mAAEAAHic42FgYEgH4lwoLgHiMiAuAOIsIE4D4iQgTgXiTCBOAOIIIA4E4kggDgbicCjfH4hDgDgWqi4Wqs/a0hJIMhGN+YEkKZiRRIwMACb9Cqo=');
__r := Point(4,4);
end;
end;
6:begin
with cook_r_base do
begin
name := 'Lobster';
uptext := 'Use Raw lobster -> Range';
clvl := 40;
cxp := 120;
cdtm1 := DTMFromString('m6wAAAHiclcsxCoNAAETRNXamsBFEJcTKwkpBBUHs9ALe0XPmpUu5GXjT/WcIoaah403Fi5acgpKMhYGemZODnZGVjYn7+laPKKmPlfzhZx8uoATY');
cdtm2 := DTMFromString('mKgEAAHicncm5CYBQEIThVXNLsAEDUcEDHireR2QJ9t+EfzCJoW/gm4Wd2MxmmbDhwIUdp+6NDiN61KiQY8WCAU5biQwpWv0LeZqEDn+LaB+Bp29eNBkH6g==');
cdtm3 := DTMFromString('mAAEAAHic42FgYMgD4iIoXQzEJVBcAMQ5QJwBxYlAXAXEZkCsD8SGQGwKxJZAbA/ErkBsA+WD5IyAWAvENwPpYCIaswJJUjAjiRgZAAALWwjK');
__r := Point(3,4);
end;
end;
7:begin
with cook_r_base do
begin
name := 'Tuna';
uptext := 'Use Raw tuna -> Range';
clvl := 30;
cxp := 100;
cdtm1 := DTMFromString('m1gAAAHic42JgYBAHYkkozQfEykAsC8RyQMwDxIJALAzEokDMD8TyQCwCFZeCqgGJKUDl06MjgSQTQcwFJInBjERiBAAA6jADZQ==');
cdtm2 := DTMFromString('m6wAAAHic42ZgYHAEYmcgtgViSyA2BWIrIHYCYg8g9oViEFsUiPmBmA+IhYFYAogVgFgeiCWBWAwqB8ITu7uBJBNRmAtIEosZScBIAAAMPwX8');
cdtm3 := DTMFromString('mFQEAAHic42VgYMgG4hwgLgLiciAuBeJCIM6DyqUBcSIQxwNxMhCnA7EYEPMDMR8Ug/hSQCwLxPJArAClJYFYGKrG2tISSDKRhLmAJKmYkQyMAgDtMgf3');
__r := Point(5,7);
end;
end;
end;
LeDebug('Setup: DTM naming');
SetDTMName(cook_r_base.cdtm1, 'X Cooked DTM');
SetDTMName(cook_r_base.cdtm2, 'X Raw DTM');
SetDTMName(cook_r_base.cdtm3, 'X Burnt DTM');
if use_urns then
begin
Strong_Urn := DTMFromString('mfgEAAHicrc7NCkBQEIbhOWdn4SdFOkmKu3AtIgsWrCyEq/fKUcqSqWe+xXyLCUVk0iKjvnJHjRYrFnQYMFv9o9dgs71UiTgoESNCjgweXHu/O6cAiU2DApVJ+Up/5rP/oH7yngNe1ws4');
SetDTMName(Strong_Urn, 'Strong Urn DTM');
end;
writeln('Setup: Loaded our food, type: '+cook_r_base.name + '.');
end;
// Free the loaded food DTM's + the strong urn if using, @ the end of the script.
procedure FreeFood();
begin
FreeDTM(cook_r_base.cdtm1);
FreeDTM(cook_r_base.cdtm2);
FreeDTM(cook_r_base.cdtm3);
FreeDTM(Strong_Urn);
end;
// Loads the user defined random event settings
procedure RandomSettings;
begin
RandomChecker;
if log_player then
begin
CloseAllScreens;
Logout;
end;
if use_tool then
SetupRandomTool(60000, 5, scriptpath+'randomsound.wav');
end;
// Teleports a urn from a given slot in the inventory.
function SlotUrn(LeNumber: Integer): boolean;
begin
result := false;
if inrange(LeNumber, 1, 28) then
begin
case random(2) of
0..1: MouseTBox(InvBox(LeNumber), mouse_left);
2: begin MouseTBox(InvBox(LeNumber), mouse_right); WaitOption('eleport', 750); end;
end;
LeDebug('Teleported a Urn from Slot '+ToStr(LeNumber)+'.');
Result := True;
Exit;
end else
cancelscript('error: not in range @SlotUrn');
end;
// Finds the specific colors that signify the 'full urn,'
// which require specific counts of the color in a given space to be considered full.
// For 1 urn teleported, there's no chat interface that arises.
function FindUrnToTele: boolean;
var
x, y, dx, dy: Integer;
begin
result := false;
if not LoggedIn then
exit;
if FindColoredAreaTolerance(x, y, 5137749, 555, 210, 600, 245, 9, 27) and // Filled Urn area
FindColoredAreaTolerance(dx, dy, 1907518, 555, 210, 600, 245, 16, 15) then // Actual urn piece (so we're making sure its a urn too)
begin
SlotUrn(1);
Wait(RandomRange(1500, 2500));
end else
LeDebug('No teleport-able urns found in Slot 1.');
if FindColoredAreaTolerance(x, y, 5137749, 600, 210, 640, 245, 9, 27) and
FindColoredAreaTolerance(dx, dy, 1907518, 600, 210, 640, 245, 16, 15) then
begin
SlotUrn(2);
Wait(RandomRange(1500, 2500));
end else
LeDebug('No teleport-able urns found in Slot 2.');
Result := True;
end;
// Thanks for Runaway, giving the idea;
// Thanks to J J / beginner for the help on Global vars / memory stacking (respectively)
function BoxColThreshold(SlotFrom, SlotTo, LeColor, LeTol, LowCount: integer): integer;
var
i: integer;
temp: tbox;
begin
result := 0;
for i := SlotFrom to SlotTo do
begin
temp := invbox(i);
if (CountColorTolerance(LeColor,temp.x1,temp.y1,temp.x2,temp.y2,LeTol)>=LowCount) then
result := result+1;
Wait(10+Random(10));
end;
end;
// Wrapper to the BoxColThreshold function
function UrnsInInventory: integer;
begin
result := BoxColThreshold(1, 28, 1841724, 5, 70);
end;
// Opens the
function VCGBankQuiet(WhichBank:string): boolean;
var
TheCounter, dx, dy, tol, Mark2, Mark3: Integer;
acc, accthres: Extended;
begin
Result := False;
case WhichBank of
'vcga': TheCounter := BitmapFromString(6, 1, 'meJyzTe+0BSOn/ClmSVXOLm4AQRMGrA==');
'vcgb': TheCounter := BitmapFromString(12, 3, 'meJyLb18R377CNr0TjhzzJpklVTm7uAFRdNPCmObF8RhqnPKnoKlJ6l4b17YcjxogAgB+aCxF');
else
begin
srl_Warn('VCGBankQuiet', 'Unknown bank: ' + WhichBank, warn_AllVersions);
Exit;
end;
end;
MarkTime(Mark3);
tol := 1;
accthres := 0.6;
repeat
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen Or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
if WaitUpTextMulti(['ank', 'Bo', 'ot'], 1000) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, Mouse_Left);
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
LeDebug('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
FindDeformedBitmapToleranceIn(TheCounter, dx, dy, MSX1 + 50, MSY1 + 50, MSX2
- 50, MSY2 - 50, tol, 4, True, acc);
if (acc >= accthres) then
begin
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen Or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
MMouse(dx, dy, 0, 0);
if WaitUptextMulti(['ank', 'Bo', 'ot'], 1000) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, Mouse_Left);
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
LeDebug('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;
Wait(100);
tol := tol + 4;
if tol >= 20 then
begin
tol := 1;
accthres := accthres - 0.1;
if accthres < 0.2 then
begin
LeDebug('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
end;
until TimeFromMark(Mark3) > 60000;
FreeBitmap(TheCounter);
end;
// A custom function I designed;
// help from people on this thread: [url]http://villavu.com/forum/showthread.php?t=88487[/url]
function BestSaturatedBox(Colors: TIntegerArray; Tol: Integer): boolean;
var
hColors, hCollected: Integer;
i, ii, t: integer;
TempResult, TempGather: TPointArray;
CollectResArr: T2DPointArray;
MSArr, ClearFromMS: TPointArray;
SearchCols: TIntegerArray;
begin
result := false;
if not loggedin then
exit;
ClearFromMS := TPAFromBox(IntToBox(240, 130, 275, 185));
hColors := High(Colors);
SetLength(CollectResArr, Length(Colors));
hCollected := High(CollectResArr);
MarkTime(t);
for i := 0 to hColors do
begin
if FindColorsTolerance(MSArr, colors[i], MSX1, MSY1, MSX2, MSY2, tol) then // Finds the 1st indexed Color
begin
ClearTPAFromTPAWrap(MSArr, ClearFromMS, MSArr); // Clears any of the 1st indexed color from our Player's Box
TPAToATPAExWrap(MSArr, 50, 50, CollectResArr); //Make all occurences of the TPA to an ATPA, in which we want to save.
end;
for ii := 0 to hCollected do
begin
QuickATPASort(Colors, CollectResArr, 0, hCollected, false);
TempResult := CollectResArr[ii];
SortTPAFrom(TempResult, Point(90,270{MSX1, MSY2}));
writeln(tempresult);
if (Length(TempResult) < 1) then
begin
writeln('not enough matches');
break;
end
else
begin
MMouse(TempResult[ii].x, TempResult[ii].y, 5, 5);
ClickMouse2(Mouse_Right);
WaitOption('nk Ba', 1500);
Result := True;
Exit;
end;
end;
end;
end;
// Custom banking failsafe, so there's 4 possibly ways to attempt @ opening the
// VCG bank booth.
function EditBankVCG(WhichBank: Variant; ChangeCompass, ChangeAngle: Boolean): boolean;
var
i: Integer;
begin
Result := False;
if BankScreen then
begin
Result := True;
Exit;
end;
if (varType(WhichBank) = varInteger) then
if (OpenBankChest(WhichBank)) then
begin
Result := true;
Exit;
end;
for i := 0 to 3 do
begin
case i of
0: Result := BestSaturatedBox([{15132400,}1184275,4137771,
7576523,3362139,1930439], 5);
1: Result := OpenBankFast('cg');
2: Result := VCGBankQuiet('vcga');
3: Result := VCGBankQuiet('vcgb');
end;
if Result then
Exit;
end;
end;
// A forwarded function to help banking.. Used in the forwarded function for
// redundancy
function Restock: boolean; forward;
function BankStuff: boolean;
var
Fails, MarkFailsT: Integer;
begin
Result := False;
RandomChecker;
MarkTime(MarkFailsT);
repeat
if Fails > 5 then
Break;
if (TimeFromMark(MarkFailsT)>=45000) then
Break;
IncEx(Fails, 1);
EditBankVCG('vcga', False, False);
until(BankScreen) or (PinScreen);
if (BankScreen) or (PinScreen) then
begin
if (PinScreen) then
InPin(Players[CurrentPlayer].Pin);
Restock;
Wait(RandomRange(100, 300));
Result := True;
end;
end;
// Stats Committing, idea from flightt, to send in the information at once,
// as well as resetting the data vars.
procedure StatsCommit;
begin
LeDebug('Sending EXP tracks of the skill we are training! (Scripters appreciate this!)');
Stats_RawFood := 26;
Stats_CookXP := cook_r_base.cxp * 26;
Stats_IncVariable(cook_r_base.name + ' Cooked', Stats_RawFood);
Stats_IncVariable('Cooking EXP (Gained)', Stats_CookXP);
Stats_Commit;
Stats_RawFood := 0;
Stats_CookXP := 0;
MarkTime(CommitTime);
end;
// A function that counts the DTM in the bankscreen.
// (Not to be confused with the inventory CountDTM function.
function CountDTM(aDTM, failsafe: integer): Integer;
var
x, y: integer;
bbox: tbox;
begin
result := 0;
if not loggedin then
exit;
if findDTM(aDTM, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
bbox := PointToBox(Point(x-20,y-20), Point(x+20,y+20));
result := GetAmountBox(bbox);
end;
if result < failsafe then
cancelscript('out of raw '+cook_r_base.name+' materials. Ciao');
end;
// Restocks the supplies for cooking raw fish.
function Restock: boolean;
var
FoodStack, UrnStack: string;
a, b, x, y, r_dep: integer;
begin
Result := False;
RandomChecker;
if (pinscreen) then
inpin(Players[CurrentPlayer].Pin);
if (BankScreen) then
begin
r_dep := 3+random(25);
deposit(r_dep, 28, true);
wait(RandomRange(100, 300));
if use_urns then
begin
if (UrnsInInventory = 1) then
begin
LeDebug('Always need 2 Urns in our inventory; withdrawing 1.');
UrnStack := IntToStr(countDTM(Strong_Urn, 2));
writeln('Have: '+UrnStack+' Urns left in the bank.');
if finddtm(Strong_Urn, a, b, MSX1, MSY1, MSX2, MSY2) then
mouse(a, b, 10, 10, mouse_left);
end;
end;
LeDebug('Time to get more food.');
FoodStack := IntToStr(countDTM(cook_r_base.cdtm2, 22));
writeln('Have: '+FoodStack+' raw '+cook_r_base.name+' left in the bank.');
if finddtm(cook_r_base.cdtm2, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
mouse(x, y, 10, 10, mouse_right);
waitoption('raw-All', 1500);
end;
Wait(Random(1000));
CloseBank;
StatsCommit;
Result := True;
Exit;
end;
GameTab(Tab_Inv);
FindUrnToTele;
RandomChecker;
BankStuff;
end;
// Clicks the chat to cook. Basic, simple, and allows for to be used.
function ClickChatToCook: boolean;
var
x, y: integer;
begin
result := false;
if not loggedin then
exit;
if WaitFindDTMEx(cook_r_base.cdtm2, x, y, MCX1, MCY1, MCX2, MCY2, 250, 5000) then
begin
mouse(x, y, 20, 20, mouse_left);
result := true;
end;
end;
// Antiban that helps to prevent being banned.. Also keeps track of the movements
// preformed & records the preformed actions to the Report;
procedure LeAntiban;
begin
if not LoggedIn then
Exit;
RandomChecker;
case Random(500) of
1..25:
begin
LeDebug('[Antiban] Preforming a Random Right Click.');
RandomRClick;
Inc(Players[CurrentPlayer].Integers[1]);
end;
26:
begin
LeDebug('[Antiban] Preforming a Hover Skill Cooking.');
HoverSkill('Cooking', False);
Inc(Players[CurrentPlayer].Integers[1]);
end;
27:
begin
LeDebug('[Antiban] Preforming a Hover Skill Random.');
HoverSkill('Random', False);
Inc(Players[CurrentPlayer].Integers[1]);
end;
30..35:
begin
LeDebug('[Antiban] Preforming a Pickup Mouse.');
PickupMouse;
Inc(Players[CurrentPlayer].Integers[1]);
end;
36..40:
begin
LeDebug('[Antiban] Preforming an Examine Inventory.');
ExamineInv;
Inc(Players[CurrentPlayer].Integers[1]);
end;
end;
Wait(RandomRange(10, 150));
end;
// Runaway's function. This code works great in finding specific range color
// clusters. I plan to create my own function after I begin programming classes
// and better understand this functionality. Or if I can teach myself thoroughly,
// the concepts, and understand them to the extent I have No Doubts.
Var
Colors, Area: array of Integer;
Arr: array of TPointArray;
SortFrom: TPoint;
MaxDist, Tol: Integer;
FilterArr, TrimArr: Integer;
x, y: Integer;
a: Integer;
RangeT: Integer;
function FindTPACluster(Colors: TIntegerArray; Tol: Integer; SortFrom: TPoint; Filter, Trim: Integer; MinDist, MaxDist: Extended; Strict: Boolean; x1, y1, x2, y2: Integer): array of TPointArray;
var
TPA, Res: TPointArray;
aPoints: array of TPointArray;
Dist: array of Extended;
Which: array of Integer;
hDist, hPoints, hColors: Integer;
Error, Len: Integer;
d, t: Integer;
w, ww: Integer;
r: Integer;
i, ii, iii: Integer;
Match, Count: Integer;
Duplicate: Boolean;
begin
MarkTime(t);
SetLength(aPoints, Length(Colors));
hColors := High(Colors);
Error := 0;
r := 0;
for i := 0 to hColors do
begin
if (FindColorsTolerance(TPA, Colors[i], x1, y1, x2, y2, Tol)) then
begin
SortTPAFrom(TPA, SortFrom);
if (Filter <> -1) then
FilterPointsDist(TPA, 0, Filter, SortFrom.x, SortFrom.y);
if (Trim <> -1) and (Length(TPA) > Trim) then
SetLength(TPA, Trim);
aPoints[i - Error] := TPA;
end else
begin
if Strict then
begin
LeDebug('Error: not enough colors found!');
Exit;
end;
Len := Length(aPoints) - 1;
SetLength(aPoints, Len);
Inc(Error);
end;
if (Error >= hColors) then
begin
LeDebug('Error: not enough colors found!');
Exit;
end;
end;
SetLength(Dist, Length(aPoints) - 1);
SetLength(Which, Length(aPoints) - 1);
hPoints := High(aPoints);
hDist := High(Dist);
for i := 0 to hPoints do
begin
Count := 0;
for w := 0 to hDist do
begin
if (hPoints - w = hPoints - i) or (hPoints - w < hPoints - i) then
Which[w] := w + 1
else
Which[w] := w;
end;
for ii := 0 to High(aPoints[i]) do
begin
Match := 0;
for iii := 0 to hDist do
begin
if (Count > High(aPoints[Which[iii]])) then
begin
Inc(Count);
Break;
end;
Dist[iii] := Distance(aPoints[i][ii].x, aPoints[i][ii].y, aPoints[Which[iii]][Count].x, aPoints[Which[iii]][Count].y);
if (Dist[iii] >= MinDist) and (Dist[iii] <= MaxDist) then
Inc(Match)
else
begin
Inc(Count);
Break;
end;
end;
if (Match >= hPoints) then
begin
SetLength(Res, Length(aPoints));
Res[0] := aPoints[i][ii];
for ww := 0 to hDist do
Res[ww + 1] := aPoints[Which[ww]][Count];
SortTPAByX(Res, True);
if (Length(Result) > 1) then
begin
Duplicate := False;
for d := 0 to High(Result) do
begin
if (Result[d] = Res) then
Duplicate := True;
end;
if Duplicate then
begin
Inc(Count);
Continue;
end;
end;
SetLength(Result, r + 1);
Result[r] := Res;
Inc(r);
Res := [];
end;
Inc(Count);
end;
end;
LeDebug('Took: '+IntToStr(TimeFromMark(t))+' ms, found '+IntToStr(Length(Result))+' unique cluster(s)');
end;
// Declares the var's for the TPA Cluster func.
// much cleaner to delcare here rather than bunch up into 1 function..
procedure Declare;
begin
// Red 1st, then light grey
Colors := [1911500, 2241005, 1845704, 1845702, 1779904, 10726315, 10528679, 10857644, 10397350, 10331300];
Tol := 40; // Tolerance on each color
MaxDist := 30; // Maximum distance between each color
Area := [275, 75, 405, 215];
SortFrom := Point(340, 146); // Point to sort each TPA from
FilterArr := -1; // Max distance from SortFrom (-1 to ignore)
TrimArr := -1; // Max TPA size (-1 to ignore)
end;
// Function-ized, as so told via Runaway.
Function DoWork(MaxTries: Integer): Boolean;
Var
Tries: Integer;
Box: TBox;
Begin
Declare;
Box := IntToBox(44, 345, 52, 357);
Tries := 0;
Repeat
Arr := FindTPACluster(Colors, Tol, SortFrom, FilterArr, TrimArr, 0, MaxDist, True, Area[0], Area[1], Area[2], Area[3]);
MarkTime(RangeT);
For a := 0 To High(Arr) Do
Begin
x := MiddleTPA(Arr[a]).x;
y := MiddleTPA(Arr[a]).y;
Mouse(x, y, 3, 3, Mouse_Move);
If WaitUptextMulti(['ang', 'nge'], 500) Then // Uptext check is a great failsafe
begin
ClickMouse2(Mouse_Left)
result := didredclick;
exit;
end
Else
Continue;
If DidClick(False, 1250) Then
Begin
Result := True;
Wait(RandomRange(1500, 2500));
Exit;
End;
If FindColorTolerance(x, y, 16777215, 44, 345, 52, 357, 15) Then // Searches for white chat interface text.
Begin
Result := True;
Exit;
End;
If (a >= 2) Then // Breaks from the current set of clusters since the greater a gets, the less
Break; // likely the cluster you're checking is the one you're searching for.
End;
If (TimeFromMark(RangeT)>=30000) Then
Begin
LeDebug('Fail: Either 1. Cannot Locate Range or ' +
'2. Cannot find the chatbox to cook food.');
TerminateScript;
End;
Inc(Tries);
Until(Tries > MaxTries);
End;
// Wrapper func for checking the items to cook.
function CheckTails: Boolean;
var
r, Raw: Integer;
begin
result := false;
if not LoggedIn then
Exit;
r := RandomRange(5, 20);
if not (bankscreen) or (pinscreen) then
begin
gametab(tab_inv);
Raw := CountItems('dtm', cook_r_base.cdtm2, []);
if (Raw = 26) Then
begin
Result := True;
Exit;
end;
end;
end;
// returns the last cooked item.
function FoundLastCooked: integer;
var
Cooked: Integer;
begin
result := 0;
if not LoggedIn then
Exit;
GameTab(Tab_Inv);
Cooked := CountItems('dtm', cook_r_base.cdtm1, []);
if (Cooked = 26) then
Result := 1;
Wait(RandomRange(1000, 1500));
end;
// detailed progress report.
procedure Report;
var
OurXP: longint;
UrnsXP: integer;
begin
if use_urns then
begin
case random(2) of
1: UrnsXP := 1547;
2: UrnsXP := 1548;
end;
end;
OurXp := Round((Raw_C * 225) + (UrnT * UrnsXP));
ClearDebug;
WriteLn('Time Ran : '+MsToTime(Integer(GetTimeRunning),Time_Formal));
WriteLn('Raw '+cook_r_base.name+' Cooked : '+IntToStr(Raw_C));
WriteLn('Gained Cook Xp : '+ToStr(OurXp));
WriteLn('Urns Teleported : '+ToStr(UrnT));
WriteLn('Random Events : '+ToStr(Players[CurrentPlayer].Integers[0]));
WriteLn('Antiban''s Done : '+ToStr(Players[CurrentPlayer].Integers[1]));
end;
// all of the functions combined into a loop
procedure MainLoop;
var
InvS: Integer;
begin
if not LoggedIn then
lelogin;
RandomChecker;
if not (rs_GetCompassAngleDegrees = 270) then
MakeCompass('W');
Report;
if CheckTails then
begin
InvMouse(RandomRange(3, 27), Mouse_Left);
DoWork(5);
Wait(RandomRange(500, 750));
if WaitFindDTMEx(cook_r_base.cdtm2, x, y, MCX1, MCY1, MCX2, MCY2, 250, 5000) then
mouse(x, y, 20, 20, mouse_left);
MarkTime(InvS);
repeat
FindNormalRandoms;
LeAntiBan;
FoundLastCooked;
Wait(RandomRange(1000, 2000));
until(TimeFromMark(InvS)>=85000) or (FoundLastCooked = 1);
FindUrnToTele;
IncEx(Raw_C, 26);
LeDebug('Time to restock!');
BankStuff;
end else
BankStuff;
end;
// the real main loop ;)
// optional smart user, repeats the main loop,
// free's the food if we end the script.
begin
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
SRL_Procs[SRL_OnFindRandom] := @RandomSettings;
SetupSRL;
AddOnTerminate('FreeFood');
leset;
LoadFood(The_Food);
repeat
mainloop;
report;
until(not(loggedin));
writeln('Script Ended: '+MsToTime(StartOfScript, Time_Formal));
FreeFood();
end.