SRL Archive - First Scripts

MossMangler -


Oaks

2012-01-26 13:41:52

Ever grow tired of those pesky moss giants?
Have you got an unquenchable thirst for peach juice?

well then this is the script for you!

Welcome, this is my first ever attempt at script, there really is very little benefit to using my script over any other autofighter. However as this is my first time I am posting my code here in the hopes that some amazing person can give me some constructive criticism.
To get this script to work all you need to do is go to the moss giants found in the chaos tunnels the entrance is in level 9-10 wildy just north of varrock and edge with bones to peach tabs and a full invent of either peaches or big bones.

many thanks and I hope you enjoy your peaches :-)

EDIT: just included a whole mess of antibans and randomisers to reduce chance of ban :-D also tidied up the main loop and added comments to make it easier to understand.

program mossmangler;
{$define srl5}
{$loadlib sps}
{$define smart}
{$i srl/srl.simba}
{$i sps/sps.simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
//Major credit to YoHoJo his tutorials showed me how to make most of it
with Players[0] do // script still being produced please leave me feedback and suggestions :-D
begin // fill these 2 in and also down at the bottom there is a place to insert the world you want :-)
Name := ''; // username here
Pass := ''; // pass here
Pin := ''; // not really needed for this script
Active := true;
end;
end;
var foodnumber, attempts, linetime: integer;

/////////////////// this procedure handles the finding and attacking of the moss
/////////////////// giant
procedure AttackMoss;
var Mossx, Mossy: Integer;
begin
wait(50+random(100));
If FindObjEx(Mossx, Mossy, ['Att','ack'], [3034986,4548456,5269599], 5, 70, MSX1, MSY1, MSX2, MSY2) Then
begin
Case Random(3) Of
0: Mouse(Mossx, Mossy, 10, 20, True);
1: Mouse(Mossx, Mossy, 10, 20, True);
2: Begin
Mouse(Mossx, Mossy, 10, 20, false);
Wait(500+random(75))
ChooseOption('Attack');
End;
End;
Flag;
wait(300+random(100));
End else
begin
MakeCompass('random') ;
wait (500+random(200));
attempts:= 1+ attempts ;
writeln (attempts)
writeln ('attempts to find a moss giant')
If (attempts > 20) then
begin ///ends script if it cant find a moss giant change line above to
logout; // change number of attemps
writeln('tried to find a moss giant, no sign of one')
TerminateScript;
end;
end;
End;
//////////////// this procedure handles the looting of the bones
procedure Lootbones;
var Bonex, Boney, loottimer, plusone : Integer;
begin
Bonex:=MSCX
Boney:=MSCY
If (InvCount <24+random(4)) Then
begin
wait (50+random(100));
If FindObjEx(Bonex, Boney, ['Ta','ke'], [14342884,13948382,13356245], 5, 70, MSX1, MSY1, MSX2, MSY2) Then
begin
plusone:= InvCount +1

MarkTime(loottimer);
repeat
Mouse(Bonex, Boney, 5, 5, False);
Wait(400+random(50));
WaitOptionMulti(['Take Big', 'e Big', 'orstol', 'dragon', 'ol seed'], 200);
Wait(600+random(200));
until(InvCount = plusone) or (TimeFromMark(loottimer) > 5000-random(600))
end;
End;
end;
/////////////////// this procedure handles all eating stuffs :-)
procedure eat;
var peachx, peachy, peachDTM: Integer;

begin
peachDTM := DTMFromString('m1gAAAHicjcyxCYAwAAXRn5QOEcRCwbQGHchhBC0EIaQQlMzggF5naQ5ee5WkaKUVB07cyLiQsGODN1KHGg1a9AiYMGLAs8xc7S+nskyhrxd0TAmk');
if findDTM (peachDTM, peachx, peachy, MIX1, MIY1, MIX2, MIY2) then
begin
writeln(foodnumber);
Mouse (peachx, peachy, 15, 15, true);
writeln('mm.. tasty peach');
foodnumber:= CountItems('dtm', peachDTM, []);
writeln(foodnumber)
wait(300+random(200))
if (foodnumber < 5) then
begin
lootbones;
lootbones;
end;
end else
begin /////should logout when you run out of tabs
writeln('out of tabs!')
logout;
terminatescript;
end;
end;
/////////////////////// this procedure handles the b2p support
///////////////////////(turns bigbones into peaches using tabs)
procedure makefood;
var b2px, b2py, b2pDTM: Integer;
begin
b2pDTM := DTMFromString('m1gAAAHicjclNCkBQGIXhcw2twfYswMQmGFnKLcUARZQb1uQl/yOnnq/ePl9S50k1KkxY4JDDHtrtb6QSDSwGOIzoURw9h4GyNNlJ3iWOolf73NNz3zY/3VsBFhcVYw==');
if findDTM (b2pDTM,b2px,b2py, MIX1, MIY1, MIX2, MIY2) then
begin
if (foodnumber <5) then
begin
Mouse(b2px, b2py, 9, 15, true);
wait (250);
end;
if (HPPercent >60) then
begin
wait(200)
eat;
end;
end;
end;
////////////////////// this is just a failsafe incase it
//////////////////////clicks on the rope, it causes the script to log you out
procedure wildy;
var wildyx, wildyy, wildyDTM: integer;
begin
wildyDTM := DTMFromString('mQwAAAHicY2ZgYDjLCMEXgVgdyDeA4oczZOEYBliBmBEJAwEATZcHww==');
if findDTM (wildyDTM,wildyx,wildyy, MSX1, MSY1, MSX2, MSY2) then
begin
logout;
writeln('oops clicked the rope!')
TerminateScript;
end;
end;
/////////////////////antiban stuffs
/////////////////////
procedure antiban;
begin
case random(950)of
0: begin
HoverSkill('Attack', False);
wait (random(3000));
Gametab(Tab_inv);
end;
1: begin
HoverSkill('strength', False);
wait (random(3000));
Gametab(Tab_inv);
end;
2: begin
HoverSkill('defence', False);
wait (random(3000));
Gametab(Tab_inv);
end;
3: begin
HoverSkill('Hitpoints', False);
wait (random(3000));
Gametab(Tab_inv);
end;
10:randomRclick;
20:BoredHuman;
30:randomMovement;
40:begin
Gametab(21+random(16));
wait(1000+random(3000));
Gametab(Tab_inv);
end;
50:lootbones;
60:makefood;
70:if (HPpercent <RandomRange(75, 85)) and LoggedIn then
begin
eat;
end;
end;
end;
/////////// this procedure handles the looting and peach making
/////////// just to clean up the main loop :-)
procedure fightwon;
begin
writeln('we won!');
Lootbones;
wait(400);
Lootbones;
if (HPpercent < RandomRange(45, 75)) and LoggedIn then
begin
eat;
end;
if (foodnumber <5+random(2)) then
begin
makefood;
end;
begin
wait(200+random(50));
end;
end;
////////////// this just handles all of the startup stuffs :-)
procedure startup;
begin
Smart_Server := 23;//world here
Smart_Members := true;
Smart_Signed := false;
Smart_SuperDetail := false;
SetupSRL;
DeclarePlayers;
LoginPlayer;
linetime := 3001;
Writeln('starting up looking for mossies');
Gametab(Tab_inv);
SetAngle(0);
attempts := 0;
end;
////////////// main loop starts here :-)
begin
startup;
repeat;
if (not(srl_InFight)) then
begin
AttackMoss;
if (TimeFromMark(linetime)> 3000) then
begin
writeln('looking for a target');
marktime(linetime);
end;
end;
if srl_InFight then
begin
writeln('found some moss, destroying it');
repeat
wait(400 + random(50));
antiban;
if (HPpercent < RandomRange(45, 65)) and LoggedIn then
begin
eat;
end;
if (foodnumber < 3) and LoggedIn then
begin
lootbones;
lootbones;
makefood;
end;
until (not (srl_InFight));
fightwon;
end;
FindNormalRandoms;
Gametab(Tab_inv);
wildy;
writeln(TimeRunning + ' is how long you have been killing mossies')
Until(False);
end.

Purpledan

2012-01-26 13:50:28

Love the introduction paragraph ^_^.

The script is pretty cool, you've done really well with it in the short time =D. I wish I could see it in action, but I don't particularly want to ruin my range tank with melee ^_^.

Itankbots

2012-01-26 14:05:10

Ooo Ill try this out! i Dont think any scripts here support btp tabs …been looking for one :o

okokokok

2012-01-26 14:08:37

I don't know how your script really is due to my lack of time, but i think your main loop contains too much. Some things should be in the functions/procedures. Also it is a bit organised, but hey it is your first script. So keep on going, you will learn alot more :)

Oaks

2012-01-26 14:19:16

From: okokokok
I don't know how your script really is due to my lack of time, but i think your main loop contains too much. Some things should be in the functions/procedures. Also it is a bit organised, but hey it is your first script. So keep on going, you will learn alot more :)


thanks for the feedback I will try to minimalize that. The issue I was having was when I called a procedure in another procedure it seemed to be unable to find it so I just put everything in the loop, any ideas? :-(

Oaks

2012-01-26 14:20:29

From: Itankbots
Ooo Ill try this out! i Dont think any scripts here support btp tabs …been looking for one :o


let me know how it goes please :-D

okokokok

2012-01-26 15:03:40

From: Oaks
thanks for the feedback I will try to minimalize that. The issue I was having was when I called a procedure in another procedure it seemed to be unable to find it so I just put everything in the loop, any ideas? :-(


Well i'd suggest, make seperate procedures. Call them after each other in the main loop. What you can also do to shorten the main loop is:


ahbnbdanba
badkljbhalkdbn
hkbaldhbna
(dlhnalg = whole script etc....)

procedure AllActions

begin
repeat
CutWood;
AntiBan;
AntiRandom;
DropWood;
until (false) or (Not(LoggedIn));
end

MainLoop;

begin
Declareplayers
etc
etc
if (Not(LoggedIn)) then
begin
LogInPlayer;
Wait(2500 + Random(1500));
end;
AllActions;
end

This way you organise it a bit more. At least that is what i do to make it simple for me :)

Oaks

2012-01-26 15:04:51

From: okokokok
This way you organise it a bit more. At least that is what i do to make it simple for me :)


thanks alot ill get right on it :-)

okokokok

2012-01-26 15:05:36

From: Oaks
thanks alot ill get right on it :-)


Ok nice :) Goodluck with your future scripts :)

halloweener

2012-01-26 16:21:59

hey guys
stupid question but i'm new
how to start this script as i'm new
cuz…when i start it it only compiles and does nothing

suggestions? help appreciated :)

okokokok

2012-01-26 16:33:10

From: halloweener
hey guys
stupid question but i'm new
how to start this script as i'm new
cuz…when i start it it only compiles and does nothing

suggestions? help appreciated :)


Fill out the form and hit the green arrow…

Nebula

2012-01-26 16:33:40

From: halloweener
hey guys
stupid question but i'm new
how to start this script as i'm new
cuz…when i start it it only compiles and does nothing

suggestions? help appreciated :)


You have to uncomment (remove the //) the line at the top that says "//{$define smart}"

okokokok

2012-01-26 16:36:33

From: Nebula
You have to uncomment (remove the //) the line at the top that says "//{$define smart}"


Yes sir

Oaks

2012-01-26 17:16:57

sorry forgot to remove the // :-( ill add comments to help beginners out too

Oaks

2012-01-27 03:38:54

been testing my script for a while now but I keep getting an error:
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.


any ideas? I've had a brief search on the forums but can't seem to find a fix, thanks.

Purpledan

2012-01-27 18:37:54

I ran it for around an hour without any problems, that error you mentioned appears throughout the use of the script, but only intermittently, it doesn't seem to affect how the script runs at all though, but I can see why it would be a bit annoying.