SRL Archive - First Scripts

[SR: 4] Simple PowerChopper 0.4 (beta)


Zach1188

2007-10-27 19:20:37

This is my first attempt on a practical script. It is near complete, I would just like some feedback thus far.

Features:
Rotates map if tree cannot be found.
Randomly rotated map.
Effective ent detection.
Detects first free inv slot (see below).
Fast tree detection.
Decent anti-randoms (detects talking randoms quickly =P)
Logs out of unsolvable random is found
Basic (incomplete) report

Lacking (Coming soon):
Decent anti-ban
Detect all axes broken/lost
Multiplayer

Instructions:
Put all items in the first inventory slots. If you skip any slots, some logs will be skipped and/or other items will be dropped. I recommend getting 5 steel axes, wielding one and putting 4 on the top 4 inventory slots. It detects the last used slot, and drops everything after that. Don't start with logs in your inventory, they will be skipped. Always have at least one axe in your inventory. If you have one axe, dont wield it (this doesn't apply yet, but it will when I make axe detection).

Start Runescape with Low Detail, Unsigned client. Set your computer to 32-bit colors. Scar 3.12c and SRL 4 required.


program SimplePowerChopper;
{.include SRL\SRL.scar}
{.include SRL\SRL\skill\WoodCutting.scar}

const
TreeType = 2; //0 = Tree/Dead tree, 1 = Oak, 2 = Willow
//Yews are NOT recommended for training, use Willow.
//If you insist on cutting Yews however, enter 3.
TreeColor = 3307371; //Works for me, only change if necessary or if cutting dead trees
TreeTol = 4; //Tolerance. If you don't know what this means, procede to press Alt - F4
RunDirection = 'E'; //Direction to run if attacked
RunDefault = False; //Run under normal circumstances


var
TreeName: string;
LogsChopped, Loads, i, InvUsed, InvUsedReport: integer;
TreePTS: TPointArray;

procedure DeclarePlayers;
begin

Disguise('Norton Anti-Virus');
//No multiplayer yet!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

HowManyPlayers:=1; //DONT CHANGE UNTIL I MAKE MULTIPLAYER
NumberOfPlayers(HowManyPlayers); //DONT CHANGE UNTIL I MAKE MULTIPLAYER
CurrentPlayer := 0; //DONT CHANGE UNTIL I MAKE MULTIPLAYER

Players[0].Name :='Runescape'; //Your username
Players[0].Pass :='password'; //Your password
Players[0].Nick :='esca'; //3 - 4 letters of username. ie "Runescape" could be "esca"
Players[0].Active := True; //Is the Player used?

SetScreenName(Players[0].Nick);
writeln(inttostr(HowManyPlayers)+' Players');

end;

procedure SetSettings;
begin
case TreeType of
0: TreeName:= 'Tree';
1: TreeName:= 'Oak';
2: TreeName:= 'Willow';
3: TreeName:= 'Yew';
end;
InvUsed:= InvCount + 1;
InvUsedReport:= InvCount;
writeLn('First free inventory slot: ' + IntToStr(InvUsed));
writeLn('Tree: ' + TreeName);
SetRun(RunDefault);
GameTab(4);
HighestAngle;
SendArrowWait(2, 400 + Random(100)); //Lowers cameras slightly
//Makes ent detection more accurate
end;

procedure Report;
begin
writeLn('//////////Simple PowerChopper by Zach1188\\\\\\\\\\\\');
writeLn('// \\');
writeLn(' Logs Chopped: ' + IntToStr(LogsChopped) + '. Loads: ' + IntToStr(Loads));
writeLn(' Complete report coming soon.... ');
writeLn(' ');
writeLn('\\ //');
writeLn('\\\\\\\\\-------------------------------/////////////');
end;


function FindFastRandoms: Boolean; //By WT-Fakawi, ALL credits to him.
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 EndAuto;
begin
if LoggedIn then LogOut;
Report;
writeLn('Unsolvable random found, script unable to continue.');
TerminateScript;
end;

procedure AvoidFight;
begin
if FindFight then
begin
MakeCompass('N');
RunTo(RunDirection,True);
end;
end;

Procedure CheckForRandoms(FullCheck: boolean);
begin
if FindFastRandoms then EndAuto;
//FindInventoryRandoms;
AvoidFight;
FindTalk;
if FullCheck then FindNormalRandoms;
end;

procedure RotateCompass;
begin
CheckForRandoms(False);
case Random(3) of //Randomly chooses N, S, E, or W
0: MakeCompass('N');
1: MakeCompass('S');
2: MakeCompass('E');
3: MakeCompass('W');
end;
end;

Procedure DropLogs;
var ii: integer;
begin
CheckForRandoms(True);
if InvFull then
LogsChopped:= LogsChopped + 28 - InvUsedReport;
begin
for ii:= InvUsed to 28 do
begin
DropItem(ii);
CheckForRandoms(False);
case Random(14) of
0: begin
RotateCompass;
end; //1 in 15 chance of compass rotation
end;
end;
Loads:= Loads + 1;
end;
end;

Procedure WaitForTree;
begin
repeat
wait(50 + random(50));
case Random(19) of
0: Mouse(TreePTS[i].x, TreePTS[i].y, 3 - Random(2), 1, true);
end;
FindEnt(TreePTS[i].x, TreePTS[i].y, true);
CheckForRandoms(False);
GameTab(4);
until(Not(IsUpText(TreeName)) or (InvFull))
wait(1000 + random(500));
end;


Function FindTree(Tree: string; Color, Tol: integer): boolean;
begin
FindColorsSpiralTolerance(255, 166, TreePTS, Color, 5, 5, 515, 337, Tol);
if Length(TreePTS) <= 0 then RotateCompass
else for i:= 0 to Length(TreePTS) - 1 do
begin
CheckForRandoms(False);
MMouse(TreePTS[i].x, TreePTS[i].y, 3 - Random(2), 1)
If (IsUpText('down ' + Tree)) and (Length(TreePTS) > 0) then
begin
result:= true;
exit;
end
else if i = Length(TreePTS) - 1 then RotateCompass;
end;
result:= false;
end;

Procedure ChopTree;
begin
repeat
CheckForRandoms(False);
if FindTree(TreeName, TreeColor, TreeTol) then
begin
if Not(FindEnt(TreePTS[i].x, TreePTS[i].y, false)) then
begin
Mouse(TreePTS[i].x, TreePTS[i].y, 3 - Random(2), 1, true);
CheckForRandoms(False);
FindInventoryRandoms;
WaitForTree;
case Random(14) of
0: RotateCompass;
end;
end
end;
GameTab(4);
until(InvFull);
end;

begin
ActivateClient;
SetupSRL;
SetSettings;
DeclarePlayers;
repeat
CheckForRandoms(True);
ChopTree;
DropLogs;
Report;
until(false)
end.

Sir R. M8gic1an

2007-10-28 07:39:55

well you obviously know what you're doing, i'd say it's just a matter of time until the script is completed. Looking nice, im impressed that you used standards in your first script, the antiban as you said it yourself needs some work, as for selecting the tree i'd suggest you auto choose it, instead of asking the person to choose, and when they lvl up to the necessary lvl you change trees. for example from 1-15 it automatically chooses normal, once it reaches 15 it switches to oaks. I suggest you try adding multiplayer.

only found a couple problems, a possibly infinite loop.


Procedure ChopTree;
begin
repeat
writeLn('Chop Tree');
if FindTree(TreeName, TreeColor, 2) then
begin
if Not(FindEnt(TreePTS[i].x, TreePTS[i].y, false)) then
begin
Mouse(TreePTS[i].x, TreePTS[i].y, 3 - Random(2), 1, true);
WaitForTree;
AntiBanCompass;
end else
writeLn('Ent found');
end;
until(InvFull);
end;

what if it doesn't find the tree anymore? it'll just be there waiting to have the inv full.

yoou should add in: else break;

in the find tree function:

Function FindTree(Tree: string; Color, Tol: integer): boolean;
begin
writeLn('Finding tree');
FindColorsSpiralTolerance(255, 166, TreePTS, Color, 5, 5, 515, 337, Tol);
for i:= 0 to Length(TreePTS) - 1 do
begin
MMouse(TreePTS[i].x, TreePTS[i].y, 3 - Random(2), 1)
If IsUpText(Tree) then
begin
result:= true; // im not quite sure if the function will
// stop once it reaches this point
writeLn('Found tree.');
exit; //will this exit the whole function or just the if?
end
else if i = Length(TreePTS) - 1 then
case Random(3) of
0: MakeCompass('N');
1: MakeCompass('S');
2: MakeCompass('E');
3: MakeCompass('W');
end;
end;
result:= false;//if the function hasn't stopped before this it'll always return false. this should be in the else.
end;

ok, here it might be my mistake, but if that exit up there only exits the if once the function comes all the way down it'll always give Result:=False;

thedarkmage

2007-10-28 11:36:16

boredhuman;
wait2(time,true);
randomrclick;
hoverskill(skill,false);
pickupmouse;
almostlogout;
doemote(random(36)+1);//correct me if im wrong plz
getxp(skill)

thedarkmage

2007-10-28 11:37:16

im going to try yours out soon

prblmkid

2007-10-28 16:25:39

lemme try this one out

Zach1188

2007-10-28 22:10:34

From: Rasta Magician
well you obviously know what you're doing, i'd say it's just a matter of time until the script is completed. Looking nice, im impressed that you used standards in your first script, the antiban as you said it yourself needs some work, as for selecting the tree i'd suggest you auto choose it, instead of asking the person to choose, and when they lvl up to the necessary lvl you change trees. for example from 1-15 it automatically chooses normal, once it reaches 15 it switches to oaks. I suggest you try adding multiplayer.

only found a couple problems, a possibly infinite loop.


...

what if it doesn't find the tree anymore? it'll just be there waiting to have the inv full.

yoou should add in: else break;

in the find tree function:

...

ok, here it might be my mistake, but if that exit up there only exits the if once the function comes all the way down it'll always give Result:=False;


Thank you for your feedback, I've improved the script and also added in some anti-randoms, now I just need some decent anti-ban. I'll try adding in multiplayer later, as of now if FindFastRandoms is true, it just logs out and terminates the script.

And "exit" ends that entire function, so that part works. I've attempted to fix that possible infinite loop, it rotates the map in attempt to find a tree. However if that fails, it will sit there rotating the map infinitively. I will attempt to resolve this.

I look forward to contributing to this community :)

geforce

2007-10-30 04:26:32

i tested it worked well for me

Sir R. M8gic1an

2007-10-30 04:40:52

From: Zach1188
Thank you for your feedback, I've improved the script and also added in some anti-randoms, now I just need some decent anti-ban. I'll try adding in multiplayer later, as of now if FindFastRandoms is true, it just logs out and terminates the script.

And "exit" ends that entire function, so that part works. I've attempted to fix that possible infinite loop, it rotates the map in attempt to find a tree. However if that fails, it will sit there rotating the map infinitively. I will attempt to resolve this.

I look forward to contributing to this community :)


you'll find out that MarkTime(aMark) and TimeFromMark(aMark) are very useful to stop infinite loops. you can also use for to do loops to go by tries. i suggest you read The Claw's Flawless scripting tutorial in the intermediate section, you'll get a deep explanation of all the things you need for flawless scripting.

and btw, FindFastRandoms will usually solve them for you, and if it's an unsolvable it'll log out for you.

RMagician

FurshizzleItsYannick

2007-11-02 08:07:13

nice simple powerchopper easy to understand

awesom

2007-11-02 19:00:04

Good Work.

Drops everything in invent including axe though :S

I got frog princess random had to stop it luckily I was watching, solved a mysterious box though.