SCAR Code:
program Kharidcooker;
{$i SRL/SRL/misc/SMART.scar}
{$i SRL/SRL.scar}
(*
Things to Do
- Set Chat
* Clan Chat -> off
* Private -> off/friends only
* Public -> Hide
- Test all food compatibility
* anchovies need to be fixed. -> beta fix
* trout/salmon/tuna all work.
- Form?
* optional for right now, workability is more important.
*)
const
SMART_world = 82; // set to 0 for random world.
AVG_loads = 6; // per player. +-2; 0 = no breaks
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Active := True;
{ Players[1].Name := '';
Players[1].Pass := '';
Players[1].Active := True; }
end;
const
// Index
SYMBOL_KEBAB = 0;
SYMBOL_COOK = 1;
SYMBOL_BANK = 2;
LOC_BANK = false;
LOC_COOK = true;
CHATS_FRIENDS = 0;
CHATS_CLAN = 1;
CHATS_PUBLIC = 2;
// Color
COLOR_SYMBOL_KEBAB = 2698232;
COLOR_SYMBOL_COOK = 1391463;
COLOR_SYMBOL_BANK = 2216175;
COLOR_MM_WHITE = 16711422;
COLOR_MS_RANGE = 1845443;
COLOR_MS_BOOTH = 11065085;
COLOR_MS_WINDOW = 4606801;
COLOR_MI_WHITE = 16777215;
COLOR_MI_RED = 128;
COLOR_MI_OUTLINE = 131072;
COLOR_MC_GREEN = 65280;
// Area
FSx1 = 229;
FSy1 = 395;
FSx2 = 287;
FSy2 = 435;
WIx1 = 43;
WIy1 = 100;
WIx2 = 68;
WIy2 = 116;
// Player
lvl_gained = 0;
cooked = 1;
XP = 2; // not used atm
loads = 3;
food = 4;
type
tWalkInfo = record
symbol: string;
area: tPoint;
color: integer;
end;
tPlayerInfo = record
present: boolean;
sort: tPoint;
end;
var
Player: tPlayerInfo;
function Indent(str: string; len: integer): string;
begin
Result := str;
for len := len downto length(str) do
Result := Result + ' ';
end;
function grabText(): string;
var
s: string;
begin
if players[currentplayer].Strings[Food] <> '' then Exit;
s := rs_GetUpText();
if s = '' then Exit;
result := between('1 ', ' /', s);
// writeLn('text grabbed: '+result);
end;
function isPlayerAt(point: tPoint): boolean;
var
TPA: tPointArray;
begin
try
FindColorsToleranceOptimised(TPA, COLOR_MM_WHITE, point.x-50, point.y-15, point.x+50, point.y+15, 4);
result := Length(TPA) > 0;
except
writeLn('point came off MM. Exception caught, continuing script.');
end;
end;
function setSymbolRecord(index: byte): tWalkInfo;
begin
case index of
SYMBOL_KEBAB:
begin
with Result do
begin
symbol := 'Kebab';
area := point(648, 28);
color := COLOR_SYMBOL_KEBAB;
end;
end;
SYMBOL_COOK:
begin
with Result do
begin
symbol := 'Cook';
area := point(637, 33);
color := COLOR_SYMBOL_COOK;
end;
end;
SYMBOL_BANK:
begin
with Result do
begin
symbol := 'Bank';
area := point(641, 82);
color := COLOR_SYMBOL_BANK;
end;
end;
end;
end;
function createWalkLocation(Location: Boolean): Boolean;
var
Symbol: tWalkInfo;
I: Byte;
Loc: Boolean;
tolerance: ShortInt;
TPA: tPointArray;
aTPA: t2DPointArray;
P: tPoint;
DTM, x, y: Integer;
begin
case Location of
LOC_COOK:
begin
Symbol := setSymbolRecord(SYMBOL_KEBAB);
repeat
with Symbol do
begin
tolerance := 5;
while tolerance < 10 do
begin
findColorsTolerance(TPA, color, MMx1, MMy1, MMx2, MMy2, tolerance);
if length(TPA) > 0 then
begin
Loc := true;
sortTPAFrom(TPA, area);
// writeLn('Found '+symbol+' symbol.');
break;
end;
inc(tolerance);
end;
end;
if not Loc then
begin
if I < 1 then
begin
writeLn('attempting to find cooking symbol');
Symbol := setSymbolRecord(SYMBOL_COOK);
inc(i);
continue;
end else
Exit;
end else
break;
until I > 2;
I := 0;
aTPA := TPAtoATPAEx(TPA, 15, 15);
if Length(aTPA) <= 0 then Exit;
for i := 0 to High(aTPA) do
begin
P := MiddleTPA(aTPA[i]);
if not RS_onMiniMap(P.x, P.y) then continue;
player.present := isPlayerAt(P);
Mouse(P.x-randomRange(3, 6), P.y, 8, random(8), true);
wait(randomRange(500, 1500));
if FlagPresent then
begin
Flag();
result := True;
Exit;
end;
end;
end;
LOC_BANK:
begin
symbol := setSymbolRecord(SYMBOL_BANK);
with symbol do
begin
FindColorsTolerance(TPA, color, MMx1, MMy1, MMx2, MMy2, 5);
if Length(TPA) <= 0 then
begin
Exit;
writeLn('Could not find '+symbol+' symbol.');
end;
end;
DTM := DTMFromString('78DA634C61626098CC0006CC108AE1E8D1A30' +
'CCB18191818A17CC668A09A0E281B2AF6E70F13032B039A9A1E22D44' +
'CC4AF0600E6D00CB7');
DTMRotated(DTM, x, y, MMx1, MMy1, MMcx+25, MMy2);
FreeDTM(DTM);
if x or y = 0 then Exit;
Mouse(x+2, y, random(5), random(5), true);
wait(randomRange(750, 1500));
if FlagPresent then
begin
Flag();
result := true;
Exit;
end;
end;
end;
end;
function IsRun(): Boolean;
begin
Result := GetColor(724, 112) = 6806252;
end;
function NoRun(): Boolean;
var
x, y: Integer;
begin
Result := FindColor(x, y, 255, 735, 106, 760, 121);
end;
procedure SetRunEx();
begin
if not IsRun then
if not NoRun then
SetRun(True);
end;
function new_setChat(const index: byte; option: string): boolean;
var
area: tIntegerArray;
begin
case index of
CHATS_FRIENDS: area := [128, 484, 170, 496];
CHATS_CLAN: area := [184, 485, 225, 494];
CHATS_PUBLIC: area := [243, 485, 281, 497];
end;
if countColorTolerance(COLOR_MC_GREEN, area[0], area[1], area[2], area[3], 4) <= 0 then
begin
result := true;
Exit;
end;
mouseBox(area[0], area[1], area[2], area[3], 2);
wait(randomRange(250, 350));
result := chooseOption(option);
end;
function findRange(): Boolean;
var
aTPA: t2DPointArray;
TPA: tPointArray;
P: tPoint;
I: Cardinal;
H, x, y: Integer;
click: Boolean;
begin
findColorsToleranceOptimised(TPA, COLOR_MS_RANGE, MSx1, MSy1, MSx2, MSy2, 7);
if Length(TPA) <= 0 then Exit;
aTPA := SplitTPAEx(TPA, 20, 20);
if Length(aTPA) <= 0 then Exit;
SortATPASize(aTPA, true);
H := high(aTPA);
click := not player.present;
if click then
click := random(4) <> 1;
for i := 0 to H do
begin
P := MiddleTPA(aTPA[i]);
MMouse(P.x, P.y, random(5), random(5));
wait(randomRange(250, 550));
if isUpTextMultiCustom(['ange', 'evel']) then
begin
getMousePos(x, y);
Mouse(x, y, 0, 0, click);
wait(randomRange(150, 250));
chooseOption('se');
result := true;
Exit;
end;
end;
end;
function chooseCookAll(): Boolean;
begin
MouseBox(FSx1, FSy1, FSx2, FSy2, 2);
wait(randomRange(250, 350));
result := ChooseOption('All');
end;
function clickInvSlot(): Boolean;
var
TPA: tPointArray;
I: Integer;
b: tBox;
begin
repeat
I := randomRange(1, 28);
until ExistsItem(I);
b := InvBox(I);
MouseBox(b.x1, b.y1, b.x2, b.y2, 1);
result := FindColorsTolerance(TPA, COLOR_MI_WHITE, b.x1, b.y1, b.x2, b.y2, 3);
end;
function CookOption(): Boolean;
begin
result := CountColor(COLOR_MI_RED, MCx1, MCy1, MCx2, MCy2) > 0;
end;
procedure isCooking();
var
I, index: Byte;
pA, pB: tPoint;
tempC: Cardinal;
timer: LongInt;
begin
for i := 28 downto 1 do
begin
if ExistsItem(i) then
begin
Index := I;
break;
end;
end;
if Index = 1 then Exit;
pA := ItemCoords(Index);
pB := ItemCoords(Index-1);
tempC := getColor(pA.x, pA.y);
if tempC = COLOR_MI_OUTLINE then
while tempC = COLOR_MI_OUTLINE do
begin
pA.x := pA.x-1;
tempC := getColor(pA.x, pA.y);
end;
if not tempC = getColor(pA.x, pA.y) then
Exit;
timer := getSystemTime();
while getColor(pA.x, pA.y) = tempC do
begin
if getSystemTime()-timer > randomRange(80000, 120000) then
Exit;
wait(randomRange(500, 750));
findNormalRandoms();
if clickToContinue() then
begin
writeLn('gained Cooking level');
inc(Players[CurrentPlayer].Integers[lvl_gained]);
end;
if Random(15) = 1 then SleepAndMoveMouse(randomRange(1000, 6000));
end;
end;
function withdrawFood(): Boolean;
var
x, y: Integer;
text: string;
t: LongInt;
begin
if not BankScreen() then Exit;
MouseBox(WIx1, WIy1, WIx2, WIy2, 3);
t := getSystemTime();
{while not isUpText('aw') do
begin
wait(randomRange(250, 450));
findNormalRandoms();
if getSystemTime()-t > 2500 then
Exit;
end;}
wait(randomRange(150, 200));
getMousePos(x, y);
with players[currentplayer] do
begin
if Strings[food] = '' then
begin
text := grabText();
Strings[food] := copy(text, 6, length(text));
end;
end;
Mouse(x, y, 0, 0, false);
wait(randomRange(250, 450));
result := chooseOption('ithdraw-All');
end;
Procedure ProgressReport;
var
A: String;
i, ToPA, Load, Total: Integer;
begin
ClearDebug();
for i := 0 to HowManyPlayers-1 do
begin
if Players[i].Active then Inc(ToPA);
Total := Players[i].Integers[cooked]+Total;
Load := Players[i].Integers[loads]+Load;
end;
writeLn(' ________________________________________________________________________________');
writeLn('|`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`""`""`""`""`""`"`"`"`"`"`"`"`""`""`"`"`"`"`"`"`|');
writeLn('|`"|'+Indent(' Time Running : '+TimeRunning, 80));
writeLn('|`"|'+Indent(' Players Active : '+IntToStr(ToPA)+' out of '+IntToStr(HowManyPlayers)+' total', 80));
writeLn('|`"|'+Indent(' Cooked : '+IntToStr(Total)+' total fish', 80));
writeLn('|`"|'+Indent(' Completed : '+IntToStr(Load)+' total loads', 80));
writeLn('|`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`"`""`""`""`""`""`"`"`"`"`"`"`"`""`""`"`"`"`"`"`"`|');
for i := 0 to HowManyPlayers-1 do
begin
if Players[i].Active then
A := 'T'
else
A := 'F';
writeLn('|`"|'+Indent(' P['+IntToStr(i)+']: Active: '+A+'; Loads: '
+IntToStr(Players[i].Integers[loads])+'; Cooked: '+IntToStr(Players[i].Integers[cooked])
+'; Levels: '+IntToStr(Players[i].Integers[lvl_gained])+'; Type: '
+Capitalize(trim(players[i].strings[Food])), 80));
end;
writeLn('|________________________________________________________________________________|');
end;
var
timer: LongInt;
I: Integer;
opt: tStringArray;
begin
if SMART_world <> 0 then
SMART_Server := SMART_world;
SMART_members := false;
SMART_signed := true;
SetUpSRL();
DeclarePlayers();
opt := ['id', 'ff'];
while not LoggedIn() do LogInPlayer();
repeat
if not LoggedIn() then LogInPlayer();
// Set Up Player
setAngle(true);
makeCompass('N');
Players[CurrentPlayer].Integers[loads] := 0;
new_setChat(CHATS_FRIENDS, 'vat');
new_setChat(CHATS_PUBLIC, opt[random(high(opt))]);
new_setChat(CHATS_CLAN, 'ff');
while Players[CurrentPlayer].Active do
begin
// Breaking System
if AVG_loads >= 2 then
if players[CurrentPlayer].integers[loads] <> 0 then
if players[CurrentPlayer].Integers[loads] mod randomRange(AVG_loads-2, AVG_loads+4) = 0 then
begin
if BankScreen() then closeBank();
wait(randomRange(500, 1000));
LogOut();
if howManyPlayers = 1 then
begin
writeLn('Break Handler Initiated. Sleeping for aprox. 2-4 minutes.');
Sleep(randomRange(120000, 40000));
end else
writeLn('Switching Players.');
NextPlayer(True);
end;
// Banking Loop
status(' Banking Loop ');
repeat
wait(randomRange(350, 650));
if not OpenBankFast('akb') then
inc(I)
else
break;
if I > 5 then
begin
writeLn('could not open bank.');
logOut();
NextPlayer(False);
break;
end;
until False;
timer := getSystemTime();
while not BankScreen() do
begin
wait(randomRange(150, 550));
findNormalRandoms();
if getSystemTime()-timer > 2000 then
break;
end;
wait(randomRange(450, 750));
if Random(5) = 1 then DepositAll()
else
Deposit(1, 28, true);
if Players[CurrentPlayer].Integers[loads] = 0 then
BankColor := getcolor(53, 109);
if countColorTolerance(BankColor, WIx1, WIy1, WIx2, WIy2, 10) <= 0 then
begin
writeLn('Cooked all Food. NextPlayer');
CloseBank();
wait(RandomRange(500, 1000));
logOut();
NextPlayer(False);
Break;
end;
if not WithdrawFood() then
begin
writeLn('Could not Withdraw Food.');
if BankScreen() then CloseBank();
wait(randomRange(500, 1000));
LogOut();
NextPlayer(false);
end;
timer := getSystemTime();
while InvCount = 0 do
begin
wait(randomRange(500, 750));
if getSystemTime-timer > randomRange(2500, 3500) then
break;
end;
if InvCount() < 10 then
begin
writeLn('Could not Withdraw Food. NextPlayer');
if BankScreen() then CloseBank();
LogOut();
NextPlayer(False);
end;
incEx(Players[currentplayer].Integers[cooked], InvCount());
findNormalRandoms();
// Walking Loop (to Range)
status(' Walking Loop ');
setRunEx();
if not CreateWalkLocation(LOC_COOK) then
begin
writeLn('Walking to Range Failed. NextPlayer');
LogOut();
NextPlayer(False);
end;
wait(randomRange(950, 1200));
findNormalRandoms();
// Cooking Loop
status(' Cooking Loop ');
if clickInvSlot() then
begin
for I := 0 to 20 do
begin
if findRange() then
break;
if I = 5 or randomRange(8, 11) then
clickInvSlot();
if I > 15 then
begin
writeLn('Could not Find Range.');
LogOut();
NextPlayer(False);
end;
wait(randomRange(250, 550));
end;
wait(randomRange(500, 1000));
timer := getSystemTime();
while not CookOption() do
begin
wait(randomRange(350, 450));
if getSystemTime()-timer > randomRange(3000, 5000) then
break;
findNormalRandoms();
end;
if chooseCookAll() then
isCooking();
end;
wait(randomRange(500, 750));
findNormalRandoms();
// Walking Loop (to Bank)
status(' Walking Loop ');
setRunEx();
if not CreateWalkLocation(LOC_BANK) then
begin
findNormalRandoms();
writeLn('Walking to Bank Failed. NextPlayer');
LogOut();
NextPlayer(False);
end;
wait(randomRange(900, 1200));
inc(Players[CurrentPlayer].Integers[loads]);
progressReport();
end;
until allPlayersInactive();
end.