SRL Archive - First Scripts

Aser"s Power Woodcutter


Aser

2009-01-17 20:15:55

This is my first script. It cuts down regular trees. It uses FindObjCustom to find the trees. If this fails if uses FindColorSpiral. If that fails if is supposed to move to a new area on the minimap.

Still needs …
Ent finding
Axe Finding
Better antiban/randoms

Later versions…if I can get good feed back
more tree types
TPA's
Only drop logs
SRL stats


I would appreciate feedback and suggestions. I know my standards might not be perfect, but at least I tried…

///////////////////////////////////////////////////////
Version 1.1
Added ability to cut trees based on lvl. ex. finds current woodcutting lvl and if at lvl requirement will cut oaks (hopefully willows too)

Less clicking to accomplish task
/////////////////////////////////////////////////////

mormonman

2009-01-17 23:10:56

umm… you should definitely take the time to learn tpas, they are very powerful.
If you noticed on your proggy that you have at the end of the script that it used the backup 9 times… ya you should work on the main cut so that it doesn't have to have a backup.

Aser

2009-01-17 23:23:18

The backup is the same as the regular except will FindColorSpiral instead of FindObjCustom so that if for some random reason ObjCustom doesn't work it will do ColorSpiral.

I've done a few searches for TPA finding and can't find one. Would you post a link?

mormonman

2009-01-17 23:26:46

http://www.villavu.com/forum/showthread.php?t=40670?t=43601&highlight=tree+finder

http://www.villavu.com/forum/showthread.php?t=35504?t=38284&highlight=tpa+atpa

those are two very good ones!

Aser

2009-01-18 00:18:07

Those are beyond me for a little bit I think. I tried using

FindObjTPA(x,y,Colour[i],25,2,50,50,10,[TreeNames[0],TreeNames[1],TreeNames[2]])

but it seemed slower/less accurate than FindObjCustom;

I wasn't having any problems with tree finding before. The TPA thing is having lots of problems.

Any advice?

mormonman

2009-01-18 01:49:47

the amazing tree finder is really easy to use… you just need to add an

isuptext('treename');
to it…

Aser

2009-01-18 17:52:00

I don't want to use somebody else's code. I want to write my own.

trentuno30

2009-01-18 18:53:48

is this your first script?

if so good job! just need to add a few more things into it but good job so far :)

Aser

2009-01-18 23:59:31

From: trentuno30
is this your first script?


Um…yes?…That's why it's in first script section?

Sarcasm aside, thank you. Would you care to elaborate on what I need to add. I agree it is missing stuff; I just don't know what it is/where to start.

ian.

2009-01-19 00:37:21

:p

all your code is someone else's, don't worry about using someone's TPA stuff, your doing the same thing by using MMouse :)

TPA is just better (Use the tut on XYZ by Cazax), more accurate, and not much slower than CTS2 (I think that's the right one)

sooooo

try to learn XYZ if you can :D

(this looks alright for a first script btw)

noidea

2009-01-19 00:44:28

From: 99_
:p

all your code is someone else's, don't worry about using someone's TPA stuff, your doing the same thing by using MMouse :)

TPA is just better (Use the tut on XYZ by Cazax), more accurate, and not much slower than CTS2 (I think that's the right one)

sooooo

try to learn XYZ if you can :D

(this looks alright for a first script btw)


I wouldnt Use XYZ for Tree finding. IT will be too slow. Use HSL or RGB

Aser

2009-01-19 02:08:32

From: 99_

all your code is someone else's


?

I would rather learn how to do something myself than just copy someone else's code just so I can have a better code. It's not like my code would help anyone if it had it included. The person who make the code that I had to copy would be a much better scripter so people would use their scripts not mine.

If I include a tree finding function in my script it should be mine. Then I can at least say to myself that I've learned something.

ian.

2009-01-19 03:22:52

what I'm saying is when you use MMouse(0,0,700,700); your using someone else's code :o

it's all included in SRL..

so.. if someone made something called like.. TPA(color, tol, blah blah);

that's the same thing as you using MMouse :p

sorry, just had to be a jerk about it..

and XYZ wouldn't be slow.. well actually yes it would..

HSL :p

Kyle Undefined

2009-01-20 15:32:19

Good job on the script Aser. Looks pretty decent for a first script. As for your TPA tree finding, your colors and tree names should be a case. So that way your
FindObjTPA(x,y,Colour[i],25,2,50,50,10,[TreeNames[0],TreeNames[1],TreeNames[2]])
could look something like this:
FindObjTPA(x, y, Colour, 25, 2, 50, 50, 10, TreeNames)
As to setting up a case, you can use my script as an example (It's in my sig). Here is an example of something you could do:
procedure Colour;
begin
if not LoggedIn then
Exit;
case Random(3) of
0 : Color := blah;
1 : Color := blah;
end
end;

procedure TreeNames;
begin
if not LoggedIn then
Exit;
case Random(4) of
0 : Uptexts := 'ree';
1 : Uptexts := 'Tre';
2 : Uptexts := 'Tree';
end
end;

Those are just examples of something you could do to better up the script a bit. Only thing bad with those is that you have to declare global vars. If you add more trees you can combine those two cases into one.
procedure SetTreeVariables;
begin
if (not LoggedIn) then
Exit;
case lowercase(Players[CurrentPlayer].strings[0]) of
'normal' : begin
Color := 332817;
UpTexts := ['Tree', 'Tre', 'ree'];
end;
'oak' : begin
Color := 3307111;
UpTexts := ['Oak', 'Oa', 'ak'];
end;
'willow' : begin
Color := 2372909;
UpTexts := ['illow', 'Willo', 'Willow'];
end;
'maple' : begin
Color := 3693966;
UpTexts := ['aple', 'Maple', 'Mapl'];
end;
'yew' : begin
Color := 1455664;
UpTexts := ['Yew', 'ew', 'Ye'];
end;
'dead' : begin
Color := 1382943;
UpTexts :=['ead', 'ad tr', 'Dead', 'd Tre'];
end;
end
end;
That's what I did in mine. Feel free to pm me if you have any questions or add my IM's. Looks good tho, keep it up ;)

Edit: Oh, try to keep your standards the same. They vary between places. Just thought I would give you that tidbit.

~Camo

Aser

2009-01-20 20:20:22

Thanks Camo. The reason that I don't have the case is because I wanted it to just cut all of the trees that the char is able to. Ex lvl 26…cut up to oaks.

I like your idea and will try to get it into my script.

About the standards…. I know they aren't too great. I start editing stuff and I miss a couple spaces here and there. I'm working on it. As for the variations, those are probably from the time it took to write the script. I wrote part a few months ago and the rest recently.

Thanks for the feed back everyone.

Lvl6

2009-01-21 06:05:34

Good but work with TPAs. They are more effective and powerful.

I scrolled through your script and your standards are pretty good.

Good job 8/10

Kyle Undefined

2009-01-21 08:55:24

You're welcome Aser, later when I get back from class I will take a look at your new version.

~Camo

Aser

2009-01-21 21:19:22

From: Lvl6
Good but work with TPAs. They are more effective and powerful.

I scrolled through your script and your standards are pretty good.

Good job 8/10


What TPA's?

Input on how to get the 8 to a 10?

Kyle Undefined

2009-01-22 15:46:25

I looked at your new version. It's pretty good. I couldn't help but fix the standards. I didn't change the code at all, hope you don't mind. Here is the corrected standard one:
program AserPowerCutter;
{.include srl/srl.scar}
{.include srl/srl/skill/woodcutting.scar}

const
/////////////////////////////////////////////////////////////
// GENERAL SETUP //
TreeType = 'ree'; // Tree for now, might add other kinds later
UseMiniMapMove = True; //Will try to move to another tree if it
//can't find any near
WieldAxe = True; //Are you weilding the axe? False for no
LoadsToCut = 10; //False if extra axe in first inventory slot
//////////////////////////////////////////////////////////////
// COLOR SETUP //
TreeColor = 3700329; // Color of the Tree you want to cut
TreeColor2 = 2776404; //Another Color
TreeColor3 = 3766379; //Another Color
MiniMapTree = 78895; //Color of the tree on the mini map

var
Colour: array [0..2] of integer;
TreeNames: array [0..2] of string;
LoadCounter, EntsFound, BackupUsed : Integer;

//////////////////////////////////////////////////////////////
// PLAYER SETUP //
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :=''; //account name
Players[0].Pass :=''; //account password
Players[0].Nick :=''; //3-4 Letters of name
Players[0].Active:=True; // Active true or false.

{Players[1].Name :=''; //account name
Players[1].Pass :=''; //account password
Players[1].Nick :=''; //3-4 Letters of name
Players[1].Active:=False; // Active true or false.
}
end;
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////................ END OF SETUP............////////////////////////
//////////////////////////////////////////////////////////////////////

procedure AntiBan;
begin
if not LoggedIn then
Exit;
case (Random(100)) of
0 : RandomRClick;
5 : HoverSkill('Woodcutting', False);
10 : BoredHuman;
15 : RandomMovement;
20 : GameTab(Random(15));
///////ADD MORE///////////
end;
end;

procedure AntiRandoms;
{var
x, y : Integer; }
begin
if not LoggedIn then
Exit;
FindNormalRandoms;
if FindFight then
RunAway('N', True, 1, 5000);
{if FindEnt(x, y, True) then
Inc(EntsFound); }
end;

procedure Login;
begin
if not LoggedIn then
begin
LoginPlayer;
Wait(1000+random(1000));
MakeCompass('N');
Wait(500+random(1000));
FindAxe;
end;

{if not EquipAxe then
begin
WriteLn('No axe was found switching players and setting this one as inactive');
NextPlayer(False);;
end;}
end;

procedure LevelCheck;
var
WCLvL, WcLvlMod : Integer;
begin
WcLvl:=GetSkillInfo('Woodcutting', False);
Wait(1000 + Random(2000));
case WcLvl of
0..14 : WcLvlMod:= 1;
15..29 : WcLvlMod:=2;
30..59 : WcLvlMod:=3;
end;
case WcLvlMod of
1 : begin
TreeNames[0]:= 'ree';
TreeNames[1]:= '';
TreeNames[2]:= '';
end;
2 : begin
TreeNames[0]:= 'ree';
TreeNames[1]:= 'ak';
TreeNames[2]:= '';
end;
3 : begin
TreeNames[0]:= 'ree';
TreeNames[1]:= 'ak';
TreeNames[2]:= 'illo';
end;
end;
end;

procedure MiniMapMove;
var
x, y : Integer;
begin
if not LoggedIn or InvFull then
Exit;
if (UseMiniMapMove = True) then
begin
if (FindColorSpiral(x, y, MiniMapTree, MMX1, MMY1, MMX2, MMY2)) then
begin
AntiRandoms;
AntiBan;
Wait(100 + Random(100));
Mouse(x, y, 3, 3, True);
Flag;
end;
end;
end;

procedure BackupCutter;
var
i, x ,y, BackupFail, Waits : Integer;
BackupFind : Boolean;
begin
if not LoggedIn or InvFull then
Exit;
for i:=0 to 2 do
if FindColorSpiral(x, y, Colour[i], MSX1, MSY1, MSX2, MSY2) then
begin
AntiRandoms;
AntiBan;
Wait(200 + Random(250));
Mouse(x, y, 3, 3, True);
repeat
Wait(random(500));
Inc(Waits);
until (not(IsUpText(TreeNames[0]) or IsUpText(TreeNames[1]) or IsUpText(TreeNames[2]))) or InvFull or (Waits > 20);
BackupFind:= True;
Exit;
end;
if not (BackupFind = True) then
Inc(BackupFail);
if (BackupFail > 2) then
begin
WriteLn('BackupFind failed moving if preferences allow');
MiniMapMove;
end;
end;

procedure FindAndCutTree;
var
i, x, y, MissFind, Waits : Integer;
Find : Boolean;
begin
if not LoggedIn or InvFull then
Exit;
Login;
Colour[0]:= TreeColor;
Colour[1]:= TreeColor2;
Colour[2]:= TreeColor3;
for i:=0 to 2 do
begin
if FindObjCustom(x, y, [TreeNames[0], TreeNames[1], TreeNames[2]], [Colour[i]], 5) then
begin
Wait(100 + Random(100));
if IsUpText('hop') then
Mouse(x, y, 2, 2, True);
Flag;
AntiBan;
AntiRandoms;
repeat
Wait(Random(500));
Inc(Waits);
until (not(IsUpText(TreeNames[0]) or IsUpText(TreeNames[1]) or IsUpText(TreeNames[2]))) or InvFull or (Waits > 20);
Find:= True;
end;
if not Find then
begin
Inc(MissFind);
WriteLn('Missed FindObjCustom Find ' + IntToStr(MissFind) + ' times.');
end;
if (MissFind > 2) then
begin
BackupCutter;
Inc(BackupUsed);
end;
end;
end;

procedure Drops;
var
i : Integer;
begin
if not LoggedIn then
Exit;
if InvFull then
begin
case WieldAxe of
False : begin
for i:=2 to 28 do
DropItem(i);
AntiRandoms;
end;
True : DropAll;
end;
Inc(LoadCounter);
if (LoadCounter + 1 > LoadsToCut) then
NextPlayer(True);
end;
end;

procedure ProgressReport;
begin
Wait(1000 + Random(250));
ClearDebug;
WriteLn('--------------------------');
WriteLn(' Aser"s Woodcutter ');
WriteLn(IntToStr(LoadCounter) + ' loads were dropped.');
WriteLn(IntToStr(EntsFound) + ' Ents were encountered.');
WriteLn('Backup was used ' + IntToStr(BackupUsed) + ' time(s).');
WriteLn('---------------------------');
end;

begin
SetupSRL;
SetupWoodcutting;
DeclarePlayers;
LevelCheck;
repeat
Login;
FindAndCutTree;
Wait(1000 + Random(250));
Drops;
ProgressReport;
until (Players[0].Active = False);
end.


{Progs

--------------------------
Aser"s Woodcutter
3 loads were dropped.
0 Ents were encountered.
Backup was used 9 time(s).
---------------------------
Successfully executed }

One thing that I noticed is in your mainloop, the repeat until isn't correct. If you want it to repeat until all players are inactive use (AllPlayersInactive); What you have there is a repeat until your first player isn't active, and it will stop even if you have more players. Your code can be shortened but it looks good tho. Keep it up ;)

~Camo

Aser

2009-01-23 19:09:05

From: Camo¤Kyle


One thing that I noticed is in your mainloop, the repeat until isn't correct. If you want it to repeat until all players are inactive use (AllPlayersInactive); What you have there is a repeat until your first player isn't active, and it will stop even if you have more players. Your code can be shortened but it looks good tho. Keep it up ;)

~Camo


Thanks for reminding me about that. That was when I was testing the script with just one player. Thanks for the standards fix and the correct way to end it.