Ed, if it's not asking for too much wait one more week for woodcutting. it'll only take me a day or two to do it (seeing that i already have a wcer), but my computer is messed up and i can't install scar and svn on my sis' computer :(
edit: i have decided to advance some work on that, using notepad.
//stuff i need for SmartColors and other things for WCing
type
Monster = record
Name: string;
UpText: TStringArray;
Colors: TIntegerArray;
AutoColor: boolean;
RG, RB, GB: integer;
end;
var
Find: Array of Monster;
AllTIA: Array[0..3] of TIntegerArray;
LoadsDone, TotalLoads, SpotMark:integer;
//i think we should get a global proggy, but i'll leave this here for now
procedure Proggy;
var i:integer;
begin
ClearReport;
SrlRandomsReport;
AddToReport('[ Total Loads: '+IntToStr(TotalLoads));
AddToReport('[ Total Logs: '+IntToStr(TotalLoads*27));
AddToReport('[ Time Running: '+TimeRunning);
AddToReport('');
AddToReport('Nick, Tree, Logs, Active');
for i:=0 to High(Players) do
AddToReport(Players[i].Nick+', '+Players[i].Strings[0]+', '+
IntToStr(Players[i].Integers[0])+', '+
BoolToStr(Players[i].Active));
end;
// By Frozen Soul
Function PosArray(SubStr : Array of String; S : String) : Boolean;
var i:integer;
Begin
for i := 0 to GetArrayLength(SubStr) - 1 do
Begin
Result := Pos(SubStr[i], Lowercase(S)) > 0;
if Result then exit;
end;
end;
//to move the mouse if it hasn't moved for too long
procedure InactiveMove;
var x, y, i, h:integer;
begin
GetMousePos(x, y);
IncEx(MouseSpeed, 10);
i := GetCurrentTab;
repeat
h := 1+Random(12);
until(h <> i)
GameTab(h);
wait(1000+Random(500));
GameTab(i);
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 10);
end;
//checks if it's over the right tree and if it isn't an ent
Function CheckAndClick(var x, y:integer; text:TStringArray): boolean;
var
m:integer;
FoundIt:boolean;
begin
if not LoggedIn then exit;
wait(100);
MMouse(x, y, 3, 3);
wait(100);
for m:=0 to high(text) do
begin
if IsUpText(text[m]) then
begin
if MVPDebug then writeln('text is up, '+text[m]);
FoundIt:=True;
break;
end;
end;
if FoundIt then
begin
GetMousePos(x, y);
if FindEnt(x, y, False) then
begin
Result := False;
Inc(EntsAvoided);
wait(1000);
if MVPDebug then writeln('exiting');
exit;
if MVPDebug then writeln('exited');
end;
if MVPDebug then writeln('moving mouse to tree');
Mouse(x, y, 3, 3, True);
Result := True;
end else
Result := False;
end;
//Smart Colors By Tarajunky, Custom by Rasta Magician
Function SmartColorsCustom(name:string; UpText:TStringArray; colors:TIntegerArray):boolean;
var
j, k:integer;
b, Found:boolean;
var RMInt, RMx, RMy:integer;
var x,y,TestColor,a,l,m,i,red,green,blue, ClickColor:integer;
var p: array of Tpoint;
begin
if not LoggedIn then exit;
for i:=0 to High(Find) do
begin
if lowercase(name) = Find[i].Name then
begin
b := True;
k := i;
end;
end;
if not b then //we have to add it.
begin
k:=GetArrayLength(Find);
SetArrayLength(Find, k+1);
Find[k].Name:= lowercase(name);
Find[k].UpText := UpText;
Find[k].Colors := colors;
end;
{autocoloring}
if not Find[k].AutoColor then
begin
for i:=0 to High(Find[k].Colors) do
begin
ColorToRGB(Find[k].Colors[i], j, l, m)
IncEx(Find[k].RG, (j-l));
IncEx(Find[k].RB, (j-m));
IncEx(Find[k].GB, (l-m));
end;
Find[k].RG := (Find[k].RG/Length(Find[k].Colors))
Find[k].RB := (Find[k].RB/Length(Find[k].Colors))
Find[k].GB := (Find[k].GB/Length(Find[k].Colors))
Find[k].Autocolor := True;
end;
FFlag(0);
Wait(50);
if MVPDebug then writeln('Finding '+name);
l:=GetArrayLength(Find[k].Colors); //Checks known colors first
if l>0 then
begin
for i:= 0 to l-1 do
begin
if MVPDebug then writeln('finding color: '+IntToStr(Find[k].Colors[i]));
FindColorsSpiralTolerance(MSCX,MSCY,p,Find[k].Colors[i],MSX1,MSY1,MSX2,MSY2,0);
m:=GetArrayLength(p);
if m>0 then
begin
if m > 30 then exit;
for a:= 0 to m-1 do
begin
if CheckAndClick(p[a].x,p[a].y, Find[k].UpText) then //Moves mouse to position, checks uptext and clicks if correct.
begin
result:=true;
if i>0 then //if the color is not in the first position of the array...
Swap(Find[k].Colors[i], Find[k].Colors[i-1]);
// Swap found color with the one ahead of it in the array
exit; // We found our color, so we exit the function completely.
end;
end;
end;
end;
end;
//We didn't find any known colors, so continue on to the tolerance search
for j:=0 to High(Find[k].Colors) do
begin
if j >= 3 then break; //only wanna look for 3 colors with tol
if MVPDebug then writeln('finding color '+IntToStr(Find[k].Colors[j])+' with tol ');
FindColorsSpiralTolerance(MSCX, MSCY, p, Find[k].Colors[j],MSX1,MSY1,MSX2,MSY2,25);
l:=GetArrayLength(p);
if (l>0)and(not l>30) then
begin
for i:= 0 to l-1 do
begin
TestColor:=GetColor(p[i].x,p[i].y); //Additional autocoloring to reduce wrong points. (Optional)
{turning it to RGB}
red:=(TestColor mod 256);
green:=((TestColor/256) mod 256);
blue:=((TestColor/256) / 256);
{comparing colors}
if ((green-blue)<=(Find[k].GB+20)) then if ((green-blue)>=(Find[k].GB-20)) then
if ((red-green)>=(Find[k].RG-20)) then if ((red-green)<=(Find[k].RG+20)) then
if ((red-blue)>=(Find[k].RB-20)) then if ((red-blue)<=(Find[k].RB+20)) then
begin
Wait(20);
ClickColor:=GetColor(p[i].x,p[i].y);
for RMInt:=0 to High(Find[k].Colors) do
begin
if RMInt <> j then
if FindColorSpiralTolerance(RMx, RMy, Find[k].Colors[RMInt],x-5,y-5,x+5,y+5, 20) then
begin
Found:=True;
break;
end;
end;
If Found then
if CheckAndClick(p[a].x,p[a].y, Find[k].UpText) then //Move mouse, check uptext and click
begin
result:=true;
FindColorsSpiralTolerance(x,y,p,ClickColor,MSX1,MSY1,MSX2,MSY2,0);
if GetArrayLength(p)<20 then //Make sure that the color is somewhat rare, and doesn't take up half the screen
begin
a:=GetArrayLength(Find[k].Colors);
for i:= 0 to a-1 do
begin
if ClickColor=Find[k].Colors[i] then //If color is already in the array...
begin
if i>0 then
begin // Move it up one spot in the array search priority
Swap(Find[k].Colors[i], Find[k].Colors[i-1]);
end;
exit;
end;
end;
// if it's not in the array yet, then add it to the end of the array
SetArrayLength(Find[k].Colors,a+1);
Find[k].Colors[a]:=ClickColor;
if MVPDebug then Writeln(IntToStr(ClickColor)+' added to '+name+' array');
end;
exit;
end;
end;
end;
end;
end;
end;
//chooses the best unique colors around the mouse, used to autocolor for SmartColors
Function ScanColors: TIntegerArray;
var
x, y, i, h, j, k:integer;
RMColors, GoodColors:TIntegerArray;
p: TPointArray;
begin
if not LoggedIn then exit;
j := 0;
GetMousePos(x, y);
SetArrayLength(RMColors, 441);
for i:=x-10 to x+10 do //getting all the colors
begin
for h:=y-10 to y+10 do
begin
RMColors[j] := GetColor(i, h);
Inc(j);
end;
end;
ClearSameIntegers(RMColors);
h := High(RMColors)
k:=0;
SetArrayLength(GoodColors, h);
for i:= 0 to h do //checking out which colors are good;
begin
if k > 7 then break;
FindColorsSpiralTolerance(x, y, p, RMColors[i], MSX1, MSY1, MSX2, MSY2, 0);
j := Length(p);
if (j > 0)and(j < 30) then
begin
GoodColors[k]:= RMColors[i];
Inc(k);
end;
end;
//now we still need to sort them to see which ones are the best.
//or is that too much work, seeing that smart colors will end up doing it?
SetArrayLength(GoodColors, 7);
Result:=GoodColors;
end;
procedure CutTrees; forward;
//cheks if the axe is broken (if false its broken)
Function CheckAxe(StringArray: TStringArray):boolean;
begin
Result:=True;
if (PosArray(['do not have an axe'], StringArray[7])) or
(PosArray(['do not have an axe'], StringArray[8])) or
(PosArray(['need an axe to chop'], StringArray[7]))or
(PosArray(['need an axe to chop'], StringArray[8]))then
begin //Withdraw Axe
Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].loc := 'No Axe';
if MVPDebug then writeln('axe broke');
LogOut;
// we should make it get the axe from the bank here
Result := False;
end;
end;
//gets away from ent, comes back close to tree and restarts chopping trees
procedure RunAwayEnt;
var
Rx, Ry, RBoolx, RBooly:integer;
begin
if not LoggedIn then exit;
if MVPDebug then writeln('running from ent');
RBoolx := Random(100)+1;
RBooly := Random(100)+1;
if RBoolx < 51 then
Rx := RandomRange(-15, -10)
else
Rx := RandomRange(10, 15);
if RBooly < 51 then
Ry := RandomRange(-15, -10)
else
Ry := RandomRange(10, 15);
Mouse(MMCX+Rx, MMCY+Ry, 0, 0, True);
wait(1000+Random(1000));
EntsAvoided := EntsAvoided + 1;
AntiBan;
//returning to place
if RBoolx < 51 then
Rx := RandomRange(10, 15)
else
Rx := RandomRange(-15, -10);
if RBooly < 51 then
Ry := RandomRange(10, 15)
else
Ry := RandomRange(-15, -10);
Mouse(MMCX+Rx, MMCY+Ry, 0, 0, True);
wait(1000+Random(1000));
CutTrees;
end;
procedure WaitUntilCut(name:string); forward;
//waits for player to move close to the tree and puts mouse over the tree
procedure GetToTree(name:string; WaitForTree:boolean);
var x, y, x1, x2, y1, y2, i:integer;
begin
if not LoggedIn then exit;
GetMousePos(x, y);
if FindEnt(x, y, False) then
begin
RunAwayEnt;
Exit;
end;
name := lowercase(name);
if MVPDebug then writeln('getting to tree '+name);
if (abs(MSCX - x)>30) then
if x > MSCX then //tree is to the right
begin
x1 := MSCX + 15;
if name='oak' then IncEx(x1, 15);
if name='willow' then IncEx(x1, 10);
if name='yew' then IncEx(x1, 30);
x2 := x1+30;
end else
begin
x1 := MSCX - 55;
if name='oak' then DecEx(x1, 15);
if name='willow' then DecEx(x1, 10);
if name='yew' then DecEx(x1, 30);
x2 := x1+30;
end
else
begin
x1 := MSCX-20;
x2 := x1 +40;
end;
//the bigger y the further down it is
if (abs(MSCX - y)>59) then
if y > MSCY then //it's under the player
begin
y1 := MSCY+20;
if name='oak' then IncEx(y1, 35);
if name='willow' then IncEx(y1, 25);
if name='yew' then IncEx(y1, 40);
y2 := y1+20;
end else
begin
y1 := MSCY - 50;
if name='oak' then DecEx(y1, 35);
if name='willow' then DecEx(y1, 25);
if name='yew' then DecEx(y1, 40);
y2 := y1 + 20;
end
else
begin
y1 := MSCY-25;
y2 := y1 +50;
end;
FFlag(0);
wait(500+Random(100));
if MVPDebug then writeln('decided where tree should be');
for i:= 0 to 5 do
begin
if MVPDebug then writeln('trying to find tree');
wait(100);
if (name = 'tree') then
if (GetBlackChatMessage = 'You get some logs.') then
exit;
if i = 0 then
MMouse((x1+x2)/2, (y1+y2)/2, 3, 3)
else
MouseBox(x1, y1, x2, y2, 3);
wait(100);
if IsUpText(Capitalize(name)) then
break;
end;
wait(100);
if InvFull then Exit; // Bank it?;
if WaitForTree then WaitUntilCut(name);
end;
//autocolors all trees
procedure AutoColorTree(name:string);
var
i, x, y:integer;
s: string;
Found:boolean;
begin
i := 10;
name := Capitalize(name);
case name of
'Tree', 'Normal': i:= 0;
'Oak': i:= 1;
'Willow': i:= 2;
'Yew': i:= 3;
end;
if i = 10 then
begin
writeln('tree name incorrect');
exit;
end;
if (Length(AllTIA[i]) > 0) then
begin
if MVPDebug then writeln('already AutoColored');
exit;
end;
if MVPDebug then writeln('autocoloring '+name);
repeat
if FindObjTPA(x, y, 2772296, 11, -1, 7, 7, 15, [ name ]) then
begin
if IsUpText(name) then
begin
AllTIA[i]:=ScanColors;
if AllTIA[i][0] <> 0 then Found:=True;
end;
end;
until(found)
if MVPDebug then writeln(name+' color: '+IntToStr(AllTIA[i][0]));
end;
//checks for next available spot
Function NextSpot: integer;
var
i, h:integer;
begin
Result := 1;
for i:=1 to 28 do
if not ExistsItem(i) then
begin
Result:= i;
exit;
end;
end;
//looks for a tree with SmartColors
//also autocolors if needed, if already autocolored the autocoloring function just exits
function FindTree(name:string): boolean;
begin
if not LoggedIn then exit;
AutoColorTree(name);
case lowercase(name) of
'normal', 'tree':
Result := SmartColorsCustom('normal', ['Tree'], AllTIA[0]);
'oak':
Result:=SmartColorsCustom('oak', ['Oak'], AllTIA[1]);
'willow':
Result:=SmartColorsCustom('willow', ['Willow'], AllTIA[2]);
'yew':
Result:=SmartColorsCustom('yew', ['Yew'], AllTIA[3]);
end;
end;
//waits until the tree is cut with various failsafes
procedure WaitUntilCut(name:string);
var
x, y, color, i, j, k, t, CheckSpot, CutMark:integer;
p:TPointArray;
Found : boolean;
TSA:TStringArray;
begin
if not LoggedIn then exit;
if MVPDebug then writeln('waiting until cut');
wait(10);
MarkTime(CutMark);
GetMousePos(x, y);
if FindEnt(x, y, False) then
begin
RunAwayEnt;
exit;
end;
wait(250);
NoRandoms;
wait(150);
MarkTime(t);
repeat
NoRandoms;
if not LoggedIn then break;
if InvFull then
begin
wait(10);
Exit; // Bank it?;
MarkTime(CutMark);
end;
TSA:=ChatsBlackText;
if not CheckAxe(TSA) then exit;
wait(300);
NoRandoms;
if (PosArray(['swing your axe'], TSA[7]))or
(PosArray(['swing your axe'], TSA[8]))or
(PosArray(['get some'], TSA[8]))then
begin
if MVPDebug then writeln('found TSA');
break;
end;
if (TimeFromMark(t) > 3000) then
begin
wait(100);
if MVPDebug then writeln('tree took too long');
Exit;
end;
until(false);
if MVPDebug then writeln('cutting tree');
GetMousePos(x, y); //let's keep our mouse over the tree now.
wait(100);
MarkTime(SpotMark);
CheckSpot := NextSpot;
repeat
if not LoggedIn then exit;
NoRandoms;
if InvFull then
begin
wait(50);
Exit; // Bank it?;
MarkTime(CutMark);
end;
if ExistsItem(CheckSpot) then
begin
CheckSpot := NextSpot;
wait(50);
MarkTime(SpotMark);
end;
if (TimeFromMark(SpotMark) > 30000) then
begin
wait(100);
if MVPDebug then
begin
writeln('i dont think were cutting, but we should be!')
writeln('lets try finding that tree again!');
end;
exit;
end;
if (name='tree') then
if (GetBlackChatMessage = 'You get some logs.') then
exit;
wait(50);
NoRandoms;
wait(50);
Found:=False;
if IsUpText('hop') then
begin
if FindEnt(x, y, False) then
begin
RunAwayEnt;
exit;
end;
Found := True;
wait(100);
end else
begin
if MVPDebug then writeln('tree seems to be gone..?');
NoRandoms;
GetMousePos(x, y);
//if looking for one trre then one color if looking for other tree then other color
i := Find[0].Colors[0];
FindColorsSpiralTolerance(x, y, p, i, x-5, y-5, x+5, y+5, 10);
j := High(p);
if j > 0 then
if j > 10 then j := 10;
for k:=0 to j do
begin
if (name='tree')and(GetBlackChatMessage = 'You get some logs.') then exit;
if ((abs(x-p[k].x))>2)or((abs(y-p[k].y))>2) then
MMouse(p[k].x, p[k].y, 0, 0);
wait(150);
Found := IsUpText('hop');
if Found then break;
wait(50);
end;
wait(100);
end;
if not LoggedIn then exit;
NoRandoms;
wait(150);
GetMousePos(x, y);
if FindEnt(x, y, False) then
begin
RunAwayEnt;
break;
end;
wait(150);
if InvFull then
begin
wait(100);
Exit; // Bank it?;
MarkTime(CutMark);
end;
if (TimeFromMark(CutMark) > 45000) then
begin
InactiveMove;
MarkTime(CutMark);
end;
until(not Found);
if MVPDebug then writeln('tree gone');
end;
//Grabs wc level and decides what is best to cut
Function WhatToCut: string;
begin
Players[CurrentPlayer].Level[20] := GetSkillLevel('woodcutting');
if Players[CurrentPlayer].Level[20]=0 then
begin
writeln('error detecting wc level');
Result:='tree';
exit;
end;
if InRange(Players[CurrentPlayer].Level[20], 1, 14) then
Result:= 'tree';
else if InRange(Players[CurrentPlayer].Level[20], 15, 59) then
Result:= 'oak';
else
Result:='yew';
//i don't think there are any willows in varrock, are there?
end;
//checks if we have everything needed for wcing. -> missing withdraw axe
procedure SetupWCing;
var AllGood:boolean;
begin
//check for axe, wc lvl etc
if not LoggedIn then exit;
repeat
FindNormalRandoms;
if not LoggedIn then
begin
Players[CurrentPlayer].Active := False;
exit;
end;
LoadsDone:=0;
Players[CurrentPlayer].Strings[0] := WhatToCut;
if FindAxe then
begin
if MVPDebug then writeln('Axe found');
wait(500+Random(1000));
SetAngle(True);
AllGood := True;
end else
//if not WithdrawAxe then NextPlayer(False);
NextPlayer(False);
until(AllGood);
GameTab(4);
end;
//everything needed to cut the trees.
procedure CutTrees;
var i:integer;
begin
NoRandoms;
if not (LoadsDone >= LoadsWanted) then
begin
repeat
if LoadsDone >= LoadsWanted then break;
if Not LoggedIn then Exit;
NoRandoms;
wait(Random(1000));
if InvFull then Exit; // Bank it?;
if LoadsDone >= LoadsWanted then break;
if FindTree(Players[CurrentPlayer].Strings[0]) then
begin
Players[CurrentPlayer].Integers[1] := 0;
i:=0;
NoRandoms;
GetToTree(Players[CurrentPlayer].Strings[0], True);
end else
begin
writeln('couldnt find tree');
wait(3000);
InactiveMove;
inc(i);
end;
if i >= 5 then
begin
NoRandoms;
writeln('pretty sure there are no damn trees around.');
LoadsDone := LoadsWanted + 1;
Inc(Players[CurrentPlayer].Integers[1]);
if Players[CurrentPlayer].Integers[1] >= 3 then
Players[CurrentPlayer].Active := False;
exit;
end;
NoRandoms;
until(False);
end;
end;
a few notes:
- autocolor
- many failsafes
- i call NoRandoms, which is a function that checked for FindNormalRandoms and FindFight, i'll leave it there until there's one in the MVP Folder.
- when the inv is full it exits CutTrees, left a "//bank it?" comment next to it.
- i use MVPDebug, not sure if it's gonna be in the whole MVP, but i think it would be useful to have a debug for such a huge script
- i have used SmartColorsCustom
- i have not yet a made a function that would get their level and decide what to cut - added
- i have made absolutely no walking
- if the axe is broken it logs out, but i left a comment there to withdraw new axe.
- there is my proggy function there but it is never called
SetupWCing;
for i:=0 to 3 do
begin
WalkToTrees;
CutTrees;
WalkToBank;
BankIt;
end;
That should be enough to do the whole wcing after i add in the withdrawing axe from bank and once the walking and the banking are done
i did not upload it to the svn or post it as a scar file cus i don't have access to either of them right now.
~RM