Simba Code:
program CoalRaper;
{
Credits to:
Flight - Mousemovements
superuser - Surfaces
NKN - Being picky about giving credits
}
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/SmartGraphics.simba}
{$i sps/sps.simba}
{$i su_surfaces.simba}
var
obj_coal_rock,obj_deposite: TSurfaceObject;
World_valid:TintegerArray;
logout_message:TstringArray;
MineTimeout, player_count, PSX1, PSY1, PSX2, PSY2, Seconds:Integer;
StartTime, XpGained, OresMined, tries, bad_rocks:Integer;
Hop_mode, Status, reason, Log_action:string;
Procedure DeclareVs;
begin
NumberOfPlayers(1);
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Active := True;
MineTimeout := 3800; // timeout of mining rock
Hop_mode := 'yes'; // [yes], [no]
Log_action := 'yes' // type in "no" if you don't want to
player_count := 3; // number of players before hopping
// change location were it logs to at line 164
{free worlds}
world_Valid := [3, 7, 8, 11, 13, 17, 19, 20, 29, 33, 34, 38, 41, 43, 57, 61, 80, 81, 108, 120, 135, 136]
{members worlds}
//world_Valid := [1, 2, 4, 5, 6, 9, 10, 12, 14, 15, 16, 18, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 35, 36, 37, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 56, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 27, 73, 74, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 96, 97, 98, 99, 100, 103, 104, 105, 106, 114, 115, 116, 117, 119, 123, 124, 134, 137, 138, 139]
{both worlds}
//world_Valid := [3, 7, 8, 11, 13, 17, 19, 20, 29, 33, 34, 38, 41, 43, 57, 61, 80, 81, 108, 120, 135, 136, 1, 2, 4, 5, 6, 9, 10, 12, 14, 15, 16, 18, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 35, 36, 37, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 56, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 27, 73, 74, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 96, 97, 98, 99, 100, 103, 104, 105, 106, 114, 115, 116, 117, 119, 123, 124, 134, 137, 138, 139]
//logout_message := ['to full','to many bots ffs'] // message to say if world is full
//message_odds := [1,1000] // 1 out of 1000
PSX1 := 251;
PSY1 := 213;
PSX2 := 264;
PSY2 := 233;
end;
Procedure SuperWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
Var
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
lastX,lastY,MSP,W: integer;
sqrt2,sqrt3,sqrt5: extended;
Begin
MSP := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
While hypot(xs - xe, ys - ye) > 1 Do
Begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
If dist >= targetArea Then
Begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
End Else
Begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
If (maxStep < 3) Then
Begin
maxStep:= random(3) + 3.0;
End Else
Begin
maxStep:= maxStep / sqrt5;
End;
End;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
Begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
End;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
Case RanDom(50) Of
1..25: W := (MSP + (RanDom((MSP/4))));
26..50: W := (MSP - (RanDomRange((MSP/2), MSP-1)));
End;
If (W < 1) Then
W := 1;
If (lastX <> Round(xs)) Or (lastY <> Round(ys)) Then
MoveMouse(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
wait(W);
lastdist:= dist;
End;
If (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) Then
MoveMouse(Round(xe), Round(ye));
MouseSpeed := MSP;
End;
Procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
Var
randSpeed: extended;
X,Y,X2,Y2,j,Dist,MP: integer;
Begin
j := MouseSpeed;
GetMousePos(X, Y);
Dist := Distance(X, Y, eX, eY);
MP := Round(Dist/150);
If MP < 0 Then
MP := 1;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
X2 := RanDomRange(eX-(j*MP), eX+(j*MP));
Y2 := RanDomRange(eY-(j*MP), eY+(j*MP));
SuperWindMouse(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
GetMousePos(X, Y);
MMouse(eX, eY, ranX, ranY);
MouseSpeed := j;
End;
procedure WriteProgress;
Var
OresPerHour,XpPerHour, CashGained, CashPerHour:Integer;
begin
Seconds := (1 + ((Getsystemtime - StartTime) / 1000));
XpGained := (OresMined*50);
XpPerHour := (3600 * XPGained) / (Seconds);
OresPerHour := (3600 * OresMined) / Seconds;
CashGained := (OresMined*250);
CashPerHour := (3600 * CashGained) / Seconds;
ClearDebug;
Writeln('*****************************');
Writeln('Time Running:' + TimeRunning + '');
Writeln('State:' + Status);
writeln('Mining XP: ' + ToStr(XPGained) + ' | ' + ToStr(XpPerHour) + ' per hour');
writeLn('Coal Mined: ' + ToStr(OresMined) + ' | ' + ToStr(OresPerHour) + ' per hour');
writeLn('Cash gained: ' + ToStr(CashGained) + ' | ' + ToStr(CashPerHour) + ' per hour');
Writeln('*****************************');
end;
function OpenReportFile(): integer;
var
fileName, Bot_SavePath: string;
begin
Bot_SavePath := 'C:/Simba/'
if (not directoryExists(Bot_SavePath)) then
forceDirectories(Bot_SavePath);
fileName := 'Coal Raper [MJ style].txt';
fileName := Bot_SavePath + fileName;
try
if (fileExists(fileName)) then
result := appendFile(fileName)
else
result := createFile(fileName);
except
writeln('OpenSRLLogFile: '+exceptionToString(exceptionType, exceptionParam));
end;
end;
procedure update_state_log(s: string);
var
tmpFile: integer;
begin
status := s;
writeProgress;
if Log_action = 'no' then exit;
tmpFile := OpenReportFile();
if (tmpFile >= 0) then
try
writeFileString(tmpFile, '['+msToTime(getTimeRunning(), TIME_BARE)+']: '+s+#13+#10);
except
Writeln('Error writing File');
finally
closeFile(tmpFile);
end;
end;
procedure AntiBan;
begin
case random(10000) of
1: MakeCompass(255 - Random(30));
2: MakeCompass(255 + Random(30));
3..10: Wait(RandomRange(1500, 4000));
11..12: Wait(RandomRange(2000, 17000));
13..19: RandomRClick;
20..70: BoredHuman;
end;
end;
procedure InitRocks();
begin
SMART_ClearMS();
CreateSurfaceParts(obj_coal_rock, 2);
with obj_coal_rock do begin
parts[0].c := 1460836;
parts[0].hm := 0.05;
parts[0].sm := 1.21;
parts[0].t := 10;
parts[0].minw := 4; // At least 4 pixels wide.
parts[0].maxw := 35; // No more than 80 pixels wide.
parts[0].minh := 4; // At least 4 pixels tall.
parts[0].maxh := 30; // No more than 80 pixel tall.
parts[0].step := 9;
parts[0].max_distance := 200;
parts[1].c := 2303269;
parts[1].hm := 1.67;
parts[1].sm := 0.15;
parts[1].t := 10;
parts[1].filter := @SurfaceFilterClosest; // We want to have the closest iron rock next to us.
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;
name := 'Coal ore';
uptext := 'Coal';
filter := @SurfaceFilterClosest;
end;
CreateSurfaceParts(obj_Deposite, 2);
with obj_Deposite do begin
parts[0].c := 6845305;
parts[0].hm := 0.16;
parts[0].sm := 0.07;
parts[0].t := 8; //5
parts[0].minw := 1;
parts[0].maxw := 120;
parts[0].minh := 1;
parts[0].maxh := 130;
parts[0].step := 9;
parts[0].max_distance := 900;
parts[1].c := 5140096;
parts[1].hm := 0.05;
parts[1].sm := 0.38;
parts[1].t := 13; //4
parts[1].filter := @SurfaceFilterClosest;
parts[1].minw := 5;
parts[1].maxw := parts[0].maxw;
parts[1].minh := 5;
parts[1].maxh := parts[0].maxh;
parts[1].step := 16;
parts[1].max_distance := parts[0].max_distance;
name := 'Deposite booth';
uptext := 'deposite';
filter := @SurfaceFilterClosest;
end;
end;
Procedure SwitchWorld;
Var
o, j:Integer;
begin
update_state_log('Hopping worlds because ' + reason)
o := Random(high(World_Valid))
j := Random(high(logout_message))
//i := Random(message_odds[1])// := ['1','1000'] // 1 out of 1000
//if (i>=message_odds[0]) then smartsendkeys(ToStr(logout_message[j]),5,5);
ChangeWorld(World_Valid[o]);
end;
function NeedHop: Boolean;
begin
Result := CountDots('player') >=player_count
end;
Procedure B_FindAbNormalRandoms;
Var
Rand_bad:Integer;
begin
Rand_bad := RandomRange(3, 10)
if not loggedin then
begin
update_state_log('Logging in')
LoginPlayer;
ExitSquealOfFortune;
SetAngle(SRL_ANGLE_HIGH)
end;
if Hop_mode = 'no' then exit;
if bad_rocks >= Rand_bad then
begin
reason := 'Bad colors';
SwitchWorld;
bad_rocks := 0;
end;
if tries >= 10 then
begin
reason := 'Too many tries';
SwitchWorld;
bad_rocks := 0;
end;
if NeedHop then
begin
reason := 'Too many people';
SwitchWorld;
bad_rocks := 0;
end;
end;
function NearBank(): boolean;
var
P:Tpoint;
begin
Result := false;
SPS_Setup(RUNESCAPE_OTHER,['dwarven_mine']);
SPS_AnyAngle := True;
SPS_MatchesPercent := 0.45;
SPS_Tolerance := 500.000;
p := SPS_Getmypos;
if PointInBox(p, IntToBox(88, 602, 168, 667)) then
begin
result := true;
end;
end;
function BoxScreen: Boolean;
var
X,Y:Integer;
begin
Result := FindColorTolerance(X, Y, 4512575, 296, 330-50, 301, 336-50, 10)
end;
Procedure WalkMine;
Var
ToMine:TPointArray;
begin
SPS_Setup(RUNESCAPE_OTHER,['dwarven_mine']);
SPS_AnyAngle := True;
SPS_MatchesPercent := 0.45;
SPS_Tolerance := 500.000;
update_state_log('Walking to mine')
ToMine:=[Point(102,633),Point(103,633),Point(104,634),Point(106,635),Point(108,636),Point(111,636),Point(114,636),Point(116,637),Point(119,637),Point(121,636),Point(123,636),Point(126,637),Point(129,637),Point(131,637),Point(134,638),Point(138,638),Point(140,639),Point(141,640),Point(143,640),Point(147,640),Point(151,640),Point(154,640),Point(158,640),Point(162,640),Point(164,640),Point(167,640),Point(172,641),Point(175,641),Point(180,640),Point(184,639)];
SPS_WalkPath(ToMine);
if NearBank then
begin
WalkMine;
end;
end;
function Lowshift: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(PSX1, PSY1 - 50, PSX2, PSY2 - 50);
Result := (AveragePixelShift(PBox, 250, 350) < 60);
Writeln(IntToStr(AveragePixelShift(PBox, 400, 500)));
end;
function Barb_DepositScreen: Boolean;
var
X, Y: Integer;
begin
Result := FindText(x, y, 'osit Box', UpCharsEx, 314, 85-50, 389, 96-50);
end;
Procedure StoreAll;
begin
HumanMMouse(312,328-50,8,8)
ClickMouse2(Mouse_Left)
Wait(RandomRange(150, 600));
end;
Procedure ClickBox;
var
BankCount:Integer;
begin
if (invfull) and (BoxScreen) then
begin
StoreAll;
exit;
end;
while (isMoving) do
wait(5);
if FindSurfaceObject(obj_Deposite, MSX1, MSY1, MSX2, MSY2) then
begin
update_state_log('Found bank at (' + ToStr(obj_Deposite.p.x) + '),(' + ToStr(obj_Deposite.p.y) + ')')
WriteProgress;
Humanmmouse(obj_Deposite.p.x,obj_Deposite.p.y,7,7)
Wait(RandomRange(35, 300));
clickmouse2(mouse_left)
MarkTime(BankCount);
if didyellowclick then
begin
Wait(RandomRange(35, 700));
ClickBox;
exit;
end;
repeat
Wait(RandomRange(25, 600));
Until (TimeFromMark(BankCount) > 5000) or(BoxScreen);
end;
end;
Procedure Bank;
Var
ToBank:TPointArray;
begin
SPS_Setup(RUNESCAPE_OTHER,['dwarven_mine']);
SPS_AnyAngle := True;
SPS_MatchesPercent := 0.45;
SPS_Tolerance := 500.000;
update_state_log('Walking to bank')
ToBank:=[Point(171,638),Point(168,638),Point(164,639),Point(160,639),Point(157,639),Point(155,639),Point(150,639),Point(145,638),Point(142,638),Point(137,637),Point(134,638),Point(130,638),Point(127,637),Point(123,637),Point(120,636),Point(116,637),Point(112,638),Point(109,636),Point(106,635),Point(101,634),Point(97,631)];
SPS_WalkPath(ToBank);
if NearBank then
begin
ClickBox;
StoreAll;
end;
if not NearBank then
begin
Bank;
end;
end;
procedure MineCoal;
var
OreCount, MineCount, r_wait: Integer;
c_angle: Extended;
begin
if not FindSurfaceObject(obj_coal_rock, MSX1, MSY1, MSX2, MSY2) then
begin
if (tries > 6) then
begin
WalkMine;
exit;
end;
if (tries > 0) then
begin
update_state_log('Cannot find rock waiting') r_wait := (tries * (random(500)) + Random(1000));
Wait(RandomRange(0, (300 + r_wait)));
end;
tries := tries + 1 c_angle := (rs_GetCompassAngleDegrees);
update_state_log('Cannot find rock ajusting compass') if (c_angle >= 180) then
MakeCompass(c_angle - Random(179));
if (c_angle <= 180) then
MakeCompass(c_angle + Random(179));
end;
if FindSurfaceObject(obj_coal_rock, MSX1, MSY1, MSX2, MSY2) then
begin
update_state_log('Found rock at (' + ToStr(obj_coal_rock.p.x) + '),(' + ToStr(obj_coal_rock.p.y) + ')') WriteProgress;
Humanmmouse(obj_coal_rock.p.x, obj_coal_rock.p.y, 7, 7) case random(45) of
1..38: Wait(RandomRange(35, 300));
39..43: Wait(RandomRange(100, 600));
44..45: Wait(RandomRange(200, 1000));
end;
clickmouse2(mouse_left) if didyellowclick then
begin
update_state_log('Misclicked re-trying') Wait(RandomRange(700, 2500));
while ismoving do
wait(3);
MineCoal;
exit;
end;
if FindBlackChatMessage('here') then
begin
update_state_log('Found text [here] the rock is empty!') bad_rocks := bad_rocks + 1;
exit;
end;
Flag;
OreCount := InvCount + 1 MarkTime(MineCount);
repeat
update_state_log('Mining') AntiBan;
case random(1000) of
1..700: Wait(RandomRange(150, 500));
701..850: Wait(RandomRange(200, 750));
851..985: Wait(RandomRange(300, 900));
986..1000: Wait(RandomRange(409, 1100));
end;
Wait(RandomRange(35, 400));
until (TimeFromMark(MineCount) > MineTimeout) or (InvCount = OreCount);
if (InvCount = OreCount) then
begin
OresMined := OresMined + 1;
bad_rocks := 0;
end;
B_FindAbNormalRandoms;
tries := 0;
end;
end;
begin
SetupSRL;
SRL_SIXHOURFIX := TRUE;
update_state_log('')
update_state_log('**********Officer Barbrady Coal Raper**********')
update_state_log('************Log file of bot actions**********')
update_state_log('')
update_state_log('Loading surfaces')
InitRocks();
update_state_log('Declaring variables')
DeclareVs;
StartTime := GetSystemTime;
WriteProgress;
repeat
if not invfull and nearbank then
begin
walkmine;
B_FindAbNormalRandoms;
end;
if invfull then
begin
Bank;
B_FindAbNormalRandoms;
end;
WriteProgress;
SMART_ClearMS();
B_FindAbNormalRandoms;
MineCoal;
Until False;
end.