Simba Code:
program EduardsWillowChopper;
{$Define SMART8}
{$include SRL/SRL.simba}
{$include SPS/SPS.simba}
{$include SRL/SRL/Misc/SmartGraphics.simba}
var
StartXP, TreeAttempts, UserStatsLogsChopped, UserStatsXPgain: integer;
TimeInMinutes: string;
XpPerHour: Extended;
const
CurrentVersion = '22';
Update = 'on';
SD = 'on';
MSDB = 'on';
TextDebug = true;
WillowCol = 2569268;
WillowSat = 0.43;
WillowHue = 0.48;
WillowTol = 7;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;
function VersionChecker: string;
var
MyHttpClient: integer;
begin
MyHttpClient := InitializeHttpClient(true, false);
result := GetHTTPPage(MyHttpClient, 'http://pastebin.com/raw.php?i=anP5DPNF');
FreeHTTPClient(MyHttpClient);
end;
function DownloadNewVersion: boolean;
var
UpdatedFile, MyHttpClient: integer;
UpdatePath, UpdatedFileString: string;
begin
result := false;
UpdatePath := (AppPath + 'Scripts\' + 'EduardDraynorCutter' + VersionChecker + '.simba');
UpdatedFile := RewriteFile(UpdatePath, false);
MyHttpClient := InitializeHttpClient(true, false);
UpdatedFileString := GetHTTPPage(MyHttpClient, 'http://pastebin.com/raw.php?i=2ns6BWHT');
if (WriteFileString(UpdatedFile, UpdatedFileString)) then
result := true;
FreeHTTPClient(MyHttpClient);
CloseFile(UpdatedFile);
end;
procedure PaintDebug(Txt: string);
var
ClearBox: Tbox;
begin
if (SD = 'on') then
begin
ClearBox.x1 := 350;
ClearBox.X2 := 525;
ClearBox.Y1 := 75;
ClearBox.Y2 := 130;
SMART_ClearCanvas;
Smart_DrawText(375, 26, 'FriendChars', 'Eduard Willow Chopper V1', clWhite);
Smart_DrawText(375, 41, 'FriendChars', txt, ClYellow);
if (TextDebug) then
writeln(txt);
end
end;
function SendData: Boolean;
var
i: integer;
begin
i := InitializeHTTPClientWrap(False);
writeln('Time ran:' + IntToStr(GetTimeRunning / 1000));
writeln('XP Gained:' + IntToSTr(UserStatsXpGain));
writeln('Logs chopped:' + IntToStr(UserStatsLogsChopped));
AddPostVariable(i, 'time', IntToStr(GetTimeRunning / 1000));
AddPostVariable(i, 'xp', IntToStr(UserStatsXpGain));
AddPostVariable(i, 'logs', IntToStr(UserStatsLogsChopped));
Result := Pos('true', Lowercase(PostHTTPPageEx(i, 'draynorcuttereduard.hostei.com/update.php'))) <> 0;
FreeHTTPClient(i);
end;
procedure PaintDebugProgress;
var
CharBox: Tbox;
TimeRan, LogsChopped, XpGain, XpBar: integer;
begin
CharBox.x1 := 375;
CharBox.X2 := 500;
CharBox.Y1 := 105;
CharBox.Y2 := 220;
Smart_ClearCanvasArea(CharBox);
XpBar := GetXpBarTotal;
XpGain := XpBar - StartXp;
LogsChopped := XpGain / 67;
UserStatsLogsChopped := LogsChopped;
UserStatsXPgain := XpGain;
Smart_DrawText(375, 56, 'FriendChars', ('XP Gain ' + inttostr(XpGain)), Clpurple);
Smart_DrawText(375, 71, 'FriendChars', ('Logs Chopped ' + inttostr(LogsChopped)), Clred);
if (LogsChopped > 0) then
begin
TimeRan := GetTimeRunning;
XpPerHour := ((TimeRan / XpGain) * 360);
TimeInMinutes := MsToTime(TimeRan, Time_Abbrev);
Smart_DrawText(375, 86, 'FriendChars', ('Xp per hour ' + floattostr(XpPerHour) + 'xp'), ClWhite);
Smart_DrawText(375, 101, 'FriendChars', (TimeInMinutes), Clgreen);
end;
end;
function WillowAutoColorMS: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(WillowHue, WillowSat);
FindColorsSpiralTolerance(MSCX, MSCY, arP, WillowCol, MSX1, MSY1, MSX2, MSY2, WillowTol);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 1.31) and (X <= 5.40) and (Y >= 1.50) and (Y <= 5.97) and (Z >= 1.07) and (Z <= 4.37) then
begin
Result := arC[i];
PaintDebug('Willow tree color ' + IntToStr(arC[i]));
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
function Antiban: boolean;
begin
case Random(500) of
1:
begin
PaintDebug('Antiban hovering woodcutting');
HoverSkill('woodcutting', False);
end;
2:
begin
PaintDebug('Antiban hovering random skill');
HoverSkill('random', False);
end;
3:
begin
PaintDebug('Antiban Bored human');
Boredhuman;
end;
4:
begin
PaintDebug('Antiban waiting random 2 to 7 seconds');
Wait(2500 + random(4500));
end;
5:
begin
PaintDebug('Antiban picking up mouse');
PickUpMouse;
end;
6:
begin
PaintDebug('Antiban RandomMovement');
RandomMovement;
end;
7:
begin
PaintDebug('Antiban RandomRClick');
RandomRClick;
end;
end;
result := false;
end;
function WaitLoggedIn(Time: Integer): Boolean;
var
T: Integer;
begin
MarkTime(T);
repeat
SRL_ResetNavBar;
if TimeFromMark(T) > Time then
begin
Result := False;
Exit;
end;
until (GetColor(472, 490) = 16777215);
result := True;
end;
function StillCutting: boolean;
var
CharBox: Tbox;
PixelShiftMS: integer;
begin
CharBox.x1 := 240;
CharBox.X2 := 280;
CharBox.Y1 := 140;
CharBox.Y2 := 200;
PixelShiftMS := AveragePixelShift(CharBox, 200, 500);
if (PixelShiftMS > 150) then
begin
PaintDebugProgress;
AntiBan;
result := true;
end
else
result := false;
end;
function StillRunning: boolean;
var
CharBox: Tbox;
iShift: integer;
begin
CharBox.x1 := 240;
CharBox.X2 := 275;
CharBox.Y1 := 140;
CharBox.Y2 := 190;
iShift := AveragePixelShift(CharBox, 200, 500);
if (Ishift > 200) then
result := true;
result := false
end;
procedure WalkToBank;
var
WillowsToBank: TPointArray;
begin
WillowsToBank := [Point(4148, 3672), Point(4132, 3646), Point(4136, 3627), Point(4140, 3613), Point(4158, 3609), Point(4164, 3627)];
SPS_WalkPath(WillowsToBank);
end;
procedure WalkToWillows;
var
BankToWillows: TPointArray;
begin
BankToWillows := [Point(4172, 3628), Point(4157, 3610), Point(4141, 3613), Point(4136, 3634), Point(4141, 3667)];
SPS_WalkPath(BankToWillows);
end;
procedure FindBanker;
var
Attempts: integer;
begin
if (not (LoggedIn)) then
Exit;
repeat
if (OpenBankFast('db')) then
begin
if (Bankscreen) then
begin
DepositAll;
CloseBank;
Wait(200 + random(200));
Exit;
end
else
begin
PaintDebug('Bankscreen failed!');
Exit;
end;
end
else
begin
PaintDebug('OpenBankFast failed!');
inc(Attempts);
end;
until (Attempts > 4) if (Attempts > 4) then
begin
Exit;
PaintDebug('failed opening bank, walking to bank again.');
end;
Exit;
end;
procedure CutTree;
var
MiddleBoxTP: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
ATPABox: Tbox;
x, y, i: integer;
begin
if (FindColorsSpiralTolerance(x, y, TPA, WillowAutoColorMS, MSX1, MSY1, MSX2, MSY2, WillowTol)) then
begin
TPAtoATPAExWrap(TPA, 25, 25, ATPA);
SortATPASize(ATPA, true);
for i := 0 to High(ATPA) do
begin
ATPABox := GetTPABounds(ATPA[i]);
MiddleBoxTP := MiddleBox(ATPABox);
if (MSDB = 'on') then
begin
Smart_DrawBoxEx(false, false, ATPABox, ClPurple);
Smart_DrawDotsMulti(False, ATPA);
end;
MMouse(MiddleBoxTP.x, MiddleBoxTP.y, 0, 0);
Wait(400 + random(100));
PaintDebug('Finding tree');
inc(TreeAttempts);
if (TreeAttempts > 6) then
begin
PaintDebug('Cant find tree walking back to Willow spot');
WalkToWillows;
TreeAttempts := 0;
Exit;
end;
if (WaitUpText('illow', 30)) then
begin
Mouse(MiddleBoxTP.x, MiddleBoxTP.y, 0, 0, 1);
Wait(300 + random(200));
PaintDebug('Cutting tree');
TreeAttempts := 0;
while StillCutting do
begin
Wait(20);
end;
Exit;
end;
end;
end;
end;
procedure BankInventory;
begin
PaintDebug('Inventory is full');
WalkToBank;
FindBanker;
Wait(500 + random(500));
if Bankscreen then
begin
DepositAll;
CloseBank;
end;
Wait(350 + random(200));
end;
procedure UpdateScript;
begin
if (Update = 'on') then
begin
writeln('Current version: ' + (CurrentVersion) + '.');
if (CurrentVersion <> VersionChecker) then
begin
if (VersionChecker <> '') then
begin
writeln('Newest version: ' + (VersionChecker) + '');
if (DownloadNewVersion) then
begin
writeln('Succesfully downloaded newest version, its located in your script path. Please open this version!');
TerminateScript;
end
else
begin
writeln('Could not download newest version, this is a filewriting error! Please check your file access!');
TerminateScript;
end;
end
else
begin
writeln('Newest version: Unavailable, please check the forums or disable updater');
TerminateScript;
end;
end
else
writeln('You have the newest version');
end;
end;
procedure Setup;
begin
{$IFDEF SIMBAMAJOR980}
SMART_SERVER := 10;
SMART_MEMBERS := TRUE;
SMART_SIGNED := TRUE;
SMART_SUPERDETAIL := FALSE;
{$ELSE}
SRL_SIXHOURFIX := TRUE;
SMART_FIXSPEED := TRUE;
{$ENDIF}
ClearDebug;
UpdateScript;
SPS_Setup(RUNESCAPE_SURFACE, ['10_8', '10_9']);
SetupSRL;
DeclarePlayers;
Smart_ClearCanvas;
SetRun(true);
StartXp := GetXpBarTotal;
LoadSRLFonts;
ClickNorth(SRL_ANGLE_HIGH);
Gametab(tab_inv);
Smart_DrawText(200, 14, 'FriendChars', 'Eduard Willow Chopper V1', clWhite);
end;
procedure MainLoop;
begin
if not WaitLoggedIn(1000) then
LoginPlayer;
PaintDebugProgress;
FindNormalRandoms;
if (InvFull) then
begin
BankInventory;
WalkToWillows;
end;
CutTree;
end;
begin
Setup;
repeat
if (not (LoggedIn)) then
LoginPlayer;
MainLoop;
AddOnTerminate('SendData');
until (false)
end.