SRL Archive - RS3 Outdated / Broken Scripts

[KYAB] [SRL] SolarMiner - a KYAB community project.


solarwind

2007-10-10 17:19:19

SolarMiner is a great guild coal miner that reliably and quickly mines coal and banks it for you. It uses the KYAB bot SCAR extension to deliver flawless walking (never gets lost) and animation and motion detection for script speed and accuracy. It is still pretty early in development, but it is rapidly getting better and better. To download it, simply make an account at the KYAB forums at http://www.kyab.asssoft.org and follow this link: http://www.kyab.asssoft.org/smf/index.php/topic,637.0.html

Edit: since Ram wanted me to post the script, here it is.


{==============================================================================]
[ _________ .__ _____ .__ ]
[ / _____/ ____ | | _____ _______ / \ |__| ____ ___________ ]
[ \_____ \ / _ \| | \__ \\_ __ \/ \ / \| |/ \_/ __ \_ __ \ ]
[ / ( <_> ) |__/ __ \| | \/ Y \ | | \ ___/| | \/ ]
[ /_______ /\____/|____(____ /__| \____|__ /__|___| /\___ >__| ]
[ \/ \/ \/ \/ \/ ]
[ ]
[ The ultimate falador mining guild miner with perfect fail proof walking. ]
[ Version 2.10 ]
[ ]
[==============================================================================]
[ __ __ __ ]
[ _____________ ____ _/ /____ ____/ / / /_ __ __ ]
[ / ___/ ___/ _ \/ __ `/ __/ _ \/ __ / / __ \/ / / / ]
[ / /__/ / / __/ /_/ / /_/ __/ /_/ / / /_/ / /_/ / ]
[ \___/_/ \___/\__,_/\__/\___/\__,_/ /_.___/\__, / ]
[ /____/ ]
[ .__ .__ .___ ]
[ __________ | | _____ _________ _ _|__| ____ __| _/ ]
[ / ___/ _ \| | \__ \\_ __ \ \/ \/ / |/ \ / __ | ]
[ \___ ( <_> ) |__/ __ \| | \/\ /| | | \/ /_/ | ]
[ /____ >____/|____(____ /__| \/\_/ |__|___| /\____ | ]
[ \/ \/ \/ \/ ]
[ ]
[==============================================================================]
[ Official website of the KYAB bot: ]
[ <a href="http://www.kyab.asssoft.org" target="_blank">http://www.kyab.asssoft.org</a> ]
[ ]
[ ImpWiki - the best RuneScape cheating information site on the planet! ]
[ <a href="http://www.impwiki.org" target="_blank">http://www.impwiki.org</a> ]
[ ]
[ This script requires KYAB version 6.2 or greater, SCAR 3.12 or greater ]
[ and a recent SRL include. Get KYAB for free at the official KYAB website. ]
[ ]
[ This script complies with SRL scripting standards and the SRL library. ]
[ ]
[ Licensed under the terms of the GNU GPL v3.0 ]
[==============================================================================]
[ Credits: ]
[ * Solarwind: the initial script, idea and structure. ]
[ * Metho D: standard setup routines. ]
[ * The 1337: many script fixes such as deathwalk, failsafes and speed. ]
[ * Sumillion: took some of his mining ideas. ]
[==============================================================================]
[ Version history: ]
[ * v1.00 (Oct 6, 2070): Initial release, needs a lot of work, see todo. ]
[ * v1.20 (Oct 6, 2070): Many things fixed and improved. Need to fix ]
[ player statistics issue. ]
[ * v2.00 (Oct 7, 2070): Many fixes by The 1337. ]
[ * v2.10 (Oct 8, 2070): Script works much smoother now. ]
[==============================================================================]
[ Todo: ]
[ * Fix player statistics and timing issue. ]
[ * Add broken pickaxe and flying pick head support. ]
[ * Add more random paths. ]
[ * Add detection when someone mines the ores out of the rock before us. ]
[ * Add empty rock finding. (Rock that no one is mining.) ]
[==============================================================================]
[ Notes: ]
[ Animation code for mining a coal rock with a rune pickaxe: 624 ]
[ ]
[ Tile locations: from bank to mine: ]
[ West most bank booth tile: (3010, 3355) ]
[ East most bank booth tile: (3015, 3355) ]
[ Near guild: (3025, 3350) ]
[ Near ladder top: (3022, 3337) ]
[ Near ladder bottom: (3019, 9737) ]
[ ]
[ Rock group locations inside cave: ]
[ West rock set: (3033, 9737) ]
[ Middle rock set: (3043, 9738) ]
[ East rock set: (3049, 9739) ]
[ South rock set: (3038, 9734) ]
[ North rock set: (3038, 9742) ]
[ North east rock set: (3047, 9744) ]
[==============================================================================]
[==============================================================================}

program SolarMiner;
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/Mining.scar}
{.include SRL/SRL/misc/KYAB.scar}

//========== Global variables: ==========\\
const
Version = 2.10;

const
MinutesPerPlayer = 15; // Time in minutes per player.
RandomMinutes = 5; // Random number under this gets added to above.
RunDir = 'N'; // Direction to run to when in fight.
RunFar = True; // Run far when in fight?
MaxSecRock = 7; // Maximum seconds to wait for a rock.
OreColour = 2703167;

var
x, y : integer;
DeathWalk : Array of TPoint;

var
OresMined, GemsReceived, GasAvoided, TotalMinutesPerPlayer, RunTime : integer;


//========== Player controls: ==========\\
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

Players[0].Name := '...'; //Your RuneScape user name.
Players[0].Pass := '...'; //Your RuneScape password.
Players[0].Nick := '...'; //3 to 4 letters from your name.
Players[0].Booleans[0] := true; //Is pickaxe wielded?
Players[0].Active := true;
end;

procedure ProgressReport;
var
PActive, Spaces : string;
i, k, SpaceNumber : Integer;
begin
SRLRandomsReport;
if Players[CurrentPlayer].Active then
PActive := 'true'
else
PActive := 'false';

WriteLn(' ');
WriteLn('//========== SolarMiner v' + FloatToStr(Version) + ' ==========\\');
WriteLn('//========== Global statistics ==========\\');
WriteLn(' Worked for ' + TimeRunning);
WriteLn(' Mined ' + inttostr(OresMined)+(' ores.'));
if(GemsReceived > 0)then
WriteLn(' Received ' + IntToStr(GemsReceived) + ' gem(s).');
if(GasAvoided > 0)then
WriteLn(' Avoided gas ' + IntToStr(GasAvoided) + ' time(s).');
WriteLn('//========== Player statistics ==========\\');
WriteLn(' Name: ' + Players[CurrentPlayer].Name);
WriteLn(' Mining Lvl: ' + IntToStr(Players[CurrentPlayer].Level[15]));
WriteLn(' Worked for: ' + IntToStr(Players[CurrentPlayer].Worked) + ' minutes.');
WriteLn(' Banked: ' + IntToStr(Players[CurrentPlayer].Banked) + ' time(s).');
WriteLn(' Active: ' + PActive);
WriteLn(' LastRandom: ' + Players[CurrentPlayer].Rand);
WriteLn('\\========================================//');
{
WriteLn('============================================');
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active then
PActive:='True'
else
PActive:='False';
SpaceNumber := 12 - Length(Players[i].Name);
for k := 0 to SpaceNumber do
Spaces := Spaces + ' ';
WriteLn(IntToStr(i) + ': ' + Players[i].Name + Spaces +
'= ' + PActive + ', ' + IntToStr(Players[i].Banked) + ' Bank(s)' +
', Worked ' + IntToStr(Players[i].Worked) + ' minutes, ' +
'Random: ' + Players[i].Rand);
Spaces := '';
end
WriteLn('============================================');
}
end;

procedure DeathWalkArray;
begin
SetArrayLength(DeathWalk,31);
DeathWalk[0].X:=3229; DeathWalk[0].Y:=3219;
DeathWalk[1].X:=3233; DeathWalk[1].Y:=3229;
DeathWalk[2].X:=3223; DeathWalk[2].Y:=3238;
DeathWalk[3].X:=3218; DeathWalk[3].Y:=3250;
DeathWalk[4].X:=3216; DeathWalk[4].Y:=3263;
DeathWalk[5].X:=3213; DeathWalk[5].Y:=3275;
DeathWalk[6].X:=3205; DeathWalk[6].Y:=3280;
DeathWalk[7].X:=3195; DeathWalk[7].Y:=3280;
DeathWalk[8].X:=3183; DeathWalk[8].Y:=3285;
DeathWalk[9].X:=3169; DeathWalk[9].Y:=3288;
DeathWalk[10].X:=3158; DeathWalk[10].Y:=3292;
DeathWalk[11].X:=3144; DeathWalk[11].Y:=3297;
DeathWalk[12].X:=3130; DeathWalk[12].Y:=3296;
DeathWalk[13].X:=3116; DeathWalk[13].Y:=3296;
DeathWalk[14].X:=3102; DeathWalk[14].Y:=3296;
DeathWalk[15].X:=3089; DeathWalk[15].Y:=3291;
DeathWalk[16].X:=3077; DeathWalk[16].Y:=3290;
DeathWalk[17].X:=3073; DeathWalk[17].Y:=3282;
DeathWalk[18].X:=3064; DeathWalk[18].Y:=3277;
DeathWalk[19].X:=3053; DeathWalk[19].Y:=3277;
DeathWalk[20].X:=3039; DeathWalk[20].Y:=3276;
DeathWalk[21].X:=3025; DeathWalk[21].Y:=3278;
DeathWalk[22].X:=3012; DeathWalk[22].Y:=3279;
DeathWalk[23].X:=3004; DeathWalk[23].Y:=3288;
DeathWalk[24].X:=3005; DeathWalk[24].Y:=3301;
DeathWalk[25].X:=3006; DeathWalk[25].Y:=3314;
DeathWalk[26].X:=3005; DeathWalk[26].Y:=3328;
DeathWalk[27].X:=3006; DeathWalk[27].Y:=3340;
DeathWalk[28].X:=3006; DeathWalk[28].Y:=3351;
DeathWalk[29].X:=3011; DeathWalk[29].Y:=3357;
DeathWalk[30].X:=3011; DeathWalk[30].Y:=3358;
end;

procedure TheDeathWalk;
var r : integer;
begin
KYAB_Log('Death walk');
for r := 0 to 30 do
begin
Status('Death-Walking');
NewWalkToTile(DeathWalk[r].X, DeathWalk[r].Y);
FFlag(0);
end;
end;

//========== Random methods: ==========\\
function FindFastRandoms : boolean; // By WT-Fakawi.
var
i: Integer;
begin
for I := 1 to 11 do
begin
case I of
1: if FindDead then
begin
Result := True;
TheDeathWalk;
end;

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 FindTalk then
Result := True;

7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
KYAB_Log('No GameTab, logout');
Logout;
Exit;
end;
end;

9 : if RC then
Result := True;

10 : if FindFight then
begin
Result := True;
RunTo(RunDir, RunFar);
end;

11: if FindTalk then
Result := True;
end;
Wait(1);
end;
end;

function SumCheckGas(rx, ry: Integer) : boolean;
var
TempMouseSpeed, GasTime: Integer;
begin
Result := FindGas(rx, ry - 20);
if(Result)then
begin
KYAB_Log('Gas found!');
TempMouseSpeed := MouseSpeed;
MouseSpeed := 5;
MouseFindNoFlag(MMCX, MMCY + 4, 1, 1);
MarkTime(GasTime);
MouseSpeed := TempMouseSpeed;
while(TimeFromMark(GasTime) < 35000)do
if(Random(20) > 15)then
IdleTime(500, 500, 0.4)
else
Wait(RandomRange(500, 1000));
GasAvoided := GasAvoided + 1;
ReportVars[2] := ReportVars[2] + 1;
end;
end;

procedure FindRandoms;
begin
KYAB_Log('Checking for randoms.');
FindFastRandoms;
FindNormalRandoms;
end;

function RandSleep(min, max : integer) : boolean;
begin
Sleep(min + random(max - min));
result := true;
end;

//========== Mining methods: ==========\\
function RockGone(rx, ry: Integer): Boolean;
begin
Result := not FindColorSpiralTolerance(rx, ry, OreColour, rx - 10, ry - 10, rx + 10, ry + 10, 10);
end;

procedure WorkUntilMined(wx, wy : integer);
var
i, MineTime: integer;
Breakout : boolean;
begin
MarkTime(MineTime);
while(LoggedIn)and(not Breakout) do
begin
for i := 1 to 4 do
begin
case i of
1 : begin
KYAB_Log(IntToStr(i) + ' FindFastRandoms.');
if(FindFastRandoms) then
begin
Breakout := True;
break;
end;
end;
2 : begin
KYAB_Log(IntToStr(i) + ' FindFastRandoms.');
if(SumCheckGas(wx, wy)) then
begin
Breakout := True;
break;
end;
end;
3 : begin
KYAB_Log(IntToStr(i) + ' Check for ore in rock.');
if(RockGone(wx, wy)) then
exit;
end;
4 : begin
KYAB_Log(IntToStr(i) + ' Check for timeout.');
if(TimeFromMark(MineTime) > MaxSecRock * 1000) then
exit;
end;
end;
sleep(10);
end;
if(Random(100) > 90)then
IdleTime(500, 500, 0.4);
end;
end;

function FindCoal : boolean;
begin
KYAB_Log('Find coal');
if(FindObj(x, y, 'ocks', OreColour, 12)) then
begin
result := true;
end;
end;

function ClickCoal : boolean;
begin
RandSleep(100, 500);
if(FindCoal) then
begin
SumCheckGas(x, y);
Mouse(x, y, 5, 5, true);
end;
result := true;
OresMined := OresMined + 1;
end;

function FindLadder(kind : Integer) : boolean;
var
i : Integer;
kindp, targetp : TPoint;
begin
if(kind = 1)then
begin
kindp.x := 3019;
kindp.y := 3337;
targetp.x := 3019;
targetp.y := 9737;
end else
if(kind = 2)then
begin
kindp.x := 3019;
kindp.y := 9737;
targetp.x := 3019;
targetp.y := 3337;
end;

//Keep trying to climb the ladder until we reach our destination.
repeat
if(FindObj(x, y, 'adder', 6716, 10)) then
Mouse(x, y, 5, 5, true);
RandSleep(3500, 4000);

if(AtTile(targetp.x, targetp.y, 10))then
begin
result := true;
KYAB_Log('We climbed the ladder!');
break;
end else
begin
KYAB_Log('Could not find the ladder, trying again.');
end;
until(false);
end;

//========== Walking methods: ==========\\
function WalkToMine : boolean;
begin
SetRun(true);
KYAB_Log('Walking to the guild.');
NewWalkToTileTol(3025, 3350, 3); //Walk near the mining guild.
FFlag(random(5));

KYAB_Log('Walking to the ladder.');
NewWalkToTileTol(3022, 3337, 3); //Walk to the ladder.
FFlag(random(5));

KYAB_Log('Finding and clicking the ladder.');
FindLadder(1);
RandSleep(3500, 4000);

KYAB_Log('Walking to the west rock set.');
NewWalkToTileTol(3033, 9737, 3); //Walk to the west rock set.
FFlag(random(5));

result := true;
end;

function WalkToBank : boolean;
begin
SetRun(false);
NewWalkToTileTol(3042, 9740, 3); //Walk to the center to avoid errors.
FFlag(random(5));

NewWalkToTileTol(3031, 9735, 3); //Walk to the west rock set.
FFlag(random(5));

NewWalkToTileTol(3019, 9737, 3); //Walk to the ladder.
FFlag(random(5));

KYAB_Log('Finding and clicking the ladder.');
FindLadder(2);
RandSleep(3500, 4000);

NewWalkToTileTol(3025, 3350, 3); //Walk ouside the guild area.
FFlag(random(5));

NewWalkToTileTol(3012, 3356, 2); //Walk to the bank.
FFlag(random(5));

result := true;
end;

procedure AutoWalker;
begin
//If we are near the bank:
if(AtTile(3012, 3355, 35))then
begin
KYAB_Log('We are near the bank, walking to guild.');
WalkToMine;
FFlag(random(5));
end;
//If we are in the guild.
if(AtTile(3043, 9738, 35))then
begin
KYAB_Log('Already at mine.');
end;
//If we have full inventory in the guild.
if(AtTile(3019, 9737, 45) and InvFull)then
begin
KYAB_Log('Already at mine with full inventory.');
WalkToBank;
FFlag(random(5));
end;
end;

procedure StoreAll;
begin
KYAB_Log('Storing all ores.');
OpenBankQuiet('feb');
DepositAll;
CloseBank;
end;


//========== General script methods: ==========\\
procedure SetupScript;
begin
ClearDebug;
SetupSRL;
KYAB_connect;
DeclarePlayers;
CheckUserNicks;
Sleep(100);
end;

procedure SetupPlayer;
begin
if not(LoggedIn)then
LoginPlayer;
MakeCompass('N');
HighestAngle;
GameTab(2);
Players[CurrentPlayer].Level[15] := GetSkillLevel('mining');
TotalMinutesPerPlayer := MinutesPerPlayer + Random(RandomMinutes);
GameTab(4);
MarkTime(RunTime);
end;

function TimeToSwitchPlayers: boolean;
begin
if(TimeFromMark(RunTime) / 60 / 1000 > TotalMinutesPerPlayer)then
begin
result := true;
KYAB_Log('Time for player is up.');
end else
result := false;
end;

function Mining : boolean;
begin
if(GetAnimation = 624) then
begin
result := true;
end else
begin
result := false;
end;
end;

procedure SleepWhileMoving;
begin
while(GetMotion > 0) do
begin
KYAB_Log('Sleep while moving...');
Sleep(1000);
end;
end;

//========== Event loop: ==========\\
function EventLoop : boolean;
begin
AutoWalker;
repeat
while(not Mining) do
begin
KYAB_Log('Mining...');
FindRandoms;
ClickCoal;
Sleep(1000);
SleepWhileMoving;
end;
KYAB_Log('WorkUntilMined...');
WorkUntilMined(x, y);
until(InvFull);

if(InvFull) then
begin
KYAB_Log('Inventory is full, walking back to bank to deposit all items.');
AutoWalker;
StoreAll;
end;
result := true;
end;



//========== Main method: ==========\\
begin
SetupScript;
KYAB_Log('===== Starting script. =====');
repeat
SetupPlayer;

repeat
EventLoop;
ProgressReport;
if(TimeToSwitchPlayers) then
LogOut;
until not(LoggedIn);
NextPlayer(true);
until not(Players[CurrentPlayer].Active);
KYAB_Log('All players are inactive.');
KYAB_Close;
end.

The script requires the latest KYAB.scar and KYAB bot, get them at http://www.kyab.asssoft.org.


Please note that this contribution uses the KYAB bot and is 99% a fully valid SRL script.

I would like to point out the Jukka's guildminer, which uses SCARSCAPE is still up, yet SolarMiner since it uses KYAB is not.

Explain please.

-badman1


I would also like an answer from an administrator (particularly the one who closed the other thread).


Note: This is my thread and no flaming is allowed here. Do not flame me, any of the KYAB members or this script. It is a solid contribution out of OUR spare time and we don't need any of that crap from you.

The Element

2007-10-10 17:24:12

Great script! Now what kind of jerk off asshole wonna be reno 911 cop would ever send this to the BBQ section? Jealous much?

Anyhow, I'll test this for sure!

solarwind

2007-10-10 17:26:39

From: The Element
Great script! Now what kind of jerk off asshole wonna be reno 911 cop would ever send this to the BBQ section? Jealous much?

Anyhow, I'll test this for sure!


No problem dude. The progress report is failing though so if you have any fixes, please add them, post and add yourself to the credits!

tatootian

2007-10-10 17:42:01

I don't know yet, but it seems that for whatever reason… when my character has a full inventory, it doesn't seem to proceed to the bank, it just continues to try to mine the coal… (this is what I've seen so far)

http://tatootian.co.nr/images/nu42F8A.tmp.jpg

Also, I told the player setup that I DO NOT have my pickaxe wielded, and yet… the script still banks the pickaxe… is there a reason why?

solarwind

2007-10-10 17:43:55

Pickaxe non wielding is not supported yet, also, the I have no idea why it keeps clicking even after full inventory.

solarwind

2007-10-10 17:45:33

Administrators! FFS! you force me to moralize you. You are behaving unrespectfull, like stupid frustrated kids! Leave him alone. There is absolutely no reason to hunt solarwind down the way you all do. Stop this nonsense and leave the guy alone. He is desperately fighting for content over at his server and this is his blunt way of raising a fire. Dont you recognize his game? Dont you see through this obvious provocation?

Mods/Admins?
-WT-Fakawi


1) Thank you for the first bit.
2) Not really, I'm not fighting for content at all, we're doing just fine, thank you.
3) I don't really have a "game".
4) There is no provocation intended, only what you guys make of it which is your own fault.

tatootian

2007-10-10 17:49:52

:/, thanks for the answers

solarwind

2007-10-10 17:51:53

From: tatootian
:/, thanks for the answers


It never failed for me so far.

Smartzkid

2007-10-10 18:19:27

Sorry about what I said before, solar; it was both immature and quite thoughtless. You've put together a very nice script.

I made some small edits; couldn't test them, though. I'm unsure of how well the status change will work, too. Among other things, I made all 'Status' calls forward to KYAB_Log. It might be a bit of an annoyance, so it will probably end up being removed.

{==============================================================================]
[ _________ .__ _____ .__ ]
[ / _____/ ____ | | _____ _______ / \ |__| ____ ___________ ]
[ \_____ \ / _ \| | \__ \\_ __ \/ \ / \| |/ \_/ __ \_ __ \ ]
[ / ( <_> ) |__/ __ \| | \/ Y \ | | \ ___/| | \/ ]
[ /_______ /\____/|____(____ /__| \____|__ /__|___| /\___ >__| ]
[ \/ \/ \/ \/ \/ ]
[ ]
[ The ultimate falador mining guild miner with perfect fail proof walking. ]
[ Version 2.10 ]
[ ]
[==============================================================================]
[ __ __ __ ]
[ _____________ ____ _/ /____ ____/ / / /_ __ __ ]
[ / ___/ ___/ _ \/ __ `/ __/ _ \/ __ / / __ \/ / / / ]
[ / /__/ / / __/ /_/ / /_/ __/ /_/ / / /_/ / /_/ / ]
[ \___/_/ \___/\__,_/\__/\___/\__,_/ /_.___/\__, / ]
[ /____/ ]
[ .__ .__ .___ ]
[ __________ | | _____ _________ _ _|__| ____ __| _/ ]
[ / ___/ _ \| | \__ \\_ __ \ \/ \/ / |/ \ / __ | ]
[ \___ ( <_> ) |__/ __ \| | \/\ /| | | \/ /_/ | ]
[ /____ >____/|____(____ /__| \/\_/ |__|___| /\____ | ]
[ \/ \/ \/ \/ ]
[ ]
[==============================================================================]
[ Official website of the KYAB bot: ]
[ <a href="http://www.kyab.asssoft.org" target="_blank">http://www.kyab.asssoft.org</a> ]
[ ]
[ ImpWiki - the best RuneScape cheating information site on the planet! ]
[ <a href="http://www.impwiki.org" target="_blank">http://www.impwiki.org</a> ]
[ ]
[ This script requires KYAB version 6.2 or greater, SCAR 3.12 or greater ]
[ and a recent SRL include. Get KYAB for free at the official KYAB website. ]
[ ]
[ This script complies with SRL scripting standards and the SRL library. ]
[ ]
[ Licensed under the terms of the GNU GPL v3.0 ]
[==============================================================================]
[ Credits: ]
[ * Solarwind: the initial script, idea and structure. ]
[ * Metho D: standard setup routines. ]
[ * The 1337: many script fixes such as deathwalk, failsafes and speed. ]
[ * Sumillion: took some of his mining ideas. ]
[ * Smartzkid: tiny status edit. ]
[==============================================================================]
[ Version history: ]
[ * v1.00 (Oct 6, 2070): Initial release, needs a lot of work, see todo. ]
[ * v1.20 (Oct 6, 2070): Many things fixed and improved. Need to fix ]
[ player statistics issue. ]
[ * v2.00 (Oct 7, 2070): Many fixes by The 1337. ]
[ * v2.10 (Oct 8, 2070): Script works much smoother now. ]
[==============================================================================]
[ Todo: ]
[ * Fix player statistics and timing issue. ]
[ * Add broken pickaxe and flying pick head support. ]
[ * Add more random paths. ]
[ * Add detection when someone mines the ores out of the rock before us. ]
[ * Add empty rock finding. (Rock that no one is mining.) ]
[==============================================================================]
[ Notes: ]
[ Animation code for mining a coal rock with a rune pickaxe: 624 ]
[ ]
[ Tile locations: from bank to mine: ]
[ West most bank booth tile: (3010, 3355) ]
[ East most bank booth tile: (3015, 3355) ]
[ Near guild: (3025, 3350) ]
[ Near ladder top: (3022, 3337) ]
[ Near ladder bottom: (3019, 9737) ]
[ ]
[ Rock group locations inside cave: ]
[ West rock set: (3033, 9737) ]
[ Middle rock set: (3043, 9738) ]
[ East rock set: (3049, 9739) ]
[ South rock set: (3038, 9734) ]
[ North rock set: (3038, 9742) ]
[ North east rock set: (3047, 9744) ]
[==============================================================================]
[==============================================================================}

program SolarMiner;
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/Mining.scar}
{.include SRL/SRL/misc/KYAB.scar}

//========== Global variables: ==========\\
const
Version = 2.10;

const
MinutesPerPlayer = 15; // Time in minutes per player.
RandomMinutes = 5; // Random number under this gets added to above.
RunDir = 'N'; // Direction to run to when in fight.
RunFar = True; // Run far when in fight?
MaxSecRock = 7; // Maximum seconds to wait for a rock.
OreColour = 2703167;

var
x, y : integer;
DeathWalk : Array of TPoint;

var
OresMined, GemsReceived, GasAvoided, TotalMinutesPerPlayer, RunTime : integer;


//========== Player controls: ==========\\
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

Players[0].Name := '...'; //Your RuneScape user name.
Players[0].Pass := '...'; //Your RuneScape password.
Players[0].Nick := '...'; //3 to 4 letters from your name.
Players[0].Booleans[0] := true; //Is pickaxe wielded?
Players[0].Active := true;
end;

procedure Status(s: string);
begin
KYAB_Log(s);
end;

procedure ProgressReport;
var
PActive, Spaces : string;
i, k, SpaceNumber : Integer;
begin
SRLRandomsReport;
if Players[CurrentPlayer].Active then
PActive := 'true'
else
PActive := 'false';

WriteLn(' ');
WriteLn('//========== SolarMiner v' + FloatToStr(Version) + ' ==========\\');
WriteLn('//========== Global statistics ==========\\');
WriteLn(' Worked for ' + TimeRunning);
WriteLn(' Mined ' + inttostr(OresMined)+(' ores.'));
if(GemsReceived > 0)then
WriteLn(' Received ' + IntToStr(GemsReceived) + ' gem(s).');
if(GasAvoided > 0)then
WriteLn(' Avoided gas ' + IntToStr(GasAvoided) + ' time(s).');
WriteLn('//========== Player statistics ==========\\');
WriteLn(' Name: ' + Players[CurrentPlayer].Name);
WriteLn(' Mining Lvl: ' + IntToStr(Players[CurrentPlayer].Level[15]));
WriteLn(' Worked for: ' + IntToStr(Players[CurrentPlayer].Worked) + ' minutes.');
WriteLn(' Banked: ' + IntToStr(Players[CurrentPlayer].Banked) + ' time(s).');
WriteLn(' Active: ' + PActive);
WriteLn(' LastRandom: ' + Players[CurrentPlayer].Rand);
WriteLn('\\========================================//');
{
WriteLn('============================================');
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active then
PActive:='True'
else
PActive:='False';
SpaceNumber := 12 - Length(Players[i].Name);
for k := 0 to SpaceNumber do
Spaces := Spaces + ' ';
WriteLn(IntToStr(i) + ': ' + Players[i].Name + Spaces +
'= ' + PActive + ', ' + IntToStr(Players[i].Banked) + ' Bank(s)' +
', Worked ' + IntToStr(Players[i].Worked) + ' minutes, ' +
'Random: ' + Players[i].Rand);
Spaces := '';
end
WriteLn('============================================');
}
end;

procedure DeathWalkArray;
begin
SetArrayLength(DeathWalk,31);
DeathWalk[0].X:=3229; DeathWalk[0].Y:=3219;
DeathWalk[1].X:=3233; DeathWalk[1].Y:=3229;
DeathWalk[2].X:=3223; DeathWalk[2].Y:=3238;
DeathWalk[3].X:=3218; DeathWalk[3].Y:=3250;
DeathWalk[4].X:=3216; DeathWalk[4].Y:=3263;
DeathWalk[5].X:=3213; DeathWalk[5].Y:=3275;
DeathWalk[6].X:=3205; DeathWalk[6].Y:=3280;
DeathWalk[7].X:=3195; DeathWalk[7].Y:=3280;
DeathWalk[8].X:=3183; DeathWalk[8].Y:=3285;
DeathWalk[9].X:=3169; DeathWalk[9].Y:=3288;
DeathWalk[10].X:=3158; DeathWalk[10].Y:=3292;
DeathWalk[11].X:=3144; DeathWalk[11].Y:=3297;
DeathWalk[12].X:=3130; DeathWalk[12].Y:=3296;
DeathWalk[13].X:=3116; DeathWalk[13].Y:=3296;
DeathWalk[14].X:=3102; DeathWalk[14].Y:=3296;
DeathWalk[15].X:=3089; DeathWalk[15].Y:=3291;
DeathWalk[16].X:=3077; DeathWalk[16].Y:=3290;
DeathWalk[17].X:=3073; DeathWalk[17].Y:=3282;
DeathWalk[18].X:=3064; DeathWalk[18].Y:=3277;
DeathWalk[19].X:=3053; DeathWalk[19].Y:=3277;
DeathWalk[20].X:=3039; DeathWalk[20].Y:=3276;
DeathWalk[21].X:=3025; DeathWalk[21].Y:=3278;
DeathWalk[22].X:=3012; DeathWalk[22].Y:=3279;
DeathWalk[23].X:=3004; DeathWalk[23].Y:=3288;
DeathWalk[24].X:=3005; DeathWalk[24].Y:=3301;
DeathWalk[25].X:=3006; DeathWalk[25].Y:=3314;
DeathWalk[26].X:=3005; DeathWalk[26].Y:=3328;
DeathWalk[27].X:=3006; DeathWalk[27].Y:=3340;
DeathWalk[28].X:=3006; DeathWalk[28].Y:=3351;
DeathWalk[29].X:=3011; DeathWalk[29].Y:=3357;
DeathWalk[30].X:=3011; DeathWalk[30].Y:=3358;
end;

procedure TheDeathWalk;
var r : integer;
begin
KYAB_Log('Death walk');
for r := 0 to 30 do
begin
Status('Death-Walking');
NewWalkToTile(DeathWalk[r].X, DeathWalk[r].Y);
FFlag(0);
end;
end;

//========== Random methods: ==========\\
function FindFastRandoms : boolean; // By WT-Fakawi.
var
i: Integer;
begin
for I := 1 to 11 do
begin
case I of
1: if FindDead then
begin
Result := True;
TheDeathWalk;
end;

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 FindTalk then
Result := True;

7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
KYAB_Log('No GameTab, logout');
Logout;
Exit;
end;
end;

9 : if RC then
Result := True;

10 : if FindFight then
begin
Result := True;
RunTo(RunDir, RunFar);
end;

11: if FindTalk then
Result := True;
end;
Wait(1);
end;
end;

function SumCheckGas(rx, ry: Integer) : boolean;
var
TempMouseSpeed, GasTime: Integer;
begin
Result := FindGas(rx, ry - 20);
if(Result)then
begin
KYAB_Log('Gas found!');
TempMouseSpeed := MouseSpeed;
MouseSpeed := 5;
MouseFindNoFlag(MMCX, MMCY + 4, 1, 1);
MarkTime(GasTime);
MouseSpeed := TempMouseSpeed;
while(TimeFromMark(GasTime) < 35000)do
if(Random(20) > 15)then
IdleTime(500, 500, 0.4)
else
Wait(RandomRange(500, 1000));
GasAvoided := GasAvoided + 1;
ReportVars[2] := ReportVars[2] + 1;
end;
end;

procedure FindRandoms;
begin
KYAB_Log('Checking for randoms.');
FindFastRandoms;
FindNormalRandoms;
end;

function RandSleep(min, max : integer) : boolean;
begin
Sleep(min + random(max - min));
result := true;
end;

//========== Mining methods: ==========\\
function RockGone(rx, ry: Integer): Boolean;
begin
Result := not FindColorSpiralTolerance(rx, ry, OreColour, rx - 10, ry - 10, rx + 10, ry + 10, 10);
end;

procedure WorkUntilMined(wx, wy : integer);
var
i, MineTime: integer;
Breakout : boolean;
begin
MarkTime(MineTime);
while(LoggedIn)and(not Breakout) do
begin
for i := 1 to 4 do
begin
case i of
1 : begin
KYAB_Log(IntToStr(i) + ' FindFastRandoms.');
if(FindFastRandoms) then
begin
Breakout := True;
break;
end;
end;
2 : begin
KYAB_Log(IntToStr(i) + ' FindFastRandoms.');
if(SumCheckGas(wx, wy)) then
begin
Breakout := True;
break;
end;
end;
3 : begin
KYAB_Log(IntToStr(i) + ' Check for ore in rock.');
if(RockGone(wx, wy)) then
exit;
end;
4 : begin
KYAB_Log(IntToStr(i) + ' Check for timeout.');
if(TimeFromMark(MineTime) > MaxSecRock * 1000) then
exit;
end;
end;
sleep(10);
end;
if(Random(100) > 90)then
IdleTime(500, 500, 0.4);
end;
end;

function FindCoal : boolean;
begin
KYAB_Log('Find coal');
if(FindObj(x, y, 'ocks', OreColour, 12)) then
begin
result := true;
end;
end;

function ClickCoal : boolean;
begin
RandSleep(100, 500);
if(FindCoal) then
begin
SumCheckGas(x, y);
Mouse(x, y, 5, 5, true);
OresMined := OresMined + 1;
result := true;
end;
end;

function FindLadder(kind : Integer) : boolean;
var
i : Integer;
kindp, targetp : TPoint;
begin
if(kind = 1)then
begin
kindp.x := 3019;
kindp.y := 3337;
targetp.x := 3019;
targetp.y := 9737;
end else
if(kind = 2)then
begin
kindp.x := 3019;
kindp.y := 9737;
targetp.x := 3019;
targetp.y := 3337;
end else
begin
KYAB_Log('Bad ladder number.');
Exit;
end;

//Keep trying to climb the ladder until we reach our destination.
repeat
if(FindObj(x, y, 'adder', 6716, 10)) then
Mouse(x, y, 5, 5, true);
RandSleep(3500, 4000);

if(AtTile(targetp.x, targetp.y, 10))then
begin
result := true;
KYAB_Log('We climbed the ladder!');
break;
end else
begin
KYAB_Log('Could not find the ladder, trying again.');
end;
until(false);
end;

//========== Walking methods: ==========\\
function WalkToMine : boolean;
begin
SetRun(true);
KYAB_Log('Walking to the guild.');
NewWalkToTileTol(3025, 3350, 3); //Walk near the mining guild.
FFlag(random(5));

KYAB_Log('Walking to the ladder.');
NewWalkToTileTol(3022, 3337, 3); //Walk to the ladder.
FFlag(random(5));

KYAB_Log('Finding and clicking the ladder.');
FindLadder(1);
RandSleep(3500, 4000);

KYAB_Log('Walking to the west rock set.');
NewWalkToTileTol(3033, 9737, 3); //Walk to the west rock set.
FFlag(random(5));

result := true;
end;

function WalkToBank : boolean;
begin
SetRun(false);
NewWalkToTileTol(3042, 9740, 3); //Walk to the center to avoid errors.
FFlag(random(5));

NewWalkToTileTol(3031, 9735, 3); //Walk to the west rock set.
FFlag(random(5));

NewWalkToTileTol(3019, 9737, 3); //Walk to the ladder.
FFlag(random(5));

KYAB_Log('Finding and clicking the ladder.');
FindLadder(2);
RandSleep(3500, 4000);

NewWalkToTileTol(3025, 3350, 3); //Walk ouside the guild area.
FFlag(random(5));

NewWalkToTileTol(3012, 3356, 2); //Walk to the bank.
FFlag(random(5));

result := true;
end;

procedure AutoWalker;
begin
//If we are near the bank:
if(AtTile(3012, 3355, 35))then
begin
KYAB_Log('We are near the bank, walking to guild.');
WalkToMine;
FFlag(random(5));
end;
//If we are in the guild.
if(AtTile(3043, 9738, 35))then
begin
KYAB_Log('Already at mine.');
end;
//If we have full inventory in the guild.
if(AtTile(3019, 9737, 45) and InvFull)then
begin
KYAB_Log('Already at mine with full inventory.');
WalkToBank;
FFlag(random(5));
end;
end;

procedure StoreAll;
begin
KYAB_Log('Storing all ores.');
if(not(OpenBankQuiet('feb')))then
if(not(OpenBankFast('feb')))then
if(not(OpenBankGlass('feb')))then
KYAB_Log('Couldn''t open bank');
DepositAll;
CloseBank;
end;


//========== General script methods: ==========\\
procedure SetupScript;
begin
ClearDebug;
SetupSRL;
KYAB_connect;
DeclarePlayers;
CheckUserNicks;
Sleep(100);
end;

procedure SetupPlayer;
begin
if not(LoggedIn)then
LoginPlayer;
MakeCompass('N');
HighestAngle;
GameTab(2);
Players[CurrentPlayer].Level[15] := GetSkillLevel('mining');
TotalMinutesPerPlayer := MinutesPerPlayer + Random(RandomMinutes);
GameTab(4);
MarkTime(RunTime);
end;

function TimeToSwitchPlayers: boolean;
begin
if(TimeFromMark(RunTime) / 60 / 1000 > TotalMinutesPerPlayer)then
begin
result := true;
KYAB_Log('Time for player is up.');
end else
result := false;
end;

function Mining : boolean;
begin
if(GetAnimation = 624) then
begin
result := true;
end else
begin
result := false;
end;
end;

procedure SleepWhileMoving;
begin
while(GetMotion > 0) do
begin
KYAB_Log('Sleep while moving...');
Sleep(1000);
end;
end;

//========== Event loop: ==========\\
function EventLoop : boolean;
begin
AutoWalker;
repeat
while(not Mining) do
begin
KYAB_Log('Mining...');
FindRandoms;
ClickCoal;
Sleep(1000);
SleepWhileMoving;
end;
KYAB_Log('WorkUntilMined...');
WorkUntilMined(x, y);
until(InvFull);

if(InvFull) then
begin
KYAB_Log('Inventory is full, walking back to bank to deposit all items.');
AutoWalker;
StoreAll;
end;
result := true;
end;



//========== Main method: ==========\\
begin
SetupScript;
KYAB_Log('===== Starting script. =====');
repeat
SetupPlayer;

repeat
EventLoop;
ProgressReport;
if(TimeToSwitchPlayers) then
LogOut;
until not(LoggedIn);
NextPlayer(true);
until not(Players[CurrentPlayer].Active);
KYAB_Log('All players are inactive.');
KYAB_Close;
end.

solarwind

2007-10-10 18:32:52

Wow, smartzkid, I am amazed, surpsed and highly appreciate your post. Especially after I called you a wiseass. I am sorry as well.

pwnaz0r

2007-10-10 18:39:47

Solar, could you get on msn for a sec?

WT-Fakawi

2007-10-10 18:42:32

Administrators! FFS! you force me to moralize you. You are behaving unrespectfull, like stupid frustrated kids! Leave him alone. There is absolutely no reason to hunt solarwind down the way you all do. Stop this nonsense and leave the guy alone. He is desperately fighting for content over at his server and this is his blunt way of raising a fire. Dont you recognize his game? Dont you see through this obvious provocation?

Mods/Admins?
-WT-Fakawi


Well solarwind?

I will give you exactly 10 minutes to come up with an explanation for this.

WT-Fakawi

2007-10-10 18:47:14

Duh.

nvm.

I am off to bed.


GRRRR

solarwind

2007-10-10 18:47:50

From: pwnaz0r
Solar, could you get on msn for a sec?


I am on MSN, what's your address? I'll add your or something…

From: WT-Fakawi
Well solarwind?

I will give you exactly 10 minutes to come up with an explanation for this.


You posted that on the other thread.

WT-Fakawi

2007-10-10 18:48:36

From: solarwind
You posted that on the other thread.


I know. Sorry.

SKy Scripter

2007-10-10 18:55:41

Lol, whats going on?!?!,

nice script Solarwind ;)

solarwind

2007-10-10 19:01:14

From: SKy Scripter
Lol, whats going on?!?!,

nice script Solarwind ;)


LOL! Thanks bro! Nice to hear coming from an SRL dev! I know it honestly kind of sucks, but I'm not that good at SCAR scripting, and I don't have much time with all that homework, but when I'm free, I try to work on stuff like this.

TheSantaMan

2007-10-10 23:23:42

Looks very good. I like the idea of the includes. Umm only thing i found was that it still tries to mine when invy is full.

RudeBoiAlex

2007-10-11 16:17:55

Hmm what exactly is tilewalking?

Drakan

2007-10-11 18:09:37

You know how runescape is built of tiles? Like the little squares you see because they suck at their graphics? Well KYAB gets the fields of that info and stuff using reflection and so u know where you are at, and where other tiles are. Im kinda bad at explaining it

solarwind

2007-10-11 18:22:26

From: RudeBoiAlex
Hmm what exactly is tilewalking?


Register at kyab.asssoft.org and read the big stickyfied tutorial in the tutorial section. That explains everything.

Bramble

2007-10-11 18:33:12

well dude if you wanted to fix the inv full continue mining bug, go into your mining procedure, and search for dtm of the ore in position 28 of inventory, if found, exit loop, yadda yadda yadda, and that should fix it

solarwind

2007-10-11 18:48:31

From: Bramble
well dude if you wanted to fix the inv full continue mining bug, go into your mining procedure, and search for dtm of the ore in position 28 of inventory, if found, exit loop, yadda yadda yadda, and that should fix it


I will do that, thanks! However, why doesn't the InvFull function detect that? Should it not return true when the inventory is full?

Sp0rky

2007-10-11 19:36:48

Nah, if you get like a mysterious box in ur last invent, then you're fucked. Think of a better method :p

Sumilion

2007-10-12 10:22:18

Are you perhaps interested in a msn talk ? I might be able to talk some (scar) sense in you ;).

~Sumilion

solarwind

2007-10-12 17:37:26

From: Sumilion
Are you perhaps interested in a msn talk ? I might be able to talk some (scar) sense in you ;).

~Sumilion


For sure, I would highly appreciate that. solarwind__ hotmail would be my email. (Removed the obvious symbols so I don't get spammed).

Sumilion

2007-10-12 18:38:29

Ok, I have you added but we probably wont be talking today anymore, it's rather late here.