SRL Archive - First Scripts

Neitiznot Gold Bar Maker


DarkCoder

2011-12-16 16:03:05

In the last week AK Smelter has been so temperamental that today I decided to write a script for myself in order to continue smelting. So within the last ten or so hours I taught myself the basic scripting for here and Pascal stuff and got to work.

I am pretty certain that the following script works next to flawlessly. All suggestions on improving the script, be it a minor more effective way to write a line or a more substantial recommendation would be warmly welcomed!


// !!!!!!!!!!! BEFORE PUBLISIHING REMOVE USER AND PASSWORD !!!!!!!!!!!!
program iSmelter;
{$i srl/srl/misc/smart.scar}
{.include srl/srl.scar}

const
TOLERANCE = 35; // Change to min which works!

var
X, Y: integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
Players[0].BoxRewards := ['Xp', 'ostume', 'oins', 'aphire', 'ssence']; // change to whatever suits
end;

procedure AntiRandoms;
begin
FindNormalRandoms; // Whenever this is called, the script will check to see if your character is in a random event
LampSkill := 'prayer'; // If you set the script to choose an experience lamp from a random event box, it will use the exp on the woddcutting skill
LevelUp; // This is an Antiban procedure, but I find it more useful when called here because AntiRandoms is usually called more often than Antiban
end;

// maybe one for open bank, one for running and one for smelting?!?!
procedure Antiban; // make this far more dynamic asap
begin
case Random(280) of // Random(x) generates a random integer from 0 to (x - 1)
0: Wait(100+random(750));
10: RandomRClick;
20: HoverSkill('smithing', False);
30: PickUpMouse;
40..42: RandomMovement;
50..52: BoredHuman;
60: ExamineInv;
70: RandomAngle(1);
80..89: mMouse(0, 0, random(750), random(500));
90: case Random(50) of
0: Typesend('cmon');
1: Typesend('lol');
2: Typesend('lagg');
3: Typesend('hmm');
4: Typesend('hurry');
5: Typesend('bored XD');
end;
100: GameTab(RandomRange(tab_Combat, tab_Notes));
end;
end;

procedure SetCompass;
var Deg: Variant;
begin
Deg := rs_GetCompassAngleDegrees;
if (Deg > 9) then // works as an approx
begin
MakeCompass(7);
end;
end;

procedure DepositAllNow;
begin
DepositAll;
Wait(1000+random(250));
end;

procedure WithdrawOresNow;
begin
Withdraw(0, 0, 28); // collum, row, amount
Wait(1000+random(250));
end;

procedure StartSmelt;
begin
X := 500;
Y := 60;
if (FindColorSpiralTolerance(X, Y, 7172802, MSX1, MSY1, MSX2, MSY2, TOLERANCE)) then
Mouse(X, Y, 0, 0, false);
ChooseOption('melt-ore');
Wait(500+random(250));
X := (220+random(80));
Y := (380+random(80));
Mmouse(X,Y, 0, 0);
while (Flag) do
if not LoggedIn then exit;
if FindNormalRandoms then exit;
Wait(200+random(350));
Wait(1000+random(250));
end;

procedure OpenBankBox;
begin
X := 16;
Y := 280;
if (FindColorSpiralTolerance(X, Y, 7105649, MSX1, MSY1, MSX2, MSY2, TOLERANCE)) then
Mouse(X, Y, 0, 0, false);
ChooseOption('se');
Wait(500+random(250));
X := (375+random(40));
Y := (290+random(35));
Mmouse(X,Y, 0, 0);
while (Flag) do
if not LoggedIn then exit;
if FindNormalRandoms then exit;
Wait(200+random(350));
Wait(900+random(150));
end;

function SelectOnScreen:boolean;
var MakeX: Integer;
begin
MakeX := BitmapFromString(17, 8, 'meJyTaFkmgRvJr76OiUhVj0cLddX' +
'z+SYCEfHqFTbchWhBRvjVE6kFWT3xWuDqgQgAUyW6TQ==');
Result := (FindBitmapToleranceIn(MakeX, X, Y, MCX1, MCY1, MCX2, MCY2, TOLERANCE));
FreeBitmap(MakeX);
end;

function ContainsOre:boolean;
var
ChosenOre: Integer;
begin
GameTab(25);
ChosenOre := BitmapFromString(18, 12, 'meJxNkv8rA3EYx6/7Bzh2t/ui7D' +
'fJplFsSEu+JF+a72k/rNVI+MW3rPmyEAuZtY1ZtxZJJBKRJpKl/F3' +
'e56Pn7np3PXf3vD7P+3mec/r8tW19PMc5HG7cywOLYjQnrmQQk/CJ' +
'CXGNp7uhZ9LVMVzXPkCUEIpKa7p9+1KKnYuRLCHc34VHJHv84frOU' +
'afPT1TFVMygdq/lg3t5/w4xz5kX4sbeQPNgyN01gXJEVc7FDWrnSj' +
'l6VFOvkLRZ4C0U7IFqHZtFOaJsCwn09U+dvmu5Ly3/DcNWEGoZmQF' +
'OlLh6go7k+K1y/KxlP6oKP5peUjNv8EwgMr1D07BKlLSeRwKzBwqF' +
'GKUknnAUgaAgouxbF/LejXz4oCRfDId6iSjrLjBGiFHMNprC9JCmp' +
'ova2SdaA8WSMSsmIJiJlWIyTYJKF/GmbHxeCEZsyyl4AAI19QdZMr' +
'aAXRDLxshiIbyBWWFKOI0S8Ktg3UAw0mqXlzo1l7KUhHPUBfgLpLa' +
'UPA==');
Result := (FindBitmapToleranceIn(ChosenOre, X, Y, 560, 214, 734, 457, TOLERANCE));
FreeBitmap(ChosenOre);
end;

begin
Smart_Server := 35; // Having the same world in all your scripts allows you to change scripts without smart restarting.
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;

ClearDebug;
SetupSRL;
DeclarePlayers; // Calls the procedure, you can't forget this!
LoginPlayer; // You want your player to login, right?

repeat
if FindNormalRandoms then Break; // meant to be exit or break?!?
if not LoggedIn then Break;// Try and make it log back in?

SetCompass;// set angle up to highest also??

if (BankScreen) then // if bank is open
begin
if (InvFull) then
begin
if (ContainsOre) then
begin
CloseBank;
Wait(200+random(350)); // sleep?
end else
DepositAllNow;
end else
WithdrawOresNow;

end else
begin
if (ContainsOre) then // contains ore
begin
if (SelectOnScreen) then
begin
X := (235+random(45));
Y := (400+random(50));
Mmouse(X,Y, 0, 0);
Wait(200+random(150)); // shorten
if(IsUpText('ake All'))then
begin
Mouse(X, Y, 0, 0, true);
While (ContainsOre) do
begin
if not LoggedIn then exit;
if FindNormalRandoms then exit; // perhaps do not need ths line
LevelUp; // not needed here and does not work?!?
AntiRandoms;
Antiban;
Wait(350+random(150));
end;
end else
begin
writeln('Unable to click'); // Consider removing
Wait(100+random(50));
end;
end else
StartSmelt
end else
OpenBankBox; // open bank
end;
until(false);
end.

Mat

2011-12-16 16:25:25

Hey Man can I ask why on your Mouse are you not using random pixel like
Mouse(X, Y, 7, 7, True);
As where you are going
Mouse(X, Y, 0, 0, True);
As it would be click mainly on the same pixel?
I'm a noob at scripting so. :D Just wondering (:
Ali

DarkCoder

2011-12-16 16:31:49

Because I randomly decide the X and Y values beforehand therefore I don't have to make an already random value random. Truth be told I am not sure if I am doing it in the most effective manner :P

Mat

2011-12-16 16:38:51

Your in the same boat as me lol :D
Does it do that as it is picking up on the Colours and choosing randomly between them?

DarkCoder

2011-12-16 16:48:53

From: Aligndude
Your in the same boat as me lol :D
Does it do that as it is picking up on the Colours and choosing randomly between them?


Lol I was hoping to get advice with my script ;) but I am happy to help you on this thread as well.

In this case the mouse will randomly select an X and Y on the limit i want it to then wait, then confirm it can do the action i want it to (Make All) then left click (true being a left click).

X := (235+random(45));
Y := (400+random(50));
Mmouse(X,Y, 0, 0);
Wait(200+random(150));
if(IsUpText('ake All'))then
begin
Mouse(X, Y, 0, 0, true);

Mat

2011-12-16 16:53:13

:o I see and I prefer that wait to the one I'm using :D
I'm use Wait(RandomRange(200, 300));
But does that mean your clicking a set coordinates?
Lol Sorry about all these questions :D

[XoL]

2011-12-16 16:55:55

I like the idea but future reference auto-talking normally results in ban when doing something as repetitive as smithing (Real player stay there for a while too, and will notice the few words you say :P)

DarkCoder

2011-12-16 16:57:11

The above is clicking a set of coordinates without any relations to colour or object detecion, it can do this due to the script checking (using a bitmap that the object it wants to click) is present straight beforehand.

Kyle Undefined

2011-12-16 16:57:44

I would change your coord clicking to object finding, but it's not bad for a first script! Keep it up :)

DarkCoder

2011-12-16 16:59:59

From: R4nd0m
I like the idea but future reference auto-talking normally results in ban when doing something as repetitive as smithing (Real player stay there for a while too, and will notice the few words you say :P)


Hmm, yea, good point.

Mat

2011-12-16 17:00:44

I agree its a good Idea but It really need to read what they say and then it reacts to what they say. good Idea tho :)

DarkCoder

2011-12-16 17:01:15

From: Camo Developer
I would change your coord clicking to object finding, but it's not bad for a first script! Keep it up :)


Ok, will do :) thanks

Mat

2011-12-16 17:02:39

Camo, I couldn't seem to find any tuts on how to use object finder, any links or help :)
Ali

Kyle Undefined

2011-12-16 17:05:25

Do this one first, http://villavu.com/forum/showthread.php?t=67691

Then this one, http://villavu.com/forum/showthread.php?t=69179

Then check out all of these, http://villavu.com/forum/forumdisplay.php?f=95

Sin

2011-12-16 17:44:50

Will this work for Gold Bracelets?
Could you modify and release a script which crafts Gold Bracelets at Neitznot?

Kyle Undefined

2011-12-16 17:46:30

All you'd have to make it do is click a gold bar, then the smelter, and choose the gold bracelet mold. Should be like a 5 minute change.

Sir R. M8gic1an

2011-12-17 06:43:26


while (Flag) do
if not LoggedIn then exit;
if FindNormalRandoms then exit;
Wait(200+random(350));

//change to
while (Flag) do
begin
if not LoggedIn then exit;
if FindNormalRandoms then exit;
Wait(200+random(350));
end

otherwise it only loops the findNormalRandoms.

Also, u might want a proggie in ur next version

-RM

DarkCoder

2011-12-17 08:09:05

@ Sir R. M8gic1an
Thanks, have made the ammendents for the next version. Will also add a proggie in due course!

@ S1N
As Kyle/Camo said it shouldn't be too hard to do yourself, if I get my work for today done quickly and have time I will add it.

DarkCoder

2011-12-18 08:31:11

Just went crazy…

Implemented gold bar then Gold Bracelet making, will now test it and iron it all out :D

On a side note i don't think "LevelUp" function works anymore…

rsstorm

2012-01-21 22:28:10

I was trying to modify this to make gold bracelets, but i'm not very good at programming. so can someone modify it and post the code here?

Mink

2012-01-21 22:34:49

u cud always use narcles… which already has a string created for gold bracelets

rsstorm

2012-01-21 22:46:28

narcles?

rsstorm

2012-01-21 22:50:24

From: Mink
u cud always use narcles… which already has a string created for gold bracelets


i tried that but i always get this message.

Player 0 has no name, making inactive for now.
Error: Type Mismatch at line 1806
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]