Simba Code:
program DirectionTest;
{$DEFINE SMART}
{$i srl/srl.simba}
{$I SRL/SRL/MISC/SMARTGRAPHICS.SIMBA}
{$i sps/sps.simba}
const
Server = 35; // enter "0" to pick a Random server.
Members = False; // is this player a member
NumbOfPlayers = 1; // how many players should be active
StartPlayer = 0; // the player who should be first used
LoadsToDo = 73; // Set how many repetitions to do of a certain Activity
PowerMine = False; // True Or False For Drop Ore
OreChoice = 0; // Valid Mining Choices
var
Path:TPointArray;
OreSpot:Tpoint;
Desc:String;
Start_Time, End_Time, TotalTime, TripStart, TripEnd, TripTotal, Colour,
TolR, Cam, CopperLoads, ClayLoads, GoldLoads, IronLoads, TinLoads,
TotalLoads, MCurrentXP, MOriginalXP, CMSkillLevel, MSkillGain,
TotalXP, OMSkillLevel: Integer;
MineFirstRun, LostMyWay:Boolean;
MBox:TBox;
procedure DeclarePlayers; // Setup Players
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with players[0] do
Begin
Name := ''; // Player Username
Pass := ''; // Player Password
Pin := ''; // Player Bankpin Number
Nick := ''; // Player Nickname
Worldinfo := [Members,Server];
Boxrewards := ['xp','xp','lamp'];
Lampskill := Skill_Crafting;
Active := True;
End;
End;
procedure SetLocation;
Begin
Flag;
SPS_WalkToPos(OreSpot);
End;
function AutoColorIron: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.93);
FindColorsSpiralTolerance(MSCX, MSCY, arP, 3227492, MSX1, MSY1, MSX2, MSY2, 7);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
procedure SelectRock(Choice:Integer); // Select The Type Of Rock To Mine
Begin
Case Choice of
0: Begin // Mine Iron
Colour := AutoColorIron;
TolR := 7;
Desc := 'ron';
Case Random(3) of
0..1: Begin
OreSpot := Point(139,208);
Cam := 150;
End;
2: Begin
OreSpot := Point(95,184);
Cam := 0;
End;
End;
End;
End;
End;
type
TRadial = record
Length: Integer;
Angle: Extended;
Direction: String;
end;
function GetRadial(A, B: TPoint): TRadial; // Credit To Runaway
var // For This Function
Direction: TStringArray;
Angle: Extended;
begin
Direction := ['n', 'e', 's', 'w'];
Angle := Degrees(FixRad((ArcTan2(A.y - B.y, A.x - B.x) + Radians(90)) - Pi));
if not InRange(Round(Angle), 0, 360) then
Exit;
Result.Length := Distance(A.x, A.y, B.x, B.y);
Result.Angle := Angle;
if (Angle >= 315) then
Angle := 360 - Angle;
Result.Direction := Direction[Round(Angle / 90.0)];
end;
Function IsVein(var VBox:TPoint): Boolean;
var
VX, VY, x, y: Integer;
VTPA : Array Of TPoint;
ATPA : T2DPointArray;
i : Integer;
Begin
SMART_DrawBoxEx(True, False, IntToBox(VBox.x - 12, VBox.y - 12, VBox.x + 12, VBox.y + 12), ClWhite)
FindColorsSpiralTolerance(VX, VY, VTPA, Colour, VBox.x - 12, VBox.y - 12, VBox.x + 12, VBox.y + 12, TolR)
Begin
ATPA := SplitTPA(VTPA, 6);
For i := 0 To High(ATPA) Do
Begin
If MiddleTPAEX(ATPA[i], VX, VY) then
Begin
MMouse(VX, VY, 1, 1);
End else
Continue;
WriteLn(GetUpText);
Result := FindColorTolerance(x, y, Colour, VBox.x - 12, VBox.y - 12, VBox.x + 12, VBox.y + 12, TolR);
WriteLn(Result);
Exit;
End;
End;
End;
Function FindOre(var x,y:integer) : Boolean;
var
ItemX, ItemY : Integer;
TPA : Array Of TPoint;
ATPA : T2DPointArray;
i : Integer;
PlayerBox, MBox: TPointArray;
Begin
SMART_ClearMS;
PlayerBox := TPAFromBox(IntToBox(MSCx - 15, MSCy - 25, MSCx + 15, MSCy + 20));
// MiningBox := IntToBox((x + 100),(y + 100),(x - 100),(y - 100));
// SMART_DrawBoxEx(True, False, IntToBox((MSCX - 100), (MSCY - 100), (MSCX + 100), (MSCY + 100)), ClRed);
FindColorsSpiralTolerance(ItemX, ItemY, TPA, Colour, (MSCX - 80), (MSCY - 80), (MSCX + 80), (MSCY + 80), TolR)
ClearTPAFromTPAWrap(TPA, PlayerBox, {var}TPA);
SortTPAFrom(TPA, IntToPoint(MSCx, MSCy));
Begin
ATPA := SplitTPA(TPA, 10);
For i := 0 To High(ATPA) Do
Begin
If MiddleTPAEX(ATPA[i], ItemX, ItemY) then
Begin
MMouse(ItemX, ItemY, 1, 1);
End else
Continue;
If WaitUptext(Desc, 300) Then
Begin
x := ItemX;
y := ItemY;
Writeln('We Have Found The Ore');
Result := True;
Exit;
End;
End;
End;
End;
procedure Mining; // Mining Operations
var
x, y, RockCounter, FailSafeTime, TempTime, Counter, ODistance,
NDistance, TDistance: integer;
Mined:Boolean;
Ore, NOre, Player:Tpoint;
VBox:TBox;
Direction:TRadial;
Begin
If FindNormalRandoms then
Begin
If Not LoggedIn Then
Begin
Writeln('Found unsolvable random');
NextPlayer(False);
End;
End;
MarkTime(FailSafeTime);
Writeln('Clear The Canvas');
SMART_ClearMS;
Writeln('Select The Type Of Ore To Mine');
Mined := False;
SelectRock(OreChoice);
ToggleXPBar(True);
Writeln('Set The Location Of The Ore I`m Going To Mine');
SetLocation;
While IsMoving do
Begin
Wait(50);
If (TimeFromMark(FailSafeTime) > 5000) then
Begin
Break;
End;
End;
MakeCompass(Cam);
Wait(200 + Random(100));
SetAngle(SRL_ANGLE_HIGH);
MarkTime(FailSafeTime);
Mined := False;
Writeln('The Beginning Of the Mining Sequence');
Repeat
Disguise('Starting Mining For ' + Desc);
If FindNormalRandoms then
Begin
If Not LoggedIn Then
Begin
Writeln('Found unsolvable random');
NextPlayer(False);
End;
End;
SelectRock(OreChoice);
While IsMoving Do
Begin
Wait(10);
End;
Writeln('Start Looking For The Ore');
If (FindOre(x, y)) then
Begin
MBox := IntToBox(x - 10, y - 10, x + 10, y + 10);
VBox := IntToBox(x - 15, y - 15, x + 15, y + 15);
SMART_DrawBoxEx(True, False, MBox, ClGreen);
If not(Mined) Then
Begin
ClickMouse2(Mouse_Left);
MarkTime(RockCounter);
MarkTime(FailSafeTime);
Mined := True;
Ore := Point(x, y);
Writeln(Ore);
Player := Point(MSCX, MSCY);
Direction := GetRadial(Ore, Player);
ODistance := Direction.Length;
Writeln(Direction);
Writeln('Clicked The Ore To Start Mining');
End;
// Wait(RandomRange(800, 1200));
End;
While IsMoving Do
Begin
SMART_ClearCanvasArea(VBox);
Player := Point(MSCX, MSCY);
Direction := GetRadial(Ore, Player);
NDistance := Direction.Length;
Writeln('New TPoint For Ore');
TDistance = (ODistance - NDistance);
ODistance := NDistance;
NOre := Point(x, y - TDistance);
Ore := NOre;
Writeln('Create New Box');
VBox := IntToBox(NOre.x - 20, NOre.y - 20, NOre.x + 20, NOre.y + 20);
SMART_DrawBoxEx(True, False, IntToBox(NOre.x - 12, NOre.y - 12, NOre.x + 12, NOre.y + 12), ClWhite)
End;
Antiban;
While IsVein(NOre) or not(FindBlackChatMessage('nage')) or (TimeFromMark(RockCounter) > (3700 + Random(300))) and (not(IsMining)) do
Begin
Writeln('Looking For The Vein Color');
If FindNormalRandoms then
Begin
If Not LoggedIn Then
Begin
Writeln('Found unsolvable random');
NextPlayer(False);
End;
End;
End;
{ Repeat
Writeln('Looking For The Vein Color');
If FindNormalRandoms then
Begin
If Not LoggedIn Then
Begin
Writeln('Found unsolvable random');
NextPlayer(False);
End;
End;
Until {not(IsVein(NOre)) or }(FindBlackChatMessage('nage')) or (TimeFromMark(RockCounter) > (3700 + Random(300))) and (not(IsMining));}
Writeln('Starting Next Loop For Finding Ore');
Mined := False;
SMART_ClearCanvasArea(VBox);
Until (InvFull);
End;
procedure SetupClient; // Setup Client For Run
Begin
WriteLn('Start Bot Client');
SRL_SIXHOURFIX := True;
SMART_FIXSPEED := True;
Setupsrl;
SRL_EnableNavBar;
Objdtm_Setup;
DeclarePlayers;
If not (loggedin) then
Begin
LoginPlayertoLob;
OpenWorldScreen;
SelectWorld(Server);
LoginPlayer;
Wait(4000+Random(400));
End;
SPS_Setup(RUNESCAPE_OTHER,['remington']);
End;
Begin // Begin Main Loop
SetupClient;
SetAngle(srl_angle_high);
// Repeat
Mining;
// Until allplayersinactive;
End.