kevin33
2011-12-28 20:56:26
Okay so I finished my ChopNBurn script. It all compiles so I began to test. When I test the mouse hovers all over the screen. I figure the chopping aspect is in need of a lot of help. Any ideas? Colors are probably bad. Im not really sure how to get unique colors for trees.
I get this error when I start it:
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong xs to a finder function: -16. That is below 0, thus out of bounds. Setting the value to 0 for now.
Any suggestions or help to try and fix the script would be greatly appreciated.
I get this error when I start it:
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong xs to a finder function: -16. That is below 0, thus out of bounds. Setting the value to 0 for now.
Any suggestions or help to try and fix the script would be greatly appreciated.
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 := ''; //username
Pass := ''; //password
Nick := ''; //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(True); //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 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.