SRL Archive - First Scripts

Chicken Killer


Bliss

2008-12-14 12:17:09

Well I haven't done any kind of SCAR coding in a long time, and I'm still new to it. I just put together this chicken killer using information from the SRL wiki, and thus far it seems to be working fine.
'
program HolyChicken;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Fighting.scar}

var
i, x, y, bones, burried : Integer;
const
version = '0.3';
takeBones = false; //Should it pick up bones and bury when inventory is full?
takeFeathers = false; //Should it collect feathers?
autoRespond = true; //Enable auto-responder?


procedure DeclarePlayers;
begin
NumberOfPlayers(1);
CurrentPlayer := 0;

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

procedure setStatus(status : String);
begin
clearDebug;
Writeln('Holy Chicken by Bliss \\ Version 0.3');
Writeln('------------------------------------');
Writeln('Currently: ' + status);
Writeln('------------------------------------');
Writeln('Bones aquired: ' + inttostr(bones) + ' | Inventory: ' + inttostr(InvCount) + '/28');
Writeln('Bones burried: ' + inttostr(burried) + ' | ');
Writeln('------------------------------------');
Writeln('Running for: ' + TimeRunning + '');

end;

procedure buryBones;
begin
for i := 1 to 28 do
begin
Case Random(1) of
0: MouseItem(i, True);
1: begin
MouseItem(i, False);
ChooseOption('ury');
end;
end;
burried := burried + 1;
ReportVars[0] := ReportVars[0] + 1;
Wait(1000 + Random(1000));
setStatus('Burying bones');
end;
end;

procedure getBones;
begin
if not takeBones then Exit;
setStatus('Picking up bones');
if FindColorSpiralTolerance(x, y, 13421779, MSX1, MSY1, MSX2, MSY2, 10) then
begin
Mouse(x, y, 5, 5, false);
if chooseOption('ones') then
begin
ReportVars[1] := ReportVars[1] + 1;
bones := bones + 1;
end;
end;
if InvCount = 28 then
begin
buryBones;
Exit;
end;
Wait(3000);
end;

procedure getFeathers;
begin
if not takeFeathers then Exit;
setStatus('Getting feathers');
if FindColorSpiralTolerance(x, y, 13421779, MSX1, MSY1, MSX2, MSY2, 10) then
begin
Mouse(x, y, 2, 2, false);
chooseOption('eather');
end;
Wait(3000 + Random(2000));
end;

procedure killChickens;
var oldX, oldY, newX, newY : integer;
begin
MouseSpeed := 10 + Random(4);
if not InFight then
begin
setStatus('Searching for chicken');
FindColorSpiralTolerance(newX, newY, 923758, MSX1, MSY1, MSX2, MSY2, 3);
if not isFightAt(newX, newY) then
begin
setStatus('Trying to get to chicken at ' + inttostr(newx) + ', ' + inttostr(newy));
MMouse(newX, newY, 1, 1);
if IsUpText('hicken') then
begin
Mouse(newx, newy, 5, 5, false);
if ChooseOption('ttack') then
begin
oldX := newx;
oldY := newy;
end;
Wait(3000);
if infight then
begin
setStatus('Fighting');
Repeat
if random(19) = 10 then IdleTime(1500, 1000, 1);
Wait(1000);
Until not infight;
end;
end;
end;
end;
FindNormalRandoms;
end;

procedure mainSetup;
begin
clearDebug;
bones := 0;
burried := 0;
DeclarePlayers;
setupSRL;
ScriptID := '1117';
loginPlayer;
SetAngle(True);
SetRun(True);
end;

procedure antiBan;
begin
findNormalRandoms;
if random(19) = 10 then boredHuman;

{AUTO RESPONDER}
if not autoRespond then Exit;
if inChat(players[CurrentPlayer].Name) then
begin
Wait(3000 + Random(1000));
case Random(9) of
0: TypeSend('sup');
1: TypeSend('hey');
2: TypeSend('?');
3: TypeSend('ohai');
4: TypeSend('hi');
5: TypeSend('hey');
6: TypeSend(':)');
7: TypeSend('wuzza');
8: TypeSend('what');
9: TypeSend('yes?');
end;
end;
end;

procedure ScriptTerminate;
begin
SRLRandomsReport;
end;


begin
mainSetup;
repeat
killChickens;
getBones;
getFeathers;
antiBan;
if not LoggedIn then
begin
Wait(120000);
loginPlayer;
end;
until (not loggedIn);
end.

I would greatly appreciate any tips or advice. Thanks. :)

D1zl3

2008-12-15 18:10:12

I think its good considering the autocolor/ arrays. I would work on your standards tho :)

Edit: also antibans/antirandoms, very easy

Bliss

2008-12-15 21:43:22

Okay, well I've added some extra features like picking up bones, feathers, and auto responder.

Sandstorm

2008-12-15 21:51:35

Instead of doing Condition = false, do Not Condition.

kitchenrange

2008-12-15 21:59:49

I cant say ive ran it yet, but just looking at it, thats a very nice job especially for someone who is as new as you.

senrath

2008-12-15 22:44:57

A couple suggestions. Change this:
Case Random(1) of
0: MouseItem(i, True);
1: MouseItem(i, False);
1: ChooseOption('ury');
end;
to this:
Case Random(1) of
0: MouseItem(i, True);
1: begin
MouseItem(i, False);
Wait(50+random(25));
ChooseOption('ury');
end;
end;

Also, remove the SRLRandomsReport from the main loop, and instead add this in:
procedure ScriptTerminate;
begin
SRLRandomsReport;
end;

That way, the report will be sent any time the script terminates, instead of just when the loop is finished. So if someone manually stops the script, the report will still be sent.