SRL Archive - First Scripts

First Power Chopper


Jahooma

2007-10-08 20:30:35

This is my first working script for scar, but I have had some small amount of programming experience elsewhere. Everything is written by me except all the anti random stuff was copied from other people's scripts, so thank you to YoHoJo, WT-Fakawi and BobboHobbo . Also I want to thank the helpful tutorial writers that have taught me and will continue help teach me to script in scar.

It works as posted (I think), and I would greatly appreciate any constructive criticism or comments you might have.

Thanking the scar community in advance,

Jahooma


Version 1:
program Chopper;
{.include SRL/SRL.scar}
Var
loads, count: Integer;
const
LoadsPerPlayer = 8; //Number of loads each player does before switching
TreeColor1 = 4420244; //pick 3 tree colors
TreeColor2 = 1852988;
TreeColor3 = 2506836;

procedure DeclarePlayers;
begin
HowManyPlayers := 5;
NumberOfPlayers(HowManyPlayers); //Leave this alone
CurrentPlayer := 1; //the starting player

Players[0].Name := 'username';
Players[0].Pass := 'password';
Players[0].Nick := 'nickname';
Players[0].Active := True;


Players[1].Name := 'username';
Players[1].Pass := 'password';
Players[1].Nick := 'nickname';
Players[1].Active := True;


Players[2].Name := 'username';
Players[2].Pass := 'password';
Players[2].Nick := 'nickname';
Players[2].Active := True;

Players[3].Name := 'username';
Players[3].Pass := 'password';
Players[3].Nick := 'nickname';
Players[3].Active := True;

Players[4].Name := 'username';
Players[4].Pass := 'password';
Players[4].Nick := 'nickname';
Players[4].Active := True;

end;

procedure EntFinder; // Thanks to YoHoJo.
var
EX, EY: integer;
FX, FY, EntAvoid: integer;
SafeEntWait: LongInt;
begin
if (not (LoggedIn)) then
begin
Nextplayer(false);
end;
begin
Status('Checking For Ent')
if
(FindObjCustom(EX, EY, ['Tree', 'Willow', 'Oak'], [4690821], 5)) then
begin
MMouse(EX, EY, 0, 0)
if FindColorTolerance(FX, FY, 55769, 85, 15, 115, 15, 20) then
begin
Status('Ent Found');
MouseFindFlag(645, 83, 2, 2);
MarkTime(SafeEntWait)
repeat
FTWait(5)
FindNormalRandoms;
if not (LoggedIn) then
NextPlayer(False);
until TimeFromMark(SafeEntWait) > 29000 + Random(10000)
EntAvoid := EntAvoid + 1
end;
end;
end;
end;

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 8 do
begin
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
7: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
8: RC;
end;
wait(1);

end;
end;

procedure FindRandoms; // copied from BobboHobbo's Rhimngton Woodcutter + Firemaker
begin
if (not (LoggedIn)) then Exit
FindFastRandoms;
FindNormalRandoms;
Wait(20)
FindTalk;
FTWait(3)
EntFinder;
if (FindFight) then
begin
RunAwayDirection('N');
Wait(8000 + Random(2000));
RunBack;
end;
Wait(20)
FindTalk;
end;

Procedure AntiBan;
Var
WaitAmount: integer;
begin
WaitAmount:=234+random(2000);
case random(5) of
0: SleepAndMoveMouse(WaitAmount + random(WaitAmount/2)+ random(WaitAmount/3) + random(WaitAmount/3));//more likely to get midrange times, i.e. maximum time is not the same chance as mean time-the mean is WaitAmount
1: begin
PickUpMouse;
end;
2: begin
HoverSkill('Woodcutting', False);
end;
end;
end;

function FindTree: Boolean;
var
x, y, MyMark1: integer;
begin
MarkTime(MyMark1);
repeat
if FindObjCustom(x, y, ['hop down Tree'], [TreeColor1, TreeColor2, TreeColor3], 10) Then
begin
wait(random(145)+ random(164));
Mouse(x,y,0,0,False);
wait(random(450)+ random(164));
if ChooseOption('hop') Then
begin
count:=0
Flag;
result:= True;
Exit;
end;
end;
wait(random(100)+random(100)+random(100));
until(TimeFromMark(MyMark1) > 1000* 4 + random(1975))

case Random(4) + 1 of
1:MakeCompass('N');
2:MakeCompass('S');
3:MakeCompass('E');
4:MakeCompass('W');
end;

count:=count+1
if count >= 7 Then Logout;
result:=False;
end;


procedure Chopping;
Var
MyMark2, C: integer;
begin
if not Loggedin then Exit;
if FindTree then
begin
MarkTime(MyMark2);
C:=InvCount;
FindRandoms;
AntiBan;
repeat
wait(random(200)+10);
until( (InvCount>C) or (TimeFromMark(MyMark2) > 1234* 3 + random(2798)) );
end;
end;

procedure ProgressReport;
begin
ClearDebug;
Writeln('/_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\');
Writeln('/--------------->Progress:<---------------\');
Writeln('/ Did ' + IntToStr(loads) + ' Loads' + ' in ' + TimeRunning + '\');
Writeln('/_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\');
end;


begin
SetupSRL;
DeclarePlayers;
if not(Loggedin) Then LoginPlayer;
repeat
if InvFull then
begin
DropToPosition(2, 28);
Inc(loads); //add 1 to the number of total loads
Inc(Players[CurrentPlayer].Banked); //add 1 to the number of this player's loads
if Players[CurrentPlayer].Banked >= LoadsPerPlayer then
begin
NextPlayer(True);
ProgressReport;
end;
end;
Chopping;
if not Loggedin then
begin
NextPlayer(False);
ProgressReport;
end;
until false
end.