Here is my first script. It finds and fights a chicken, waits for 5 seconds and then looks for all feathers and bones on the ground and buries the bones. It works, but it is slow and inefficient. I will add stuff like antirandoms and progress reports and try to make it act less stupid later. Please post any comments and suggestions.
EDIT: Forgot to mention, all the multiplayer code came straight from the_rs_monkey's woodcutting tutorial. Thanks for the great tutorial!
SCAR Code:
////////////////////////////////////////////////////////////////////////////////
// ChickenFighter.scar //
////////////////////////////////////////////////////////////////////////////////
// - Kills chickens //
// - Picks up feathers //
// - Picks up and buries bones //
// //
// Instructions: //
// 1. Drag crosshairs to client //
// 2. Pick a color on the chickens and edit the script variables //
// 3. Enter the number of players and information for each //
////////////////////////////////////////////////////////////////////////////////
program ChickenFighter;
// SRL Includes
{.include SRL/SRL.scar}
const
ChickenColor = 6326691; // Color of chicken to look for
FeatherColor = 9737377; // Color of feather to look for
BoneColor = 12435141; // Color of bone to look for
KillsPerPlayer = 50; // Number of chickens killed before switching
WaitTime = 5000; // Time to wait before attacking a new chicken
var
BoneDTM : Integer;
// Shows title
procedure ShowTitle;
begin
writeln(' ===========================================================');
writeln(' __ ___ ');
writeln(' / | * | | * | | ');
writeln(' | | _ _ | _ | _ |__ __ | _ -+- _ | _ ');
writeln(' | |/ \ | / |/ /_\ |/ \ | | / \ |/ \ | /_\ |/ \');
writeln(' \__ | | | \_ |\ \_ | | | | \__| | | | \_ | ');
writeln(' | ');
writeln(' -Version 1.0- By ElPolloFeo \_/ ');
writeln(' ===========================================================');
end;
// Set up the players
procedure DeclarePlayers;
begin
NumberOfPlayers(2);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := True;
end;
// Find all of the feathers on the ground
procedure FindFeathers;
var
x, y : Integer;
begin
Flag;
repeat
if not FindObj(x, y, 'eather', FeatherColor, 0) then Exit;
Mouse(x, y, 0, 0, True);
Flag;
until (False);
end;
// Find all of the bones on the ground and bury them
procedure FindBones;
var
x, y : Integer;
FoundAllBones : Boolean;
begin
Flag;
FoundAllBones := False;
repeat
if not FindObj(x, y, 'ones', BoneColor, 0) then FoundAllBones := True;
if not FoundAllBones then Mouse(x, y, 0, 0, True);
Flag;
until (FoundAllBones);
repeat
if not FindDTM(BoneDTM, x, y, 540, 180, 750, 480) then Exit;
Mouse(x, y, 3, 3, True);
Wait(2000);
until (False);
end;
// Kill a chicken
procedure KillChicken;
var
x, y : Integer;
begin
repeat
Wait(100);
until FindObj(x, y, 'hicken', ChickenColor, 0);
Mouse(x, y, 1, 1, True);
Wait(WaitTime);
end;
// Main program
begin
ShowTitle;
SetupSRL;
DeclarePlayers;
if LoggedIn then Logout;
LoginPlayer;
BoneDTM := DTMFromString('78DA63CC616260E0606440067B366F626005D' +
'23051C62CA01A465435CB66CD4455930E54C389AA664E5F1FAA9A' +
'12A01A2E54352BE7CD4555538EE91E137D7D5435A94035CCA86A4' +
'0B2286AF2806AD850D594E764A3AAC904AA11C46DCE7F20000065' +
'0B1167');
// Main Loop
repeat
KillChicken;
FindFeathers;
FindBones;
Inc(Players[CurrentPlayer].Banked);
if Players[CurrentPlayer].Banked mod KillsPerPlayer = 0 then
begin
NextPlayer(True);
end;
if not LoggedIn then NextPlayer(False);
until False;
end.