Trojan_
2011-11-05 16:16:01
How do i code so my character moves to a specific area ingame?
2011-11-05 16:16:01
2011-11-05 16:16:58
2011-11-05 16:20:58
2011-11-05 17:33:52
From: Trojan_
Hmm, not worldwide, basically a few tiles should do the work, draynor - willow trees?
2011-11-05 17:48:46
From: noidea
With Simba and SRL, you're going to want to change your mindset. You dont want to walk to a certain tile. You want to walk into that area. Area being, a range. You will almost never be able to walk to an exact point.
If you want to walk to the fishing area in draynor, there are a couple of things youll want to look for.
o The Fishing symbol. Will you be able to see the fishing spot symbol from where you are?
o Will looking for the colour of the trees and walking towards that colour be accurate enough?
o What about the water? What if walk towards certain areas of the water on the minimap. We could do some math to help improve accuracy on this.
o Make a bitmap or a dtm of the area and walk to it?
Not necessarily in that order. Before attempting this, you may want to learn the basics if you havent already. TPA's, DTM's, and all that stuff will be important to the success of your script.
Good luck :)
2011-11-05 18:03:24
2011-11-05 19:12:50
function FindTreeColor: Integer;
var
TPA, TestTPA: TPointArray;
ATPA: T2DPointArray;
H, S, L: Extended;
i, TestColor, R, G, B, AL: Integer;
BlackListCol: TIntegerArray;
begin
result := -1;
if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
begin
AL := high(TPA);
For i := 0 to AL do
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
if not InIntArray(BlackListCol, TestColor) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, -10, 50) then
if InRange(R - G, -75, -30) then
if InRange(G - B, 50, 88) then
if L < 31.5 then
if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
begin
FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
if Length(TestTPA) > 0 then
begin
ATPA := TPAtoATPAEx(TestTPA, 11, 10);
SortATPAFrom(ATPA, Point(mmcx, mmcy));
if not InRange(Length(ATPA[0]), 21, 28) then
if Length(ATPA[0]) < 30 then
if not InRange(Length(ATPA[0]), 8, 10) then
begin
writeln('Tree colour = '+ Inttostr(TestColor));
Result := TestColor;
exit;
end else
begin
ColorToHSL(TestColor, H, S, L);
if L > 24 then
begin
SetArrayLength(BlackListCol, Length(BLackListCol) + 1);
BlackListCol[High(BlackListCol)] := TestColor;
end;
end;
end;
end;
end;
end;
end;
writeln('Couldn''t find tree color!');
Result := -1;
end;
procedure tofish();
var
treetpa, watertpa: tpointarray;
lowest, sym: tpoint;
i, lowy, d, treecol: integer;
begin
if not loggedin then exit;
treecol := findtreecolor;
findcolorstolerance(treetpa, treecol, mmx1, mmy1, mmx2, mmy2, 0);
if (treecol > 0) and (length(treetpa) > 0) then
begin
writeln('Walking to trees via treecolor');
FilterPointsPie(treetpa, 85, 115, 50, 70, mmcx, mmcy);
for i := 0 to high(treetpa) do
if lowest.y < treetpa[i].y then lowest := treetpa[i];
mfnf(lowest.x, lowest.y, 1, 1);
flag;
wait(300+random(300));
end else
begin
writeln('Couldnt find treecolor, attempting to walk to the farthest water spot');
//Hopefully this will do till the autocolors are fixed......
findcolorstolerance(watertpa, 10327174, mmx1, mmy1, mmx2, mmy2, 10);
if length(watertpa) > 0 then
begin
debugtpa(watertpa, 'a');
lowy := 0;
for i := 1 to high(watertpa) do
if watertpa[i].y < watertpa[lowy].y then lowy := i;
mfnf(watertpa[lowy].x-7, watertpa[lowy].y-3, 1, 1);
flag;
wait(300+random(300));
end else
begin
if findsymbol(sym.x, sym.y, 'fish') then
begin
mfnf(sym.x, sym.y-5, 1, 1)
flag;
wait(300+random(300));
end else
begin
writeln('Couldnt get to fishing spot!');
killplayer();
end
end;
end;
end; 2011-11-05 20:52:21
From: noidea
The autocolors are still broken, so if you're planning on using the tree color, FindTreeColor still works.function FindTreeColor: Integer;
var
TPA, TestTPA: TPointArray;
ATPA: T2DPointArray;
H, S, L: Extended;
i, TestColor, R, G, B, AL: Integer;
BlackListCol: TIntegerArray;
begin
result := -1;
if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
begin
AL := high(TPA);
For i := 0 to AL do
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
if not InIntArray(BlackListCol, TestColor) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, -10, 50) then
if InRange(R - G, -75, -30) then
if InRange(G - B, 50, 88) then
if L < 31.5 then
if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
begin
FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
if Length(TestTPA) > 0 then
begin
ATPA := TPAtoATPAEx(TestTPA, 11, 10);
SortATPAFrom(ATPA, Point(mmcx, mmcy));
if not InRange(Length(ATPA[0]), 21, 28) then
if Length(ATPA[0]) < 30 then
if not InRange(Length(ATPA[0]), 8, 10) then
begin
writeln('Tree colour = '+ Inttostr(TestColor));
Result := TestColor;
exit;
end else
begin
ColorToHSL(TestColor, H, S, L);
if L > 24 then
begin
SetArrayLength(BlackListCol, Length(BLackListCol) + 1);
BlackListCol[High(BlackListCol)] := TestColor;
end;
end;
end;
end;
end;
end;
end;
writeln('Couldn''t find tree color!');
Result := -1;
end;
procedure tofish();
var
treetpa, watertpa: tpointarray;
lowest, sym: tpoint;
i, lowy, d, treecol: integer;
begin
if not loggedin then exit;
treecol := findtreecolor;
findcolorstolerance(treetpa, treecol, mmx1, mmy1, mmx2, mmy2, 0);
if (treecol > 0) and (length(treetpa) > 0) then
begin
writeln('Walking to trees via treecolor');
FilterPointsPie(treetpa, 85, 115, 50, 70, mmcx, mmcy);
for i := 0 to high(treetpa) do
if lowest.y < treetpa[i].y then lowest := treetpa[i];
mfnf(lowest.x, lowest.y, 1, 1);
flag;
wait(300+random(300));
end else
begin
writeln('Couldnt find treecolor, attempting to walk to the farthest water spot');
//Hopefully this will do till the autocolors are fixed......
findcolorstolerance(watertpa, 10327174, mmx1, mmy1, mmx2, mmy2, 10);
if length(watertpa) > 0 then
begin
debugtpa(watertpa, 'a');
lowy := 0;
for i := 1 to high(watertpa) do
if watertpa[i].y < watertpa[lowy].y then lowy := i;
mfnf(watertpa[lowy].x-7, watertpa[lowy].y-3, 1, 1);
flag;
wait(300+random(300));
end else
begin
if findsymbol(sym.x, sym.y, 'fish') then
begin
mfnf(sym.x, sym.y-5, 1, 1)
flag;
wait(300+random(300));
end else
begin
writeln('Couldnt get to fishing spot!');
killplayer();
end
end;
end;
end;
That is my walking procedure, please dont copy it, but do learn from it :)
Note: TPA = TPointArray = array of tpoint
tpoint = a set of x and y in one var
var t: tpoint;
t := point(1, 2);
writeln(t.x);
writeln(t.y);
2011-11-05 21:47:01
From: Trojan_
Nice, what i don't get is how i'm gonna get the co-ordinates? Not 300 which is millisecounds, but x = something etc…, can i make it click an area by x= and y= etc, What does RGB Mean…? I don't get those points
2011-11-06 09:59:53
From: noidea
Oh, you can copy paste FindTreeColor into your script. Its an old srl function that still works that was scrapped and the new one doesnt. What I was talking about was the function that walks to the trees/fishing spot ;)
2011-11-22 18:29:15
2011-11-22 19:40:10
2011-11-22 21:19:36
2011-11-23 08:06:51
program new;
{.include srl/srl.scar}
{.include sps/sps.simba}
// This function will walk you to Draynor willow trees,
// assuming you're only 1 click away
function WalkToWillows: boolean;
begin
Result := SPS_WalkToPos(4155, 3700);
end;
// This function will walk you to Draynor bank,
// assuming you're only 1 click away
function WalkToWillows: boolean;
begin
Result := SPS_WalkToPos(4185, 3670);
end;
{
YOUR OWN PROCEDURES AND FUNCTIONS HERE
}
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE, ['10_8', '10_9']);
{
YOUR SCRIPTS MAIN EXECUTION HERE
}
end.