Wizzup?
2007-12-24 13:46:49
Hey, we need tile walking for SMART.
I made this, quickly.
It walks from edgeville to the zamorak mage (can be done on f2p and p2p, on f2p the zammy mage just isn't there. :p )
Is there a way to make the walking more accurate with rotation?
It works, but it isn't 100% acc.
Can you make a more accurate one, Ben?
Here's the code:
I made this, quickly.
It walks from edgeville to the zamorak mage (can be done on f2p and p2p, on f2p the zammy mage just isn't there. :p )
Is there a way to make the walking more accurate with rotation?
It works, but it isn't 100% acc.
Can you make a more accurate one, Ben?
Here's the code:
program New;
{.include smart.scar}
{.include srl/srl.scar}
{const
MMX1 = 570;
MMY1 = 5;
MMX2 = 715;
MMY2 = 160;
MMCX = 643;
MMCY = 84; }
Function AtTile(Tile: TPoint; Dist: Integer): Boolean;
Var
P: TPoint;
Begin
GetMyPos(P.X, P.Y);
Result := Distance(P.X, P.Y, Tile.X, Tile.Y) <= Dist;
writeln('Current Tile: (' + inttostr(p.x) + ' ,'+inttostr(p.y) + ')');
End;
Function WalkTile(Tile: TPoint; Disttol, Randomness: Integer): Boolean;
Var
wTile, P: TPoint;
d, degs: extended;
dist, t: integer;
Begin
Result := False;
Randomize(Tile.X, Randomness);
Randomize(Tile.Y, Randomness);
GetMyPos(P.X, P.Y);
Degs := rs_GetCompassAngleDegrees;
writeln('Compass angle: ' + floattostr(Degs));
D := Degrees(ArcTan2(p.y - tile.y, p.x-tile.x)) - 90;
d := d - degs;
writeln('Point angle' + floattostr(d));
writeln('CompassPoint angle: ' + floattostr(d - degs));
dist := Distance(MMCX, MMCY, p.x-tile.x + mmcx, p.y-tile.y + mmcy) * 4;
wTile.X := Round(MMCX + dist * Sin(D * pi / 180));
wTile.Y := Round(MMCY + dist * Cos(D * pi / 180));
If Not rs_OnMiniMap(wTile.X, wTile.Y) Then
Begin
WriteLn('Not in minimap');
WriteLn('('+inttostr(wtile.x)+','+inttostr(wtile.y)+')');
Exit;
End;
Result := True;
If AtTile(Tile, DistTol) Then
Begin
WriteLn('Already at tile');
Exit;
End;
mouse(wtile.x, wtile.y, 0, 0, true);
t := getsystemtime;
While Not AtTile(Tile, DistTol) And ((getsystemtime - t) < 60000) Do
Begin
Wait(2000);
End;
result := (getsystemtime - t) < 60000;
End;
Procedure RecordPath;
Var
I, x, y: Integer;
Begin
Repeat
Wait(500);
If IsFKeyDown(11) Then
Begin
GetMyPos(x, y);
WriteLn('TPA['+IntToStr(I) + '].X := ' + IntToStr(x)+';');
WriteLn('TPA['+IntToStr(I) + '].Y := ' + IntToStr(y)+';');
I := I + 1;
End;
Until IsFKeyDown(8);
End;
{var
x, y: integer; }
Var
TPA: TPointArray;
p:tpoint;
i:integer;
begin
ClearDebug;
SmartSetup('ams5', false, false);
SetTargetDC(SmartGetDC);
setupsrl;
SetLength(TPA, 9);
{3049, 4832} // Middle mage
TPA[0] := Point(3087, 3496); // Oustside bank
TPA[1] := Point(3094, 3491);
TPA[2] := Point(3100, 3500);
TPA[3] := Point(3103, 3510);
TPA[4] := Point(3104, 3517); // In front of ditch
TPA[5] := Point(3110, 3525);
TPA[6] := Point(3110, 3536);
TPA[7] := Point(3107, 3544);
TPA[8] := Point(3106, 3555); // At mage
for i := 0 to high(tpa) do
begin
GetMyPos(P.X, P.Y);
writeln(inttostr(tpa[i].x) + ','+inttostr(tpa[i].y));
writeln('Walking tile number: ' + inttostr(i));
WalkTile(tpa[i], 3, 0);
wait(1000);
end;
end.