Smidqe
2013-03-07 13:05:55
How Long have You Played Runescape?
7 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
Visual basic, Pascal, basics of HTML
Are you a member of any other communities?
Yes,
Dreamviews, RaceDepartment, Steam and some forums I can't remember.
Username for all of these is Smidqe, which is the same username I use here. So if you see username Smidqe on some forum, there's a high chance that it's me.
Tell us about yourself…
Please show us one (or multiple) of your scripts.
7 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
Visual basic, Pascal, basics of HTML
Are you a member of any other communities?
Yes,
Dreamviews, RaceDepartment, Steam and some forums I can't remember.
Username for all of these is Smidqe, which is the same username I use here. So if you see username Smidqe on some forum, there's a high chance that it's me.
Tell us about yourself…
From: Smidqe
Name's Miikka and I'm 18 years old. I live in southern Finland with my family, though I'll be leaving this summer since I have need to go to army.
Currently my hobbies are gaming and metal detecting. Thanks to my uncle I got excited from metal detecting two years ago. It's just so exciting to find old coinage, but it's also fun to find modern currency and jewelry (it's also profitable).
I am currently preparing for my matriculation exams which will start next week. After those I'll try to get to the university (LUT), I really wish that I could get there only with my matriculation exam grades (mainly mathematics, physics and chemistry). I haven't decided what subject I'll take, but I think that I'll go with the IT, after all I've used computers since I was a small kid.
Please show us one (or multiple) of your scripts.
program AK_Cooker;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/debug.simba}
{$IFDEF SMART}
{$i srl/srl/misc/smartGraphics.simba}
{$ENDIF}
(*
______________________________________________________________________
| Instructions: |
|____________________________________________________________________|
| ~ I prefer that you would keep it at scripts folder, for easier |
| to find the debug log |
| ~ Comment {DEFINE SMART} if you don't want to use SMART with |
| this script |
| ~ Fill player details |
| ~ Supported fishes: 'shrimp', 'anchovies', 'trout', 'salmon' |
| 'pike', 'lobster', 'swordfish', 'crayfish', 'sardine', |
| 'herring' |
| |
| ~ Set maximum runtime (put 0 if you want it to go forever) |
| ~ Set breaking times and their lengths |
| |
| ~ Push play |
| ~ Remember to watch it for couple first loops, for any bugs |
|____________________________________________________________________|
| What to do if you find a bug: |
|____________________________________________________________________|
| ~ Post the debug log or part of it, it is in the same folder |
| ~ Describe the bug if possible, debug log may not be enough |
| ~ Please, no "it's not working, please fix it" type of posts |
| I prefer more detailed ones, as they help me to find the bug |
| and perhaps fix it faster. |
|____________________________________________________________________|
| Couple words: |
|____________________________________________________________________|
| ~ I'm not responsible for any bans you may encounter so don't come |
| to thread and complain about it. |
| |
| ~ Feel free to post suggestions to this script |
| |
| ~ Credits: |
| ~ WT-Fakawi: DDTM anchoring tutorial, and functions used here, |
| look DDTMRelocate, grabColor and initDDTM |
| ~ MSI and its writers: For the filewriting function, |
| look writeDebug and setupScript |
| ~ Community: For such an atmosphere where you really |
| want to learn |
|____________________________________________________________________|
*)
(*~ Here are the constants used in DeclarePlayer and in progress report ~*)
const
PLAYER_BTIME = 0;
PLAYER_BREAK = 1;
PLAYER_TTIME = 2;
PLAYER_BREAKS = 3;
PLAYER_LOADS = 4;
PLAYER_EXP = 5;
PLAYER_ITEM = 0;
(*~~*)
const
takeBreaks = true;
saveDebug = true;
paintSmart = true;
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Change to amount of players wanted
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //0 is the first player as it goes like this 0, 1, 2..
with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // Nickname, 3-4 letters (Used for progress reports)
Active := True; // Using this player?
Pin := ''; // Leave blank if you dont have a bank pin
Integers[PLAYER_TTIME] := 500; // Total time (in minutes)
Integers[PLAYER_BREAK] := 90; // Breaking or switching after x minutes
Integers[PLAYER_BTIME] := 20; // Time to break, +- random 3 minutes
Strings[PLAYER_ITEM] := 'lobster'; // Food to cook
end;
{
with Players[1] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // Nickname, 3-4 letters (Used for progress reports)
Active := True; // Using this player?
Pin := ''; // Leave blank if you dont have a bank pin
Integers[PLAYER_TTIME] := 500; // Total time (in minutes)
Integers[PLAYER_BREAK] := 90; // Breaking or switching after x minutes
Integers[PLAYER_BTIME] := 20; // Time to break, +- random 3 minutes
Strings[PLAYER_ITEM] := 'trout'; // Food to cook
end;
with Players[2] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // Nickname, 3-4 letters (Used for progress reports)
Active := True; // Using this player?
Pin := ''; // Leave blank if you dont have a bank pin
Integers[PLAYER_TTIME] := 500; // Total time (in minutes)
Integers[PLAYER_BREAK] := 90; // Breaking or switching after x minutes
Integers[PLAYER_BTIME] := 20; // Time to break, +- random 3 minutes
Strings[PLAYER_ITEM] := 'trout'; // Food to cook
end;
}
end;
type
TObj = record
Name : string;
Color : TIntegerArray;
Tol : TIntegerArray;
UpTexts : TStringArray;
Width : integer;
Height : integer;
end;
type
TFish = record
Name : string;
EXP : integer;
DTM : Integer;
end;
var
reason : TstringArray;
nextBreak, areaDDTM, debugLog, curLoc : integer;
fish : TFish;
const
OBJECT_BANK = 0;
OBJECT_RANGE = 1;
LOC_LOST = -1;
LOC_BANK = 0;
LOC_RANGE = 1;
OUTLINE_COLOR = 15856882;
OUTLINE_TOLERANCE = 18;
OPTIONBOX_COLOR = 16711422;
OPTIONBOX_TOLERANCE = 1;
MM_RANGE_WIDTH = 17;
MM_RANGE_HEIGHT = 21;
MM_RANGE_MIN_PIXELS = 35;
MM_RANGE_MAX_PIXELS = 100;
COOKBOX_X1 = 260;
COOKBOX_Y1 = 304;
COOKBOX_X2 = 483;
COOKBOX_Y2 = 324;
const
scriptVersion = 1.5;
procedure setupItem(load : boolean); forward;
function findCookbox: boolean; forward;
(*~ Writes given string to a txt file, credits to MSI and its writers ~*)
procedure writeDebug(what: string);
begin
WriteLn(what);
if saveDebug then
try
if (debugLog <> -1) then
if (not WriteFileString(debugLog, '[' + Players[CurrentPlayer].Name + ']: ' + what + #13 + #10)) then
writeLn('[writeDebug]: Failed to write to the log');
except
Writeln('[writeDebug]: ' + ExceptionToString(ExceptionType, ExceptionParam));
end;
end;
(*~ Gets the colors for DDTM, credits for WT-Fakawi for his tutorial ~*)
function grabColor(what: string; min, max : integer): integer;
var
arr: tPointArray;
begin
case what of
'dead': findColorsTolerance(arr, 993849, MMX1, MMY1, MMX2, MMY2, 8);
'cactus': findCOlorsTolerance(arr, 3567433, MMX1, MMY1, MMX2, MMY2, 13);
'ladder': findColorsTolerance(arr, 471898, MMX1, MMY1, MMX2, MMY2, 8);
'rock': findColorsTolerance(arr, 2380165, MMX1, MMY1, MMX2, MMY2, 8);
end;
writeLn('[grabColor]: Length(' + what + '): ' + intToStr(length(arr)));
if (length(arr) > 0) then
if (inRange(length(arr), min, max)) then
result := GetColor(arr[0].x, arr[0].y)
else
writeDebug('[grabColor]: Color is out of range')
else
writeDebug('[grabColor]: Colour was not found, perhaps need updating?');
end;
procedure getBorders(var res : TPointArray);
var
p : TPoint;
arr : TPointArray;
begin
if FindColorsSpiralTolerance(p.x, p.y, arr, OUTLINE_COLOR, MMX1, MMY1, MMX2, MMY2, OUTLINE_TOLERANCE) then
clearTPAFromTPAWrap(arr, getMinimapDots('player'), res)
else
res := [];
if (length(res) <= 1) then
writeDebug('[findBorders]: Colour outdated, inform this in the thread!');
end;
procedure switchPlayer(usable : Boolean);
begin
writeDebug('[switchPlayer]: Player switching initiated');
freeDTM(areaDDTM);
setupItem(false);
if usable then
nextPlayer(true)
else
nextPlayer(false);
writeDebug('[switchPlayer]: Player switching finished, last player: ' + boolToStr(usable));
end;
function waitUntilMoving: boolean;
var
f : integer;
begin
result := false;
f := getSystemTime + 10000;
while (not isMoving) do
begin
if f < getSystemTime then
break;
wait(randomRange(210, 340));
end;
result := isMoving;
end;
function initObjects(obj : integer): TObj;
begin
case obj of
OBJECT_BANK:
with result do
begin
Name := 'Bank booth';
Color := [5595504, 7173503];
Tol := [3, 5];
UpTexts := ['ank', 'ooth'];
Width := 25;
Height := 30;
end;
OBJECT_RANGE:
with result do
begin
Name := 'Range';
Color := [4283087, 10069424];
Tol := [10, 5];
UpTexts := ['Range', 'Use']; //for chooseOPtion!
Width := 10;
Height := 10;
end;
end;
end;
function initFish: TFish;
begin
with Players[CurrentPLayer] do
case Lowercase(Strings[PLAYER_ITEM]) of
'shrimp':
with Result do
begin
Name := 'Shrimps';
DTM := DTMFromString('mggAAAHicY2NgYIhgYWDIBOI4IA4F4jQgDgHipYwMDLOBeAOUXgnEq4C4Nd4LqIsJA3MxYAeMODAEAADRSwd5');
EXP := 30;
end;
'crayfish':
with result do
begin
Name := 'Crayfish';
DTM := DTMFromString('mggAAAHicY2NgYGhnYWDoAuI2IK4B4mlAPAmIa5kYGPKAuBOIW4G4AohLgDjRXBaoiwkDczFgB4w4MAQAAM8NBxo=');
EXP := 30;
end;
'anchovies':
with Result do
begin
Name := 'Anchovies';
DTM := DTMFromString('mggAAAHicY2NgYNBnYWCwBGIrIHYGYnUg1gXiJYwMDOuBeBYQL4DidUAcEBgL1MWEgbkYsANGHBgCAFLjBlE=');
EXP := 30;
end;
'sardine':
with Result do
begin
Name := 'Sardine';
DTM := DTMFromString('mWAAAAHicY2FgYOBkYWBgBWJ+IBYD4mWMDAyrgHgOEC8AYtdmN6AqJjjmZ0AFjGgYBADt5QP/');
EXP := 40;
end;
'herring':
with Result do
begin
Name := 'Herring';
DTM := DTMFromString('mrAAAAHic42BgYDBkYWDQAGI7IHYGYjMWiJgmEOsB8QpGBoY1QDwTiJcA8SogXgvEy4B4ERCvXrgAaAoTTizAQBgw4sEwAABb7wkK');
EXP := 50;
end;
'trout':
with Result do
begin
Name := 'Trout';
DTM := DTMFromString('mlwAAAHicY2dgYOAGYh4gFgdiaSBmZ4AAJqgcC5TPDlUjCsT8QFxRXARVhYmFGHADRjwYCgDVFAIt');
EXP := 70;
end;
'salmon':
with Result do
begin
Name := 'Salmon';
DTM := DTMFromString('mlwAAAHicY2dgYFjGxMAwF4jnAPEKIN4MxNuh7CxGBoZSIM4F4gQgjgXiZCAuBuK2UG+gbiasWJIBN2DEg6EAACAVCOc=');
EXP := 90;
end;
'pike':
with Result do
begin
Name := 'Pike';
DTM := DTMFromString('mlwAAAHicY2dgYOABYi4glgFiCQYIYARiXiAWAGIxIGaHigtB1bAAcWFfEZBkwopFGHADRjwYCgDk8wJT');
EXP := 80;
end;
'tuna':
with Result do
begin
Name := 'Tuna';
DTM := DTMFromString('mrAAAAHic42BgYDBlgWANIDYHYicgtgdiKyDWA+KTjAwM+4D4EhTD+AeA+BgQL5g2DWgKE07Mz4AfMBLAMAAA2/4KDA==');
EXP := 100;
end;
'lobster':
with Result do
begin
Name := 'Lobster';
DTM := DTMFromString('mggAAAHicY2NgYOAHYmYGCJAFYj4gFgVidiAWAmI2qJwEEPMCcbiRNJBkwsD8DNgBIw4MAQB3zAFg');
EXP := 120;
end;
'swordfish':
with Result do
begin
Name := 'Swordfish';
DTM := DTMFromString('mbQAAAHicY2VgYGhmYWDoBOIZQDwJiKuA+BQjA8MuID4OxGeB+DIQr5iyGqiaCQWzMmACRiwYDAC6Mgiz');
EXP := 140;
end;
end;
end;
(*~ Creates the DDTM, credits for WT-Fakawi for his tutorial ~*)
(*~ I only modified so that it would look nicer in my eye ~*)
procedure initDDTM;
var
subP: array of TDTMPointDef;
mainP: TDTMPointDef;
curDDTM: TDTM;
i : integer;
begin
mainP.x := MMCX;
mainP.y := MMCY;
mainP.areasize := 1;
mainP.areashape := 0;
mainP.color := 16777215;
mainP.tolerance := 255;
setLength(subP, 4);
for i := 0 to high(subP) do
begin
with subP[i] do
begin
case i of
0:
begin
x := 601;
y := 73;
end;
1:
begin
x := 600;
y := 130;
end;
2:
begin
x := 588;
y := 137;
end;
3:
begin
x := 664;
y := 93;
end;
end;
case i of
0: color := grabColor('rock', 20, 500);
1: color := grabColor('cactus', 20, 900);
2: color := grabColor('cactus', 20, 900);
3: color := grabColor('rock', 20, 500);
end;
tolerance := 2;
areasize := 3;
areashape := 0;
end;
end;
curDDTM.MainPoint := mainP;
curDDTM.subPoints := subP;
areaDDTM := AddDTM(CurDDTM);
writeDebug('[initDDTM]: areaDDTM is finished');
end;
(*~ Used for walking :P, credits to WT-Fakawi and his DDTM anchoring tutorial! ~*)
(*~ I only modified so that it would look nicer in my eye ~*)
function DDTMRelocate(where: integer): boolean;
var
oX, oY: integer;
p : tPoint;
whichAngle : extended;
begin
if (not LoggedIn) then
exit;
case where of
LOC_BANK:
begin
oX := 0;
oY := 0;
end;
LOC_RANGE:
begin
oX := 4;
oY := -9;
end;
end;
if findDTMRotatedSe(areaDDTM, p.x, p.y, MMX1, MMY1, MMX2, MMY2, rs_getCompassAngleRadians - pi, rs_GetCompassAngleRadians + pi, 0.05, whichAngle) then
begin
writeDebug('[DDTMRelocate]: DDTM found! Point: ' + toStr(p));
if rs_OnMinimap(p.x, p.y) then
begin
{$IFDEF SMART_GRAPHICS}
if paintSMART then
SMART_DrawLine(true, Point(MMCX, MMCY), Point(p.x + oX, p.y + oY), clRed);
{$ENDIF}
Mouse(p.x + oX, p.y + oY, 2, 2, mouse_left);
wait(randomRange(900, 1400));
while (isMoving) do
wait(randomRange(350, 500));
Result := True;
WriteLn('[DDTMRelocate]: Relocating to: ' + intToStr(where) + ' succesfull');
end;
end else
begin
writeDebug('[DDTMRelocate]: Failed to relocate, reason: no DDTM seen');
result := false;
end;
end;
function checkUptext(uptext : TStringArray; loop, maxWait: integer): Boolean;
var
t, s, f : integer;
begin
if (not LoggedIn) then
exit;
result := false;
t := getSystemTime + maxWait;
while t > getSystemTime do
begin
if waitUpTextMulti(uptext, loop) then
inc(s)
else
inc(f);
end;
debugLn('[checkUptext]: s: ' + toStr(s) + ' f: ' + toStr(f));
if s > f then
result := true;
end;
function isOptionBox: boolean;
var
p : TPoint;
begin
result := findColorTolerance(p.x, p.y, OPTIONBOX_COLOR, MSX1, MSY1, MSX2, MSY2, OPTIONBOX_TOLERANCE);
end;
function findOptionMulti(strs : TStringArray; options : array of TOptions; matchAll : boolean; percentage : integer): tbox;
var
i, ii, j, f, t: integer;
temp : TStringArray;
found : boolean;
begin
result := intToBox(-1, -1, -1, -1);
t := length(strs);
if isOptionBox then
begin
for i := 0 to high(options) do
begin
f := 0;
debugLn('[findOptionMulti]: ' + options[i].Str);
for ii := 0 to high(strs) do
begin
explodeWrap(' ', options[i].str, temp);
for j := 0 to high(temp) do
if temp[j] = strs[ii] then
inc(f);
end;
writeDebug('[findOptionMulti]: ' + toStr(f) + ' strings found in this option');
if matchAll then
found := (f = t)
else
found := (((f / t) * 100) >= percentage);
if found then
begin
result := options[i].Bounds;
break;
end;
end;
end else
writeDebug('[findOptionMulti]: Option box wasn''t found.');
if found then
writeDebug('[findOptionMulti]: Correct option bounds are : ' + toStr(result));
end;
function vanishOptionBox: boolean;
var
arr, MS, oBox, possible : TPointArray;
p : TPoint;
b : TBox;
i : integer;
label
randomPoint;
begin
if (not isOptionBox) then
exit;
result := false;
if findColorsTolerance(arr, OPTIONBOX_COLOR, MSX1, MSY1, MSX2, MSY2, OPTIONBOX_TOLERANCE) then
begin
b := getTPABounds(arr);
with b do
begin
x1 := x1 - 3;
x2 := x2 + 3;
y1 := y1 - 3;
y2 := y2 + 3;
end;
TPAFromBoxWrap(MSBox, MS);
TPAFromBoxWrap(b, oBox);
ClearTPAFromTPAWrap(MS, oBox, possible);
end;
if length(possible) > 0 then
begin
i := 0;
randomPoint:
inc(i);
p := possible[random(high(possible))];
mmouse(p.x, p.y, 2, 2);
result := (not waitFunc(@isOptionBox, 50, 750));
if (not result) then
if i < 6 then
goto randomPoint;
end;
end;
function findBankersMM : TPoint;
var
dots, ref : TPointArray;
i : integer;
atpa : T2DPointArray;
begin
result := Point(-1, -1);
dots := getMinimapDots('npc');
splitTPAExWrap(dots, 15, 5, atpa);
if paintSmart then
SMART_DebugATPA(true, atpa);
for i := 0 to high(atpa) do
begin
if inRange(length(atpa[i]), 4, 7) then
begin
ref := atpa[i];
break;
end;
end;
if length(ref) > 1 then
result := middleTPA(ref)
else
result := Point(-1, -1);
writeDebug('[findBankersMM]: Point: ' + toStr(result));
end;
procedure pointsNear(var res : TPointArray; tpa, tpa2 : TPointArray);
var
i, j : integer;
boxes : TBoxArray;
begin
res := [];
// writeLn('[PointsNear]: Length(tpa): ' + toStr(length(tpa)));
// writeLn('[PointsNear]: Length(tpa2): ' + toStr(length(tpa2)));
for i := 0 to high(tpa) do
for j := 0 to high(tpa2) do
begin
if distance(tpa[i].x, tpa[i].y, tpa2[j].x, tpa2[j].y) <= 1 then
begin
SetLength(res, Length(res) + 1);
res[High(res)] := tpa2[j];
end else
continue;
end;
clearDoubleTPA(res);
//just for debug purposes!
if paintSmart then
begin
setLength(boxes, length(res));
for i := 0 to high(res) do
boxes[i] := PointToBox(Point(res[i].x - 3, res[i].y - 3), Point(res[i].x + 3, res[i].y + 3));
SMART_DrawBoxes(true, false, boxes, 255);
end;
writeLn('[pointsNear]: Points: ' + toStr(res));
end;
procedure fillLines(var res : TPointArray; points: TPointArray);
var
i, j : integer;
temp : TPointArray;
begin
res := [];
for i := 0 to high(points) do
begin
{ if pointInTPA(points[i], res) then
continue; //no duplicates }
for j := 0 to high(points) do
begin
if j = i then
continue;
temp := tmp_TPAFromLine(points[i].x, points[i].y, points[j].x, points[j].y);
appendTPA(res, temp);
end;
end;
if length(res) <> 0 then
clearDoubleTPA(res);
end;
function findRangeMM: TPoint; //IT'S a MESS! This needs a rewrite!!!
var //doesn't always work, because symbols might cover a whole side of range
i, j, k, f : integer; //and I can't do anything about it.
bords, symbolTPA, temp, tmp, tpa : TPointArray;
atpa, res, aTmp : T2DPointArray;
boxes : array of TBox;
mP : TPoint;
b : TBox;
toRemove : TStringArray;
label
alternate;
begin
result := Point(-1, -1);
getBorders(bords);
clearTPAFromTPAWrap(bords, getMinimapDots('player'), bords);
atpa := splitTPA(bords, 5);
sortATPAFrom(atpa, Point(MMX1, MMY1));
//making the boxes
setLength(boxes, length(atpa));
for i := 0 to high(atpa) do
boxes[i] := getTPABounds(atpa[i]);
if paintSmart then
SMART_DrawBoxes(true, false, boxes, 255);
//cycling through every box until a desired box is found
f := -1;
for i := 0 to high(boxes) do
begin
if (inrange((boxes[i].X2 - boxes[i].X1), MM_RANGE_WIDTH - 3, MM_RANGE_WIDTH + 3)) then
begin
f := i;
break;
end;
end;
if f = -1 then
goto alternate;
if f <> -1 then
begin
if (inrange((boxes[i].Y2 - boxes[i].Y1), MM_RANGE_HEIGHT - 2, MM_RANGE_HEIGHT + 2)) then
begin
if paintSmart then
SMART_DrawBox(boxes[f]);
if boxes[f].Y2 > MMCY then
result := Point(-1, -1)
else
result := Point((boxes[f].X1 + boxes[f].X2) / 2, (boxes[f].Y1 + boxes[f].Y2) / 2);
end else
begin
alternate:
writeDebug('[findRangeMM]: No clear view, utilising symbols!');
if findColors(symbolTPA, 65536, MMX1, MMY1, MMX2, MMY2) then
begin
temp := [];
splitTPAWrap(symbolTPA, 13, res); //dist is 10 because I know that there are no other than 2 symbols around range which would be visible!
// debugATPA(res, '');
for i := 0 to high(atpa) do
for j := 0 to high(res) do
begin
if length(res[j]) < 5 then
continue;
for k := 0 to high(res[j]) do
if nearbyPointInArray(res[j][k], 3, atpa[i]) then
appendTPA(temp, atpa[i]);
end;
splitTPAWrap(temp, 10, atpa);
// debugATPA(atpa, '');
toRemove := ['player', 'npc', 'item'];
for i := 0 to high(atpa) do
for j := 0 to 2 do
clearTPAFromTPAWrap(atpa[i], getMinimapDots(toRemove[j]), atpa[i]);
end;
setLength(aTmp, length(res));
temp := [];
for i := 0 to high(res) do
begin
for j := 0 to high(atpa) do
begin
mP := middleTPA(atpa[j]);
if nearbyPointInArray(mP, 12, res[i]) then
appendTPA(aTmp[i], atpa[j]);
end;
end;
sortATPASize(aTmp, false);
tpa := [];
for i := 0 to high(aTmp) do
begin
clearDoubleTPA(aTmp[i]);
writeLn('[findRangeMM]: Length(tpa): ' + toStr(length(aTmp[i])));
if length(aTmp[i]) < 20 then
continue;
if inRange(length(aTmp[i]), MM_RANGE_MIN_PIXELS, MM_RANGE_MAX_PIXELS) then
tpa := aTmp[i];
if length(tpa) > 1 then
break;
end;
sortATPAFrom(res, middleTPA(tpa));
symbolTPA := res[0];
if length(tpa) >= 1 then
begin
// debugTPA(tpa, '');
pointsNear(temp, tpa, symbolTPA);
fillLines(tmp, temp);
appendTPA(tpa, tmp);
b := getTPABounds(tpa);
if paintSmart then
SMART_DrawBox(b);
writeLn('[findRangeMM]: B(w): ' + toStr(b.X2 - b.X1));
writeLn('[findRangeMM]: B(h): ' + toStr(b.Y2 - b.Y1));
if (inrange((b.X2 - b.X1), MM_RANGE_WIDTH - 2, MM_RANGE_WIDTH + 4)) and
(inrange((b.Y2 - b.Y1), MM_RANGE_HEIGHT - 2, MM_RANGE_HEIGHT + 2)) then
result := Point((b.X1 + b.X2) / 2, (b.Y1 + b.Y2) / 2)
else
result := Point(-1, -1);
if result = Point(-1, -1) then
writeDebug('[findRangeMM]: Either a NPC or a player interrupted, sigh...');
end;
if result.y > MMCY then
result := Point(-1, -1);
end;
writeDebug('[findRangeMM]: Point: ' + toStr(result));
end;
if result <> Point(-1, -1) then
writeDebug('[findRangeMM]: Range found successfully!')
else
writeDebug('[findRangeMM]: Failure, range not found!');
end;
(*~ Finds the location we are in ~*)
function findArea: integer;
var
p : TPoint;
ang : extended;
begin
result := -1;
p := findBankersMM;
if (p <> Point(-1, -1)) or (p <> Point(0, 0)) then
begin
if (MMCX - p.x) <> 0 then
begin
ang := arcTan2(MMCY - p.y, MMCX - p.x);
debugLN('[findArea]: Angle: ' + toStr(ang));
if (ang > (pi / 6)) and (ang < (pi - (pi / 6))) then
result := LOC_BANK;
if (ang < (-pi / 3)) and (ang > (-pi + (pi / 3))) then
result := LOC_RANGE;
end else
begin
writeDebug('[findArea]: dX = 0, checking y coordinate.');
if p.y < MMCY then
result := LOC_BANK
else
result := LOC_RANGE;
end;
end else
result := LOC_LOST;
if result <> -1 then
case result of
LOC_RANGE : writeDebug('[findArea]: Player is in range.');
LOC_BANK : writeDebug('[findArea]: Player is in bank.');
LOC_LOST : writeDebug('[findArea]: Player is lost!');
end;
end;
function blindWalk(sRad, eRad: extended; minDist, maxDist: integer): boolean;
var
mmTPA : TPointArray;
p : TPoint;
begin
result := false;
writeDebug('[blindWalk]: Relying on blind walking...');
TPAFromCircleWrap(MMCX, MMCY, 75, mmTPA);
fillEllipse(mmTPA);
FilterPointsPie(mmTPA, sRad, eRad, minDist, maxDist, MMCX, MMCY);
p := mmTPA[random(high(mmTPA))];
mouse(p.x, p.y, 4, 4, mouse_left);
wait(randomRange(1132, 1583));
if p <> Point(-1, -1) then
if waitUntilMoving then
while isMoving do
wait(randomRange(532, 793));
end;
function lostWalk(): boolean;
var
f, i : integer;
p : TPoint;
whichAngle : extended;
begin
result := false;
if lodestoneTeleport('Al Kharid') then
begin
f := getSystemTime + 25000; //just enough time
while (not findSymbol(p.x, p.y, Symbol_Lodestone)) do
begin
if getSystemTime > f then
break;
wait(100 + random(15));
end;
if (not findSymbol(p.x, p.y, Symbol_Lodestone)) then
begin
reason[currentPlayer] := 'lostWalk failed';
exit;
end;
wait(randomRange(5492, 6902));
for i := 0 to 3 do
begin
while flagPresent do
wait(randomRange(242, 350));
writeDebug('[lostWalk]: Current step: ' + toStr(i));
if i = 0 then
blindWalk(265, 275, 54, 60)
else
blindWalk(220, 225, 35, 40);
if findSymbol(p.x, p.y, SYMBOL_BANK) then
begin
writeDebug('[lostWalk]: Symbol found: Point: ' + toStr(p));
if rs_onMinimap(p.x, p.y) then
begin
writeDebug('[lostWalk]: Point is inside minimap, clicking it');
mouse(p.x, p.y, 3, 3, mouse_left);
wait(randomRange(340, 400));
if flagPresent then
begin
result := true;
writeDebug('[lostWalk]: Relocate using symbol: Success!');
break;
end;
writeDebug('[lostWalk]: Symbol is at the edge of the minimap, failure on clicking it');
end;
end;
p := findBankersMM;
if ((p.x <> 0) and (p.x <> -1)) then
begin
writeDebug('[lostWalk]: Bankers found: Point: ' + toStr(p));
mouseBox(p.x - 4, p.y, p.x + 3, p.y + 4, mouse_left);
wait(randomRange(240, 400));
if (not FlagPresent) then
result := false
else
begin
writeDebug('[lostWalk]: Flag is present, relocating successful!');
result := true;
writeln('bankers');
break;
end;
if (not result) then
writeDebug('[lostWalk]: Flag isn''t present, failure');
end;
if areaDDTM > 1 then
if findDTMRotatedSe(areaDDTM, p.x, p.y, MMX1, MMY1, MMX2, MMY2, rs_getCompassAngleRadians - pi, rs_GetCompassAngleRadians + pi, 0.05, whichAngle) then
begin
DDTMRelocate(LOC_BANK);
result := true;
writeln('ddtm');
break;
end;
end;
writeDebug('[lostWalk]: Starting position found: ' + toStr(result));
if result then
waitUntilMoving;
while isMoving do
wait(randomRange(214, 531));
end;
end;
function relocatePlayer: boolean;
var
p : TPoint;
begin
result := false;
writeDebug('[relocatePlayer]: Normal walking failed, trying to relocate the player to bank');
if findSymbol(p.x, p.y, SYMBOL_BANK) then
begin
mouse(p.x, p.y, 4, 4, mouse_left);
waitUntilMoving();
while isMoving do
wait(randomRange(340, 506));
result := true;
end;
end;
function walkTo(t : Integer): Boolean;
var
dP : TPoint;
i : integer;
s : string;
label
start, ending;
begin
i := 0;
start:
result := false;
inc(i);
if getMMLevels('run', s) < 15 then
if setRest then
begin
while getMMLevels('run', s) < 80 do
begin
case random(15) of
0: sleepAndMoveMouse(6000);
1: boredHuman;
2: RandomRClick;
end;
wait(randomRange(2352, 3599));
end;
end;
clickNorth(SRL_ANGLE_HIGH);
setRun(true);
begin
if t = LOC_BANK then
dP := findBankersMM
else
dP := findRangeMM;
if dP = Point(-1, -1) then
if t = LOC_BANK then
writeDebug('[walkTo]: Walking to bank failed: No bankers found!')
else
writeDebug('[walkTo]: Walking to range failed: No outlines or no box found!');
//randomizing the point
if dP <> Point(-1, -1) then
begin
if t = LOC_BANK then
begin
dP.x := dP.x + randomRange(-4, 8);
dP.y := dP.y + randomRange(5, 10);
end else
begin
dP.x := dP.x + RandomRange(0, 3);
dP.y := dP.y + RandomRange(0, 5);
end;
mouse(dP.x, dP.y, 3, 3, mouse_left);
end else
result := DDTMRelocate(t);
end;
//if DDTM is used, this won't be necessary (= botlike!)
if (not result) then
begin
waitUntilMoving();
if (not flagPresent) and (not isMoving) then
begin
writeDebug('[walkTo]: No flag present, and we are not moving, point selection failed!');
if i = 1 then
goto start
else
begin
reason[currentPlayer] := 'walking failed: walkTo';
goto ending;
end;
end else
reason[currentPlayer] := '';
wait(randomRange(3000, 4500));
while isMoving do
begin
wait(randomRange(350, 450));
if findNormalRandoms then
break;
end;
end;
ending:
{ if reason[currentPlayer] <> '' then
if findNormalRandoms then
goto start; }
//if walking succeeded findArea should be the same as t
if findArea = t then
result := true;
end;
//these constants are only used in locateObject, will replace result[*]
const
COORD_X = 0;
COORD_Y = 1;
CLICK_RIGHT = 2;
function locateObject(obj: TObj; sort: boolean): TVariantArray;
var
cts, tries, dist, i, cF, uF, h : integer;
p : TPoint;
tpa, sTPA : TPointArray;
sATPA, ATPA : T2DPointArray;
turnCamera : boolean;
label
noUptext;
begin
setLength(result, 3);
if bankscreen or pinscreen or findCookbox or (not loggedIn) then
exit;
result[COORD_X] := -1;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(3);
repeat
inc(tries);
turnCamera := false;
findColorsSpiralTolerance(p.x, p.y, tpa, obj.color[0], MSX1, MSY1, MSX2, MSY2, obj.Tol[0]);
if (length(tpa) < 2) and (tries >= 4) then
turnCamera := true;
if turnCamera then
makeCompass('w');
//initial sorting
if ((sort = true) and (length(tpa) > 1)) then
begin
// debugTPA(TPA, '');
if obj.name = 'Range' then
begin
splitTPAExWrap(TPA, 30, 10, ATPA);
sortATPASize(ATPA, true);
TPA := ATPA[0];
end;
// debugTPA(tpa, '');
if findColorsSpiralTolerance(p.x, p.y, sTPA, obj.Color[1], MSX1, MSY1, MSX2, MSY2, obj.Tol[1]) then
begin
if (length(stpa) > 1) then
begin
sATPA := floodFillTPA(sTPA);
// debugATPA(sATPA, '');
if obj.name = 'Range' then
dist := 15
else
dist := 12;
for i := 0 to high(sATPA) do
if nearbyPointinArray(middleTPA(TPA), dist, sATPA[i]) then
appendTPA(TPA, sATPA[i]);
end;
end;
// debugTPA(TPA, '');
end;
ATPA := TPAToATPAEx(TPA, Obj.width, Obj.Height);
if (Length(ATPA) < 2) then
begin
writeDebug('[locateObject]: Failed to find color: ' + toStr(obj.color));
inc(cF);
if (cF >= 10) then
begin
Reason[currentPlayer] := 'color finding failed';
continue;
end;
end;
if obj.name = 'Range' then
sortATPASize(ATPA, true)
else
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if paintSmart then
SMART_DebugATPA(true, atpa);
h := High(ATPA);
for i := 0 to h do
begin
vanishOptionBox;
writeDebug('[locateObject]: Length(TPA): ' +IntToStr(Length(ATPA[i])));
MiddleTPAEx(ATPA[i], p.x, p.y);
cF := 0;
MMouse(p.x, p.y, 5, 5);
wait(randomRange(250, 400));
if obj.name = 'Range' then
goto noUptext;
writeDebug('[locateObject]: Current uptext: ' + rs_GetUpText);
if checkUptext(obj.UpTexts, 400, 80) then
begin
result[COORD_X] := p.x;
result[COORD_Y] := p.y;
result[CLICK_RIGHT] := false;
break;
end else
begin
writeDebug('[locateObject]: Uptext not found');
noUptext:
if obj.name <> '' then
begin
mouse(p.x, p.y, 0, 0, mouse_right);
wait(randomRange(500, 700));
if optionsExist(obj.UpTexts, false) then
begin
result[COORD_X] := p.x;
result[COORD_Y] := p.y;
result[CLICK_RIGHT] := true;
break;
end else
begin
result[COORD_X] := -1;
result[COORD_Y] := -1;
vanishOptionBox;
end;
end;
inc(uF);
if (uF > 10) then
begin
Reason[currentPlayer] := 'uptext finding failed';
Break;
end;
if result[0] <> -1 then
break;
end;
end;
until (tries >= 8) or (reason[currentPlayer] <> '') or (result[COORD_X] <> -1);
if result[0] <> -1 then
writeDebug('[locateObject]: Object found at ' + ToStr(result))
else
writeDebug('[locateObject]: Object wasn''t found, setting player false');
ColorToleranceSpeed(cts);
end;
(*~ Starts the banking function ~*)
function initBank : Boolean; //cant use openBank...
var
timeLimit : Integer;
vars : TVariantArray;
p : TPoint;
open : Boolean;
options : array of TOptions;
oB : TBox;
label
start;
begin
if (not LoggedIn) then
exit;
if bankscreen or pinscreen then
exit;
start:
vars := locateObject(initObjects(OBJECT_BANK), true);
if vars[0] <> -1 then
begin
p := intToPoint(vars[0], vars[1]);
if vars[2] = false then
mouse(p.x, p.y, 0, 0, mouse_left)
else
begin
mouse(p.x, p.y, 0, 0, mouse_right);
wait(randomRange(240, 500));
options := getChooseOptions('cyan');
oB := findOptionMulti(initObjects(OBJECT_BANK).UpTexts, options, true, 0);
if oB.X1 <> -1 then
mouseBox(oB.X1, oB.Y1, oB.X2, oB.Y2, mouse_left)
else
goto start;
end;
end;
writeDebug('[initBank]: Click happened at: ' + ToStr(p));
begin
Wait(RandomRange(600, 1000));
open := (BankScreen or PinScreen);
timeLimit := (GetSystemTime + 10000);
if (not open) then
begin
writeDebug('[initBank]: Bank wasn''t open');
repeat
Wait(RandomRange(400, 600));
if timeLimit < GetSystemTime then
begin
reason[currentPlayer] := 'bank opening failed';
break;
end;
open := (BankScreen or PinScreen);
until (open);
end;
with Players[CurrentPlayer] do
if PinScreen then
if (Pin <> '') then
begin
writeDebug('[initBank]: Entering pin');
InPin(Pin);
end else
begin
writeDebug('[initBank]: Player has a pin, but it was not declared at declareplayers');
Reason[currentPlayer] := 'pin not set';
Result := False;
end;
end;
if (BankScreen) then
begin
Wait(RandomRange(500, 700));
Result := True;
end;
writeDebug('[initBank]: Bank opening: ' + BoolToStr(Result));
end;
(*~ Counts the amount of given DTM found in inventory ~*)
function countDTMs(DTM : integer) : integer; //I know that countItems does the same job!
var
i, f : integer;
p : TPoint;
b : TBox;
begin
if (not LoggedIn) then
exit;
f := 0;
gameTab(tab_Inv);
for i := 1 to 28 do
begin
b := InvBox(i);
if findDTM(DTM, p.x, p.y, b.X1, b.Y1, b.X2, b.Y2) then
inc(f);
end;
if f = 0 then
writeDebug('[countDTMs]: No searched items in inventory!')
else
writeDebug('[countDTMs]: Amount of items: ' + intToStr(f));
Result := f;
end;
(*~ Withdraws items ~*)
function itemWithdraw: Boolean;
var
x, y, c, f : integer;
begin
if (InvFull) or (not BankScreen) {or (FindNormalRandoms)} then
exit;
if (not LoggedIn) then
Exit;
writeDebug('[itemWithdraw]: Initiating withdrawing');
if FindDTM(fish.DTM, x, y, MBX1, MBY1, MBX2, MBY2) then
begin
writeDebug('[itemWithdraw]: Item found, checking their amount');
c := GetMSBankItemAmount(x, y);
writeDebug('[itemWithdraw]: ' + intToStr(c) + ' items found');
if c >= 1 then
begin
Mouse(x, y, 4, 4, mouse_right);
f := getSystemTime + 10000;
if WaitOptionMulti(['-All'], 400) then
while invCount = 0 do
begin
wait(randomRange(325, 405));
if invCount > 1 then
break;
if f < getSystemtime then
break;
end;
result := (invCount > 1);
end;
end else
begin
if Players[CurrentPlayer].Integers[PLAYER_EXP] > 1 then
begin
reason[currentPlayer] := 'out of items';
writeDebug('[itemWithdraw]: We''re out of items, which is a good thing!');
end else
begin
reason[currentPlayer] := 'no items';
writeDebug('[itemWithdraw]: Item not detected in the bank!');
end;
end;
writeDebug('[itemWithdraw]: Withdrawing: ' + toStr(result));
end;
function findCookbox : Boolean; // Finds the cooking box at mainscreen, by counting certain color
begin
Result := CountColor(16777215, 240, 42, 455, 83) > 0;
end;
function waitConversion(DTM, time : integer): boolean;
var
p : TPoint;
i, f, iC, ii, cC : integer;
begin
result := false;
{ if findNormalRandoms then
exit; } // possible source for skipping the loop?
writeDebug('[waitConversion]: Entering conversion loop!');
wait(20);
iC := countDTMs(DTM);
wait(20);
MarkTime(f);
while findDTM(DTM, p.x, p.x, MIX1, MIY1, MIX2, MIY2) do
begin
if random(100) > 80 then
begin
i := random(100);
case i of //slight antiban
1: boredHuman;
2: SleepAndMoveMouse(RandomRange(2000, 4000));
3: PickUpMouse;
4: RandomMovement;
5: Wait(randomRange(500, 5000));
6: HoverSkill('random', false);
end;
end;
wait(20);
//checks if items have really changed
if timeFromMark(f) > time then
begin
cC := countDTMs(DTM);
if cC < iC then
begin
iC := cC;
ii := 0;
end else
inc(ii);
//marks time for new check
markTime(f);
end;
{
if findNormalRandoms then // remove?
exit; }
if (not tabExists(tab_Inv)) then
break;
wait(randomrange(250, 300));
if ii >= 5 then
begin
writeDebug('[waitConversion]: Inventory count hasn''t changed in 5 tries');
break;
end;
end;
//if not find DTM anymore then result = true
if (not findDTM(DTM, p.x, p.y, MIX1, MIY1, MIX2, MIY2)) then
result := true
else
result := false;
if result then
writeDebug('[waitConversion]: Conversion successfull')
else
writeDebug('[waitConversion]: We failed somehow, probably random');
end;
function useRaw: boolean;
var
p : TPoint;
t : integer;
begin
if findDTM(fish.DTM, p.x, p.y, MIX1, MIY1, MIX2, MIY2) then
begin
mouse(p.x, p.y, 2, 2, mouse_left);
t := getSystemTime + 5000; //5 second failsafe...
while (getSystemTime < t) do
begin
result := ItemActivated(CoordsToItem(p.x, p.y));
if result then
break;
end;
end else
reason[currentPlayer] := 'no dtm found';
if result then
writeDebug('[useRaw]: Item successfully clicked');
end;
function findRange : boolean;
var
p : TPoint;
vars : TVariantArray;
f, ff : integer;
options : array of TOptions;
oB : TBox;
label
start;
begin
if (not LoggedIn) then
exit;
if bankscreen or pinscreen then
exit;
start:
vars := locateObject(initObjects(OBJECT_RANGE), true);
if vars[0] <> -1 then
begin
p := intToPoint(vars[0], vars[1]);
if vars[2] = false then
mouse(p.x, p.y, 0, 0, mouse_left)
else
begin
mouse(p.x, p.y, 0, 0, mouse_right);
wait(randomRange(240, 500));
options := getChooseOptions('cyan');
oB := findOptionMulti(initObjects(OBJECT_RANGE).UpTexts, options, true, 0);
if oB.X1 <> -1 then
mouseBox(oB.X1, oB.Y1, oB.X2, oB.Y2, mouse_left)
else
goto start;
end;
end;
wait(randomRange(450, 600));
f := GetSystemTime + 15000;
while ((getSystemTime < f) and (not findCookbox)) do
begin
{ if findNormalRandoms then
break; }
//this really doesn't have any use currently
if pos('othing', getBlackChatMessage) <> 0 then
if ((getSystemTime - f) > 5000) then
break;
if GetSystemTime > f then
reason[currentPlayer] := 'cookbox not found';
wait(randomRange(250, 350));
end;
if findCookbox then
begin
writeDebug('[findRange]: Cookingbox found at mainscreen!');
mouseBox(COOKBOX_X1, COOKBOX_Y1, COOKBOX_X2, COOKBOX_Y2, mouse_left);
//waits until it finds a fish name in the chatbox
ff := GetSystemTime + 7500;
while (not (pos(lowercase(fish.name), GetBlackChatMessage) <> 0)) do
begin
wait(randomRange(250, 350));
if{ findNormalRandoms or }(getSystemTime > ff) then
break;
end;
wait(20);
if countDTMs(fish.DTM) <= 27 then
result := waitConversion(fish.DTM, 3000);
end;
end;
(*~ Calculates experience by comparing new XP and old one ~*)
procedure calcExp(oldXp : longInt); // calculates gained experience
var
xpGained : longInt;
begin
with players[CurrentPlayer] do
begin
if IsXPBarOpen then
xpGained := (getXPBar(1) - oldXP);
incEx(Integers[PLAYER_EXP], xpGained);
end;
end;
procedure printReport;
var
i : integer;
begin
writeDebug(' ________________________________ ');
writeDebug('/________________________________\');
writeDebug('| AK Cooker by Smidqe |');
writeDebug('|________________________________|');
writeDebug('|________________________________|');
writeDebug('| - Version: ' + PadR(FloatToStr(scriptVersion), 20) + '|');
writeDebug('| - Total runtime: ' + PadR(MSToTime(GetTimeRunning, Time_Bare), 14) + '|');
writeDebug('|________________________________|');
for i := 0 to High(Players) do
with Players[i] do
begin
writeDebug('|________________________________|');
writeDebug(PadR('| Player: ' + IntToStr(i), 33) + '|');
writeDebug(PadR('| - Nickname : ' + nick, 33) + '|');
writeDebug(PadR('| - Time played : ' + MsToTime(PlayerWorked(i), Time_Bare), 33) + '|');
writeDebug(PadR('| - Fish : ' + Capitalize(Strings[PLAYER_ITEM]), 33) + '|');
writeDebug(PadR('| - Cooked : ' + intToStr(Integers[PLAYER_EXP] / fish.exp), 33) + '|');
writeDebug(PadR('| - Experience : ' + IntToStr(Integers[PLAYER_EXP]), 33) + '|');
writeDebug(PadR('| - EXP/H : ' + IntToStr((Integers[PLAYER_EXP] * 3600) / (GetTimeRunning / 1000)), 33) + '|');
writeDebug(PadR('| - Breaks : ' + IntToStr(Integers[PLAYER_BREAKS]), 33) + '|');
if (not active) then
writeDebug(PadR('| - Reason : ' + reason[currentPlayer], 33) + '|');
end;
writeDebug('|________________________________|');
writeDebug('\________________________________/');
end;
procedure setupItem(load : boolean);
begin
if load then
fish := initFish
else
freeDTM(fish.DTM);
end;
(*~ Setups player, for autoing, required for every player! ~*)
procedure setupPlayer;
label
reasoning;
begin
markTime(nextBreak);
reason[currentPlayer] := '';
loginPlayer;
while PercentBlackMM > 95 do // to compensate the slow laoding
wait(randomRange(340, 500));
//set current location
clickNorth(SRL_ANGLE_HIGH);
exitSquealOfFortune();
ToggleActionBar(false);
curLoc := findArea;
if curLoc = LOC_LOST then
if lostWalk() then
curLoc := LOC_BANK;
//setup location and logs
initDDTM;
setupItem(true);
gameTab(tab_Inv);
exitSquealOfFortune();
wait(randomRange(2134, 3352));
//see two comments before this ^^
reasoning :
if reason[currentPlayer] <> '' then
switchPlayer(false);
end;
procedure setupBreaks;
var
randTime, timeBreak : Integer;
begin
if (not LoggedIn) then
exit;
if (HowManyPlayers > 1) or (PlayersActive > 1) then
Exit;
with Players[CurrentPlayer] do
if (TimeFromMark(nextBreak) >= (Integers[PLAYER_BREAK] * 60000)) then
begin
writeDebug('[setupBreaks]: Taking a break');
begin
if (LoggedIn) then
ExitToLobby;
Active := True;
randTime := Integers[PLAYER_BTIME] * 60000 + RandomRange(-180000, 180000);
timeBreak := (GetSystemTime + randTime);
writeDebug('[setupBreaks]: Break takes: ' + MsToTime(randTime, Time_Abbrev));
while GetSystemTime < timeBreak do
begin
writeDebug('[setupBreaks]: Continuing in about: ' + MsToTime(timeBreak - GetSystemTime, Time_Abbrev));
Wait(35000 + RandomRange(-10000, 10000)); //35 seconds -+ 10 seconds
end;
end;
writeDebug('[setupBreaks]: Finished taking a break');
MarkTime(nextBreak);
writeDebug('[setupBreaks]: Marked time for next break');
begin
Integers[PLAYER_BREAKS] := Integers[PLAYER_BREAKS] + 1;
writeDebug('[setupBreaks]: Increased amount of breaks');
end;
end;
end;
procedure setupChecks(var usable : boolean);
begin
if (not LoggedIn) then
Exit;
printReport;
with players[CurrentPlayer] do
begin
if Integers[PLAYER_TTIME] <> 0 then
begin
if Integers[PLAYER_TTIME] * 60000 <= PlayerWorked(CurrentPlayer) then
begin
Reason[currentPlayer] := 'total time done';
Usable := False;
end;
end else
writeDebug('[setupChecks]: Total time for player is 0, going for eternity');
if Integers[PLAYER_BREAK] * 60000 <= (timeFromMark(nextBreak) + randomRange(- 5 * 60000, 5 * 60000)) then
begin
reason[currentPlayer] := 'break';
Usable := true;
end;
end;
writeDebug('[setupChecks]: Checks done');
end;
procedure setupEnd;
begin
printReport;
setupItem(false);
freeDTM(areaDDTM);
end;
procedure setupScript;
var
t, fileName : string;
begin
//creates a debug log
//Credits to MSI and its writers
t := TheDate(DATE_DAY) + ' at ' + Replace(TheTime, ':', '-');
fileName := 'Smidqe''s AK-Cooker ' + t;
if saveDebug then
try
debugLog := CreateFile(ScriptPath + fileName + '.txt');
except
writeLn(ExceptionToString(ExceptionType, ExceptionParam));
end;
writeLn(' ____ _ __ '); //My signature
writeLn(' / \ [_] || ');
writeLn('| || ');
writeLn(' \____ __ __ __ ____|| _____ ____ ');
writeLn(' \ / \/ \ / | / || / \ /_ O \ ');
writeLn(' | | || | \ | | O || | O | | \__/ ');
writeLn(' \____/ | || | |_| \____/\ \___ | \____/ ');
writeLn(' | | ');
writeLn(' ================================= | |_ ======= ');
writeLn(' | / ');
writeLn(' \_/ ');
{$IFDEF SMART}
writeLn('[setupScript]: Loading SMART, please wait.');
fixSmartSpeed;
{$ENDIF}
SetupSRL;
DeclarePlayers;
writeDebug('Log created: ' + TheDate(DATE_FORMAL) + ', ' + TheTime);
writeDebug('[setupScript]: Initiating script setup');
//Takes a screenshot when random is found
SRL_RandomScreenShot := True;
setLength(reason, howManyPlayers);
AddOnTerminate('setupEnd');
end;
procedure setupMain;
var
walk, usable : boolean;
newLoc, exp : integer;
i : integer;
label
range;
begin
setupScript;
repeat
setupPlayer;
with players[CurrentPlayer] do
repeat
case curLoc of
LOC_LOST:
begin
writeDebug('[setupMain]: We are not where we suppose to be, trying to relocate');
if relocatePlayer then
curLoc := LOC_BANK
else
if lostWalk then
curLoc := LOC_BANK
end;
LOC_BANK:
begin
walk := false;
if countDTMs(fish.DTM) = 0 then
begin
if initBank then
begin
if invCount > 1 then
begin
depositAll;
writeDebug('[setupMain]: All items deposited!');
end;
if itemWithdraw then
walk := true;
end;
end else
walk := true;
end;
LOC_RANGE:
begin
walk := false;
if countDTMS(fish.dtm) = 0 then
walk := true
else
begin
i := 0;
range:
inc(i);
exp := getXPBar(1);
if useRaw then
begin
if findRange then
walk := true
else
reason[currentPlayer] := 'cooking failed';
end;
if countDTMS(fish.dtm) > 0 then
if i < 3 then
begin
reason[currentPlayer] := '';
goto range;
end;
calcEXP(exp);
end;
end;
end;
if walk then
begin
writeDebug('[setupMain]: Walking initiated!');
if curLoc = LOC_BANK then
newLoc := LOC_RANGE
else
newLoc := LOC_BANK;
writeDebug('[setupMain]: Destination: ' + toStr(newLoc));
if walkTo(newLoc) then
curLoc := findArea
else
curLoc := LOC_LOST;
if curLoc <> newLoc then
begin
if newLoc = LOC_BANK then
if relocatePlayer() then
curLoc := LOC_BANK
else
if lostWalk() then
curLoc := LOC_BANK
else
reason[currentPlayer] := 'failure: walk, main'
else
if DDTMRelocate(newLoc) then
curLoc := LOC_RANGE
else
begin
writeDebug('[setupMain]: Not in range! Checking if we are on top of it!');
mouse(MMCX + 3, MMCY + 10, 2, 2, mouse_left);
waitUntilMoving;
while isMoving do
wait(randomRange(240, 405));
if findArea = newLoc then
begin
writeDebug('[setupMain]: We were on top of it!')
curLoc := LOC_RANGE;
end else
if lostWalk() then
curLoc := LOC_BANK
else
reason[currentPlayer] := 'failure: walk, main';
end;
end;
end;
if howManyPlayers >= 1 then
begin
setupChecks(usable);
if (Reason[currentPlayer] <> '') then
begin
if (PlayersActive = 1) or (HowManyPlayers = 1) then
begin
if reason[currentPlayer] = 'total time done' then
begin
active := false;
break;
end;
if reason[currentPlayer] = 'break' then
begin
active := true;
break;
end;
end;
{
if ((reason[currentPlayer] <> 'break') and (reason[currentPlayer] <> 'total time done')) then
saveScreenShot(ScriptPath); }
writeDebug('[setupMain]: Switching players, reason: ' + Reason[currentPlayer]);
if (not Usable) then
switchPlayer(false)
else
switchPlayer(True);
break;
end;
end;
until (not active);
until allPlayersInactive;
writeDebug('[setupMain]: This is the end, stopping the script and something.');
end;
begin
setupMain;
end.