PDA

View Full Version : My first script, power miner, please post improvements



nght spud
05-18-2007, 03:43 PM
Ok its my first script, you have to set up the colours of the rock to mine, the tolerance and how many loads.

I spent quite a while making the antiban and all that stuff, so the actual mining part is a bit rushed. It doesnt have a progress report yet. The anti randoms arent tested, and the gas detection and pick head finder may not work either, so please test it and dont blame me if anything goes wrong.

Please post improvements

Feel free to edit it or use parts of it in your own scripts just please gimme credit.

It works with Scar 2.03 and SRL 3.6 , not sure if it works with anything else.
V 1.1 ---Ok added a small progress report, and changed it so it definately wont pick up ores. Also It has mangaged to solve old man random three times.
V 1.2 ---Made the antirandom better but its still not tested, added more failssafes, and I finally managed to figure out how to make it only mine when its finished mining the last ore thanks to pwntby ownt for help with that
{My first script
Credits to
JAD for his amazing tutorials
WT-Fakawi for his also amazing anti random
Pwnt by Pwnt for helping with orefinding and only mining when neccessary
Anyone else who posted on the thread in a useful way
And of course kaitnieks the creator of scar and the SRL manual
edit lines 17-20 to set script up
The anti random/gas/pick head finder isn't tested
Please post improvements on forums
Feel free to edit anythin in this, or use anything but gimme credit please}
program PowerMiner;
{.include SRL\SRL.Scar}
{.include SRL\SRL/skill/Mining.scar}
var
loadsdone, k, l,ttlloads,progreps,mine,InvNo1,InvNo2,minedtimes2 : integer;

const
loadswanted = 5; //how many loads per player
minecolor = 5541861; //color of rock to mine
tol = 5; //what tolerance to use
minedtimes = 50; //how many times for it to try to mine unsuccesfully
procedure DeclarePlayers;
begin
HowManyPlayers := 8;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '-------';
Players[0].Pass := '-------';
Players[0].Nick := '-------';
Players[0].Active := True;


Players[1].Name := '-------';
Players[1].Pass := '-------';
Players[1].Nick := '-------';
Players[1].Active := false;

Players[2].Name := '-------';
Players[2].Pass := '-------';
Players[2].Nick := '-------';
Players[2].Active := True;

Players[3].Name := '-------';
Players[3].Pass := '-------';
Players[3].Nick := '-------';
Players[3].Active := True;

Players[4].Name := '-------';
Players[4].Pass := '-------';
Players[4].Nick := '-------';
Players[4].Active := True;

Players[5].Name := '-------';
Players[5].Pass := '-------';
Players[5].Nick := '-------';
Players[5].Active := True;

Players[6].Name := '-------';
Players[6].Pass := '-------';
Players[6].Nick := '-------';
Players[6].Active := True;

Players[7].Name := '-------';
Players[7].Pass := '-------';
Players[7].Nick := '-------';
Players[7].Active := True;


NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
end;

procedure switchplayer;
begin
if (Loadsdone = Loadswanted) then
begin
NextPlayer(True);
Loadsdone := 0; //change this variable
HighestAngle;
MakeCompass('N');
Writeln('Players have been switched');
end;
end;

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 9 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: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
9: RC;
end;
wait(1);
end;
end;

///////////////////////////////////////////////////////////////////////////

procedure FindRandoms;
begin
FindFastRandoms;
FindNormalRandoms;
FindPick;
if (FindFight = true) then
begin
RunAwayDirection('N');
Wait(10000 + random(2000));
RunBack;
end;

end;

procedure Makemereal;
begin
if (not (LoggedIn)) then
Exit;
case Random(14) of
0: Antiban;

1: RandomRClickEvery(5 + random(5));

2: LeaveScreenEvery(16 + random(5));

3: PickupMouseEvery(10 + random(3));

4: BoredEvery(3 + random(3));

5: begin
case Random(18) of
0: begin
HoverSkill('attack', false);
wait(1000 + random(1000));
GameTab(4);
end;
1: begin
HoverSkill('strength', false);
wait(1000 + random(1000));
GameTab(4);
end;
2: begin
HoverSkill('Defence', false);
wait(1000 + random(1000));
GameTab(4);
end;
3: begin
HoverSkill('Range', false);
wait(1000 + random(1000));
GameTab(4);
end;
4: begin
HoverSkill('Prayer', false);
wait(1000 + random(1000));
GameTab(4);
end;
5: begin
HoverSkill('Mage', false);
wait(1000 + random(1000));
GameTab(4);
end;
6: begin
HoverSkill('RuneCrafting', false);
wait(1000 + random(1000));
GameTab(4);
end;
7: begin
HoverSkill('HP', false);
wait(1000 + random(1000));
GameTab(4);
end;
8: begin
HoverSkill('Crafting', false);
wait(1000 + random(1000));
GameTab(4);
end;
9: begin
HoverSkill('Mining', false);
wait(1000 + random(1000));
GameTab(4);
end;
10: begin
HoverSkill('Smithing', false);
wait(1000 + random(1000));
GameTab(4);
end;
11: begin
HoverSkill('Cooking', false);
wait(1000 + random(1000));
GameTab(4);
end;
12: begin
HoverSkill('Fishing', false);
wait(1000 + random(1000));
GameTab(4);
end;
13: begin
HoverSkill('Firemaking', false);
wait(1000 + random(1000));
GameTab(4);
end;
14: begin
HoverSkill('Woodcutting', false);
wait(1000 + random(1000));
GameTab(4);
end;
15: begin
HoverSkill('Slayer', false);
wait(1000 + random(1000));
GameTab(4);
end;
16: begin
HoverSkill('Mining', false);
wait(1000 + random(1000));
GameTab(4);
end;
17: begin
HoverSkill('Mining', false);
wait(1000 + random(1000));
GameTab(4);
end;
end;
end;

6: RotateEvery(3 + random(3));

7: MouseBox(0, 0, 765, 500, 3);

8: MouseBox(MSX1, MSY1, MSX2, MSY2, 3);

9: MouseBox(MIX1, MIY1, MIX2, MIY2, 3);

10: SleepAndMoveMouse(5000 + random(5000));

11: begin
GameTab(1);
wait(2000 + random(1000));
SetFightMode(random(4));
end;

12: begin
case random(10) of
0: begin
TypeSend('Mining lvls');
wait(5000 + random(1000));
Gametab(2);
SayCurrentLevels('mining');
wait(1000 + random(1000));
GameTab(4);
end;
1: TypeSend('Booooringgg');
2: TypeSend('Gotta love mining');
3: TypeSend('I got 99 mining');
4: TypeSend('Why cant mining be more fun');
5: TypeSend('If your happy and you know it clap your hands');
6: TypeSend('Someone think of something more fun to do');
7: TypeSend('whats everyones highest lvl?');
8: TypeSend('My fave skill is smithing but i need ores');
9: TypeSend('how much are rune picks worth?');
end;
end;

13: begin
HighestAngle;
MakeCompass('N');
wait(100 + random(100));
LowestAngle
MakeCompass('E');
wait(100 + random(100));
HighestAngle;
MakeCompass('S');
wait(100 + random(100));
LowestAngle;
MakeCompass('W');
wait(100 + random(100));
HighestAngle;
MakeCompass('N');
wait(1000 + random(500));
end;

14: RandomChatEvery(14 + Random(4));
end;
end;

procedure Mining;
begin
if FindObj(k,l,'Rocks',minecolor,tol)
then begin
minedtimes2 :=0;
InvNo1 := 0;
InvNo2 := 0;
InvNo1 := InvCount;
FindGas(k,l);
FindPick;
Mouse(k, l, 0, 0, true);
wait(100 + random(100));
mine := mine + 1;
FindRandoms;
InvNo2 := InvCount;
end;
if (InvNo2=InvNo1)
then begin
repeat
minedtimes2 := minedtimes2 + 1;
if (minedtimes2 = 60)
then begin
repeat
Mining;
until (mine = minedtimes);
end;
FindRandoms;
FindGas(k,l);
FindPick;
InvNo2 := 0;
InvNo2 := InvCount;
wait (100+random(100));
until (InvNo2=(InvNo1+1)) ;
end;
if (InvFull)
then begin
mine := 0;
DropAll;
Loadsdone := Loadsdone + 1;
TtlLoads := TtlLoads + 1;
FindRandoms;
end;
if (mine = minedtimes)
then begin
Writeln('somethings not right')
NextPlayer(False);
Loadsdone := 0;
HighestAngle;
MakeCompass('N');
Writeln('Players have been switched');
end;
end;

procedure login;
begin
if (not (loggedin))
then begin
writeln('logging in');
Loginplayer;
HighestAngle;
wait(1000 + random(5000))
FindPickHeadColor
wait(1000 + random(1000))
end;
end;
procedure proggy;
begin
if (TtlLoads>progreps)
then begin
ClearDebug;
Writeln('----------------------------------------');
Writeln('--------NGHT SPUD`s Power Miner!--------');
Writeln('----------------------------------------');
Writeln('Total Time Running: ' + TimeRunning);
Writeln('Total Loads: ' + inttostr(TtlLoads));
SRLRandomsReport;
progreps := progreps + 1;
end;
end;
begin

ClearDebug;
ActivateClient;
SetUpSRL;
SetupSRLMining
DeclarePlayers;
Equippick := false;
repeat
switchplayer;
login;
FindRandoms;
case Random(4) of
0: wait(1);
1: Makemereal;
2: wait(1);
3: wait(1);
end;
Mining;
proggy;
until (false);

end.

Thanks for your comments

Jake_453
05-18-2007, 08:45 PM
looks not to bad, i really like your anti ban you obiously worked hard on that.

nght spud
05-18-2007, 11:18 PM
Yer anti Ban took the longest time to make, but wasnt too hard after learning how everything works.

NewToAutoing
05-19-2007, 02:58 AM
If i'm not mistaken (and this is just from looking at it) the method you use to find the rock only checks the color, not the name. Meaning that it would also pick up dropped iron ores, because they have the same color. Try researching the different kinds of FindObj and see which you like best. You can find them in SRL/core/object.scar

Edit: Also, it doesn't seem liked the integer "mined" is used anywhere. You declare it as 0 at one point, and then declare it as 1 at another, but it doesn't seem to do anything. Unless i missed where you use it.

nght spud
05-19-2007, 09:10 AM
Ok I changed some things, but can anyone give me and idea about how to make it know when it has mined an ore.

Edit: Figured out how to make it know when it has mined an ore, so just post improvements please

Pwnt by Pwnt
05-19-2007, 07:02 PM
hmmmmmm it looks pretty good, and like i havent tested it yet but as NewToAutoing said, you should put in there something like const
TreeColor = 622696;//Set the color of the tree
TypeOfTree = 'Tree';//What Kind Of Tree To Chop
TimeToWait = 5000;//Time Before Clicking Next Tree
StartPlayer = 0;
NumberOfUsers = 6;
LoadsPerPerson = 15;//How many loads for each player?
this is out of my powercutter3 but u should change it to mined and type of ore and stuff, and something like this below for the mining procedure//-----=-----=-----=-----=Tree Finding=-----=-----=-----=-----\\
procedure FindTheTree;
begin
If(FindColorSpiral(x,y,TreeColor,MSX1,MSY1,MSX2,MS Y2))then
begin
Writeln('Found Tree');
end;
end;

//-----=-----=-----=-----=Tree Cutting=-----=-----=-----=-----\\
procedure CutTheTree;
var
WaitMark:Integer;
TheMarkTime:Integer;
begin
MarkTime(WaitMark)
repeat
TheMarkTime:=TimeFromMark(WaitMark)
Writeln(inttostr(TheMarkTime))
Wait(50+random(51))
Cleardebug;
until(TheMarkTime>=TimeToWait)

begin
repeat
MMouse(x,y,0,0)
Until IsUpTextMulti('Cho','dow',TypeOfTree);
If IsUpTextMulti('Cho','dow',TypeOfTree) then
begin
GetMousePos(x,y);
Mouse(x,y,0,0,false);
wait(1000+random(100));
ChooseOption(x,y,''+TypeOfTree+'');
wait(100+random(10));
DoAntiRandoms;
If(IsFKeyDown(12))then terminatescript;
end;
end;
If not (FindColorSpiral(x,y,TreeColor,MSX1,MSY1,MSX2,MSY2 )) then
begin
HighestAngle;
PerfectNorth;
end;
end;

nght spud
05-19-2007, 10:08 PM
I have added something so it only clicks on the rocks, but unlike trees, rocks are called rocks no matter what type of ore your mining.


if FindObj(k,l,'Rocks',minecolor,tol)

atleast i think thats what that does.

Pwnt by Pwnt
05-20-2007, 12:55 AM
lol thats funny where u said, "I finally managed to figure out how to make it only mine when its finished mining the last ore" cuz i helped u with it :) lol idc but some cred would be nice :) lol

nght spud
05-20-2007, 10:27 AM
Oh kk sry I forgot

NewToAutoing
05-20-2007, 07:30 PM
I have added something so it only clicks on the rocks, but unlike trees, rocks are called rocks no matter what type of ore your mining.


if FindObj(k,l,'Rocks',minecolor,tol)

atleast i think thats what that does.

Yes, that should do it. Normally I use FindObj3(x,y,'ine',RockColor,tol) FindObj3 i chose myself because according to its description it searches from center of screen out, but theres other kinds too. As for 'ine' i don't remember why i chose that, but if i chose 'Rocks' i would have used 'ocks' because i believe capitals can mess it up sometimes, or at least i think i read that somewhere.

Azle
05-29-2007, 11:12 AM
Lolz all this looks very complicated =/

Pwnt by Pwnt
05-29-2007, 02:49 PM
Azle i can see your new :D but if you want help learning how to script i would be glad to help you ;-)

PwNZoRNooB
05-29-2007, 04:57 PM
There's the same mistake in the FindFastRandoms as it is in many other scripts :p :)

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 8 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: begin /// 7 Look below
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
7: begin /// HERE'S 7 TOO!!!
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
8: RC;
end;
wait(1);
end;
end;

nght spud
05-29-2007, 10:42 PM
Ah lol, i copied that from here (http://www.villavu.com/forum/showthread.php?t=9377)in a tut, may be why its in lots of scripts.

rs cheata
11-07-2007, 12:46 AM
It says duplicate identifier 'mine' in line 14

Harry
11-07-2007, 12:50 AM
It says duplicate identifier 'mine' in line 14
05-18-2007, 11:43 AM

Please do not gravedig/bump old topics.
It is not a good thing to do.