kevin33
2012-01-08 18:32:06
Alright so my last issue has resolved so Ive created this new thread asking for help on how to make it better (working better). It currently works for like 30 seconds and then the mouse will hover over different trees and take a while to cut another if it cuts one at all. Its my chopnburn script. I have no idea if the burn function works because it never gets that far. I just want to get it working so please suggest how I can improve it. If you can test it and tell me how to fix it up I would greatly appreciate it.
Heres the script improved:
*(Will convert it to SRL5 after it works)*
Heres the script improved:
program KevysChopNBurn;
{.include SRL/SRL/misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/firemaking.scar}
//have hatchet equipped
//be near some trees you want to cut
//Maples I do not have the colours for
//Colors may be off, fix them as you need to, I will do my best to fix them also
//Tinderbox must be in toolbelt or 1st inventory slot
//Under testing report any bugs and I will attempt to fix them and not sure if all trees work
Const
TREE_TOL = 5;
TREE = 0;
OAK = 1;
WILLOW = 2;
MAPLE = 3;
YEW = 4;
type
treeType = record
colors : TIntegerArray;
names : TStringArray;
end;
var
a: Integer;
procedure declarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := 'Unknown'; //username
Pass := 'Password'; //password
Nick := 'know'; //3-4 letters from your username
Active := true;
Integers[1] := 2; //tree you wish to cut
Booleans[0] := True; // Tinderbox is in your toolbelt
BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
end;
end;
procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;
procedure setupScript;
begin
ClearDebug;
SetupSRL;
SMART_Server := 4;
SMART_Signed := True;
SMART_Members := False;
declarePlayers;
while not(RSReady) do
Wait(1000);
end;
{procedure IdentifyTree; //just extra info just in case I make a pure firemaker
var
TreeDTM: Integer;
begin
if not LoggedIn then Exit;
if TreeDTM <= 0 then
case Players [CurrentPlayer].Integers[1] of
TREE:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOhiYWCYDMRtQFwHxM1A3A/EM4A4mZGBIQKIo4A4BYjzgTibESLubiYP1M0ExsUxRnA2BOMGjHgwFAAAwEQIWg==');
OAK:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOhmYWCYDMRtQFwLxC1A3A/EM4C4nZGBoQaI64C4GYgnA3E/EHcCcaa/HlA3Ew6MGzDiwVAAAPTwCJ8=');
Willow:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYLjPwsDwHIhvAPFFIL4OxI+B+A0QJzEyMEQAcRQQJwNxPhBnQ9nGuvxA3Uw4MG7AiAdDAQCWsAl2');
Maple:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYNjCwsCwF4jXAfFyIN4MxPuA+BAQJzMyMEQAcRQQJwFxLhBnAXEKELvrcwF1M+HAuAEjHgwFAAXtCGk=');
Yew:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOBiZWAQBGJmIP7NwsDABOWLAXEyIwNDBBBHAXEcEOcDcRYjRNxOlwOomwkHxg0Y8WAoAAAN1ASo');
end; //just showing I can use DTMs :)
end;}
procedure setupPlayer;
begin
if LobbyScreen then LeaveLobby;
if not(LoggedIn) then LoginPlayer;
SetAngle(False); //select true if you want camera angle to rise *best to leave lowered
MakeCompass('N');
Players[CurrentPlayer].Integers[1] := 0; //chopped
Players[CurrentPlayer].Integers[2] := 0; //burned
end;
function colorIsFound(colors : TIntegerArray) : Boolean;
var
TPA : TPointArray;
I : Integer;
begin
for I := 0 to High(Colors) do
begin
FindColors(TPA, colors[I], MIX1, MIY2, MIX2, MIY2);
if(Length(TPA) > 0)then
Break;
end;
Result := Length(TPA) > 0;
end;
procedure BurnOfChop;
var
x,y : Integer;
I : Integer;
invSlot1, logSlot : TPoint;
begin
case(Players[CurrentPlayer].Booleans[0])of
True:
begin
if(colorIsFound([4413283, 4479334]))then //colors may need changing and again no maple log you may fix that yourself.
// Set colors to match tree(s) you wish to cut. Colors can be found lines 255-259
begin
Mouse(x, y, 4, 4, False);
Wait(RandomRange(250, 750));
ChooseOption('raf');
Wait(RandomRange(1000, 2000));
end;
end;
False:
begin
if(colorIsFound([5790300, 5527128]))then
begin
invSlot1 := ItemCoords(1);
for I := 2 to 28 do
begin
logSlot := ItemCoords(I);
Mouse(invSlot1.X, invSlot1.Y, 4, 4, True);
Wait(RandomRange(250, 1000));
Mouse(logSlot.X, logSlot.Y, 4, 4, True);
Wait(RandomRange(750, 1250)); // Wait for the log to be ignited
end;
end;
end;
end;
end;
procedure ChoppingAntiban;
begin
Case Random(250) Of
0: Begin StatsGuise('Antiban') GameTab(tab_Stats) HoverSkill('Woodcutting', False) GameTab(28) End;
1: Begin StatsGuise('Antiban') SleepAndMoveMouse(7000 + Random(500)); End;
2: Begin StatsGuise('Antiban') GameTab(tab_Inv) ExamineInv; GameTab(28); End;
3: Begin StatsGuise('AntiBan') RandomAngle(1); End;
4: Begin StatsGuise('AntiBan') GameTab(Tab_Stats); Wait(3000 + Random(500)); GameTab(28); End;
5: Begin StatsGuise('AntiBan') GameTab(tab_Stats) HoverSkill('random', False); GameTab(28); End;
6: Begin StatsGuise('Antiban') GameTab(tab_Stats) HoverSkill('Firemaking', False); GameTab(28); End;
end;
end;
function TheUpTextAll(Text: TStringArray): Boolean;
var
TheText: string;
i, n: Integer;
begin
TheText := GetUpText;
n := High(Text);
Result := True
for i := 0 to n do
if (Pos(Text[i], TheText) <= 0) then //
begin
Result := False;
Exit;
end;
end;
function WaitUpTextAll(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) do
begin
if (TheUpTextAll(S)) then
begin
Result := True;
Exit;
end;
Wait(30 + Random(10));
end;
end;
function FindObjExAltered(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
ChoX, ChoY, a, b, c, i: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
Start := True;
Break;
end;
end;
if (Start) then
begin
ChoX := Round((xs + xe) div 2);
ChoY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin
a := a + 1;
i := 0;
ChoY := ChoY + Step;
end;
1: ChoX := ChoX + Step;
2: ChoY := ChoY - Step;
3: ChoX := ChoX - Step;
4: ChoY := ChoY + Step;
end;
if (ChoX >= xs) and (ChoX <= xe) and (ChoY >= ys) and (ChoY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], ChoX-(Step div 2), ChoY-(Step div 2), ChoX+(Step div 2), ChoY+(Step div 2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
If (WaitUptextAll(Text, 300)) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (Result) or ((ChoX > xe) and (ChoY > ye))
end;
end;
function setTreeType(which : Integer) : treeType;
var
tt : treeType;
begin
case(which)of
0: tt.colors := [4413283, 4479334]; //Trees
1: tt.colors := [3691619, 3757414]; //Oaks
2: tt.colors := [3556934, 3425092]; //Willows
3: tt.colors := []; //Maples don't currently have colors for
4: tt.colors := [4608859, 4740445]; //Yews
end;
tt.names := ['ree', 'ak', 'illow', 'aple', 'ew'];
Result := tt;
end;
Procedure ReturnValues(colors: TIntegerArray; var HueMods, SatMods: Extended; var color, Tolerance: Integer);
Var
h, s, t: Extended;
I,II : integer;
HSLColor : Array[1..3] of Extended;
HSL : Array[0..1] of Array[1..3] of Extended;
begin;
For I:= 1 to 3 do
begin;
HSL[0][i] := 255;
end;
For I:= 0 to High(Colors) do
begin;
ColortoHSL(Colors[i],HSLColor[1],HSLColor[2],HSLColor[3]);
For II:= 1 to 3 do
begin;
HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
end;
end;
H := (HSL[1][1] - HSL[0][1]);
S := (HSL[1][2] - HSL[0][2]);
T := (HSL[1][3] - HSL[0][3]);
try
HueMods := (H/T);
SatMods := (S/T);
Tolerance := Round(t);
except
HueMods := 0;
SatMods := 0;
Tolerance := Round(0.0);
end;
Color := HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2);
end;
function FindTree(var x, y: integer): boolean;
var
HMod, SMod: Extended;
Col, Tol: Integer;
B: TBox;
TPA: TPointArray;
L,i,CTS: Integer;
ATPA: T2DPointArray;
begin
ReturnValues([3229015, 3427165, 3690596, 3822440], Hmod, Smod, Col, Tol);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hmod, SMod);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Col, MSX1, MSY1, MSX2, MSY2, Tol);
ColorToleranceSpeed(CTS);
if (Length(TPA) < 1) then
Exit;
ATPA := TPAToATPAEx(TPA, 40, 40);
SortATPAFrom(ATPA, Point(MSCX,MSCY));
L := High(ATPA);
SetArrayLength(ATPA, L+1);
for i := 0 to L do
begin
if (GetArrayLength(ATPA[i]) > 5) then
begin
B := GetTPABounds(ATPA[i]);
MiddleTPAEx(ATPA[i], X, Y);
MMouse(X, Y, 15, 15);
if WaitUpTextMulti(['hop d', 'down'], 555) then
begin
Result := True;
GetMousePos(X, Y);
Exit;
end else
Result := False;
end;
end;
end;
procedure chop;
var
oldInv, originalInv: Integer;
x, y: Integer;
treeInfo : treeType;
TreeCounter: Integer;
begin
treeInfo := setTreeType(Players[CurrentPlayer].Integers[1]);
repeat
BurnOfChop;
if not(LoggedIn) then exit;
WriteLn('chopped ' + IntToStr(Players[CurrentPlayer].Integers[1]) + ' Logged In: ' + BoolToStr(LoggedIn));
OriginalInv := InvCount;
if FindObjExAltered(x, y, ['hop down', treeInfo.names[Players[CurrentPlayer].Integers[1]]], treeInfo.colors, TREE_TOL, 50, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 0, 0, True);
repeat
oldInv:=InvCount;
ChoppingAntiban;
if not(LoggedIn) then exit;
until((oldInv <= InvCount) or (InvFull)) or (TimeFromMark(TreeCounter) > 7000);
wait(1000 + Random(2000));
end;
Players[CurrentPlayer].Integers[1] := Players[CurrentPlayer].Integers[1] + InvCount - OriginalInv; //number chopped
until(not(LoggedIn) or InvFull);
end;
begin
SetupSRL;
setupScript;
While not(AllPlayersInactive) do
begin
if random(5)=1 then ChangeWorld(RandomWorld(False, False));
setupPlayer;
a := GetSystemTime + 3000000 + random(600000);
repeat
chop;
BurnOfChop;
until((not(LoggedIn)) or (a > GetSystemTime));
RandomNextPlayer(LoggedIn);
Logout;
end;
FreeSRL;
end. *(Will convert it to SRL5 after it works)*