SRL Archive - Help and Support

walking between near tiles


Le Jingle

2012-12-01 12:46:24

I made a snippet that collects fruit off the ground, however I'm having trouble thinking of ways to way back to the original tile.
Ex.
player tile = "x", other tiles = "-"

1. player standing still

---
-x-
---
2. player walks to tile

x--
---
---
3. [How?] player walk back to standing still tile in #1 / original tile??

---
-x-
---

All help appreciated :)
Cheers,
Lj

Oh almost forgot the snippet:


program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$IFDEF SMART}
{$i srl/srl/misc/smartgraphics.simba}
{$ENDIF}

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0;
with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
end;
end;

function searchBoxs(): boolean; // testing still, on ground color : 4606025
var
hTxt, hTol, i, j, k, l, m, n: integer;
aBox, PlayerBox: TBox;
Col, tol: TIntegerArray;
SurroundingTiles: Array[0..7] of TBox;
Texts: TStringArray;
TPA: TPointArray;
options: Array of TOptions;
begin
result := false;

PlayerBox := IntToBox(243, 218-50, 272, 241-50);

cleardebug;
writeln('---------------- search Box -----------');
{$IFDEF SMART}
SMART_DrawBox(PlayerBox);
{$ENDIF}

Surroundingtiles[0] := IntToBox(220, 142, 240, 161); // top left
Surroundingtiles[1] := IntToBox(250, 142, 270, 162); // top mid
Surroundingtiles[2] := IntToBox(280, 142, 300, 163); // top right
Surroundingtiles[3] := IntToBox(217, 219-50, 239, 240-50); // mid left
Surroundingtiles[4] := IntToBox(280, 218-50, 303, 242-50); // mid right
Surroundingtiles[5] := IntToBox(215, 246-50, 238, 269-50); // bottom left
Surroundingtiles[6] := IntToBox(248, 245-50, 270, 270-50); // bottom mid
Surroundingtiles[7] := IntToBox(280, 247-50, 303, 270-50); // bottom right
{$IFDEF SMART}
SMART_DrawBoxes(true, false, Surroundingtiles, -1);
{$ENDIF}

Texts := ['Banana', 'Lemon', 'Lime', 'Orange', 'Papaya fruit', 'Pineapple'];
Col := [ 5553855, 4248007, 4494914, 4363989, 3716772, 1802173];
tol := [ 14, 27, 24, 23, 22, 72];
hTol := high(tol);
hTxt := high(Texts);

for i := 0 to 7 do // Boxes Surrounding Player Box...
for j := 0 to hTxt do // Number of items to search for...
for k := 0 to hTol do // Tolerance on color to use...
begin
aBox := SurroundingTiles[i];
writeln(abox);
if FindColorsTolerance(TPA, Col[j], aBox.x1, aBox.y1, aBox.x2, aBox.y2, tol[j]) then
begin
Mouse(MiddleTPA(TPA).x, MiddleTPA(TPA).y, 3, 3, mouse_right);
options := GetChooseOptions('all');
for l := 0 to high(options) do
for m := 0 to hTxt do
if (Pos(texts[m], options[l].str) > 0) then
begin
n := m;
break;
end;

if WaitOption(Texts[n], 2500) then
begin
writeln('Result = FOUND!');
result := true;
exit;
end;
end else
continue;
end;
end;

// ReturnGridColorsInBox(Box: TBox): T2DIntegerArray;

begin
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
SetupSRL;
DeclarePlayers;
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('n');
searchBoxs();
end.


J J

2012-12-01 13:45:27

You know the coord where you will be clicking so what I would do
1. Calculate the angle between the middle of your character and the point where you will be clicking.
2. Click on the coord
3. What happens: 4. You want to get back so you can calculate the original tile with the angle you have. Can calculate the original position on either the mainscreen or the minimap. Can also convert minimap to mainscreen with MmToMs

Might work it out in RS soon, for now I have to work a bit on a project for college :stirthepot:

Runaway

2012-12-01 13:50:28

I attempted to do something like this once by measuring the distance between the mm flag and the character dot right after clicking. Then to get back you can take the inverse of the original displacement.

Just a thought :)

Le Jingle

2012-12-01 14:59:13

Ah, thanks you two.

I've learned angles a long time ago, and recently amplitude, midline, etc trig.. Just have to fish through some notes and relearn it. I'll see what I come up with.

Cheers,
Lj!

Nebula

2012-12-01 21:24:54

You don't need to use any angles etc. Here's something I just wrote up incase you still need help, it should work just fine. I don't feel like doing it unless you need me to, so if you need an explanation of the logic just ask.

program Ljs_a_noob;
{$i SRL\SRL.simba}

function PickUpShit: TPoint;
begin
{Click ground object here}
while not FindFlag(result.x, result.y) do
wait(25);
{wait while walking stuff here}
end;

procedure WalkBackToOriginalPosition(ClickedPoint: TPoint);
begin
Mouse(MMCX * 2 - ClickedPoint.x, MMCY * 2 + ClickedPoint.y, 0, 0, true);
{wait while walking stuff here}
end;

begin
SetupSRL;
WalkBackToOriginalPosition(PickUpShit);
end.