Log in

View Full Version : What should I add/improve before applying for members?



Coh3n
06-18-2009, 12:59 AM
Already applied for membership. :) Thanks everyone for the help!

Hey guys,

Just wondering what you think I should add/improve on this script before I apply for members. I would also like to hear what you think the chances of me getting into members is. OR maybe whether you would vote yes/no and why. Thanks. :)

Don't be afraid to criticize, just don't be TOO mean. :p


Draynor Chop N' Bank | By Coh3n

Some Features:

Cuts/banks Willows in Draynor.
AntiBan.
AntiRandoms.
Multiplayer.
Progress Report.
TPA/ATPA
DTMs.


Setup:

Have axe wielded.
Start anywhere in Draynor Bank.


program DraynorChopNBank;
{.Include SRL\SRL\Misc\SMART.SCAR}
{.include SRL\SRL.scar}
//{.include SRL\SRL\Misc\Debug.scar}

var
HatchetDTM : Array of Integer;
NumOfLogs, TotalProggies : Integer;
XpGain : TExtendedArray;
TP : TPoint;

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

Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'Nickname';
Players[0].Active := True;//Use this player?
Players[0].Pin := '';//Bank pin. Leave blank if you don't have one.
Players[0].Integers[0] := 000;//How many logs to cut?
Players[0].Booleans[0] := True;//Is hatchet equiped?
Players[0].BoxRewards := ['Xp', 'mote', 'ostume'];

{Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
Players[0].Pin := '';
Players[0].Integers[0] := 000;
Players[0].Booleans[0] := True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume'];}
end;

procedure S_TurnRunOn;
var
s : String;
begin
if GetMMLevels('energy', s) > 60 then
begin
SetRun(True);
Exit;
end;
end;

procedure S_FindRandoms;
begin
if FindFight then
RunAway('N', True, 1, 5000);
LampSkill := 'woodcutting';
FindNormalRandoms;
end;

function S_LevelUp: Boolean;
var
x, y : Integer;
begin
if FindNPCChatText('ongrat', Nothing)then
begin
ClickContinue(True, True);
Wait(80 + Random(100));
GetSkillLevel('woodcutting');
Mouse(x, y, 4, 4, True);
Wait(80 + Random(100));
CloseWindow;
Writeln('Congratulations, you have gained a Woodcutting level!');
Result := True;
end;
end;

procedure S_MyAntiBan;
begin
case Random(70) of
0: RandomMovement;
1: BoredHuman;
2: HoverSkill('random', false);
3: RandomRClick;
4: begin
case Random(2) of
0: begin
KeyDown(VK_RIGHT);
Wait(50 + Random(1300));
KeyUp(VK_RIGHT);
Wait(60 + Random(2000));
KeyDown(VK_LEFT);
Wait(70 + Random(1100));
KeyUp(VK_LEFT);
end;
1: begin
KeyDown(VK_LEFT);
Wait(50 + Random(1300));
KeyUp(VK_LEFT);
Wait(60 + Random(2000));
KeyDown(VK_RIGHT);
Wait(70 + Random(1100));
KeyUp(VK_RIGHT);
end;
end;
end;
5: begin
KeyDown(VK_LEFT);
Wait(100 + Random(1200));
KeyUp(VK_LEFT);
end;
6: begin
KeyDown(VK_RIGHT);
Wait(150 + Random(1100));
KeyUp(VK_RIGHT);
end;
end;
end;

procedure S_HatchetDTMs;
begin
SetArrayLength(HatchetDTM, 7);//[0]:= Bronze, [6]:= Rune
HatchetDTM[0] := DTMFromString('78DA630C646260D8C4C8800C7CAC9519F88 13' +
'44C94D113A86617AA1A982C5C8D1B50CD36026ABC816AD612 5013' +
'0C54B38E809A504C3763A80921EC1E00949107EF');
HatchetDTM[1] := DTMFromString('78DA630C626260D8C4C8800C02BDBD19F88 13' +
'448F43F1030BA03D5EC47550391859140DA0DA8662B01355E 4035' +
'6B09A80906AA5947404D2850CD06026A42806AB6E15703003 3F30' +
'C28');
HatchetDTM[2] := DTMFromString('78DA630C626260D8C8C8800CCAF3F318F88 13' +
'448F43F10307A02D5EC40550391859140DA0DA8660B01355E 4035' +
'6B09A80904AA5947404D28A69BB1AAD98A5F0D0090050C8D' );
HatchetDTM[3] := DTMFromString('78DA63F4676260D8C0C8800C44454418F88 13' +
'448F43F1030BA03D5EC43550391859140DA05A8661701351E 4035' +
'EB09A80900AA5947404D28A69BB1AAD98A5F0D0095870B78' );
HatchetDTM[4] := DTMFromString('78DA630C646260D8C8C8800C1C1CE319F88 13' +
'44C94D10DA8E600AA1A982C5C8D2B50CD0E026A3C806A3610 5013' +
'0054B38E809A504C3763A80901AAD9865F0D00C5940824');
HatchetDTM[5] := DTMFromString('78DA63EC64626038C0C8800C9C829D18F88 13' +
'44C94B101A8E614AA1A982C8A9A7D04D4F402D5EC2742CD21 026A' +
'6A816AAEE05703006FA208C7');
HatchetDTM[6] := DTMFromString('78DA638C676060E8614001AE31690CFC409 A1' +
'188FF0301633090B180010D302291403A1048CC22A0260448 F413' +
'501309243A08A84902129D04D42403895EFC6A00F1EB0B8F' );
end;

procedure W_WalkToWillows;
var
x, y : Integer;
begin
if not LoggedIn then Exit;
S_TurnRunOn;
if RadialWalk(FindWaterColor, 180, 220, 60, -2, 1)then
begin
Wait(80 + Random(100));
Writeln('Walking to Willows.');
FFlag(2);
end else
begin
if FindSymbol(x, y, 'fish')then
begin
Wait(80 + Random(100));
Writeln('Walking to Willows.');
Mouse(x, y - 20 - Random(15), 4, 4, True);
FFlag(2);
end else
begin
Writeln('Couldn''t walk to Willows.');
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;
end;

function W_BankFloorColor: Integer;
var
BankFloor, x, y : Integer;
begin
BankFloor := DTMFromString('78DA63AC606260D066400179E969609A11C A6' +
'7AC05AA514555F3E70F13A61A3D22D418E1570300B1E409D9 ');
if DTMRotated(BankFloor, x, y, MMX1, MMY1, MMX2, MMY2)then
begin
Result := GetColor(x + 15, y);
Writeln('Bank floor color = ' + IntToStr(Result));
end else
Writeln('Didn''t find bank color.');
end;

procedure W_WalkToBank;
var
x, y : Integer;
begin
if not LoggedIn then Exit;
S_TurnRunOn;
MakeCompass('n');
if RadialWalk(W_BankFloorColor, 0, 77, 68, -2, 1)then
begin
Wait(80 + Random(100));
Writeln('Inventory full, walking to bank.');
FFlag(2);
end else
begin
if FindSymbol(x, y, 'bank')then
begin
Wait(80 + Random(100));
Mouse(x, y, 4, 4, True);
Writeln('Inventory full, walking to bank.');
FFlag(2);
end else
begin
Writeln('Couldn''t walk to bank.');
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;
end;

procedure Cut_FindHatchet;
var
b : Boolean;
i, x, y : Integer;
begin
if Players[CurrentPlayer].Booleans[0] = True then
GameTab(5)
else
GameTab(4);
for i:= 0 to 6 do
begin
b := FindDTM(HatchetDTM[i], x, y, MIX1, MIY1, MIX2, MIY2);
FreeDTM(HatchetDTM[i]);
if b then Break;
end;
if b then Writeln('Found hatchet.')else
begin
Writeln('Didn''t find hatchet, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;

procedure Cut_WhileChopping;
var
ClickTree, NCTime, LastCount : Integer;
begin
MarkTime(ClickTree);
NCTime := 15000 + Random(10000);
LastCount := InvCount;
while(InvCount < 28)and LoggedIn do
begin
if TimeFromMark(ClickTree) > NCTime then
if InvCount = LastCount then Break;
S_MyAntiBan;
Wait(80 + Random(5000));
if S_LevelUp then Continue;
S_FindRandoms;
end;
end;

function Cut_TreeCutDown: Boolean;
var
TrCols : TPointArray;
begin
FindColorsTolerance(TrCols, 5667697, TP.x - 20, TP.y - 20, TP.x + 20, TP.y + 20, 18);
if(Length(TrCols) < 10)then
begin
//Writeln('Tree has been cut down.');
Result := True;
end;
end;

procedure Cut_ChopTrees;
var
fx, fy, k, x, y : Integer;
s : String;
TPA : TPointArray;
T2D : T2DPointArray;
begin
if not LoggedIn then Exit;
ColorToleranceSpeed(2);
repeat
FindColorsSpiralTolerance(fx, fy, TPA, 5667697, MSX1, MSY1, MSX2, MSY2, 18);
T2D := SplitTPAEx(TPA, 5, 5);
//DebugATPA(T2D, '');
if Length(T2D) = 0 then Exit;
SortATPAFromFirstPoint(T2D, Point(MSCX, MSCY));

for k := 0 to High(T2D) do
begin
//Writeln('Length:' + IntToStr(Length(T2D[k])));
if(Length(T2D[k]) < 50)then Continue;
MiddleTPAEx(T2D[k], fx, fy);
Wait(30 + Random(20));
MMouse(fx, fy, 4, 4);
s := RS_GetUpText;
if((Pos('hop', s) > 0) and (Pos('illow', s) > 0))then
begin
GetMousePos(x, y);
Wait(80 + Random(100));
Mouse(x, y, 4, 4, True);
TP := IntToPoint(x, y);
repeat
Cut_WhileChopping;
until(Cut_TreeCutDown or InvFull);
end;
end;
until(InvFull or not LoggedIn);
ColorToleranceSpeed(1);
end;

procedure B_BankItems;
var
DepositAllTab : Integer;
begin
if OpenBank('db', True, True)then
begin
if Players[CurrentPlayer].Booleans[0] = True then
begin
DepositAll;
CloseBank;
NumOfLogs := NumOfLogs + 28;
end else
begin
Deposit(2, 28, True);
CloseBank;
NumOfLogs := NumOfLogs + 27;
end;

if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
begin
Writeln('Cut desired number of logs, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end else
begin
Wait(80 + Random(100));
Writeln('Couldn''t find bank booth, logging out.');
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;

{************************************************* ******************************
function Prg_PlayerActivity(i: integer): string;
By: Drags111
Description: Determines whether the player is active or not.
************************************************** *****************************}

function F_PlayerActive(i : Integer): String;
begin
if Players[i].Active then Result := 'T' else Result := 'F';
end;

procedure F_ProgReport;
var
i : Integer;
begin
Players[i].Integers[9] := NumOfLogs / 28;
Players[i].Integers[10] := NumOfLogs;
Inc(TotalProggies);
Writeln(' _______________________________________________');
Writeln(PadR('| Coh3n''s Power Chopper', 48) + '|');
Writeln('|_________________First Script__________________|');
Writeln('| |');
Writeln(PadR('| Time run: ' + TimeRunning, 48) + '|');
Writeln(PadR('| Loads: ' + IntToStr(NumOfLogs / 28), 48) + '|');
Writeln(PadR('| Logs: ' + IntToStr(NumOfLogs), 48) + '|');
Writeln(PadR('| Exp Gained: ' + FloatToStr(NumOfLogs * 67.5), 48) + '|');
Writeln('|________________________________________ _______|');
Writeln('|________________Player''s Stats_________________|');
Writeln('| Nick T/F Loads Logs |');
Writeln('| ¯¯¯¯ ¯¯¯ ¯¯¯¯¯ ¯¯¯¯ |');
for i := 0 to High(Players)do
Writeln('| ' + PadR(Players[i].Nick, 10) + PadR(F_PlayerActive(i), 9)
+ PadR(IntToStr(Players[i].Integers[9]), 11)
+ PadR(IntToStr(Players[i].Integers[10]), 11) + '|');
Writeln('|________________________________________ _______|');
end;

procedure F_Setup;
begin
ClearDebug;
SMARTSetupEx(152, False, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
SetAngle(True);
S_HatchetDTMs;
end;

begin
F_Setup;
repeat
repeat
Cut_FindHatchet;
begin
W_WalkToWillows;
Cut_ChopTrees;
W_WalkToBank;
B_BankItems;
F_ProgReport;
end;
until(NumOfLogs >= Players[CurrentPlayer].Integers[0])or(not LoggedIn);
NextPlayer(LoggedIn);
until AllPlayersInactive;
end.

Thanks! :D

JPHamlett
06-18-2009, 01:09 AM
this

procedure B_BankItems;
var
DepositAllTab : Integer;
begin
DepositAllTab := DTMFromString('78DA633CC0C8C0A0C4C4800C9A7DE518F88 13' +
'42394CF7810C8124155C3C6C6029183A939016449A1AAE1E5 E146' +
'557314C85221A06627A61A0CBBB6035912F8D50000849406C 2');
if OpenBank('db', True, True)then
begin
if FindDTM(DepositAllTab, x, y, MSX1, MSY1, MSX2, MSY2)then
Mouse(x, y, 4, 4, True)
else
DepositAll;
NumOfLogs := NumOfLogs + 28
if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
begin
Writeln('Cut desired number of logs, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;
end;


can be


procedure B_BankItems;
var
begin
if OpenBank('db', True, True) then
begin
DepositAll;
NumOfLogs := NumOfLogs + 28
if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
begin
Writeln('Cut desired number of logs, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end;
end;


deposit all is already in SRL but i assume you knew that seeing how u put deposit all in the loop

also in your mainlopp you should cange the


until (false)

to


until (allplayersinactive)

it very good from what i can see


EDIT : and how you credit the person who made you proggy isnt right its nothing big but hey it looks nicer

theres a good tut you should look at ill go get it for you

http://www.villavu.com/forum/showthread.php?t=40470

Coh3n
06-18-2009, 01:13 AM
deposit all is already in SRL but i assume you knew that seeing how u put deposit all in the loop

Yeah I wrote the first part before I figured out that there was already a DepositAll function. XD So I just left it in there. Does it really hurt it if I left it in there? Or is it just completely useless?


it very good from what i can see

Thanks. :D



EDIT : and how you credit the person who made you proggy isnt right its nothing big but hey it looks nicer

theres a good tut you should look at ill go get it for you

Thanks, I'll change that right away, and he didn't make the progress report, it's just the Prg_PlayerActivity; procedure.

The progress report was done 100% by me. :)

Script Updated!

senrath
06-18-2009, 01:40 AM
Yeah I wrote the first part before I figured out that there was already a DepositAll function. XD So I just left it in there. Does it really hurt it if I left it in there? Or is it just completely useless?


You should remove it. Redundant, useless, or outdated code looks bad on an application. Leaving something like that in kinda gives off the feeling that you just didn't care.

Coh3n
06-18-2009, 01:41 AM
You should remove it. Redundant, useless, or outdated code looks bad on an application. Leaving something like that in kinda gives off the feeling that you just didn't care.

Okay thanks very much! :)

Script Updated!

Naike
06-18-2009, 02:14 AM
Just noticed this real quick,

In Cut_FindHatchet you don't free all the DTMs.

Solution,

procedure Cut_FindHatchet;
var
b: Boolean;
i: Integer;
begin
GameTab(5);
for i:= 0 to 6 do
begin
B := (FindDTM(HatchetDTM[i], x, y, MIX1, MIY1, MIX2, MIY2))then
FreeDTM(HatchetDTM[i]);
If B then Break;
end;

if B then Writeln('Found hatchet.') else
begin
Writeln('Didn''t find hatchet, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
end;
end;

Coh3n
06-18-2009, 02:21 AM
Just noticed this real quick,

In Cut_FindHatchet you don't free all the DTMs.

Thanks, but I did, didn't I? Or does the way I did it not work?

procedure Cut_FindHatchet;
var
b: Boolean;
i: Integer;
begin
GameTab(5);
for i:= 0 to 6 do
if(FindDTM(HatchetDTM[i], x, y, MIX1, MIY1, MIX2, MIY2))then
begin
b:= True;
Break;
end;
if(b = True)then
Writeln('Found hatchet.')
else
begin
Writeln('Didn''t find hatchet, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
FreeDTM(HatchetDTM[i]);//Here?
end;

I also see how you shortened it, and thanks for that. :)

Scrip Updated!

Naike
06-18-2009, 02:46 AM
Your For To Do loop stops before you reach the last line.


procedure Cut_FindHatchet;
var
b: Boolean;
i: Integer;
begin
GameTab(5);
for i:= 0 to 6 do
if(FindDTM(HatchetDTM[i], x, y, MIX1, MIY1, MIX2, MIY2))then
begin
b:= True;
Break;
end; // Your loop stops here, The For to do one.
if(b = True)then
Writeln('Found hatchet.')
else
begin
Writeln('Didn''t find hatchet, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
FreeDTM(HatchetDTM[i]);// Meaning, that this will only free the I valued one,
// not all of them.
end;

HyperSecret
06-18-2009, 02:58 AM
No offense but this is what the SRL Member Application process is all about. So we can judge your script, tell you what is and isn't correct and what can be done better. Just apply with it and see what we say ;).

Coh3n
06-18-2009, 03:29 AM
Your For To Do loop stops before you reach the last line.

Okay, thanks for the explanation. :)


No offense but this is what the SRL Member Application process is all about. So we can judge your script, tell you what is and isn't correct and what can be done better. Just apply with it and see what we say ;).

None taken. :) I posted this because someone asked this question the other day and a lot of people said it would be better to get people's input before I actually applied. So I'll do this for a little longer, and see how it goes.

noidea
06-18-2009, 03:30 AM
I would say yes. You look like an ambisious scriper :) You'll go far.
Get rid of the unautocoloured radial walks. They will NEVER work. (ToBank proc)
Some people say that Global Variables, such as x, y, are bad. You might want to look into localizing them :)

Very good :)

Coh3n
06-18-2009, 03:35 AM
I would say yes. You look like an ambisious scriper :) You'll go far. Wow thanks! That means a lot. :)
Get rid of the unautocoloured radial walks. They will NEVER work. (ToBank proc)Hmm didn't know that, thanks. :)
Some people say that Global Variables, such as x, y, are bad. You might want to look into localizing them :)I'll look into it, thanks. :)

Very good :)

I also don't want just the FindSymbol as the walking to the bank, as the symbol moves a lot. Nava2 said something to me a while back about making an AutoColor or something like that, so I'm going to look into that.

Thanks. :D

EDIT: I got rid of the Non-auto colored RadialWalks and added my own AutoColor function to find the color of the bank floor. I've only tested it a couple times, but it seems to work pretty well.

Updated script!

ZephyrsFury
06-18-2009, 12:03 PM
Hey there,

Just a few minor things that you could take with you if you continue scripting:

Why this?:

const
RunOn = True;//Set False to turn run off.

It would be better to have your script set the run automatically for example if energy is greater than a certain value.


function S_LevelUp: Boolean;
begin
if ClickContinue(True, True)then
begin
Writeln('Congratulations, you have gained a Woodcutting level!');
Result := True;
end;
end;


Perhaps make it check your woodcutting level after the ClickContinue() to double check you've actually leveled up. Its more or less just to prevent any errors in progress reports and stats.


case Random(2) of
0: begin
KeyDown(VK_RIGHT);
Wait(50 + Random(1300));
KeyUp(VK_RIGHT);
Wait(60 + Random(2000));
KeyDown(VK_LEFT);
Wait(70 + Random(1100));
KeyUp(VK_LEFT);
end;
1: begin
KeyDown(VK_LEFT);
Wait(50 + Random(1300));
KeyUp(VK_LEFT);
Wait(60 + Random(2000));
KeyDown(VK_RIGHT);
Wait(70 + Random(1100));
KeyUp(VK_RIGHT);
end;
end;
end;
5: begin
KeyDown(VK_LEFT);
Wait(100 + Random(1200));
KeyUp(VK_LEFT);
end;
6: begin
KeyDown(VK_RIGHT);
Wait(150 + Random(1100));
KeyUp(VK_RIGHT);
end;
7..69:
end;


7..69: isn't really needed. Makes no difference with how the script runs so its a minor thing but if none of the cases match then SCAR won't do anything. You could use an else statement as well:


case SomeVar of
0: Writeln('0');
1: Writeln('1');
else
Writeln('Something else');
end;


With this:


function W_BankFloorColor: Integer;
var
BankFloor, x, y : Integer;
begin
BankFloor := DTMFromString('78DA63AC606260D066400179E969609A11C A6' +
'7AC05AA514555F3E70F13A61A3D22D418E1570300B1E409D9 ');
begin
if FindDTM(BankFloor, x, y, MMX1, MMY1, MMX2, MMY2)then
begin
GetColor(x + 15, y); //This is unnecessary
Writeln('Bank floor color = ' + IntToStr(GetColor(x + 15, y)));
end else
Writeln('Didn''t find bank color.');
Result := GetColor(x + 15, y); //So is this pretty much.
end;
end;


The first GetColor() does nothing because you aren't assigning its result to any variable. It just slows your script down. This is what you should do:


function W_BankFloorColor: Integer;
var
BankFloor, x, y : Integer;
begin
BankFloor := DTMFromString('78DA63AC606260D066400179E969609A11C A6' +
'7AC05AA514555F3E70F13A61A3D22D418E1570300B1E409D9 ');
if FindDTM(BankFloor, x, y, MMX1, MMY1, MMX2, MMY2)then
begin
Result := GetColor(x + 15, y);
Writeln('Bank floor color = ' + IntToStr(Result));
end else
Writeln('Didn''t find bank color.');
end;


One GetColor as opposed to three - when dealing with more complicated functions or other functions apart from GetColor() that will speed it up significantly.

Perhaps more importantly though.. you're using FindDTM for the minimap. The minimap shifts slightly all the time in order to make it harder for bots so chances are your points won't be exactly north. This means most of the time FindDTM won't find the DTM. You should use SCAR's FindDTMRotated or SRL's DTMRotated. I suggest the latter which is simpler to use.

Your chopping function:

for k := 0 to High(T2D) do
begin
//Writeln('Length:' + IntToStr(Length(T2D[k])));
if(Length(T2D[k]) < 50)then Continue;
MiddleTPAEx(T2D[k], fx, fy);
Wait(30 + Random(20));
MMouse(fx, fy, 4, 4);
s := RS_GetUpText;
if((Pos('hop', s) > 0) and (Pos('illow', s) > 0))then
begin
GetMousePos(x, y);
Wait(80 + Random(100));
Mouse(x, y, 4, 4, True);
TP := IntToPoint(x, y);
repeat
S_MyAntiBan;
Wait(80 + Random(5000));
if S_LevelUp then Continue;
S_FindRandoms;
until(Cut_TreeCutDown or InvFull);
end;
end;


I'm not sure how well it works in practice but as far as I can tell, the script will attempt to find a tree by looping through your ATPA. If it finds a tree it will cut and wait till it disappears. Then it will continue looping through the rest of your loop. Chances are however that in the time since detecting the first tree and the tree getting chopped down, the other trees might have moved or disappeared. IMO it would be better to have it search for trees again after chopping.

Your banking:

if OpenBank('db', True, True)then
begin
DepositAll;
NumOfLogs := NumOfLogs + 28
if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
begin
Writeln('Cut desired number of logs, logging out.');
Wait(80 + Random(100));
Logout;
Players[CurrentPlayer].Active := False;
Exit;
end;
end else


If your axe happens to be in your inventory. DepositAll will deposit it then your script will get stuck. Perhaps during the player setup check where the axe is (equipped or in the inv) and deposit according. Or just make it deposit everything except the axe.

Finally your mainloop:

begin
F_Setup;
repeat
repeat
Cut_FindHatchet;
begin
W_WalkToWillows;
Cut_ChopTrees;
W_WalkToBank;
B_BankItems;
Prg_ProgReport;
end;
until(NumOfLogs >= Players[CurrentPlayer].Integers[0])or(not LoggedIn);
NextPlayer(False);
until False;
end.


Why do you have the players set to False once they're finished? Wouldn't you want the script to switch players but leave your current player active so you can come back to it later? You should change: NextPlayer(False) to NextPlayer(LoggedIn). That way if your players are logged out before NextPlayer() (ie. your script got lost and you logged them out) your player will be set to false else your player remains True.

Coh3n
06-18-2009, 10:55 PM
@ Zeph

Wow great post, I'll work on the script right now. Thanks! :)

Rep+

EDIT:

Okay, I think I've managed to improve almost everything you've said, I have a few comments.


I'm not sure how well it works in practice but as far as I can tell, the script will attempt to find a tree by looping through your ATPA. If it finds a tree it will cut and wait till it disappears. Then it will continue looping through the rest of your loop. Chances are however that in the time since detecting the first tree and the tree getting chopped down, the other trees might have moved or disappeared. IMO it would be better to have it search for trees again after chopping.

I know what you mean ... I think. Except when I Debug the ATPA using Nava2's tool, the Debug image refreshes everytime a tree gets cut down. Wouldn't that mean it searches again once the tree is cut down?


If your axe happens to be in your inventory. DepositAll will deposit it then your script will get stuck. Perhaps during the player setup check where the axe is (equipped or in the inv) and deposit according. Or just make it deposit everything except the axe.

I know, I originally had it so the axe had to be in your inventory, thus I had the above problem. Now, since I changed it so you have to have it equipped, this way it doesn't equip the axe. IMO, if you're autoing correctly, you should be able to equip the axe your using. It would be nice to have to option so I do know what you mean. I'll look into it. :)

EDIT2: I made it work so that you can have the hatchet either in your inventory or wielded, and it will now bank accordingly.



Why do you have the players set to False once they're finished? Wouldn't you want the script to switch players but leave your current player active so you can come back to it later? You should change: NextPlayer(False) to NextPlayer(LoggedIn). That way if your players are logged out before NextPlayer() (ie. your script got lost and you logged them out) your player will be set to false else your player remains True.

I remember reading exactly that when I was writing the script, so I'm not sure why I had it NextPlayer(False);. Maybe I just wasn't thinking that day. :p

Anyway thanks a lot for your input, it helped a lot. :)

Script updated!

ZephyrsFury
06-19-2009, 12:43 AM
I know what you mean ... I think. Except when I Debug the ATPA using Nava2's tool, the Debug image refreshes everytime a tree gets cut down. Wouldn't that mean it searches again once the tree is cut down?

Hmm I'm not sure about that but from inspection:


for k := 0 to High(T2D) do
begin
//Writeln('Length:' + IntToStr(Length(T2D[k])));
if(Length(T2D[k]) < 50)then Continue;
MiddleTPAEx(T2D[k], fx, fy);
Wait(30 + Random(20));
MMouse(fx, fy, 4, 4);
s := RS_GetUpText;
if((Pos('hop', s) > 0) and (Pos('illow', s) > 0))then
begin
GetMousePos(x, y);
Wait(80 + Random(100));
Mouse(x, y, 4, 4, True);
TP := IntToPoint(x, y);
repeat
S_MyAntiBan;
Wait(80 + Random(5000));
if S_LevelUp then Continue;
S_FindRandoms;
until(Cut_TreeCutDown or InvFull); //Breaks out of this loop when tree is cut.
end;
end; //But still in this loop


When the tree is cut down you break out of the repeat loop. However you're still stuck in the for to do loop. So theoretically it would just go straight to the next tree without searching again. Thats just from looking at the code though, I haven't actually tested it yet.

Also perhaps also have a little failsafe that breaks out of the repeat loop if you haven't chopped any logs in a certain amount of time. Sometimes the character is disrupted and just stands still and doesn't chop anything. If you were by yourself the script would just wait until the tree is cut or InvFull both of which won't happen cos you aren't cutting.

It might also be easier to split that function above into separate FindWillow and WaitWhilstChopping functions. Its a lot easier to separate them in my opinion anyway. It also makes your script appear longer which might help sway voters your way in the members app. ;)

Coh3n
06-19-2009, 12:54 AM
When the tree is cut down you break out of the repeat loop. However you're still stuck in the for to do loop. So theoretically it would just go straight to the next tree without searching again. Thats just from looking at the code though, I haven't actually tested it yet. I know what you mean, I'm not sure how to change that, but I'm sure I'll figure it out. ;) EDIT: I haven't figured this out, so if anyone has any suggestions, please tell me :)

Also perhaps also have a little failsafe that breaks out of the repeat loop if you haven't chopped any logs in a certain amount of time. Sometimes the character is disrupted and just stands still and doesn't chop anything. If you were by yourself the script would just wait until the tree is cut or InvFull both of which won't happen cos you aren't cutting. Thank you! I couldn't figure out why that was happening sometimes. A simple, but effective solution. :) Can't believe I didn't think of that. EDIT: I did this, not 100% sure if it works, from the couple tests I've done, it seems to be fine. Included in V.4.

It might also be easier to split that function above into separate FindWillow and WaitWhilstChopping functions. Its a lot easier to separate them in my opinion anyway. It also makes your script appear longer which might help sway voters your way in the members app. ;) Good idea, I'll do that. :) EDIT: Did this in V.4.

Thanks again Zeph! :D

ZephyrsFury
06-19-2009, 01:04 AM
Thanks again Zeph! :D

Hmm I'd thought you'd be at school.

Coh3n
06-19-2009, 01:04 AM
Hmm I'd thought you'd be at school.

Exams started today, and I have mono, so I'd be home regardless.

Script updated!

Nava2
06-19-2009, 04:53 AM
Exams started today, and I have mono, so I'd be home regardless.

Script updated!

CAREFUL ZEPH! HE WILL SHOVE HIS TONGUE DOWN YOUR THROAT!

Nice script, watch the freeing DTMs, I told you everything else via IRC. :)

Coh3n
06-19-2009, 04:55 AM
^^ No Nava, that's just for you. ;)

ian.
06-19-2009, 05:01 AM
His tongue is for me >.<

Wow. I don't know why I said that. >.> anywho.. everything has been said, as far as I can tell :p Good luck when you apply :D

Coh3n
06-19-2009, 05:03 AM
His tongue is for me >.<

Wow. I don't know why I said that. >.> anywho.. everything has been said, as far as I can tell :p Good luck when you apply :D

Thanks, I'm applying now. Compete with Nava for first post. He'll probably shoot me if he reads this but hey.. I'll survive.. somehow. :rolleyes: