SRL Archive - First Scripts

The Butcher - Kills cows & buries the bones!


tootallmatt

2012-03-05 02:44:39

My first release…..
The Butcher!
What it does:


  • Kills cows near Lumbridge.
  • Collects the bones.
  • Once inventory is full, it buries the bones.
  • Trains multiple skills!
Requirements:

  • High enough level to survive cows without eating.
If you want to test it and let me know of any bugs or improvements that could be made, feel free.

Make sure your inventory is empty because it will drop anything that isn't a bone. Thanks.

program TheButcher;

{$DEFINE SMART}
{$i srl/srl.simba}
{$i SRL/SRL/misc/paintsmart.simba}

CONST
NumbOfPlayers = 1; //How Many Players
StartPlayer = 0; //Starting Player
Version = 0.4; //Much More To Come!

VAR
CowColor : Array [0..4] of Integer;
CowText, DropsText : Array [0..1] of String;
AvoidText : Array [0..11] of String;

Procedure DeclarePlayers;
var
i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['XP', 'xp', 'lamp'];

with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
end;
end;

procedure SetColorsAndText;
begin
CowColor[0] := 6186605; //dark
CowColor[1] := 3755606; //medium
CowColor[2] := 8819356; //light
CowColor[3] := 7378090; //calf
CowColor[4] := 7375530; //calf2

DropsText[0] := 'Bones';
DropsText[1] := 'ones';

CowText[0] := 'Attack Cow';
CowText[1] := 'ttack Cow';

AvoidText[0] := 'ilk';
AvoidText[1] := 'rized';
AvoidText[2] := 'airy';
AvoidText[3] := 'illie';
AvoidText[4] := 'roats';
AvoidText[5] := 'ick P';
AvoidText[6] := 'alk-t';
AvoidText[7] := 'hop';
AvoidText[8] := 'hicken';
AvoidText[9] := 'oblin';
AvoidText[10] := 'alk';
AvoidText[11] := 'xamine';
end;

procedure AdjustCompass;
Begin
MakeCompass(RandomRange(1, 360));
Wait(1500+Random(100));
WriteLn ('Searching...');
Smart_ClearCanvas;
end;

procedure AntiBan;
begin
if not LoggedIn then
TerminateScript;

case Random(5) of
0: BEGIN
Writeln('AntiBan in progress...');

case Random(500) of
0..10: begin GameTab(tab_stats) HoverSkill ('Attack', false) GameTab(Tab_Inv); end;
21..31: begin GameTab(tab_stats) HoverSkill ('Strength', false) GameTab(Tab_Inv); end;
42..52: begin GameTab(tab_stats) HoverSkill ('Defense', false) GameTab(Tab_Inv); end;
63..73: begin GameTab(tab_stats) HoverSkill ('Prayer', false) GameTab(Tab_Inv); end;
84..94: begin ExamineInv; end;
105..115: begin PickUpMouse; end;
126..136: begin
GameTab(RandomRange(tab_Combat, tab_Notes));
Wait(800+Random(300));
GameTab(Tab_Inv);
end;
137..142: begin
case Random(40) of
0: TypeSend('I love this game!');
1: TypeSend('Die!');
2: TypeSend('Stupid cows!');
3: TypeSend('How much is the hide worth?');
end;
end;
end;
END;
1..4: BEGIN
WriteLn ('AntiBan was bypassed!');
EXIT;
END;
end;
AdjustCompass;
end;

Function LocateBones: TPointArray;
var
B,HPB: TBox;
TP,MHPB,MNPCB: TPoint;
TPA,GPA,RPA,
GPB,RPB,RTPA,PBox: TPointArray;
i,l,CTS,R: Integer;
ATPA: T2DPointArray;
begin
CTS := GetColorToleranceSpeed;
PBox := TPAFromBox(IntToBox(245, 135, 280, 185));
ColorToleranceSpeed(3);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 13290707, MSX1, 25, MSX2, MSY2, 3); //12763851 15527671 14803948 15001070

if (Length(TPA) < 1) then
begin
ColorToleranceSpeed(CTS);
Exit;
end;

TPA := ClearTPAFromTPA(TPA, PBox);
ATPA := TPAtoATPAEx(TPA, 30, 30);

l := High(ATPA);
SetArrayLength(ATPA, l+1);
for i := 0 to l do
begin
if (Length(ATPA[i]) > 20) then
B := GetTPABounds(ATPA[i])
else
Continue;

with B do
begin

TP := Point(((B.X1+B.X2)/2), B.Y1);

if (TP.X < MSX1) then
TP.X := MSX1;
if (TP.Y < MSY1) then
TP.Y := MSY1;

HPB:= IntToBox(TP.X-30, TP.Y-40, TP.X+30, TP.Y+40);

if (HPB.X1 < MSX1) then
HPB.X1 := MSX1;
if (HPB.X2 > MSX2) then
HPB.X2 := MSX2;
if (HPB.Y1 < MSY1) then
HPB.Y1 := MSY1;
if (HPB.Y2 > MSY2) then
HPB.Y1 := MSY2;

MHPB := Point(((HPB.x1+HPB.x2)/2), ((HPB.y1+HPB.y2)/2));
MNPCB := Point(((B.x1+B.x2)/2), ((B.y1+B.y2)/2));

ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MNPCB.X, MNPCB.Y, GPA, 52354, B.X1, B.Y1, B.X2, B.Y2, 10);
FindColorsSpiralTolerance(MNPCB.X, MNPCB.Y, RPA, 524459, B.X1, B.Y1, B.X2, B.Y2, 10);
FindColorsSpiralTolerance(MHPB.X, MHPB.Y, GPB, 52354, HPB.X1, HPB.Y1, HPB.X2, HPB.Y2, 10);
FindColorsSpiralTolerance(MHPB.X, MHPB.Y, RPB, 524459, HPB.X1, HPB.Y1, HPB.X2, HPB.Y2, 10);
ColorToleranceSpeed(CTS);

if ((Length(GPA) = 0) and (Length(RPA) = 0)
and (Length(GPB) = 0) and (Length(RPB) = 0)) then
begin
SetArrayLength(RTPA, (Length(RTPA)+1));
RTPA[R] := MNPCB;
Inc(R);
end;

end;

end;

SortTPAFrom(RTPA, Point(MSCX, MSCY));
Result := RTPA;

end;

Function GrabBones:Boolean;
var
TheBones: TPoint;
TPA: TPointArray;
begin
TPA := LocateBones;
if (Length(TPA) > 0) then
begin
TheBones := TPA[0];
Smart_DrawBoxEx(False, IntToBox(TheBones.X-3, TheBones.Y-3, TheBones.X+3, TheBones.Y+3), 196333);
MMouse(TheBones.X, TheBones.Y, 1, -1);
if WaitUpText('ake', 400) then
begin
ClickMouse2(False);
if WaitOption('ake Bo', 400) then
WriteLn ('Grabbing Bones!');
Smart_ClearCanvas;
end else
if WaitUpText('ttack Cow', 400) then
begin
ClickMouse2(False);
if WaitOption('ttack', 400) then
WriteLn ('Found bone color on a cow, so we attack!');
Smart_ClearCanvas;
end else
if WaitUpText('ilk ', 400) then
begin
Smart_ClearCanvas;
AntiBan;
WriteLn ('Hmm...We dont need any milk!');
end;
end;
Result := True;
end;

Function KillCows:Boolean;
Var
myX, myY: Integer;
Begin
myX:=MSCX;
myY:=MSCY;
if WaitUpTextMulti(AvoidText, 500+Random(25)) then
AntiBan;
if FindObjTPAMulti(myX, myY, CowColor, 2, 1, 20, 20, 7, CowText) then
ClickMouse2(False);
if WaitOption('ttack', 400) then
WriteLn ('Killing Cows!');
Result := True;
End;

procedure BuryAll;
var i: integer;
begin
repeat
for i:= 1 to 28 do
if ExistsItem(i) then
begin
MMouseItem(i);
if WaitUpTextMulti(['Bury', 'ones'], 400) then
begin
ClickMouse2(False);
if WaitOption('Bury', 400) then
end
else
begin
ClickMouse2(False);
if WaitOption('Drop', 400) then
end;
end;
until(InvEmpty);
WriteLn ('Inventory Emptied!');
end;
{|||||||||||||||||||||||||||||||||||||||||||
|| // ////// ////// /////// ||
|| // // // // // // // ||
|| // // // // // /////// ||
|| // // // // // // ||
|| ////// ////// ////// // ||
|||||||||||||||||||||||||||||||||||||||||||}
Var
Complete : Boolean;

begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
SetColorsAndText;
SetAngle(SRL_ANGLE_HIGH);
Repeat
if not LoggedIn then
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
if(InvFull)then
BuryAll
else
begin
Complete := KillCows;
Complete := GrabBones or Complete;
if(not Complete) then
AntiBan;
end;
Until(false);
end.

putonajonny

2012-03-05 16:35:51

Have a look at my comments and changes, a very good first script though

program TheButcher;

{$DEFINE SMART}
{$i srl/srl.simba}

CONST
NumbOfPlayers = 1; //you may as well let them set this in the Declare players section
StartPlayer = 0;
//you don't have to cram everything together :P
VAR
CowColor: Array [0..4] of Integer;
BoneColor: Array [0..3] of Integer;
CowText, BoneText : Array [0..1] of String; //Since these are the same you don't need to do them on seperate lines

Procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['XP', 'xp'];

with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
end;
end;

procedure SetColorsAndText; //You may as well have this as one procedure
begin
CowColor[0] := 6185836; //dark
CowColor[1] := 4217440; //medium
CowColor[2] := 9016990; //light
CowColor[3] := 7772847; //calf
CowColor[4] := 5140620; //calf2

BoneColor[0] := 11185330;
BoneColor[1] := 10396070;
BoneColor[2] := 9342869;
BoneColor[3] := 13159122;

CowText[0] := 'Attack Cow';
CowText[1] := 'ttack Cow';

BoneText[0] := 'ake';
BoneText[1] := 'Take';
end;

Function GrabBones:Boolean;
Var
myX, myY: Integer; //indend variables like this
Begin
myX:=MSCX;
myY:=MSCY;
if FindObjTPAMulti(myX, myY, BoneColor, 3, 2, 2, 2, 4, BoneText) then //12303300
repeat
Mouse(myX, myY, 0, 0, False); //When using repeat functions indent the lines in like this
WaitOption('ake Bo', 500);
WriteLn ('Grabbing Bones!');
Result := True;
until(Result);
End;

Function KillCows:Boolean;
Var
myX, myY: Integer;
Begin
myX:=MSCX;
myY:=MSCY;
if FindObjTPAMulti(myX, myY, CowColor, 3, 2, 2, 2, 3, CowText) then
//if FindObjCustom(myX, myY, ['Attack Cow'], CowColor, 3) then
Repeat
Mouse(myX, myY, 0, 0, False);
WaitOption('ttack', 500);
WriteLn ('Killing Cows!');
Result := True;
Until(Result);
End;

procedure AdjustCompass;
Begin
MakeCompass(RandomRange(1, 360));
Wait(1500+Random(500)); //you MUST have randomness here
WriteLn ('Searching...');
end;

procedure BuryAll;
var i: integer;
begin
repeat
for i:= 1 to 28 do
if ExistsItem(i) then
begin
MMouseItem(i);
if WaitUpTextMulti(['Bury', 'ones'], 400) then
begin
ClickMouse2(False);
if WaitOption('Bury', 400) then
end
else //this will make it drop everything else
begin
ClickMouse2(False);
WaitOption('Drop', 400)
end;
end;
until(InvEmpty);
WriteLn ('Inventory Emptied!');
end;
{|||||||||||||||||||||||||||||||||||||||||||
|| // ////// ////// /////// ||
|| // // // // // // // ||
|| // // // // // /////// ||
|| // // // // // // ||
|| ////// ////// ////// // ||
|||||||||||||||||||||||||||||||||||||||||||}
Var
Complete : Boolean;

begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
SetColorsAndText;
MakeCompass(RandomRange(1, 360));
SetAngle(SRL_ANGLE_HIGH);
repeat
LoginPlayer; //why are you logging in again?
SetAngle(SRL_ANGLE_HIGH);
repeat
LoginPlayer; //and again
SetAngle(SRL_ANGLE_HIGH);
repeat //why so many repeat loops
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
if (not(KillCows)) Or (not(GrabBones)) then
repeat
AdjustCompass;
until(KillCows) or (GrabBones);
until(KillCows) or (GrabBones);
until(InvFull);
BuryAll;
until(false);

//this is an alternative
Repeat
SetAngle(SRL_ANGLE_HIGH);
if(InvFull)then
BuryAll
else
begin
Complete := KillCows; //the reason you should do it like this not as an if statement is due to shortcuts pascal script takes when "or" and "and" functions return true and false respectively
Complete := GrabBones or Complete;
if(not Complete) then
AdjustCompass;
end;
Until(false);
end.

P1nky

2012-03-05 16:42:13

Good Job Mate, and congrats on your first release. Although, try to add more functions/failsafes. Keep working on it until you think it's perfect!

FifthDimension

2012-03-05 17:02:01

Good script but lately there are like 50 injection bots everywhere you go.

tootallmatt

2012-03-07 01:58:01

Updated the script if anyone would like to test it out and give me feedback.

Last Legend

2012-03-13 22:38:58

Good script, testing it on a low level pure, only problem is it is a bit slower (or my computer is a bit slower) than whatever players and or bots are at the pen at the moment, in a less populated world it worked well, although I have only ran it for an invent or two ;) Nice job on the first script!
Anubis