PDA

View Full Version : Pancakes' PowerMiner!



Pancakes
06-28-2007, 02:17 AM
Hey, how are you going?
This is my first Scar Script - it's (yes another) Power Miner, but I thought it would be good practice!
I have good coding standards because in the past I've programmed in other languages.

The first problem I've noticed, is that it only mines from one rock? I want it to change rocks, it looks less suspicious.

Can some people read through my script, test it out, and post feedback/suggestions/constructive criticism?
program PowerMiner;
{.include SRL\SRL.scar}
{.include SRL\SRL\skill\mining.scar}

type //This type is for the rocks
iRock = record
Color : Integer;
Uptxt : string;
RockLevel : Integer;
Experience : Extended;
end;

const
CopperColor = 3824768; // _
TinColor = 8290185; // |
ClayColor = 4553880; // |
IronColor = 2569045; // |
SilverColor = 12434885; // |
CoalColor = 2834753; // | --------- ROCK COLORS
GoldColor = 1881051; // |
MithrilColor = 7359564; // |
AdamantiteColor = 6322272; // |
RuniteColor = 0; // -
RunningDir = 'N'; //Direction to run in.
OreToMine = 'Copper'; //Which ore to mine.
OreTolerance = 3; //Ore Color Tolerance.
MiningWait = 3; //Time to wait before mining next ore in seconds.
PickEquipped = False;
var
Clay : iRock;
Copper : iRock;
Tin : iRock;
Iron : iRock;
Silver : iRock;
Coal : iRock;
Gold : iRock;
Mithril : iRock;
Adamantite : iRock;
Runite : iRock;
OreDTM : Integer;

{¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤Â¤START FUNCTIONS¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤Â¤Â¤Â¤Â¤Â¤Â¤Â¤}

procedure CheckLoggedIn;
begin
if (Not(LoggedIn)) then TerminateScript;
end;


procedure FindSomeGas; //This procedure is used for finding gas.
begin
if (FindGas(x,y)) then
begin
//Make the compass north, just so we run the right way.\
MakeCompass('N');
HighestAngle;
RunAwayDirection(RunningDir);
Wait(19000 + random(2000));
RunBack;
end;
end;

procedure FindSomeRandoms; //My Random Finding Procedure.
var i : Integer;
begin
for i := 1 to 7 do
begin
case i of
1: FindTalk;
2: FindNormalRandoms;
3: FindSomeGas;
4: FindPick;
5: FindTalk;
6: FindSomeGas;
7: CheckLoggedIn;
end;
Wait(100 + random(100));
end;

if (FindFight) then
begin
RunAwayDirection(RunningDir);
Wait(10000 + random(10000));
RunBack;
end;
end;


function ChooseOptionFast(x, y, Over: Integer; txt: string): Boolean; //JAD
var
x1, y1, x2, y2, LeftCorner, RightCorner: Integer;
begin
LeftCorner := BitmapFromString(4, 4, 'z78DA33753135313137C5' +
'411A600064715CEA914500CACE13F0');
RightCorner := BitmapFromString(4, 4, 'z78DA33753135313137' +
'C5200D30002E35F8C501C9C013F0');
if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
begin
if (FindText(x, y, txt, upchars, x1, y1, x2, 502)) then
begin
Result := True;
Mouse(x + Length(txt) * 3 + (Over), y + 3, 2, 2, True);
end
else if (FindText(x, y, 'Cancel', upchars, x1, y1, x2, 502)) then
Mouse(x + 9, y + 3, 2, 2, True);
end;
FreeBitmap(LeftCorner);
FreeBitmap(RightCorner);
end;

procedure MyAntiBan;
var
GameTabRandom : Integer;
RandomNumber : Integer;
begin
RandomNumber := Random(9);
case RandomNumber of
0: begin
HoverSkill('Mining', False);
Wait(2123 + Random(413));
end;
1: RandomRClick;
2: begin
GameTabRandom := Random(6);
GameTab(GameTabRandom);
end;
3: PickupMouse;
4: AlmostLogOut;
5: SayCurrentLevels('Mining');
6: begin
case Random(8) of
0: TypeSend('Mining levels?');
1: TypeSend('Mining lvls?');
2: TypeSend('Mining levls');
3: TypeSend('Minning levels');
4: TypeSend('Mining lvls');
5: TypeSend('Mining levs?');
6: TypeSend('Miining levels');
7: TypeSend('Mining lvls??');
8: TypeSend('Mining levels??');
end;
end;
7: begin
MakeCompass('N');
Wait(10 + Random(80));
MakeCompass('S');
Wait(10 + Random(80));
MakeCompass('N');
end;
8: begin
LowestAngle;
Wait(10 + Random(80));
HighestAngle;
end;
9: SleepAndMoveMouse(600000 + Random(400000));
end;
end;
function FindFastRandoms: Boolean; //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;
Logout;
Exit;
end;
end;
7: begin
if InBlack then
begin
Result := True;
Logout;
Exit;
end;
end;
8: if FindTalk then
Result := True;
9: CheckLoggedIn;
end;
wait(1);
end;
end;


{¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤Â¤START PROCEDURES¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤¤¤¤¤¤¤}

procedure DropToFast(StartSlot, EndSlot: Integer); //JAD
var FastSlot: array[1..28] of Integer;
DropSlot: array[1..28] of TPoint;
I, Q, T: Integer;
begin
T := 1;
for I := 1 to 28 do
begin
FastSlot[i] := T + Q;
Q := Q + 4;
if(Q > 24)then
begin
T := T + 1;
Q := 0;
end;
end;
GameTab(4);
Q := 0;
for I := StartSlot to EndSlot do
begin
if(ExistsItem(FastSlot[i]))then
begin
DropSlot[i] := ItemCoords(FastSlot[i]);
Mouse(DropSlot[i].x,DropSlot[i].y,3,3,false);
if(I > 7)then
ChooseOptionFast(x,y,30,'Drop') else
ChooseOptionFast(x,y,4,'Drop');
end;
end;
end;

procedure StartMining;
var x, y : Integer;
var OreColorInt : Integer;
var RandomNumber2 : Integer;
begin
case OreToMine of
'Clay': OreColorInt := Clay.Color;
'Tin': OreColorInt := Tin.Color;
'Copper': OreColorInt := Copper.Color;
'Iron': OreColorInt := Iron.Color;
'Silver': OreColorInt := Silver.Color;
'Coal': OreColorInt := Coal.Color;
'Gold': OreColorInt := Gold.Color;
'Mithril': OreColorInt := Mithril.Color;
'Adamantite': OreColorInt := Adamantite.Color;
'Runite': OreColorInt := Runite.Color;

end;
repeat
RandomNumber2 := Random(6);
CheckLoggedIn;
if(FindObj3(x, y, 'ine', OreColorInt, 3)) then
begin
MMouse(x, y, 0, 0);
FindSomeGas;
Wait(100 + random(150));
Mouse(x, y, 0, 0, True);
FindSomeRandoms;
FindSomeGas;
Wait(MiningWait * 1000 + random(500));
end;
Wait(100 + Random(200));
if (RandomNumber2) = 4 then
MyAntiban;
until(invFull);
end;

procedure DropOre;
begin
if (Not(InvFull)) then
begin
StartMining;
Exit;
end;
Wait(200 + random(200));
if (PickEquipped) then DropToFast(1, 28);
if (Not(PickEquipped)) then DropToFast(2,28);
end;


procedure LoadDTMS;
begin
OreDTM := DTMFromString('78DA635CC8C0C0D0C98002F6E41A30FC07D 28' +
'C40FC1F0818970219B50C6880918115AA06CC5B03241A08A8 590E' +
'242611503317484C27A0661211E680CC68C6AF06001A2C0EA A');
end;

procedure FreeDTMS;
begin
FreeDTM(OreDTM);
end;




procedure Signature;
begin
Writeln('_________ SCRIPT BY: __ ');
Wait(200);
Writeln('\______ \_____ ____ ____ _____ | | __ ____ ______ ');
Wait(200);
Writeln(' | ___/\__ \ / \_/ ___\\__ \ | |/ // __ \ / ___/ ');
Wait(200);
Writeln(' | | / __ \| | \ \___ / __ \| <\ ___/ \___ \ ');
Wait(200);
Writeln(' |____| (____ /___| /\___ >____ /__|_ \\___ >____ > ');
Wait(200);
Writeln(' \/ \/ \/ \/ \/ \/ \/ ');
Wait(200);
end;

procedure SetRockValues;
//This procedure sets information about the rock types.
begin
Clay.Color := ClayColor;
Clay.Uptxt := 'lay';
Clay.RockLevel := 1;
Clay.Experience := 5;
Copper.Color := CopperColor;
Copper.Uptxt := 'oppe';
Copper.RockLevel := 1;
Copper.Experience := 17.5;
Tin.Color := TinColor;
Tin.Uptxt := 'in';
Tin.RockLevel := 1;
Tin.Experience := 17.5;
Iron.Color := IronColor;
Iron.Uptxt := 'ron';
Iron.RockLevel := 15;
Iron.Experience := 35;
Silver.Color := SilverColor;
Silver.Uptxt := 'ilve';
Silver.RockLevel := 20;
Silver.Experience := 40;
Coal.Color := CoalColor;
Coal.Uptxt := 'oal';
Coal.RockLevel := 30;
Coal.Experience := 50;
Gold.Color := GoldColor;
Gold.Uptxt := 'old';
Gold.RockLevel := 40;
Gold.Experience := 65;
Mithril.Color := MithrilColor;
Mithril.Uptxt := 'thri';
Mithril.RockLevel := 55;
Mithril.Experience := 80;
Adamantite.Color := AdamantiteColor;
Adamantite.Uptxt := 'amant';
Adamantite.RockLevel := 70;
Adamantite.Experience := 95;
Runite.Color := RuniteColor;
Runite.Uptxt := 'unit';
Runite.RockLevel := 85;
Runite.Experience := 125;
end;

procedure SetRetaliation(Retaliate : Boolean);
//This procedure is used to set retaliation.
var
x : Integer;
y : Integer;
begin
if (Not(Retaliate)) then
begin
GameTab(1);
Wait (20 + Random(80));
if FindColorSpiralTolerance(x, y, 1711220, 610, 367, 620, 393, 7) then
Mouse(x, y, 0, 0, True);
end;
end;


procedure DisguiseX;
//This procedure is used to disguise Scar.
var
varDisguise : Integer;
begin
varDisguise:= Random(10);
case varDisguise of
0 : DisguiseScar('iTunes');
1: DisguiseScar('New Folder');
2: DisguiseScar('Untitled - Wordpad');
3: DisguiseScar('Untitled - Notepad');
4: DisguiseScar('Google - Microsoft Internet Explorer');
5: DisguiseScar('Untitled - Paint');
6: DisguiseScar('CommandPrompt');
7: DisguiseScar('Windows Live Messenger - Log In');
8: DisguiseScar('Yahoo - Microsoft Internet Explorer');
9: DisguiseScar('Google - Mozilla Firefox');
10: DisguiseScar('Yahoo - Mozilla Firefox');
end;
end;

procedure MainLoop;
begin
repeat
FindSomeRandoms;
if (Not(LoggedIn)) then
begin
FreeDTMS;
Exit;
end;
StartMining;
DropOre;
MyAntiBan;
until (Not(LoggedIn));
end;


procedure SetupScript;
begin
SetupSRL; //Setup SRL to make sure we compile.
SetupSRLMining; //Setup SRLMining.
ActivateClient; //Activate Runescape Client, so we can WORK!
DisguiseX; //Changes the caption of SCAR to a random string.
Wait(200 + Random(500)); //We wait now for a little bit.

SetRun(True); //Sets running to on.
SetRetaliation(False); //Sets retaliation to false.
SetRockValues; //Set the rock values.

FindPickHeadColor; //Find the pick head color, used for pickhead finding. Duh!
end;

begin
ClearDebug;
Signature;
Wait(2000);
ClearDebug;
SetupScript;
MainLoop;
end.

Thanks.

Pancakes. :spot:

EDIT: Better Script.

kariya40
06-28-2007, 02:19 AM
Looks like a great script! I will definitely test this one!!! I love how you put the rock colors already in their as well. :D

ZephyrsFury
06-28-2007, 08:45 AM
Wow great first script...:D
I've got a few suggestions though...

First of all, its not really that sus if the script only mines from one rock . A real person would probably mine from one rock aswell.

Secondly, for future updates, I recommend you add a progress report to the script that displays the number of ores mined/dropped etc.

Thirdly, with your FindSomeGas procedure, when you find gas, instead of running away you could make it click the spot next to you on the minimap so it stops mining but doesn't move very far.

Fourthly:
begin
RandomNumber := Random(9);
case RandomNumber of
0: begin
HoverSkill('Mining', False);
Wait(2123 + Random(413));
end;
1: RandomRClick;
2: begin
GameTabRandom := Random(6);
GameTab(GameTabRandom);
end;
3: PickupMouse;
4: AlmostLogOut;
5: SayCurrentLevels('Mining');
6: begin
case Random(8) of
0: TypeSend('Mining levels?');
1: TypeSend('Mining lvls?');
2: TypeSend('Mining levls');
3: TypeSend('Minning levels');
4: TypeSend('Mining lvls');
5: TypeSend('Mining levs?');
6: TypeSend('Miining levels');
7: TypeSend('Mining lvls??');
8: TypeSend('Mining levels??');
end;
end;
7: begin
MakeCompass('N');
Wait(10 + Random(80));
MakeCompass('S');
Wait(10 + Random(80));
MakeCompass('N');
end;
8: begin
LowestAngle;
Wait(10 + Random(80));
HighestAngle;
end;
9: SleepAndMoveMouse(600000 + Random(400000));
end;
end;


When you tell it do random(9); you are actually telling it to pick a number from 0 to 8 inclusive. This means 9 is never picked and SleepAndMoveMouse is never called. You need to change it to random(10) or even more so the chance of do antiban is less than 100%. Theres a similar problem with the random mining lvl talking.

Other than that great script. Keep going!! :D