program MiningAdvantage;
{.include SRL\SRL.scar}
{.include SRL\SRL\MISC\KYAB.scar}
{******************************************************************************}
const
RunDir = 'N'; //Direction to run in if a fight is found.
MaxLevel = 31; //The max mining level of the player.
MaxSecsPerRock = 8; //Max seconds per rock.
MinutesPerPlayer = 15; //How many minutes per player.
RandomStarter = True; //Choose a random player to start with.
var PickDTM, PlayerTime, RandomsTime : Integer;
var CopperColors, TinColors, TutorColors : Array of Integer;
var ToMine : Array of Tpoint;
{******************************************************************************}
procedure LoadScript;
var T : Integer;
begin
MarkTime(T);
SetupSRL;
if (Not(SetupKYAB)) then TerminateScript;
MouseSpeed := 20;
ClickTileTimeout := 10000;
MarkTime(RandomsTime);
PickDTM := DTMFromString('78DA637462626060646440067AF20C0CFF813' +
'448F43F10300603D5FC6340038C482490F600AAF94C408D3950CD' +
'0F026AAC806AF818F1ABB125AC0600450009FA');
CopperColors:= [4681883,4945571,3296877];
TinColors:= [7895168,6250343,5855584];
TutorColors := [3942946, 7690063, 6178368, 8676185, 3151633, 7050175];
SetArrayLength(ToMine, 20);
ToMine[0].X:=3227; ToMine[0].Y:=3217;
ToMine[1].X:=3232; ToMine[1].Y:=3217;
ToMine[2].X:=3236; ToMine[2].Y:=3215;
ToMine[3].X:=3236; ToMine[3].Y:=3209;
ToMine[4].X:=3237; ToMine[4].Y:=3205;
ToMine[5].X:=3237; ToMine[5].Y:=3201;
ToMine[6].X:=3241; ToMine[6].Y:=3199;
ToMine[7].X:=3245; ToMine[7].Y:=3196;
ToMine[8].X:=3245; ToMine[8].Y:=3192;
ToMine[9].X:=3245; ToMine[9].Y:=3187;
ToMine[10].X:=3245; ToMine[10].Y:=3182;
ToMine[11].X:=3242; ToMine[11].Y:=3179;
ToMine[12].X:=3241; ToMine[12].Y:=3174;
ToMine[13].X:=3239; ToMine[13].Y:=3170;
ToMine[14].X:=3239; ToMine[14].Y:=3164;
ToMine[15].X:=3242; ToMine[15].Y:=3159;
ToMine[16].X:=3238; ToMine[16].Y:=3156;
ToMine[17].X:=3235; ToMine[17].Y:=3151;
ToMine[18].X:=3232; ToMine[18].Y:=3148;
ToMine[19].X:=3228; ToMine[19].Y:=3145;
KYAB_Log('Script loaded in ' + IntToStr(T) + 'ms.');
end;
{=*****************************************************=}
{= ANTIBAN =}
{=*****************************************************=}
procedure ExamineInventory;
var j : Integer;
var T : Tpoint;
begin
if (Not(LoggedIn)) then Exit;
repeat
if (InvCount = 0) then Exit;
j := Random(28) + 1;
until(ExistsItem(j));
T := ItemCoords(j);
Mouse(T.x, T.y, 3, 3, False);
Wait(150 + Random(150));
ChooseOption('xamine');
Wait(100 + Random(500));
end;
procedure RCompassLittle;
var i : Byte;
var r : Integer;
begin
if (Not(LoggedIn)) then Exit;
//Set R to equal either 0 or 1.
r := Random(2);
case r of
//If R was equal to 0, then set i to VK_Left.
0: i := VK_LEFT;
//If R was equal to 1, then set i to VK_Right.
1: i := VK_RIGHT;
end;
//Hold the selected key down.
KeyDown(i);
//Wait for a minimum of 100ms plus a random 200ms.
Wait(50 + Random(300));
//Release the selected key.
KeyUp(i);
end;
procedure RTypeSend(TypeList : TStringArray);
var i : Integer;
begin
i := Random(GetArrayLength(TypeList) - 1);
TypeSend(TypeList[i]);
end;
procedure REmote;
begin
DoEmote(1 + Random(20));
end;
procedure RGameTab;
var i : Integer;
begin
i := GetCurrentTab;
GameTab(1 + Random(12));
Wait(100 + Random(4000));
GameTab(i);
end;
procedure RRotate;
var i : Integer;
begin
i := Random(4);
case i of
0: MakeCompass('N');
1: MakeCompass('E');
2: MakeCompass('S');
3: MakeCompass('W');
end;
end;
function Antiban : Boolean;
var i : Integer;
begin
if (Not(LoggedIn)) then Exit;
i := Random(400);
case i of
0: RandomRClick;
1: HoverSkill('random', False);
2: PickUpMouse;
3: AlmostLogout;
4: RandomMovement;
5: Wait2(3000 + Random(3000), True);
6: RRotate;
7: ExamineInventory;
8: RGameTab;
9: BoredHuman;
10: REmote;
11: RTypeSend(['hehe', 'heh', 'ha', 'hah', 'hihi', 'rofl', 'lol', 'loll', 'haha', 'lolz', 'lol/']);
12: RTypeSend(['boring', 'bored', '*sigh*', 'bored...', 'boring...', 'so bored']);
13: RCompassLittle;
end;
if (InRange(i, 0, 12)) then Result := True;
end;
{=*****************************************************=}
{= END ANTIBAN =}
{= =}
{= START RANDOMS =}
{=*****************************************************=}
Function FindFastRandoms: Boolean; // By WT-Fakawi.
var
i: Integer;
begin
if (Not(TimeFromMark(RandomsTime) > 2000)) then Exit;
if (Not(LoggedIn)) then Exit;
MarkTime(RandomsTime);
for i:=1 to 14 do
begin
case I of
1: If FindDead then
Result := True;
2: If FindMod then
Result := True;
3: If FindMime then
Result := True;
4: If FindMaze then
Result := True;
5: If FindQuiz then
Result := True;
6: If FindDemon then
Result := True;
7: if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
8 : If RC Then Result := True;
9: If FindTalk Then Result := True;
11: If SolveChatRandom Then Result := True;
12: ClickToContinue;
13: while (FindBox) do
begin
SolveBox;
end;
14: if FindFight then
begin
RunAwayDirection(RunDir);
Wait(8500 + Random(5000));
RunBack;
end;
End;
Wait(1);
end;
end;
{=*****************************************************=}
{= END RANDOMS =}
{=*****************************************************=}
function NextEmptyPosition : Integer; //Starting from 1, returns the next free inventory position.
var i : Integer;
begin
if (Not(LoggedIn)) then Exit;
GameTab(4);
for i := 1 To 28 do
begin
if (Not(ExistsItem(i))) then
begin
Result := i;
Exit;
end;
end;
end;
procedure ArrangeInventory;
var i : Integer;
begin
if (Not(LoggedIn)) then Exit;
GameTab(4);
if (InvCount > 20) then Exit;
Disguise('Arranging inventory.');
for i := 1 to 28 do
begin
if (ExistsItem(i)) then DragItem(i, NextEmptyPosition);
end;
Disguise('');
end;
function PlayerInBox(X1, Y1, X2, Y2 : Integer) : Boolean;
var PX, PY : Integer;
begin
if (Not(LoggedIn)) then Exit;
PX := GetPlayerX;
PY := GetPlayerY;
if (PX > X1) and (PY > Y1) and (PX < X2) and (PY < Y2) then Result := True;
end;
function AllPlayersInactive : Boolean;
var
Player, Inactive: Integer;
begin
for Player:= 0 to HowManyPlayers - 1 do
begin
if(Players[Player].Active = False) then
Inactive := Inactive + 1;
end;
if (Inactive = HowManyPlayers) then Result := True;
end;
function GotAnimation : Boolean;
begin
if (Not(LoggedIn)) then Exit;
//If GetAnimation does not return -1 (no animation) then we have go animation, return true.
Result := Not(GetAnimation = -1);
FindFastRandoms;
end;
procedure WaitStop;
begin
if (Not(LoggedIn)) then Exit;
//If we are moving then do the loop, if we are not then do not execute.
while(KYAB_isMoving) do
begin
//If we are not logged in then exit the procedure.
if (Not(LoggedIn)) then Exit;
//And wait 100ms.
Wait(100);
end;
FindFastRandoms;
end;
function WalkIntoMine : Boolean;
begin
if (Not(LoggedIn)) then Exit;
Result := NewWalkToTileTol(3227, 3144, 3);
FindFastRandoms;
end;
function HomeTeleport : Boolean;
var T : Integer;
begin
if (Not(LoggedIn)) then Exit;
Disguise('Casting H. Teleport.');
FindFastRandoms;
GameTab(7);
Wait(100 + Random(100));
Mouse(570, 237, 3, 3, True);
MarkTime(T);
repeat
if (GotAnimation) then
begin
Result := True;
Break;
end;
if (TimeFromMark(T) > 5000) then Exit;
Wait(200 + Random(100));
until(false);
while (GotAnimation) do
begin
Wait(200 + Random(100));
end;
Wait(500 + Random(500));
FindFastRandoms;
Disguise('');
end;
procedure Walk(Path : Array of TPoint);
var i : Integer;
begin
for i := 0 To GetArrayLength(Path) - 1 do
begin
if (Not(LoggedIn)) then Exit;
NewWalkToTileTol(Path[i].X, Path[i].Y, 3);
if (RboolEx(5)) then RCompassLittle;
end;
end;
procedure DropExceptName(ItemList : TStringArray);
var J : TPoint;
var i, X, Y : Integer;
begin
if (Not(LoggedIn)) then Exit;
GameTab(4);
for i := 1 To 28 do
begin
if (Not(ExistsItem(i))) then Continue;
J := ItemCoords(i);
MMouse(J.X, J.Y, 3, 3);
Wait(150 + Random(150));
if (Not(IsUpTextMultiCustom(ItemList))) then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(150 + Random(150));
ChooseOption('rop');
end;
end;
end;
function GotPick : Boolean;
var X, Y : Integer;
begin
if (Not(LoggedIn)) then Exit;
Disguise('Checking for pickaxe.');
if (GetCurrentTab = 4) then
begin
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Exit;
GameTab(5);
Wait(150 + Random(150));
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Exit;
end;
if (GetCurrentTab = 5) then
begin
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Exit;
GameTab(4);
Wait(150 + Random(150));
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Mouse(X, Y, 4, 4, True);
end;
GameTab(4);
Wait(150 + Random(150));
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Exit;
GameTab(5);
Wait(150 + Random(150));
Result := FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2);
if (Result) then Mouse(X, Y, 4, 4, True);
end;
procedure GetPick;
var T, X, Y : Integer;
begin
if (Not(LoggedIn)) then Exit;
Disguise('Getting another pickaxe.');
FindFastRandoms;
GameTab(4);
MarkTime(T);
repeat
if (FindObjCustom(X, Y, ['tuto', 'utor', 'alk-', 'k-to'], TutorColors, 3)) then Break;
if (TimeFromMark(T) > 15000) then Exit;
until(false);
case RBool of
True: Mouse(X, Y, 0, 0, True);
False: begin
Mouse(X, Y, 0, 0, False);
Wait(150 + Random(150));
if (Not(ChooseOption('alk-'))) or (Not(ChooseOption('lk-to'))) then Exit;
end;
end;
Wait(250 + Random(250));
WaitStop;
Disguise('Talking to Mining tutor.');
MarkTime(T)
repeat
if (ClickNpcChatText('basics', True)) or (ClickNpcChatText('teach', True)) or
(ClickNpcChatText('me the', True)) or (ClickNpcChatText('please', True)) then Break;
if (TimeFromMark(T) > 5000) then Exit;
Wait(50 + Random(50));
until(false);
MarkTime(T);
repeat
if (ClickToContinue) then MarkTime(T);
if (FindDTM(PickDTM, X, Y, MIX1, MIY1, MIX2, MIY2)) then
begin
Disguise('We receieved a pickaxe.');
Wait(500 + Random(200));
Disguise('');
Exit;
end;
if (TimeFromMark(T) > 7500) then Exit;
Wait(100);
until(false);
end;
function Location : String;
begin
if (Not(LoggedIn)) then Exit;
if (PlayerInBox(3218, 3209, 3226, 3224)) then
begin
Result := 'castle';
Exit;
end;
if (PlayerInBox(3221, 3139, 3235, 3150)) then
begin
Result := 'mine';
Exit;
end;
Result := 'lost';
Disguise('We are at ' + Capitalize(Result) + '.');
Wait(500 + Random(200));
Disguise('');
end;
procedure ClearInventory;
begin
if (Not(LoggedIn)) then Exit;
Disguise('Clearing inventory.');
DropExceptName(['pickaxe', 'oins', 'iamond', 'uby', 'aphire', 'merald']);
if (RBoolEx(3)) then ArrangeInventory;
FindFastRandoms;
Disguise('');
end;
procedure UserSetup;
begin
Disguise('Setting up the user.');
if (Not(LoggedIn)) then LoginPlayer;
MakeCompass('N');
HighestAngle;
SetRun(True);
MarkTime(PlayerTime);
//Set brightness to VHigh...
SetBar('Brightness', 4);
Disguise('');
end;
function MineRock : Boolean;
var Col : Array of Integer;
var X, Y, T, I : Integer;
begin
if (Not(LoggedIn)) then Exit;
FindFastRandoms;
case RBool of
True: Col := TinColors;
False: Col := CopperColors;
end;
if (FindObjCustom(X, Y, ['Mine', 'Rock', 'ine', 'Roc', 'roc', 'ock'], Col, 3)) then
begin
Result := True;
case RBoolEx(4) of
True: begin
Mouse(X, Y, 0, 0, False);
Wait(150 + Random(150));
case RBool of
True: ChooseOption('ine');
False: ChooseOption('ock');
end;
end;
False: Mouse(X, Y, 0, 0, True);
end;
end;
if (Not(Result)) then
begin
WalkIntoMine;
Exit;
end;
Wait(500 + Random(500));
WaitStop;
Wait(500 + Random(500));
MarkTime(T);
while (GotAnimation) do
begin
while (GotAnimation) do
begin
{===========================}
for i := 0 to 2 do
begin
case i of
0: if (FindFastRandoms) then Exit;
1: Antiban;
2: if (TimeFromMark(T) > MaxSecsPerRock * 1000) then Exit;
end;
Wait(1);
end;
Wait(250 + Random(250));
{===========================}
end;
Wait(1000 + Random(1000));
end;
FindFastRandoms;
end;
begin
LoadScript;
ClearDebug;
SRLPlayerForm(True, [], [], [], []);
Disguise('Starting script.');
Wait(1000);
Disguise('');
case RandomStarter of
True: CurrentPlayer := Random(HowManyPlayers - 1);
False: CurrentPlayer := 0;
end;
repeat
if(Not(LoggedIn)) then
begin
Disguise('Logging in player.');
LoginPlayer;
end;
UserSetup;
repeat
case Location of
'castle': Walk(ToMine);
'lost': begin
if (Not(HomeTeleport)) then Break;
Walk(ToMine);
end;
end;
if (Not(Location = 'mine')) then WalkIntoMine;
if (Not(GotPick)) then GetPick;
MineRock;
if (RBoolEx(4)) then
begin
if (GetSkillLevel('mining') > MaxLevel) then Logout;
end;
if (InvCount = 28) then ClearInventory;
until(TimeFromMark(PlayerTime) > MinutesPerPlayer * 60000) or (Not(LoggedIn));
if (AllPlayersInactive) then Break;
if (LoggedIn) then NextPlayer(True) else NextPlayer(False);
until(false);
Disguise('Script finished.');
end.